Packagenet.flashpunk
Classpublic class Engine
InheritanceEngine Inheritance flash.display.MovieClip

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



Public Properties
 PropertyDefined By
  maxElapsed : Number = 0.0333
Cap on the elapsed time (default at 30 FPS).
Engine
  maxFrameSkip : uint = 5
The max amount of frames that can be skipped in fixed framerate mode.
Engine
  paused : Boolean = false
If the game should stop updating/rendering.
Engine
  tickRate : uint = 4
The amount of milliseconds between ticks in fixed framerate mode.
Engine
Public Methods
 MethodDefined By
  
Engine(width:uint, height:uint, frameRate:Number = 60, fixed:Boolean = false)
Constructor.
Engine
  
Override this; called when game gains focus.
Engine
  
focusLost():void
Override this; called when game loses focus.
Engine
  
init():void
Override this, called after Engine has been added to the stage.
Engine
  
render():void
Renders the game, rendering the World and Entities.
Engine
  
Sets the game's stage properties.
Engine
  
update():void
Updates the game, updating the World and Entities.
Engine
Property Detail
maxElapsedproperty
public var maxElapsed:Number = 0.0333

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

maxFrameSkipproperty 
public var maxFrameSkip:uint = 5

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

pausedproperty 
public var paused:Boolean = false

If the game should stop updating/rendering.

tickRateproperty 
public var tickRate:uint = 4

The amount of milliseconds between ticks in fixed framerate mode.

Constructor Detail
Engine()Constructor
public function Engine(width:uint, height:uint, frameRate:Number = 60, fixed:Boolean = false)

Constructor. Defines startup information about your game.

Parameters
width:uint — The width of your game.
 
height:uint — The height of your game.
 
frameRate:Number (default = 60) — The game framerate, in frames per second.
 
fixed:Boolean (default = false) — If a fixed-framerate should be used.
Method Detail
focusGained()method
public function focusGained():void

Override this; called when game gains focus.

focusLost()method 
public function focusLost():void

Override this; called when game loses focus.

init()method 
public function init():void

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

render()method 
public function render():void

Renders the game, rendering the World and Entities.

setStageProperties()method 
public function setStageProperties():void

Sets the game's stage properties. Override this to set them differently.

update()method 
public function update():void

Updates the game, updating the World and Entities.