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 / Box2D disappearing objects

Author
Message
BatVink
Moderator
23
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 6th Mar 2011 01:08
Can anybody explain what I have done here?

1. Play Game (Load images, Make Dynamic, Static and Kinetic bodies with multiple fixtures, joints etc) Images are attached to Box2D bodies with b2SetBodyImage

2. End Game, Delete all bodies. This deletes all associated fixtures and joints. World is not deleted.

3. Play Game a second time. World forces have been reset, all images and bodies recreated as in step 1. This time, nothing Box2D is displayed, this is the problem.

4. Use b2SetScreenTransform to move the screen upwards as mouse gets to top. This triggers the display of the Box2D Objects.

Video of problem:



BatVink
Moderator
23
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 6th Mar 2011 14:18
I fixed this by starting each game with a b2SetScreenTransform, although it would be good to know what the real issue is.

IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 6th Mar 2011 21:03
I guess you'll have to wait for Diggsey to drop by, or drop him an email, or (if he's got post notification on it) post into the 'official' box2d thread

baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 6th Mar 2011 21:54
Looks like a bug to me...

Diggsey
20
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 8th Mar 2011 18:51 Edited at: 8th Mar 2011 19:01
Sorry I didn't reply sooner, I only just noticed this thread.

I'm not sure yet what's causing the problem. Could you post some example code or an executable which shows the problem?

I'm finding it difficult to see how b2SetScreenTransform could cause the problem as it is just this:


The only thing I can think of is that it is previously being called with values which put everything off-screen somewhere until it is called again. (The screen transform is not specific to a world)

[b]
BatVink
Moderator
23
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 8th Mar 2011 23:51
Hi Diggsey,

thanks for replying. b2SetScreenTransform doesn't cause the roblem, it fixes it.

In the first part of the video, the cloud, sky, and hoists on the left never move/up down, this is an indicator that I never transformed the screen.

In the second part, which starts off blank, it is fixed when the cursor reaches the top of screen and the transform takes place to scroll.

So...make bodies, delete bodies, make bodies again and transform required to make them visible.

I may struggle to separate some code out, I'll see what I can do.

Diggsey
20
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 9th Mar 2011 00:28
Quote: "b2SetScreenTransform doesn't cause the roblem, it fixes it."


Yeah I knew in my mind what you meant, I just wrote it down wrongly I meant it's difficult to see how it could fix it.

If you can't separate out the code, I should be able to debug the .exe itself.

[b]

Login to post a reply

Server time is: 2026-07-15 13:58:32
Your offset time is: 2026-07-15 13:58:32