I tried to add a body and the zombie is just falling down .
zombie = display.newSprite( imageSheet, sequenceData ) physics.addBody( zombie, {density=3.0} )
local Coins = 0 local centerX = 350 local centerY = 60 local CoinsTxt = display.newText( "Coins: "..Coins, centerX, centerY, native.systemFontBold, 20 ) end local bullet = {} local bCounter = 1 local function shootBullet(event) if event.phase == "ended" then bullet[bCounter] = display.newImage( "bullet5.png", 40, 298, 1, 6) bullet[bCounter].value = bCounter physics.addBody( bullet[bCounter], "dynamic" ) bullet[bCounter].gravityScale = 0 bullet[bCounter].myName = "bullet" bullet[bCounter]:setLinearVelocity( 2100, -20 ) bCounter = bCounter + 1 end end local function onCollision( self, event ) if event.phase =="began" then Coins = Coins + 5 CoinsTxt.text="Coins: "..Coins end end function game.start( ) -- Game is already started, just exit if( isRunning ) then return end -- Mark game as running isRunning = true gun:addEventListener( "touch", shootBullet ) end
Whenever I add an event listener for the zombie I get a couple of errors