local sequenceData = {
{ name="beachboy_hat_yellow", frames={1} },
{ name="beachboy_body_dark", frames={34} },
{ name="beachboy_shorts_red", frames={42} },
{ name="beachboy_arm_dark", frames={ 5,12,15,19,23,26 }, loopDirection="bounce" },
{ name="beachboy_foot_dark", frames={47} }
}
-- CREATE A DISPLAY GROUP FOR THE CHARACTER
local beachboy = display.newGroup()
-- CREATE BODY PARTS AS SPRITES
local hat = display.newSprite( sheet, sequenceData )
hat:setSequence( "beachboy_hat_yellow" )
local body = display.newSprite( sheet, sequenceData )
body:setSequence( "beachboy_body_dark" )
local shorts = display.newSprite( sheet, sequenceData )
shorts:setSequence( "beachboy_shorts_red" )
local rightArm = display.newSprite( sheet, sequenceData )
rightArm:setSequence( "beachboy_arm_dark" )
local leftArm = display.newSprite( sheet, sequenceData )
leftArm:setSequence( "beachboy_arm_dark" )
local rightFoot = display.newSprite( sheet, sequenceData )
rightFoot:setSequence( "beachboy_foot_dark" )
local leftFoot = display.newSprite( sheet, sequenceData )
leftFoot:setSequence( "beachboy_foot_dark" )
-- POSITION PARTS & ORIENT L/R SIDES WITH SCALING
shorts.x, shorts.y = 0, 15
leftArm.x, leftArm.y = -20, -18
leftArm.xScale = -1 --flip 'leftArm' horizontally
-- etc...
-- INSERT ELEMENTS INTO THE DISPLAY GROUP, ORDERED BOTTOM TO TOP
beachboy:insert(leftFoot)
beachboy:insert(rightFoot)
beachboy:insert(shorts)
-- etc...
-- STORE REFERENCES TO EACH ELEMENT
beachboy["feet"] = {leftFoot, rightFoot}
beachboy["shorts"] = shorts
beachboy["body"] = body
-- etc...