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.

AppGameKit Classic Chat / Change Physics Mode

Author
Message
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 11th Dec 2014 15:26
Hi.

I created a Sprite and add static Physics with SetSpritePhysicsOn(spr,1). now in Elsewhere I need change Physics Mode to 2 (dynamic) but I don't know how can do it.even I can't find any function for change Physics mode.

Please Guide Me.

Thanks.
Funnell7
13
Years of Service
User Offline
Joined: 8th Sep 2011
Location: UK, England
Posted: 11th Dec 2014 15:49 Edited at: 11th Dec 2014 15:50
Delete the Physics and then re-add with the new mode...

SetSpritePhysicsDelete(spr)
SetSpritePhysicsOn(spr, 2)
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 11th Dec 2014 16:08
Thank Funnell7.

but this way make exist the problem. when I delete old physics and add new physics mode, my sprite slow move down.while Set Physics Gravity is exist and other physics sprites are ok.
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 11th Dec 2014 17:57
If you change the physics mode of a sprite to 2 it will become a "dynamic" sprite (one that will be affected by gravity, other forces and sprites). If you want the sprite to not be affected you should change the sprite to physics mode 1 (static-which will not be affected by other physics but which will affect other physics sprites) or 3 (kinematic-which can have its velocity and angular velocity set but which will not be affected by other physics and will affect other physics sprites).

You could think of it as follows:
1-Static-Cannot move but can get in the way
2-Dynamic-Can move, be moved and get in the way
3-Kinematic-Can move, cannot be moved and can get in the way

Have you seen or read the help files? They really do 'help'...
http://www.appgamekit.com/documentation/home.html
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 11th Dec 2014 18:31
I think you don't good understand my mean.my physics sprite at first is static mode.then I want change it to dynamic (mean mode 2).now when change it to dynamic,no have real dynamic physic and fall to down very slowly.
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 12th Dec 2014 10:41
Ah, you probably just need to experiment with "SetPhysicsScale"

Put it at the start of your code (before you create any physics sprites) and start with a value around 0.01 going lower will make things move faster and going higher will make them move slower.
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 12th Dec 2014 11:17 Edited at: 12th Dec 2014 11:18
use "SetPhysicsScale" make exist problem for all physics sprites and Everything is destroyed. I think use "SetPhysicsScale" is not good idea for fix this problem because other sprites that have Physics no have any Problem.
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 12th Dec 2014 14:57
Ok, you know best... it could be that you are affecting the physics of this sprite in some other way. Again this is not something that can be fixed in the dark. You may need to share some code.

Login to post a reply

Server time is: 2024-11-25 13:37:26
Your offset time is: 2024-11-25 13:37:26