In order to create our character, we'll need a sprite sheet with animations for walking, running, and jumping.
It should look something like the following image:
First of all, we'll create a resource definition as follows (put this below the background resource definition):
character = { type = RESOURCE_TYPE_TILED_IMAGE, fileName = 'character/character.png', tileMapSize = {20, 6}, width = 64, height = 64, }
This is pretty much the same as we used for our Concentration game, but note that we added
width
andheight
. That's the size of the tile. In the Concentration game, we defined the size of the tile in the grid, but now there is no grid, so we need to define it here.In order to handle that definition, we need to add some lines to
resource_manager.lua
, insideloadTiledImage
, just below the call tosetSize()
:if definition.width and definition.height then local half_width = definition.width / 2 local half_height = definition.height / 2 tiledImage...