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.
Item Index
Methods
- _setMap static
- addAll
- calculateOffset static
- check
- checkAndSetSubcontainers
- getViewportWithOffset static
- init
- isObjectOutsideViewport static
- startEventListeners
- testRectangleIntersect static
- window.FlaTWorld_mapMovement_deactivate static
- window.FlaTWorld_mapMovement_subCheck static
Methods
_setMap
()
private
static
calculateOffset
()
private
static
check
-
map
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
MapThe current Map instance
Returns:
True
checkAndSetSubcontainers
-
scaledViewport
-
primaryLayers
Checks proper subcontainers and mark the correct ones visible or hidden
getViewportWithOffset
-
viewportArea
forms the total viewport parameters based on the given ones.
Parameters:
-
viewportArea
AreaSizeGiven viewport area
Returns:
The total viewportArea
isObjectOutsideViewport
-
object
-
viewportArea
-
hasParent
See if the given object or subcontainer is outside the given viewportarea. We check intersecting rectangles
Parameters:
Returns:
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.