A Little Löve Game

General discussion about LÖVE, Lua, game development, puns, and unicorns.
User avatar
felix24
Party member
Posts: 163
Joined: Tue Jul 26, 2011 4:51 pm
Contact:

Re: A Little Löve Game

Post 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
Matzexxxxx
Prole
Posts: 7
Joined: Tue Mar 06, 2012 6:20 pm

Re: A Little Löve Game

Post by Matzexxxxx »

thank you =)
Matzexxxxx
Prole
Posts: 7
Joined: Tue Mar 06, 2012 6:20 pm

Re: A Little Löve Game

Post 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 :(
User avatar
felix24
Party member
Posts: 163
Joined: Tue Jul 26, 2011 4:51 pm
Contact:

Re: A Little Löve Game

Post 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
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests