General discussion about LÖVE, Lua, game development, puns, and unicorns.
felix24
Party member
Posts: 163 Joined: Tue Jul 26, 2011 4:51 pm
Contact:
Post
by felix24 » 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:
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
Post
by Matzexxxxx » Mon Mar 12, 2012 7:30 pm
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
felix24
Party member
Posts: 163 Joined: Tue Jul 26, 2011 4:51 pm
Contact:
Post
by felix24 » Mon Mar 12, 2012 8:27 pm
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
Users browsing this forum: Ahrefs [Bot] , Bing [Bot] and 4 guests