TileSceneChanger

TileSceneChanger

A TileSceneChanger has methods for storing and referencing scene arrays and enemy arrays and other arrays. Its changeScene method also blits from your spriteSheet using the scene map changed to. The GameSkeleton Class uses this Class, doing much of the setup for you, or you can use this Class yourself to switch between various arrays.


Constructor

new TileSceneChanger(spriteSheetSource, canvasObject, sceneWidth, sceneHeight, tw, th, mainChar)

Constructs a new TileSceneChanger

Parameters:
Name Type Description
spriteSheetSource
canvasObject
sceneWidth
sceneHeight
tw
th
mainChar

Members

_cameraPoint

_direcs

_display

_enemyArrays

Used by addEnemyArray and getEnemyArray.

_map1

_map2

_mapNumber

_otherArrays

Used by addStoredArray and getStoredArray.

_source

_totalScenes

constructor

currentMap

currentScene

mainChar

sH

sW

tH

tW

Methods

add5Scenes(map2DArray, map2DArray2, map2DArray3, map2DArray4, map2DArray5)

Adds up to 5 scenes to _totalScenes

Parameters:
Name Type Description
map2DArray
map2DArray2
map2DArray3
map2DArray4
map2DArray5
Returns:

addEnemyArray(arr, scene)

Adds a enemy Array

Parameters:
Name Type Description
arr Array
scene Number

addScene(map2DArray)

These methods populate the ._totalScenes array with clones of the arrays you pass in. the ._totalScenes array should not be handled directly. Use referenceScene() if you need to reference scenes you add, the reference index will be in the order you place them starting from 1.

Parameters:
Name Type Description
map2DArray
Returns:

addStoredArray(arr, scene)

Adds a stored array. Retreve stored Arrays with getStoredArray

Parameters:
Name Type Description
arr Array

An Array to store.

scene Number

Index to store to, default is currentScene.

changeCurrentMap(mapInteger)

Changes the currentMap. If _map1 or _map2 is defined they will be used, otherwise the map is _totalScenes[mapInteger]

Parameters:
Name Type Description
mapInteger Number

The map to change to.

Returns:

changeScene(mapInteger, direction, camera, faMethod, faMethodObject, directScene, dontResetCameraX, dontResetCameraY, dontUpdateEnemyMaps, frameTime, ts, tweenType)

This method changes which map is being used and then blits it onto the canvasObject passed during construction of the Class. It also sets the mainChars ._map and any associated MapMovers/Travelers or SceneryObjects ._map property. And it will reset the camera as needed.

Parameters:
Name Type Description
mapInteger

the map to change to. 0 to change by added scenes and direction, 1 to change to the ._map1 of this class, 2 to change to ._map2 of this class.

direction

the direction the player is going; "left" "right" "down" "up" or 0 1 2 3

camera BasicCamera

a reference to the BasicCamera that is being used

faMethod String

a String of the method name to call during BlitMath.dispatchFunctionAssignments.

faMethodObject Object

the Object that contains the faMethod, normally the .game static Object for example from stage nine of the platformer tutorial.

directScene Number
dontResetCameraX Boolean
dontResetCameraY Boolean
dontUpdateEnemyMaps Boolean
frameTime Number
ts Number
tweenType String
Returns:

changeSceneEnemies(scene)

Changes the current enemy Array being referrenced.

Parameters:
Name Type Description
scene
Returns:

changeSceneryObjects(scene)

Changes the current scenery Array being referenced.

Parameters:
Name Type Description
scene
Returns:

clearAllArrays()

clears _totalScenes, _otherArrays and _enemyArrays

Returns:

defineMap1(map2DArray)

These methods use BlitMath.cloneMultiArray to clone the array you pass to them. The array passed remains a separate array, the method does not create a reference to the array passed in. Thereby ._map1 and ._map2 are unique until defineMap1/2 is called again ._map1 and ._map2 should never be set directly.

Parameters:
Name Type Description
map2DArray Array

defineMap2(map2DArray)

Defines _map2 see defineMap1.

Parameters:
Name Type Description
map2DArray Array
See:
  • defineMap1

getEnemyArray(scene) → {Array}

References a enemy Array.

Parameters:
Name Type Description
scene Number
Returns:
Type
Array

getStoredArray(scene) → {Array}

Returns a refence to a stored array stored with addStoredArray.

Parameters:
Name Type Description
scene Number
Returns:
Type
Array

referenceScene(referenceIndex)

Returns a reference to the scenes map.

Parameters:
Name Type Description
referenceIndex
Returns:

sceneryObjectSceneChange(sceneryObject, sceneryArray, limitLeft, limitRight, limitUp, limitDown) → {Number}

allow objects to be thrown into the next/previous scene

Parameters:
Name Type Description
sceneryObject SceneryObject
sceneryArray Array
limitLeft Number
limitRight Number
limitUp Number
limitDown Number
Returns:

Returns 1 if the object changed scene.

Type
Number