world callbacks problem
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
world callbacks problem
When one shape is sensor and another shape inside this sensor-shape engine calls "add" callback several times... And it is not good, so i need this callback only once - when two shapes collided. Anyone had same problem? And how I can solve it?
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: world callbacks problem
Please rephrase your question so us mortals can understand.
Help us help you: attach a .love.
Re: world callbacks problem
Ok, I'll try=)
For example I have 2 shapes, and
shape1:isSensor() = true
shape2:isSensor() = false
Also I set world callbacks like
myWorld:setCallbacks(addCallback, nil, nil, nil)
In game i have situation when second shape moves through first shape.In this situation addCallback called several times while shapes in contact.
But it should be called only once, as i understand from wiki... It is bug or feature?=) Or others don't have this bug, and probably problem in my code?
For example I have 2 shapes, and
shape1:isSensor() = true
shape2:isSensor() = false
Also I set world callbacks like
myWorld:setCallbacks(addCallback, nil, nil, nil)
In game i have situation when second shape moves through first shape.In this situation addCallback called several times while shapes in contact.
But it should be called only once, as i understand from wiki... It is bug or feature?=) Or others don't have this bug, and probably problem in my code?
- kikito
- Inner party member
- Posts: 3153
- Joined: Sat Oct 03, 2009 5:22 pm
- Location: Madrid, Spain
- Contact:
Re: world callbacks problem
I think it is a feature.
I don't have the time to do the tests now, but placing the callback on one of the nils (I don't remember which one) should do the trick - probably the second, like this:
One of the callbacks runs "every frame the bodies touch".
One of the callbacks runs once, in "the first frame the bodies touch".
The other runs once, in "just after the last frame the bodies touch".
There was also one misterous callback that I never understood when it was called.
I don't have the time to do the tests now, but placing the callback on one of the nils (I don't remember which one) should do the trick - probably the second, like this:
Code: Select all
myWorld:setCallbacks(nil, yourCallback, nil, nil)
One of the callbacks runs once, in "the first frame the bodies touch".
The other runs once, in "just after the last frame the bodies touch".
There was also one misterous callback that I never understood when it was called.
When I write def I mean function.
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: world callbacks problem
It truly is a mystery to all. Really! I'd give you money if you could tell me what it does exactly, if bartbes'd give me his bank card. (Got his PIN already.)kikito wrote:There was also one misterous callback that I never understood when it was called.
Help us help you: attach a .love.
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: world callbacks problem
The result callback, as far as I can tell, is called after a contact has been 'resolved'.
Who is online
Users browsing this forum: Bing [Bot], Google [Bot] and 9 guests