Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Box 2D: handle cannot be zero.

Author
Message
z i l c h vortex
19
Years of Service
User Offline
Joined: 20th Feb 2007
Location: united kingdom
Posted: 23rd Sep 2011 03:56
For some reason this code gives me a handle cannot be zero error.
If people could help me out it would be much appreciated Thank you.

life is short but so am i
BatVink
Moderator
23
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 23rd Sep 2011 14:38
It means you are trying to reference a body/fixture/joint that doesn't exist. You need to check your logic to see if there is a scenario where this can happen.

z i l c h vortex
19
Years of Service
User Offline
Joined: 20th Feb 2007
Location: united kingdom
Posted: 23rd Sep 2011 15:03
This is the only area of my code where i reference to any joints. And the roping code should stop it from running twice :/

life is short but so am i
Diggsey
20
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 23rd Sep 2011 23:58
b2PickFixture will return zero if it doesn't find anything, you need to test for this and respond appropriately.

[b]
z i l c h vortex
19
Years of Service
User Offline
Joined: 20th Feb 2007
Location: united kingdom
Posted: 24th Sep 2011 03:45
I tried this instead but still no cigar :/


life is short but so am i
BatVink
Moderator
23
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 24th Sep 2011 09:41
char.bodyId# could be non-existent.

z i l c h vortex
19
Years of Service
User Offline
Joined: 20th Feb 2007
Location: united kingdom
Posted: 24th Sep 2011 17:11 Edited at: 24th Sep 2011 17:12
It does exist. CHAR.BODYID# is a constant as well so it doesn't change.

life is short but so am i
Diggsey
20
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 24th Sep 2011 17:18 Edited at: 24th Sep 2011 17:18
Also, you can't store IDs in float variables, the range of a float is not large enough.

[b]
z i l c h vortex
19
Years of Service
User Offline
Joined: 20th Feb 2007
Location: united kingdom
Posted: 27th Sep 2011 04:32
I'm still having this problem. Can't seem to figure out how to fix it :/

life is short but so am i
BatVink
Moderator
23
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 27th Sep 2011 15:32
You'll need to add a B2PickFixture before using every joint/body, to establish which one is zero. Once you know which one it is, you're 90% closer to fixing the problem.

Diggsey
20
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 27th Sep 2011 18:30
Without seeing more of the code I can't do much to help.

[b]
z i l c h vortex
19
Years of Service
User Offline
Joined: 20th Feb 2007
Location: united kingdom
Posted: 28th Sep 2011 01:21
This is the main code:-
And this is the one for the functions : -


life is short but so am i
Diggsey
20
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 28th Sep 2011 12:12
JOINT is not declared global, so the first time through the "ROPE" function after releasing the mouse button, it will try to delete a joint with a handle of zero.

[b]
z i l c h vortex
19
Years of Service
User Offline
Joined: 20th Feb 2007
Location: united kingdom
Posted: 28th Sep 2011 18:17
Thank you diggsey!! Much appreciated.

life is short but so am i

Login to post a reply

Server time is: 2026-07-11 14:36:36
Your offset time is: 2026-07-11 14:36:36