i am making a game were you have stick figures run at your castle and when you tap on the screen they are removed
what i have: stick figures running at the castle and a red circle showing up when you touch the screen
what i’m missing: the stickfigures do not go away when they colide with the circle
CODE:
[lua]physics = require(“physics”)
physics.start()
physics.setGravity( 0, 0 )
sprite = require(“sprite”)
background = display.newImage(“paper.png”,0,0)
castle2 = display.newImage(“castle1.png”)
castle2.xScale=1
castle2.y=250
castle2.x=300
castle = display.newImage(“castle1.png”)
castle.xScale=1
castle.y=200
castle.x=300
physics.addBody( castle)
castle.bodyType = “kinematic”
dudes = {}
function soldierMakre (event)
soldier = sprite.newSpriteSheetFromData( “bla.png”, require(“bla”).getSpriteSheetData() )
spriteSet = sprite.newSpriteSet(soldier,1,10)
sprite.add(spriteSet,“soldier”,1,10,1000,0)
spriteInstance = sprite.newSprite(spriteSet)
spriteInstance.x = math.random(50,550)
spriteInstance.y = math.random(1100,1300)
physics.addBody( spriteInstance, { density = 1,friction=1, bounce=0 } )
dudes[#dudes+1] = spriteInstance
spriteInstance.isFixedRotation = true
spriteInstance:play()
end
timer.performWithDelay( 300,soldierMakre, 50 )
function mover(event)
for i, v in pairs(dudes) do
local phase = event.phase
if ( event.phase == “began” ) then
t= math.pow((dudes[i].x - event.x),2)
w=math.pow((dudes[i].y - event.y),2)
d=math.sqrt (t+w)
if (d>0) then
print(“d”)
dudes[i]:removeSelf()
dudes[i] = nil
end
end
dudes[i]:setLinearVelocity( math.random(-50,50), -100 )
end
end
timer.performWithDelay( 300,mover, 100000 )
local function bomb(event )
if ( event.phase == “began” ) then
local ball = display.newImage(“ball.png”)
ball.xScale=.5
ball.yScale=.5
ball.x = event.x
ball.y = event.y
physics.addBody( ball, { density = 1.0, friction = 0.3, bounce = 0.2, radius = 50})
end
end
background:addEventListener( “touch”, bomb )[/lua]
please help
THANKS IN ADVANCE
;p [import]uid: 28068 topic_id: 7715 reply_id: 307715[/import]
[import]uid: 28068 topic_id: 7715 reply_id: 27444[/import]