Page 2 of 2

Re: A Little Löve Game

Posted: Thu Mar 08, 2012 4:01 pm
by felix24
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:

Code: Select all

objects.Enemy.isDead = false
so in you add function your could have something like this:

Code: Select all

function add(a, b, coll)
    if b == "Gegner" then
        objects.Enemy.isDead = true
        objects.Enemy.b:setX(1000)
    end
end
and in your love.update function, you would only update the enemy if they are alive. ie:

Code: Select all

if objects.Enemy.isDead == false then
    **update enemy**
end

Re: A Little Löve Game

Posted: Fri Mar 09, 2012 7:42 pm
by Matzexxxxx
thank you =)

Re: A Little Löve Game

Posted: Mon Mar 12, 2012 7:30 pm
by Matzexxxxx
Now i want to set a radius down if a condution is true.
expample:


My Object / shape:

Code: Select all

  objects.player1 = {}
  objects.player1.b = love.physics.newBody(world, 650/2,650/2, 100,0)
  objects.player1.s = love.physics.newCircleShape( objects.player1.b, 0, 0, 10 )
In the update Function:...?
Maybe something like:

Code: Select all

if lvl3 == true then
objects.player1.s:setRadius(8)

end
i know its false, but i had it times ago.
Please help me :(

Re: A Little Löve Game

Posted: Mon Mar 12, 2012 8:27 pm
by felix24
i don't think you can update the radius directly like that. you could try just creating a new shape altogether.
like so:

Code: Select all

if lvl3 then
    objects.player1.s = love.physics.newCircleShape( objects.player1.b, 0, 0, 8 )
end