4.1 libgdx Lifecycle

Source: Internet
Author: User
Tags libgdx
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.