-
-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add active flag to the IUpdateable interface
This allows to exclude Updatable implementations from the update mechanism if they overwrite the default implementation of the isActive() method and define an appropriate condition (e.g. game is paused/freezed/...) Issue #267
- Loading branch information
1 parent
e2675a1
commit 90737bb
Showing
3 changed files
with
25 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,30 @@ | ||
package de.gurkenlabs.litiengine; | ||
|
||
import de.gurkenlabs.litiengine.configuration.ClientConfiguration; | ||
|
||
/** | ||
* The Interface IUpdateable provides the functionality to update an instance | ||
* from the game loop. The instance needs to register itself. | ||
* The Interface IUpdateable provides the functionality to automatically update an instance that implements it | ||
* from the game loop. The instance needs to be registered on the loop. | ||
* | ||
* @see ILoop#attach(IUpdateable) | ||
* @see ILoop#detach(IUpdateable) | ||
*/ | ||
public interface IUpdateable { | ||
|
||
/** | ||
* This method is called by the game loop on all objects that need to update | ||
* their attributes. It is called on every tick, means, it is called | ||
* Game.GameLoop.TICKS_PER_SECOND times per second. | ||
* This method is called by the game loop on all objects that are attached to the loop. | ||
* It's called on every tick of the loop and the frequency can be configured using the <code>ClientConfiguration</code>. | ||
* | ||
* @see ClientConfiguration#setUpdaterate(int) | ||
*/ | ||
public void update(); | ||
|
||
/** | ||
* This flag controls whether this instance is currently active and thereby needs to be updated by the game loop. | ||
* | ||
* @return True if this instance should be updated; otherwise false. | ||
*/ | ||
public default boolean isActive() { | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters