flatworld.maplayers.MapSubcontainer Class
Subcontainers are containers that hold objects like units and terrain etc. under them. They have some restrictions atm. since they are PIXI.ParticleContainers. But when needed we can extend MapLayers with another class which is subcontainer, but not ParticleContainer at the present there is no need, so we won't extend yet. Subcontainers help the layers to make better movement of the map, by making subcontainers visible or invisible and even helping with selecting objects on the map. Thus we don't need to use our inefficient Quadtree. The intention was to use PIXI.ParticleContainer for this, but it seems it doesn't clean up the memory afterwards the same way as normal Container.
Constructor
flatworld.maplayers.MapSubcontainer
-
size
Parameters:
-
size
ObjectSubontainer size. If given activated subcontainers, otherwise not.
-
width
Integerwidth (in pixels)
-
height
Integerheight (in pixels)
-
Item Index
Methods
Methods
_getClosestSubcontainers
-
layer
-
givenCoordinates
-
options
Get the closest subcontainers of the given area.
Parameters:
Returns:
Array of found subcontainers.
getSubcontainerArea
-
scale
-
options.toGlobal
Gets this subcontainers coordinates and size
Parameters:
Returns:
x, y, width and height returned inside object.
setCorrectSubcontainer
-
displayObject
-
parentLayer
Helper function for setting subcontainers to parent containers. Adds subcontainers when needed. Subcontainers are not and can not be initialized at the start as we won't know the size of the parent container. Container is always dynamic in size.
Parameters:
-
displayObject
PIXI.DisplayObject -
parentLayer
Object