O'Reilly logo

Corona SDK Mobile Game Development by Michelle M. Fernandez

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action – creating the character

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.

  1. Create a new local function called createChar().
        local createChar = function()
  2. Create the sprite sheet for the main character.
          local characterSheet = sprite.newSpriteSheet
            ( "charSprite.png",128, 128 )
          local spriteSet = sprite.newSpriteSet(characterSheet, 1, 4)
          sprite.add( spriteSet, "move", 1, 4, 400, 0 )
          charObject = sprite.newSprite( spriteSet )
          charObject:prepare("move")
          charObject:play()
  3. Set the starting position and physical properties for the main character.
     charObject.x ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required