Hi Rob,
Here’s the code.My local functions are not declared in any storyboard scene.Also my setSequence doesn’t work for the cowboy. Thank you.
. . . local function cowboy (event) local sheetData = {width = 70,height = 107,numFrames = 8,sheetContentWidth = 140,sheetContentHeight = 428} local mySheet = graphics.newImageSheet ("CowboyWalking.png",sheetData) local sequenceData = {name = "cowboy2",start = 1,count = 8,time = 1100,loopcount = 0}, {name = "cowboyShooting",start = 9,count = 14,time = 1200,loopcount = 0} local cowboy = display.newSprite (mySheet,sequenceData) cowboy.x = 50 cowboy.y = 700 cowboy.rotation = 90 cowboy:setSequence ("cowboyShooting") cowboy:play() physics.addBody (cowboy,"static",{friction = 0.2,radius = 18 }) return cowboy end local function cowboySpawn (event) for i = 0,0 do local cowboy = cowboy() cowboy.x = 50 cowboy.y = math.random (600,950) local removeCowboy = function() display.remove (cowboy) cowboy = nil end cowboyIntro = transition.to (cowboy,{time = 19000,y = -50,onComplete = removeCowboy}) end end local function cow (event) local sheetData = {width = 100,height = 100,numFrames = 8,sheetContentWidth = 200,sheetContentHeight = 400} local mySheet = graphics.newImageSheet ("CowWalk.png",sheetData) local sequenceData = {name = "cowOne",start = 1,count = 8,time = 950,loopcount = 0,looDirection = "forward"} local cowOne = display.newSprite (mySheet,sequenceData) cowOne.x = 35 cowOne.y = 700 cowOne.rotation = 90 cowOne:play() physics.addBody (cowOne,"static",{friction = 0.2,radius = 22}) return cowOne end local function cowSpawnOne (event) for i = 0,0 do local cowOne = cow() cowOne.x = 38 cowOne.y = math.random (600,850) local removeCow = function () display.remove (cowOne) cowOne = nil end cowIntro = transition.to (cowOne,{time = 23000,y = -50,onComplete = removeCow}) if score == 300 then cowIntro = transition.to (cowOne,{time = 18000,y = -50,onComplete = removeCow}) if score \>= 300 then cowIntro = transition.to (cowOne,{time = 15000,y = -50,onComplete = removeCow}) end end end end local function cowOneCollision (self,event) if event.phase == "began" then print ("You hit a cow") elseif event.phase == "ended" then print ("Collision ended") end end -- Normal function ends here. -- This is the enterScene function.We can add event listeners and other things. function scene:enterScene (event) local group = self.view local cowOne = cow() local cowboy = cowboy() cowOne.collision = cowOneCollision cowOne:addEventListener ("collision",cowOne) . . . --some other events listeners.