The main character was created with a sprite sheet and needs to be set up to view the animation it provides. Other display images that will make an appearance include a cracked egg when a collision to a physical object has been made. To create the character, perform the following steps:
Create a new local function called
createChar()
:local createChar = function()
Create the sprite sheet for the main character:
local sheetData = { width=128, height=128, numFrames=4, sheetContentWidth=256, sheetContentHeight=256 } local sheet = graphics.newImageSheet( "charSprite.png", sheetData ) local sequenceData = { { name="move", start=1, count=4, time=400 } } charObject = display.newSprite( sheet, sequenceData ) charObject:setSequence("move") charObject:play()
Set the starting position and physical properties for the main character:
charObject.x = 240; charObject.y = 250 physics.addBody( charObject, "static", { density...