A libgdx application has a very complete life cycle to control the state of the application. Such as creation, pause, recovery, rendering, and processing.
Applicationlistener
Developers can pass an instance to the application through the applicationlistener interface. As follows:
Public class mygame implements applicationlistener {
Public void create (){
} Public void render (){
} Public void resize (INT width, int height ){
} Public void pause (){
} Public void resume (){
} Public void dispose (){
}
} Once the applicationlistener is passed to the application, the following method is executed in sequence: Create (): This method is called when the application is created; resize (INT width, int height ): this method is called when the screen size changes and the application is not paused. The create () method is also called once. The unit of the parameter is pixel. Render (): This method is called when rendering is required. Game logic updates usually occur in this method. Pause (): This method is called when the home key is hidden in Android or when a call is received. On the desktop, this method is called before the dispose () method is called to exit the program, which is usually used to save the game status. Resume (): This method is called only in Android when an application or game recovers from the pause state. Dispose (): called when an application is destroyed. To sum up, the life cycle of an application is usually as follows: where is the main cycle of the application? Applicationlistener. Render () is usually treated as the main loop.
(Www.libgdx.cn is copyrighted. If you need to reprint it, indicate the source)
4.1 libgdx Lifecycle