Tile-Based game
The Tile-Based game template displays the use of the TileMap plugin and the TileMovement Behavior.
The Tilemap object allows tile-based games to be designed more easily. The object's tilemap can also be edited in the layout view using the Tilemap Bar.
Please read the dedicated manual article for the TileMap object to learn more on this plugin itself.
In this template, a TileMap object is used as the background images (BackgroundTilemap) and another TileMap object is used to only display elements that are solid and shouldn’t be walked across (SolidTilemap).
The player controls a character that is composed of the Player_Box (which contains the TileMovement behavior and acts as the position of the character in the game) and of the Player_Mask (which has the ScrollTo behavior to set the game view to point on the character at all times and displays the animation of the character according to its current direction and action).
The TileMovement behavior manages the movement of the character in the various tiles. If you press an arrow key once, you will see the character move in that direction up to the middle of the next tile. You can also maintain the key held down which will provide a smooth and on-going movement, without cuts or stops.
The TileMovement behavior also handles the fact that a tile present on the SolidTilemap is in the way and will prevent the movement in that direction.
The Keyboard plugin is used in addition to the “Default controls” property of the TileMovement behavior.
The default controls handle the actual movement.
Nevertheless, the fact that a specific arrow key is pressed also does trigger one of the events from 2 to 5, setting up a value for the instance variable “Direction”.
This value is then used as part of the name of the animation to display in events 6 and 7.
Animations are a collection of frames inside a Sprite. Those frames are displayed one after the other in order to give an impression of movement.
Frames are displayed according to the animation speed property of the animation.
This template has no winning or losing conditions.