4 Replies Latest reply on Apr 27, 2015 12:40 PM by seano2o7

    Haven't been able to find this question. I'm creating a game and have some questions.

    callmematthew

      How I want the game to work.

       

      There is a character head floating on the screen. Items scroll along the bottom that he could possibly eat. When you click on an item, it is thrown into his mouth and he eats it. Your score goes up or down based on what you feed the character. If you feed him the wrong items, the score goes down and you get a strike. Three strikes and you lose.

      I have four screens I am working with.

      Home Screen

      Rules Screen

      Game Screen

      You Lose Screen

       

      What I'm having trouble with:

       

      Strikes: When the wrong item is clicked, I want the strike animations to play. I can get one to play but, I cannot figure out how to get strikes two and three to play. All I can do is have the first strike play over and over again. I tried using 'if' functions but don't know how to say "if an animation has already played, then play a different animation'.

       

      Random Scrolling: I can get the items to scroll, but I can only replay the same scroll animation over and over again. I want the items to scroll in random orders.

       

      Lose Screen Score: I want the lose screen to display the score they have at the end of the game.

       

      I have been working quote a long time on this project and have learned a lot about Edge Animate but I can not find anything on the internet explaining how to do the these things. Your help will be greatly appreciated.

       

      -Matt

        • 1. Re: Haven't been able to find this question. I'm creating a game and have some questions.
          seano2o7 Level 3

          Hi,

           

          Strikes -

          Go into compositionReady and have 3 variables you will be able to set them like this

           

          strike1 = 0;

          strike2 = 0;

          strike3 = 0;

           

          So on the wrong item click have

           

          if(strike1 == 0) {

          PLAY STRIKE1 ANIMATION

          strike1 = 1;

          }

          else if(strike2 == 0) {

          PLAY STRIKE2 ANIMATION

          strike2 = 1;

          }

          else if(strike3 == 0) {

          PLAY STRIKE2 ANIMATION

          strike3 = 1;

          }

           

          So this will make it so when the wrong item is clicked each strike will be played in order.

           

          Random Scrolling -

          You should look into the Math.Random function to make things random in edge.

           

          This is an example of the Random function. It will generate a random number up to 100.

           

          var random = Math.floor (Math.random () * 100);


          Lose Screen Score -

          So we can create another variable in compositionReady for the lose score.

           

          score = 0;

           

          Now when the user gains a point to add to the score you could do this code on the click

           

          score++;

           

          which would add 1 to the score, However you can add however much you like to the score doing "score + 2" and so on.

           

          To edit a text with the score at the end which I'm assuming you will want to do you will use .html

           

          so $("Text").html("You score is " + score);

           

          I hope this helps!

          • 2. Re: Haven't been able to find this question. I'm creating a game and have some questions.
            callmematthew Level 1

            Nevermind! I got the strikes to work! I'll let you know about the other two problems! Thanks for the help!

            -Matt

             

             

            }Screen Shot 2015-04-21 at 4.51.17 PM.png

            • 3. Re: Haven't been able to find this question. I'm creating a game and have some questions.
              callmematthew Level 1

              With the math.random functions. Am I going to need to assign each item a random number that the function can reference.

              I want them to scroll randomly so what would be an example of actual code to make this happen? If an item is called "puppy" what would the code maybe look like?

              • 4. Re: Haven't been able to find this question. I'm creating a game and have some questions.
                seano2o7 Level 3

                I'm not sure what you want exactly with the random function but I'll try and explain it to make it less complicated.

                 

                var random = Math.floor (Math.random () * 100);  // This line will create a random number between 0 and 100. To get this number call random (the variable name) you can rename it to anything though.


                So now depending what you want to do with the function


                if(random < 25) {

                alert("under 25");

                }

                else {

                alert("over 25");

                }


                I don't understand what you want exactly so I can't write in more detail unless I know exactly what you want.