Flocking of mobile agents has been well studied in the literature. However, since most practical mobile agents, e.g., robots, UAVs, are typically powered by onboard batteries, it is of practical significance to consider the battery consumption in the control design, and explore how to optimize the distribution of energy consumption. In this paper, we consider the flocking of battery-powered mobile agents using the potential field approach. We first analyze the limitations of the classical potential field method. Next, we propose a new potential function by considering the battery consumption, and design the flocking control law related to the gradient of the proposed potential functions correspondingly. We verified the effectiveness of the proposed method with both simulations and a group of UAVs. The results of experiment verify that the proposed method can optimize the energy consumption of the flocking system when compared with the existing methods, which is benefit to the endurance of the system.