[BUG Workaround]Physics and reseting ScrollX: weird effects

For questions about using Classic.

Post » Sun May 23, 2010 7:20 pm

Hi all,

I have a tiled background and 2 sprites with physics.
I apply a force of X=100 to the sprites and set their "center on me" attribute in an unbound layer.

Every time ScrollX reaches 100 I set sprites X to sprites X - ScrollX and TiledBackground.X = TiledBackground.X - ScrollX.

For Tiles, no problems but the distance between the sprites is greater each time and I don't understand.

Here is the cap [url:4wrjpeod]http://www.box.net/shared/xsj88ea2al[/url:4wrjpeod]

Please, help, I'm desesperate :(
B
3
S
1
G
2
Posts: 80
Reputation: 985

Post » Sun May 23, 2010 10:51 pm

It seems to be an issue with setting the position of an object with the physics behavior. But it also seems to affect [u:3if0g87d]only[/u:3if0g87d] the first object that has physics.

The solution is to create a dummy object with the physics behavior and make it the first object at edittime by sending it to the back.

Do this:
[list:3if0g87d]Create another sprite to be a dummy object.
Give it the physics behavior.
Set the physics collision mask to none, so legitimate physics objects won't collide with it.
Right click on the object and send it to back.[/list:u:3if0g87d]
B
79
S
24
G
52
Posts: 4,725
Reputation: 39,713

Post » Mon May 24, 2010 4:53 am

[quote="R0J0hound":1uaxlbyc]It seems to be an issue with setting the position of an object with the physics behavior. But it also seems to affect [u:1uaxlbyc]only[/u:1uaxlbyc] the first object that has physics.

The solution is to create a dummy object with the physics behavior and make it the first object at edittime by sending it to the back.

Do this:
[list:1uaxlbyc]Create another sprite to be a dummy object.
Give it the physics behavior.
Set the physics collision mask to none, so legitimate physics objects won't collide with it.
Right click on the object and send it to back.[/list:u:1uaxlbyc][/quote:1uaxlbyc]
Now that's important what you found out! It should be on the wiki, because almost everyone playing around with physics stumbled upon this one without a solution (at least I couldn't read on the forums other than "there are issues")...and it is so simple to solve. Great work ROJOhound!
Image
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242

Post » Mon May 24, 2010 8:50 am

Very good idea, I'll try that.

Thanks a lot.
B
3
S
1
G
2
Posts: 80
Reputation: 985

Post » Mon May 24, 2010 12:13 pm

It works :D

Should I post a defect?
B
3
S
1
G
2
Posts: 80
Reputation: 985


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 2 guests