API Docs for: 0.1.1
Show:

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
)
private

Parameters:

  • size Object

    Subontainer size. If given activated subcontainers, otherwise not.

    • width Integer

      width (in pixels)

    • height Integer

      height (in pixels)

Methods

_getClosestSubcontainers

(
  • layer
  • givenCoordinates
  • options
)
Array private static

Get the closest subcontainers of the given area.

Parameters:

  • layer Object

    Instance of PIXI.Container - The layer being used

  • givenCoordinates Object

    Coordinates or rectangle

    • x Integer

      x coordinate

    • y Integer

      y coordinate

    • width Integer

      width of the rectangle

    • height Integer

      height of the rectangle

  • options Object

    Optional options.

Returns:

Array:

Array of found subcontainers.

getSubcontainerArea

(
  • scale
  • options.toGlobal
)
Object

Gets this subcontainers coordinates and size

Parameters:

  • scale Number

    The size of scale the map currently has

  • options.toGlobal Boolean

    Do we get the global coordinates or local

Returns:

Object:

x, y, width and height returned inside object.

setCorrectSubcontainer

(
  • displayObject
  • parentLayer
)
private static

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