Linking from 1 page to another via a Start Button

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • LONDONLAD1978
    New Member
    • Nov 2014
    • 5

    Linking from 1 page to another via a Start Button

    Hi everyone.. I've created a game using JS/CSS/HTML5 just something simple, however, I have used a start button.. with the following code ... $('#StartBtn'). click(LaunchGam e); -- which when pressed launches the game from the home screen.. however when the player loses on the game, the game panel disappears and the words "busted, Try Again" appear, which is fine, however, I'm trying to get the Start Button to appear after 2/3secs linking back through to the home page to restart the game.. However, I just can't figure out how to do it.

    Below is the code that appears when the game ends..

    function EndGame(HasTile dOut) {

    ShowHomeScreen( );

    $('#EntireScree n').html('');

    var GameOutcomeText = (HasTiledOut) ? 'Busted!!' : 'Try Again!';

    $('#GameOutcome ').text(GameOut comeText).fadeI n();


    }


    Look forward to any help given.. Many thanks in advance!!

    LondonLad1978
  • yarbrough40
    Contributor
    • Jun 2009
    • 320

    #2
    Native Javascript has a settimeout function. Here's an example that will set your button to visible after 3000 milliseconds. You could call it at the end of your EndGame function. Or set the visibility to the game panel itself.

    Code:
    setTimeout(function() {
          $('#myStartButtonID').css('visibility', 'visible');
    }, 3000);

    Comment

    • LONDONLAD1978
      New Member
      • Nov 2014
      • 5

      #3
      Hi, have sent you a message privately with a JSFiddle link..

      Comment

      • yarbrough40
        Contributor
        • Jun 2009
        • 320

        #4
        when I say $('#myStartButt onID') I don't mean that literally. replace the text "myStartButtonI D" with the ID of your actual button. Also keep in mind if the game panel object that that button is inside of is hidden then it will not work. Instead you will need to set the panel to visible

        Comment

        • LONDONLAD1978
          New Member
          • Nov 2014
          • 5

          #5
          I only want the button to appear, not the game panel, I can make that appear no problem, I just need the Start button to appear on its own.

          I presume this is right?

          Code:
          function EndGame(HasTiledOut) {
          
          
          $('#EntireScreen').html('');
          
          var GameOutcomeText = (HasTiledOut) ? 'Busted!!' : 'Try Again!';
          
          $('#GameOutcome').text(GameOutcomeText).fadeIn();
          
          setTimeout(function() {
          $('#StartBtn').css('visibility', 'visible');
          }, 3000);
          
          }

          Comment

          • LONDONLAD1978
            New Member
            • Nov 2014
            • 5

            #6
            If i enter

            Code:
            ShowHomeScreen();
            within that code, the main home panel, with start button etc appears, but its causes a few issues when playing the game.. I'm just wanting the Start Button to appear on its own linking through to the game panel.

            Comment

            • LONDONLAD1978
              New Member
              • Nov 2014
              • 5

              #7
              OK.. If if i enter:
              Code:
              setTimeout(function() {
              $('#StartBtn').css('visibility', 'visible');
              }, 3000);
              , as well as removing
              Code:
              <div id="StartBtn">Start Game</div>
              from the
              Code:
              <div id="HomePanel" class="GamePanel">
              section and have it on its own, the code works.. however.. the Start Button appears on the bottom of the game panel and when the game finishes under the wording "Busted, Try Again" which is right, but then the game starts acting strange, it almost starts looping...

              Comment

              Working...