flatworld.maplayers.MapLayer Class
Creates a basic layer for the Map. This type of layer can not hold subcontainers. Note that different devices and graphic cards can only have specific size of bitmap drawn, and PIXI cache always draws a bitmap thus the default is: 4096, based on this site: http://webglstats.com/ and MAX_TEXTURE_SIZE. This is important also when caching.
Constructor
flatworld.maplayers.MapLayer
-
options
Parameters:
-
options
Objectoptional options
-
name
StringLayers name, used for identifying the layer. Useful in debugging, but can be used for finding correct layers too
-
coord
Objectcoord starting coords of layer. Relative to parent map layer.
-
x
IntegerX coordinate -
y
IntegerY coordinate
-
-
specialLayer
ObjectIs this layer special (e.g. UILayer not included in normal operations)
-
x
IntegerX coordinate -
y
IntegerY coordinate
-
-
Item Index
Methods
Attributes
Methods
addUIObject
-
object
-
UIName
Adds and object to this layers UILayer child. If an object with the same name already exists, we remove it automatically and replace it with the new object given as parameter.
Parameters:
Returns:
All the UIObjects currently on this layer
createUILayer
-
name
-
coord
Create and add special layer, that holds UI effects in it. UILayer is normally positioned as movableLayers 3rd child. And the actual UI stuff is added there.
Parameters:
Returns:
The created UI layer
deleteUIObjects
-
object
If object is given, removes that object, otherwiseRemove all the UIObjects from this layer
Parameters:
-
object
ObjectIf you wish to delete particular object
Returns:
empty UIObjects array
getObjects
()
Array
Get all objects that are this layers children or subcontainers children. Does not return layers, but the objects. Works on primary layer only currently. So can not seek for complicated children structure, seeks only inside subcontainers.
Returns:
All the objects (not layers) found under this layer
getPrimaryLayers
()
Array
Get primary layers, that this layer holds as children. So basically all children that are not special layers (such as UI layers etc.)
Returns:
Primary children layers under this layer
getUILayer
()
MapLayer | undefined
Return the UILayer. If no UILayer is yet created, will return undefined
Returns:
getUIObjects
()
Array
get UIObjects on this layer, if there are any, or defaulty empty array if no UIObjects are active
Returns:
current UIObjects
hasSubcontainers
()
Boolean
Does this layer use subcontainers.
Returns:
true = uses subcontainers.
move
-
coord
Move layer based on given amounts
Parameters:
-
coord
ObjectThe amount of x and y coordinates we want the layer to move. I.e. { x: 5, y: 0 }. This would move the map 5 pixels horizontally and 0 pixels vertically
-
x
IntegerX coordinate
-
y
IntegerY coordinate
-
Attributes
name
String
Layers name, used for identifying the layer. Useful in debugging, but can be used for finding correct layers too
Fires event nameChange
Fires when the value for the configuration attribute name
is
changed. You can listen for the event using the on
method if you
wish to be notified before the attribute's value has changed, or
using the after
method if you wish to be notified after the
attribute's value has changed.
Parameters:
-
e
EventFacadeAn Event Facade object with the following attribute-specific properties added:
selectable
Boolean
Can you select objects from this layer. For example with Map.getObjectsUnderArea
Fires event selectableChange
Fires when the value for the configuration attribute selectable
is
changed. You can listen for the event using the on
method if you
wish to be notified before the attribute's value has changed, or
using the after
method if you wish to be notified after the
attribute's value has changed.
Parameters:
-
e
EventFacadeAn Event Facade object with the following attribute-specific properties added:
specialLayer
Boolean
Is this layer special (e.g. UILayer not included in normal operations)
Fires event specialLayerChange
Fires when the value for the configuration attribute specialLayer
is
changed. You can listen for the event using the on
method if you
wish to be notified before the attribute's value has changed, or
using the after
method if you wish to be notified after the
attribute's value has changed.
Parameters:
-
e
EventFacadeAn Event Facade object with the following attribute-specific properties added:
static
Boolean
Will this layer change dynamically or can we assume that this holds the same objects always, until game reload
Fires event staticChange
Fires when the value for the configuration attribute static
is
changed. You can listen for the event using the on
method if you
wish to be notified before the attribute's value has changed, or
using the after
method if you wish to be notified after the
attribute's value has changed.
Parameters:
-
e
EventFacadeAn Event Facade object with the following attribute-specific properties added:
UIObjectList
Array
Every added UIObject will be listed here for removal and updating. The indexes in the list provide the easy option to remove only certain object from the UIObjects.
Fires event UIObjectListChange
Fires when the value for the configuration attribute UIObjectList
is
changed. You can listen for the event using the on
method if you
wish to be notified before the attribute's value has changed, or
using the after
method if you wish to be notified after the
attribute's value has changed.
Parameters:
-
e
EventFacadeAn Event Facade object with the following attribute-specific properties added: