class-description NEWS COMMUNITY STORE TUTORIALS SIGN UP LOGIN LOGOUT ROKOJORI NEWSLETTER SIGN UP LOGIN LOGOUT NEWS COMMUNITY STORE TUTORIALS TOGGLE FULLSCREEN VOLLBILD AN/AUS Object MainLoop
Abstract base class for the game's main loop.

MainLoop is the abstract base class for a Godot project's game loop. It is inherited by SceneTree, which is the default game loop implementation used in Godot projects, though it is also possible to write and use one's own MainLoop subclass instead of the scene tree.

Upon the application start, a MainLoop implementation must be provided to the OS; otherwise, the application will exit. This happens automatically (and a SceneTree is created) unless a MainLoop Script is provided from the command line (with e.g. godot -s my_loop.gd) or the ProjectSettings.application/run/main_loop_type project setting is overwritten.

Here is an example script implementing a simple MainLoop:

class_name CustomMainLoop extends MainLoop var time_elapsed = 0 func _initialize(): print("Initialized:") print(" Starting time: %s" % str(time_elapsed)) func _process(delta): time_elapsed += delta # Return true to end the main loop. return Input.get_mouse_button_mask() != 0 || Input.is_key_pressed(KEY_ESCAPE) func _finalize(): print("Finalized:") print(" End time: %s" % str(time_elapsed))
Signal on_request_permissions_result<>( String permission=, permission:String=, bool granted=, granted:bool=, ):Signal

Emitted when a user responds to a permission request.

void _finalize<>():void

Called before the program exits.

void _initialize<>():void

Called once during initialization.

bool _physics_process<>( float delta=, delta:float=, ):bool

Called each physics frame with the time since the last physics frame as argument (delta, in seconds). Equivalent to Node._physics_process().

If implemented, the method must return a boolean value. true ends the main loop, while false lets it proceed to the next frame.

Note: delta will be larger than expected if running at a framerate lower than Engine.physics_ticks_per_second / Engine.max_physics_steps_per_frame FPS. This is done to avoid "spiral of death" scenarios where performance would plummet due to an ever-increasing number of physics steps per frame. This behavior affects both _process() and _physics_process(). As a result, avoid using delta for time measurements in real-world seconds. Use the Time singleton's methods for this purpose instead, such as Time.get_ticks_usec().

bool _process<>( float delta=, delta:float=, ):bool

Called each process (idle) frame with the time since the last process frame as argument (in seconds). Equivalent to Node._process().

If implemented, the method must return a boolean value. true ends the main loop, while false lets it proceed to the next frame.

Note: delta will be larger than expected if running at a framerate lower than Engine.physics_ticks_per_second / Engine.max_physics_steps_per_frame FPS. This is done to avoid "spiral of death" scenarios where performance would plummet due to an ever-increasing number of physics steps per frame. This behavior affects both _process() and _physics_process(). As a result, avoid using delta for time measurements in real-world seconds. Use the Time singleton's methods for this purpose instead, such as Time.get_ticks_usec().




All social media brands are registrated trademarks and belong to their respective owners.





CONTACT IMPRINT TERMS OF USE PRIVACY © ROKOROJI ® 2021 rokojori.com
CONTACT IMPRINT TERMS OF USE PRIVACY © ROKOROJI ® 2021 rokojori.com
We are using cookies on this site. Read more... Wir benutzen Cookies auf dieser Seite. Mehr lesen...