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
name
been set).Type:
- Object
-
systemOrder
-
List of system updating order.
Note:systemOrder
should only be modified after systems added! -
systems
-
Map of added systems
-
taggedEntities :Object
-
Holding all the tagged entities(has
tag
been set).Type:
- Object
Methods
-
addSystem(sys)
-
Add a system instance to this game.
Parameters:
Name Type Description sys
System 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 delta
Number Delta time in millisecond
deltaSec
Number 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 w
Number New window width
h
Number 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 timestamp
Number Timestamp at this invoking
-
spawnEntity(type, x, y, layer, settings)
-
Spawn an
Entity
into game world.Parameters:
Name Type Description type
Class Entity class
x
Number X coordinate
y
Number Y coordinate
layer
String Name of the layer to added to
settings
Object Instance settings
Returns:
Entity instance
- Type
- Entity
-
update(delta, deltaSec)
-
Update is called every single frame.
Parameters:
Name Type Description delta
Number Delta time in millisecond
deltaSec
Number Delta time in second