new Game()
Game is the main hub for a game. A game made with LesserPanda
is a combination of different Games(menu, shop, game, game-over .etc).
Extends
- EvenetEmitter
Members
-
desiredFPS
-
Desired FPS this scene should run
-
entities :Array.<Entity>
-
List of entities in the game world.
Type:
- Array.<Entity>
-
namedEntities :Object
-
Holding all the named entities(has
namebeen set).Type:
- Object
-
systemOrder
-
List of system updating order.
Note:systemOrdershould only be modified after systems added! -
systems
-
Map of added systems
-
taggedEntities :Object
-
Holding all the tagged entities(has
tagbeen set).Type:
- Object
Methods
-
addSystem(sys)
-
Add a system instance to this game.
Parameters:
Name Type Description sysSystem System instance to add
Returns:
Self for chaining
- Type
- Game
-
awake()
-
Awake is called when this scene is activated.
-
fixedUpdate(delta, deltaSec)
-
Fixed update is called in a constant frenquence decided by
desiredFPS.Parameters:
Name Type Description deltaNumber Delta time in millisecond
deltaSecNumber Delta time in second
-
freeze()
-
Freeze is called when this scene is deactivated(switched to another one)
-
pause()
-
System pause callback.
-
resize(w, h)
-
Resize callback.
Parameters:
Name Type Description wNumber New window width
hNumber New window height
-
resume()
-
System resume callback.
-
<protected> run(timestamp)
-
Called each single frame by engine core, support both idle and fixed update.
Using a modified fixed update implementation from Phaser by @photonstormParameters:
Name Type Description timestampNumber Timestamp at this invoking
-
spawnEntity(type, x, y, layer, settings)
-
Spawn an
Entityinto game world.Parameters:
Name Type Description typeClass Entity class
xNumber X coordinate
yNumber Y coordinate
layerString Name of the layer to added to
settingsObject Instance settings
Returns:
Entity instance
- Type
- Entity
-
update(delta, deltaSec)
-
Update is called every single frame.
Parameters:
Name Type Description deltaNumber Delta time in millisecond
deltaSecNumber Delta time in second