Game Development Reference
In-Depth Information
16. When you're done, simply parse through the tilesToDelete list, remove the
tile from cachedTiles , and detach it from Spatial .
17. There is one more thing we need to do before leaving the class. In the setSpa-
tial method, we should add a call to updateTiles , supplying Vector-
2f.ZERO to it to initialize the generation of the tile.
For a larger implementation, we might want to introduce an AppState instance
to handle this, but here we will manage it with a test application.
18. First of all, we need to disable flyCam with flyCam.setEnabled(false)
and possibly move the camera to some distance from the ground.
19. Then, create a Node class called worldNode and an EndlessWorldCon-
trol instance called worldControl . Attach worldNode to rootNode and
supply the worldControl object with a material before adding it to
worldNode and setting the camera.
20. Finally, set up some keys to control the movement and add the worldControl
object as a listener; refer to the following code on how to do this:
inputManager.addMapping("Forward", new
KeyTrigger(KeyInput.KEY_UP));
inputManager.addMapping("Back", new
KeyTrigger(KeyInput.KEY_DOWN));
inputManager.addMapping("Left", new
KeyTrigger(KeyInput.KEY_LEFT));
inputManager.addMapping("Right", new
KeyTrigger(KeyInput.KEY_RIGHT));
inputManager.addListener(worldControl, "Forward",
"Back", "Left", "Right");
Search WWH ::




Custom Search