Fork me on GitHub
View source

package haxepunk

class Engine

Main game Sprite class, added to the Stage. Manages the game loop.

Your main class needs to extends this.

Constructor

View source

new (width : Int = 0, height : Int = 0, frameRate : Float = 60, fixed : Bool = false) : Void

Constructor. Defines startup information about your game.


Parameters:
width   

The width of your game.

height   

The height of your game.

frameRate   

The game framerate, in frames per second.

fixed   

If a fixed-framerate should be used.

Variables

maxElapsed : Float

Cap on the elapsed time (default at 30 FPS). Raise this to allow for lower framerates (eg. 1 / 10).

maxFrameSkip : Int

The max amount of frames that can be skipped in fixed framerate mode.

onClose : Signal0

Invoked when the application is closed.

onInputPressed : Signals

Invoked when input is received.

onInputReleased : Signals

Invoked when input is received.

onResize : Signal0

Invoked after the screen is resized.

onSceneSwitch : Signal0

Invoked after the scene is switched.

paused : Bool

If the game should stop updating/rendering.

postRender : Signal0

Invoked after rendering completes.

postUpdate : Signal0

Invoked after update cycle.

preRender : Signal0

Invoked before rendering begins each frame.

preUpdate : Signal0

Invoked before the update cycle begins each frame.

scene : Scene

The currently active Scene object. When you set this, the Scene is flagged to switch, but won't actually do so until the end of the current frame.

Functions

View source

focusGained () : Void

Override this, called when game gains focus

View source

focusLost () : Void

Override this, called when game loses focus

View source

init () : Void

Override this, called after Engine has been added to the stage.

View source

iterator () : VisibleSceneIterator

View source

onRender () : Void

Called from OpenGLView render. Any visible scene will have its draw commands rendered to OpenGL.

View source

onUpdate () : Void

@private Framerate independent game loop.

View source

popScene () : Scene

Pop a scene from the stack. The current scene will remain active until the next update.


Available since:

2.5.3

View source

pushScene (value : Scene) : Void

Push a scene onto the stack. It will not become active until the next update.


Parameters:
value   

The scene to push


Available since:

2.5.3

View source

update () : Void

Updates the game, updating the Scene and Entities.