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 / how do i pause my game

Author
Message
kirtn14
12
Years of Service
User Offline
Joined: 8th Sep 2011
Location:
Posted: 23rd Oct 2011 13:13
can anyone please tell me how i can pause my app so nothing works then continue playing it again? thanks

kirtnicholls
The Zoq2
14
Years of Service
User Offline
Joined: 4th Nov 2009
Location: Linköping, Sweden
Posted: 23rd Oct 2011 20:27
One way would be



Is one way of doing it. Esentialy all you have to do is "jump" out of the "main loop" using Gosub and then Return to get back in

Hope it helps

Srry about my english im from sweeden
Steve Ancell
18
Years of Service
User Offline
Joined: 16th Feb 2006
Location: Brighton, East Sussex, UK
Posted: 23rd Oct 2011 21:31 Edited at: 23rd Oct 2011 21:35
Or, you could do this.

kirtn14
12
Years of Service
User Offline
Joined: 8th Sep 2011
Location:
Posted: 23rd Oct 2011 22:06
thasnks may i ask where i can find all these code they must origionate from somewhere?

kirtnicholls
kirtn14
12
Years of Service
User Offline
Joined: 8th Sep 2011
Location:
Posted: 23rd Oct 2011 22:09
many thanks you have answers 2 of my questions in one code

kirtnicholls
Steve Ancell
18
Years of Service
User Offline
Joined: 16th Feb 2006
Location: Brighton, East Sussex, UK
Posted: 24th Oct 2011 03:57
Quote: "may i ask where i can find all these code they must origionate from somewhere?"


My code comes from many years of my programming hobby. The more you practice, the more you learn.

The best way to learn, try to think of each task in a program as a module rather than as individual commands.
kirtn14
12
Years of Service
User Offline
Joined: 8th Sep 2011
Location:
Posted: 24th Oct 2011 11:04
i treid using the code you gave me but iy only pauses the counter not the entire game is that meant to happen?

kirtnicholls
MobileCreator
12
Years of Service
User Offline
Joined: 1st Jun 2011
Location: Ottawa - Canada
Posted: 24th Oct 2011 16:08 Edited at: 24th Oct 2011 16:09
Hey kirtn14,

when you're pausing the game, the main idea is to stop calling the portion of your code that does the game itself, like the update loop, or whatever.

So, if you took Steve's code snipet, you should use the "pause" variable to check if you should call the main loop (the game itself) or not.

Where he added the:

//Update Game Logic.
if pause = 0
counter = counter + 1
endif

means that this *if* will be true, and run the code inside it only when the game is *not* paused. In other words, your game logic, like update position, draw sprites, etc, should be inside it.

You could use game states to accomplish something similar, but try this first, and see if it works.

I hope it helps

Cheers

----------
Paulo
http://www.mobilecreators.com
Steve Ancell
18
Years of Service
User Offline
Joined: 16th Feb 2006
Location: Brighton, East Sussex, UK
Posted: 24th Oct 2011 16:26
Thankyou MobileCreator, that's a very good way of explaining my code in a simple and easy to understand way.
MobileCreator
12
Years of Service
User Offline
Joined: 1st Jun 2011
Location: Ottawa - Canada
Posted: 24th Oct 2011 16:51
Thanks! Glad you didn't think I've hijacked your answer

----------
Paulo
http://www.mobilecreators.com
kirtn14
12
Years of Service
User Offline
Joined: 8th Sep 2011
Location:
Posted: 24th Oct 2011 21:37
its really onnoying i feel like what your saying should make sense but no matter how much i read it it doesnt ive read everything inthe instructions and i still cant pause my game its so frustrating i tried making the game sleep but it only sleeps for a little while and cant be changed anyother way

kirtnicholls
Steve Ancell
18
Years of Service
User Offline
Joined: 16th Feb 2006
Location: Brighton, East Sussex, UK
Posted: 25th Oct 2011 00:30 Edited at: 25th Oct 2011 00:31
@kirtn14: Just keep experimenting and don't give up, there may be a bit of a learning curve but you will be OK.

@MobileCreator: I'm glad you helped, I'm OK-ish at doing things but not as good at explaining them.
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 25th Oct 2011 00:55
Attached is a small example project of how pausing might be done.

As you'll see from the example I have to manually stop animated sprites but other objects such as physics sprites can be stopped by setting the "update" time to zero.

Have a look and see if it helps you understand a little. If you have any questions please ask!

Attachments

Login to view attachments
Steve Ancell
18
Years of Service
User Offline
Joined: 16th Feb 2006
Location: Brighton, East Sussex, UK
Posted: 25th Oct 2011 18:05
@baxslash:
I knew that sprites and stuff would also need to be dealt with, but thanks for pointing that out. You have just provided a very useful bit of info there, something that I obviously overlooked in my example. Now I'm off to write 500 lines to learn my lesson. LOL
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 25th Oct 2011 18:15
Quote: "I knew that sprites and stuff would also need to be dealt with, but thanks for pointing that out. You have just provided a very useful bit of info there, something that I obviously overlooked in my example."

To be honest it's not something I'd dealt with yet so I took a look to see what the issues were and found that contrary to what I expected "Update" does not control animated sprites...

Quote: "Now I'm off to write 500 lines to learn my lesson."

Hee, "I must remember the sync sequence" x500

Steve Ancell
18
Years of Service
User Offline
Joined: 16th Feb 2006
Location: Brighton, East Sussex, UK
Posted: 25th Oct 2011 18:23
Quote: "Hee, "I must remember the sync sequence" x500"


I like your sense of humour baxslash, brilliant!. LOL
Impetus73
12
Years of Service
User Offline
Joined: 28th Aug 2011
Location: Volda, Norway
Posted: 25th Oct 2011 19:15
kirtn14, Do you mean that you want to pause the game so that you can use the phone it's running on to do other stuff, then go back to the game and continue where you paused it? I don't think that is doable yet.

If you mean to pause the game, while still running it, you'll have to do as sugested here. The program never stops, but you can make it run in circles waiting for you to let it run the game logic again.

----------------
AGK user - novice
Did Amiga / AMOS programming in the 90's, just started programming again with AGK.
kirtn14
12
Years of Service
User Offline
Joined: 8th Sep 2011
Location:
Posted: 25th Oct 2011 21:06
thanks soooooo much i have it working now ))) thanks

kirtnicholls
kirtn14
12
Years of Service
User Offline
Joined: 8th Sep 2011
Location:
Posted: 30th Jan 2012 20:50
omg i think ive broken the pause it wont work anymore ive tried both of your sujestions again and they wont work. which raw key number if the space bar?

kirtnicholls
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 30th Jan 2012 21:31
I can't remember but you can check by adding this in your loop:
Print(str(getRawLastPressed()))

kirtn14
12
Years of Service
User Offline
Joined: 8th Sep 2011
Location:
Posted: 31st Jan 2012 09:26
Thanks

kirtnicholls

Login to post a reply

Server time is: 2024-05-06 08:03:58
Your offset time is: 2024-05-06 08:03:58