Remove body in love.update

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
raen79
Citizen
Posts: 55
Joined: Sat Jul 21, 2012 11:58 pm

Remove body in love.update

Post by raen79 »

Hey guys, I have a script that makes a new body when a lever is pressed, however, the problem is that the script that makes the new body is in love.update so it can appear whenever I want it too. Therefore, when I load a new map, and say platform.b:destroy() (the body in question) the platform does not get destroyed, what do I do? Here is the script and love file:

Code: Select all

if platform_body==true then
lever.b:destroy()
platform.b:destroy()
platform_body=false
end
Attachments
game.love
(2.75 MiB) Downloaded 131 times
Last edited by raen79 on Sat Jul 28, 2012 7:07 am, edited 1 time in total.
raen79
Citizen
Posts: 55
Joined: Sat Jul 21, 2012 11:58 pm

Re: Remove body in love.update

Post by raen79 »

Here only one file :)
Last edited by raen79 on Sat Jul 28, 2012 7:08 am, edited 1 time in total.
User avatar
Jasoco
Inner party member
Posts: 3725
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Remove body in love.update

Post by Jasoco »

You could have edited your post to replace the original attachment. Now you have two projects. One of which is wrong. You should remove the first one.
User avatar
juno
Citizen
Posts: 85
Joined: Thu May 10, 2012 4:32 pm
Location: London

Re: Remove body in love.update

Post by juno »

Hey raen79,

I found your problem. When you flip the lever you're changing lever_pressed==true which creates the platform body dynamically.
Then... each time the love.updatemap() function is called, lever_pressed is still true and creates another platform body, and another...
If you restrict this to just one then it works fine.

Hope this helps :)

By the way, since you are using love's physics library, why do you need to check for collisions?
wat ya mean she's in another castle!?
raen79
Citizen
Posts: 55
Joined: Sat Jul 21, 2012 11:58 pm

Re: Remove body in love.update

Post by raen79 »

It helped a lot thank you :) I check for collisions because I want the character to change when it hits the platform or the ground. So when it is not on the ground or on the platform, the character is in a jumping animation ;) thank you very much.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Remove body in love.update

Post by Robin »

You will want to use World:setCallbacks.
Help us help you: attach a .love.
Post Reply

Who is online

Users browsing this forum: Bing [Bot], BrotSagtMist and 225 guests