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 / "Pausing" Revolute Joint objects

Author
Message
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 3rd May 2012 21:19 Edited at: 3rd May 2012 21:22
I'm trying to make sure that when the pause button or menu button are pressed during game play that all the moving objects stop properly. And then they should continue doing what they were doing when the unpause button or 'continue game' menu item are selected.

I've been able to get everything but the revolute joint objects to behave.

This is the setup code:


The code to pause the bits:


The code to restart it:


When I do the pause, the visible revolving sprite slows down a lot, but does not stop.

When I restart it, if I leave it paused long enough, the visible sprite goes backwards for a bit before getting back up to speed. If it is a short pause, the saved vector is still in the general forward direction of the sprite, it just gets back up to speed.

But in any case, the sprite does not stop completely.

Can anyone help me figure out the right way to pause/restart the sprites involved with a revolute joint?

Or tell me what I am doing wrong?

I do not know if this would have behaved differently in v1065. I just created the code for this piece today, with v1070.

Thank you.

Cheers,
Ancient Lady
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 3rd May 2012 21:48
Easier just to use stepPhysics(0) to pause all physics simulation.

Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 3rd May 2012 23:15 Edited at: 3rd May 2012 23:22
Sounds like a good idea.

But didn't quite work.

If I did StepPhysics(0.0) to stop and StepPhysics(ScreenFPS) to start, by themselves, there was no affect act all.

If I did them in addition to the other things, then it still only slowed the movement and it jumped forward on restart.

Thank you for trying baxslash, you generally have very good ideas.

EDIT: It turned out to be uber-simple - use SetSpritePhysicsOff and SetSpritePhysicsOn. I just had to look at the list of commands. Doh!

Cheers,
Ancient Lady
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 3rd May 2012 23:29
If you had used stepPhysics(getFrameTime()) rather than fps it would have worked much better...

Thanks for the compliment too

Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 3rd May 2012 23:33
The initial StepPhysics(0.0) didn't stop anything.

I think it is intended to 'move' where the physics action is. Like jump something forward x amount of time. It adds to the physics generation rather that stopping it.

Cheers,
Ancient Lady
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 3rd May 2012 23:45
No, if you call stepPhysics it steps the simulation forward by the specified number of seconds. This is normally done automatically by the sync but if you manually call it it is no longer done.

You have to do it before every sync in your pause loop but trust me it does work.

Email me your code or post it here and I'll show you what to change. I have used this a LOT. So I know it works.

Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 4th May 2012 16:43
As I thought, StepPhysics is definitely not what would do what I want, which is to pause everything and restart at the same point.

The SetPhysicsOn/Off commands did exactly what I needed, so my problem is solved.

Cheers,
Ancient Lady
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 4th May 2012 17:41
Oh, I didn't realise that you only wanted to pause some items and not others, my mistake.

Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 4th May 2012 20:59
No problem. I appreciate your help anyway.

The StepPhysics command may actually have a great game place use. Something like a time warp field the jumps you 'forward' in time by taking a big step. It could be quite interesting.

Cheers,
Ancient Lady
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 4th May 2012 21:01
It's also good for "bullet time" slow down effects just after explosions

Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 4th May 2012 21:24
Or for "low gravity" and everything moves slower.

Too bad you can't apply StepPhyics to selected sprites. Then you could really have some fun!

Cheers,
Ancient Lady
Max P
14
Years of Service
User Offline
Joined: 23rd Jan 2010
Location:
Posted: 4th May 2012 23:23 Edited at: 4th May 2012 23:23
You can use 'setSpriteActive(id, 0)' it should freeze the sprite.
This is my code for pausing:


Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 4th May 2012 23:49
That works, too!

And a neater solution, since you don't have to remember what the physics type was for the object when you turn physics back on.

Thank you, again.

Cheers,
Ancient Lady

Login to post a reply

Server time is: 2024-05-02 03:44:47
Your offset time is: 2024-05-02 03:44:47