Game Development Reference
In-Depth Information
How it works...
The process that we follow is that if a movement occurs, the moveTiles method will first
move all the tiles to cachedTiles . It then checks to see whether there's a new tile that
should be the center or whether it should be currentTile . If this happens, other tiles
must be checked to see which ones should be kept and which ones need to be generated.
This happens in the updateTiles method. Last in the chain is the deleteTiles
method that checks which tiles should be removed because they are too far away.
If we print out the translation of the tiles, we can see that they are never very far from the
center of their parent node. This happens because when we generate the tiles, we place
them relative to currentTile . Since currentTile is also based on a relative posi-
tion, things never move very far. It's almost like a conveyor belt.
Search WWH ::




Custom Search