Re: A Little Löve Game
Posted: Thu Mar 08, 2012 4:01 pm
the reason your program crashes is that box2d doesn't like it when you destroy bodies off hand. an easy way to solve this is just to move the enemy off the screen, and flag it as being dead. ie, give it a boolean value isDead or something. like this:
so in you add function your could have something like this:
and in your love.update function, you would only update the enemy if they are alive. ie:
Code: Select all
objects.Enemy.isDead = false
Code: Select all
function add(a, b, coll)
if b == "Gegner" then
objects.Enemy.isDead = true
objects.Enemy.b:setX(1000)
end
end
Code: Select all
if objects.Enemy.isDead == false then
**update enemy**
end