Hey guys,
I’m not sure whatI’m doing wrong with my sprite sheet.I want the “cowBeaming” sequence to play only once,but it keeps repetaing. The sequence is triggered by a collision event.I tried to create another collision function (event.phase == “ended”) to stop the cowBeaming sequence,but it didn’t work.
Got any ideas?
Thanks!
local sheetData = {width = 100,height = 100,numFrames = 14,sheetContentWidth = 200,sheetContentHeight = 700} local mySheet = graphics.newImageSheet ("cow.png",sheetData) local sequenceData = { {name = "cowWalking",start = 1,count = 8,time = 1300,loopcount = 0}, {name = "cowBeaming",frames = {9,10,11,12,13,14},time = 1000,loopcount = 1} } local cow = display.newSprite (mySheet,sequenceData) cow.rotation = 90 cow.x = 30 cow.y = 450 cow:setSequence ("cowWalking") cow:play() physics.addBody (cow,"static",{radius = 15}) cow.isSensor = true cow:setLinearVelocity (0,0) local function two (event) if cow.y == 450 then cow.xScale = 1 transition.to(cow,{time = 16000,y = 7}) elseif cow.y == 7 then cow.xScale = -1 transition.to (cow,{time = 16000,y = 450}) end end timer.performWithDelay (100,two,0) local function cowCollision (event) if event.phase == "began" then cow:setSequence ("cowBeaming") cow:play() end end cow:addEventListener ("collision",cowCollision) group:insert (cow)