Game Development Reference
In-Depth Information
The following diagram visualizes the LibGDX's application life cycle:
Start
create()
check
platform
type
true
resume()
resuming
resume event
Android only
resize()
false
render()
(
handle
system
events
pause()
pausing
pause event
Android only
running
(
terminating
Caused by:
Home Button was pressed
Incoming phone call
• Other app-interr
pause()
up
ting events
dispose()
end
Note that a full and dotted line basically has the same meaning in the preceding
diagram. They both connect two consecutive states and have a direction of flow
indicated by a little arrowhead on one end of the line. A dotted line additionally
denotes a system event.
When an application starts, it will always begin with create() . This is where the
initialization of the application should happen, such as loading assets into memory
and creating an initial state of the game world. Subsequently, the next state that
follows is resize() . This is the first opportunity for an application to adjust itself to
the available display size (width and height) given in pixels.
Next, LibGDX will handle system events. If no event has occurred in the meanwhile,
it is assumed that the application is (still) running. The next state would be
render() . This is where a game application will mainly do the following two things:
• Update the game world model
• Draw the scene on the screen using the updated game world model
Afterwards, a decision is made on which the platform type is detected by LibGDX.
On a desktop or in a web browser, the displaying application window can be
virtually resized at any time. LibGDX compares the last and current sizes on every
cycle so that resize() is only called if the display size is changed. This makes sure
that the running application is able to accommodate a changed display size.
 
Search WWH ::




Custom Search