Hi !
I have a problem with class…
I have a zombie class that is called when I create a physical body as shown called zombie when zombie is located between the variable laax I apply force, the problem is that if I call two or more zombies only apply force to the last! why?
the code below…
Zombie.ZombieMovement(laax)
local zombie1 = Zombie.new(lol.x, lol.y, ZombiePosition)
game:insert(zombie1)
module(..., package.seeall)
function Zombie(x, y, ZombiePosition)
position = ZombiePosition
local AnimZombie = graphics.newImageSheet( "images/zombie.png", { width=71, height=83, numFrames=10 } )
local Zombie = display.newSprite( AnimZombie, { name="zombie", start=1, count=10, time=850 } )
Zombie.x = x
Zombie.y = y
Zombie.type = "kill"
Zombie.isAlive = true
physics.addBody( Zombie, "dynamic", { friction=0, density=3, bounce=0} )
Zombie:play()
function ZombieMovement(laax)
if(Zombie and Zombie.isAlive == true )then
if(Zombie.x \< laax + 9 and Zombie.x \> laax - 9 )then
Zombie:applyForce(0, -100, Zombie.x, Zombie.y )
end
end
end
return Zombie
end
function new(x, y, ZombiePosition)
return Zombie(x, y, ZombiePosition)
end
Thanks to all !!! [import]uid: 47941 topic_id: 34067 reply_id: 334067[/import]