API Docs for: 0.1.1
Show:

flatworld.extensions.mapMovement Class

on the canvas / viewport or outside of it. It does this by getting object from larger area than the current viewport size and then checking if the subcontainers are actually inside the viewport or not. If inside mark them visible, if outside mark then hidden. This makes the map a lot faster and reliable resource-wise.

Methods

addAll

(
  • map
)

Ínitialize as a plugin

Parameters:

  • map Map

    Instance of Map

calculateOffset

() private static

check

(
  • map
)
Boolean

This one checks the that the objects that should currently be visible in the viewport area are visible and outside of the viewport objects are set .visible = false. This affect performance a lot. Basically when the map moves, we set a check in the future based on the given intervalCheck milliseconds. And immediately after it we check if there is another map movement. If there is we set another timeout. This works better with timeouts.

Parameters:

  • map Map

    The current Map instance

Returns:

Boolean:

True

checkAndSetSubcontainers

(
  • scaledViewport
  • primaryLayers
)

Checks proper subcontainers and mark the correct ones visible or hidden

Parameters:

  • scaledViewport Object

    Viewportarea that has been scaled.

  • primaryLayers Array

    The primarylayers that we handle

getViewportWithOffset

(
  • viewportArea
)
TotalViewportArea private static

forms the total viewport parameters based on the given ones.

Parameters:

  • viewportArea AreaSize

    Given viewport area

Returns:

TotalViewportArea:

The total viewportArea

init

(
  • map
)

Ínitialize as a plugin

Parameters:

  • map Map

    Instance of Map

isObjectOutsideViewport

(
  • object
  • viewportArea
  • hasParent
)
Boolean private static

See if the given object or subcontainer is outside the given viewportarea. We check intersecting rectangles

Parameters:

  • object Object

    Object / layer we are testing

  • viewportArea Object

    ViewportArea location and size

    • x Integer

      X coordinate

    • y Integer

      Y coordinate

    • width Integer

      Viewports width (in pixels)

    • height Integer

      Viewports height (in pixels)

  • hasParent Boolean

    default = true

Returns:

startEventListeners

(
  • map
)

Parameters:

  • map Map

    Instance of Map

testRectangleIntersect

() private static

window.FlaTWorld_mapMovement_deactivate

() static

For debugging. Sets all primaryLayers subcontainers on the map as visible = true.

window.FlaTWorld_mapMovement_subCheck

() static

For debugging. Shows the amount of currectly active and inactive subcontainers. Console.logs the data. Also extends window object.