Reader small image

You're reading from  Corona SDK Mobile Game Development: Beginner's Guide

Product typeBook
Published inMar 2015
Publisher
ISBN-139781783559343
Edition1st Edition
Tools
Right arrow
Author (1)
Michelle M Fernandez
Michelle M Fernandez
Right arrow

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. To create the character, perform the following steps:

  1. Create a new local function called createChar():

        local createChar = function()
  2. 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()
  3. Set the starting position and physical properties for the main character:

        charObject.x = 240; charObject.y = 250
        physics.addBody( charObject, "static", { density...
lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Corona SDK Mobile Game Development: Beginner's Guide
Published in: Mar 2015Publisher: ISBN-13: 9781783559343

Author (1)