Grape.Scene Class
The root layer in a game. It describes the game FPS and has a default view which can be overridden with initViews.
Item Index
Methods
Methods
add
-
instance
Adds an instance to the layer and emits it's "add" event.
Parameters:
-
instanceGrape.GameObjectInstance
Returns:
The added instance
addLayer
-
[name] -
layer
Adds a sub-layer to the current layer.
Parameters:
-
[name]String optionalLayer name
-
layerGrape.LayerSub-layer
addSystem
-
[name] -
system
Adds a system to the layer. All events are emitted to all added systems.
Parameters:
-
[name]String optionalName
-
systemGrape.SystemThe system
addView
-
name -
view
Adds a view to the layer. A synonym for addSystem.
Parameters:
-
nameStringView name
-
viewGrape.ViewThe view
createResultContainer
()
Grape.GameObjectArray
Overrides the TagContainer's method so getByTag calls produce GameObjectArray results instead of Array.
Returns:
get
-
classes -
[descendants=false]
Gets the instances of one or more class in the current layer (sub-layers not included).
Parameters:
-
classesClass | ArrayClass or classes
-
[descendants=false]Boolean optionalGet the descendants of that class or just instances of the class itself
Returns:
Instances
getByTag
()
Grape.GameObjectArray
Returns the instances with the given tag. Instances are indexed by tags.
Returns:
Instances with the tag
getSystem
-
name
Returns a system with the given name. Views are also considered as systems.
Parameters:
-
nameStringSystem name
Returns:
System
initViews
()
This method is called in the constructor, and adds an initial view to the scene with name 'view'. If you don't want this view, you can override this method and add your own views.
remove
-
instance
Removes an instance from the layer and emits it's "remove" event.
Parameters:
-
instanceObject
removeLayer
-
name
Removes a layer.
Parameters:
-
nameString | Grape.LayerName of the layer or the layer itself
removeSystem
-
system
Removes a system from the layer.
Parameters:
-
systemString | Grape.SystemThe name of the system or the system itself.
removeView
-
name
Removes a view from the layer. An alias for removeSystem.
Parameters:
-
nameString | Grape.ViewView name or the view itself
Events
add (instance)
This event is emitted to the instance when it is added to the layer. The parameter is the layer.
remove (instance)
Emitted to the instance when it is removed from the layer.
start (system)
Emitted to a system when it is added to a running layer or when the layer is started with a system added before.
stop (system)
Emitted to a system when it is removed from the running layer or when the layer is stopped.
