How to pause function then retrieve information

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • BradleyJS
    New Member
    • Mar 2008
    • 4

    How to pause function then retrieve information

    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
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    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

    Comment

    • BradleyJS
      New Member
      • Mar 2008
      • 4

      #3
      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

      Comment

      • BradleyJS
        New Member
        • Mar 2008
        • 4

        #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
        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="pausef unc()">

        Attempt at retrieve function

        function retrievefunc(){
        retrieve init();
        }

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


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

        Bradley

        Comment

        • BradleyJS
          New Member
          • Mar 2008
          • 4

          #5
          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

          Code:
          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

          Code:
          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

          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            #6
            Originally posted by BradleyJS
            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.getEle mentById(timerI D) and then get its innerHTML property.

            Comment

            Working...