469,289 Members | 2,211 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,289 developers. It's quick & easy.

How to pause function then retrieve information

BradleyJS
Hi
I have an assignment for school and i was just wondering can someone help me to
complete it correctly. It is a memory game that has a timer included and i have got a play button that when clicked it activates function init(); (this function scrambles up the memory pictures and starts the timer). I want to add a pause button which when clicked will stop the game and the timer and also a continue button that when clicked retrieves the information of the amount of completion of the game and the time that was on the timer when the pause button was clicked.

Bradley
Mar 25 '08 #1
5 1208
acoder
16,027 Expert Mod 8TB
The experts on this site are more than happy to help you with your problems but they cannot do your assignment/program for you. Attempt the assignment/program yourself first and post questions regarding any difficulties you have or about a particular function of the code that you don't know how to achieve.

Please read the Posting Guidelines and particularly the Coursework Posting Guidelines.

Then when you are ready post a new question in this thread.

MODERATOR
Mar 25 '08 #2
I am sorry I did not mean for anyone to do my assignment i just need to know can I pause the game but clicking a button then using a function to retrieve the information when a continue button is clicked
if this is possible can someone please explain how i could be done
Bradley
Mar 26 '08 #3
I have tried this code to pause but now I've used it the play button code doesn't work and how would i code for retrieving the information.

My pause function
function pausefunc(){ // this is my very own function which pauses the games when the button is pressed
pause init();
}

<img src="stop button copy.png" onclick="pausefunc()">

Attempt at retrieve function

function retrievefunc(){
retrieve init();
}

<img src="continue button copy.png" onclick="retrievefunc()">


I don't think my attempt is right because I don't even know if retrieve init(); would do anything

Bradley
Mar 26 '08 #4
I have tried this code to pause but now I've used it the play button code doesn't work and how would i code for retrieving the information.

My pause function

Expand|Select|Wrap|Line Numbers
  1. function pausefunc(){ // this is my very own function which pauses the games when the button is pressed
  2. pause init();
  3. }
  4.  
  5. <img src="stop button copy.png" onclick="pausefunc()">
  6.  
Attempt at retrieve function

Expand|Select|Wrap|Line Numbers
  1. function retrievefunc(){ 
  2. retrieve init();
  3. }
  4.  
  5. <img src="continue button copy.png" onclick="retrievefunc()">
  6.  
I don't think my attempt is right because I don't even know if retrieve init(); would do anything

Bradley
Mar 26 '08 #5
acoder
16,027 Expert Mod 8TB
I want to add a pause button which when clicked will stop the game and the timer and also a continue button that when clicked retrieves the information of the amount of completion of the game and the time that was on the timer when the pause button was clicked.
I assume you're using either setTimeout or setInterval to run the timer. I also assume the timer is displayed on the page. If so, you can just stop the setTimeout/interval with the counterpart clearTimeout/clearInterval respectively. The continue button can use setTimeout/setInterval to start the timer again. To retrieve the information on amount of time left wouldn't be difficult if the timer is displayed on the screen. If it's within a span/div element just access the element using document.getElementById(timerID) and then get its innerHTML property.
Mar 26 '08 #6

Post your reply

Sign in to post your reply or Sign up for a free account.

By using this site, you agree to our Privacy Policy and Terms of Use.