local function myCollisionPlant(self, event) if event.phase == "began" then if event.target.type == "badPlant" and event.other.type == "bird" then lifeCount = lifeCount - 1 displayLifeCount.text = "Lifes: " .. lifeCount audio.play(losePoint, {channel = audio.findFreeChannel()}); event.target:removeSelf() plant1[event.target] = nil -- We remove object from table display.getCurrentStage():setFocus(nil) end elseif (event.phase == "ended") then end end function kick1(event) ----- plant plant1 = display.newSprite(sheet2, { name="cat4", start=1, count=22, time=2000} ) plant1.xScale = -1; plant1.y = baseline -25 plant1.x = \_W+50--\_W+150; plant1.y = baseline -2 physics.addBody(plant1, "kinematic",{density=0, friction=0, bounce=0, radius=40}) plant1.type = "badPlant" plant1:play() plant1.collision = myCollisionPlant plant1:addEventListener("collision", plant1) plant1.isSensor = true end function scene:createScene( event group = scene.view; bird = display.newImage(group,"bird1.png",10) bird.x = 200 bird.y = centerY/3 --random(\_H2) -500 --\* .5 bird.type = "bird" physics.addBody( bird ,"dynamic", { density=1.0, friction=1, bounce=0, radius=20}) bird.isFixedRotation=true end function scene:enterScene( event ) group = self.view timer1 = timer.performWithDelay( math.random(5000,6000), kick1,-1) --plant end tPrevious = system.getTimer() local function move(event) local tDelta = event.time - tPrevious tPrevious = event.time local xOffset = ( 0.2 \* tDelta ) if plant1 ~= nil then plant1.x = plant1.x - xOffset end end -- Start everything moving Runtime:addEventListener( "enterFrame", move );