2 Replies Latest reply on Jan 13, 2013 11:10 PM by Acaryus

    Need help with a game


      Alright so i created a stick-figure using the line tool and made the walk animation. Each part of the body has its layer and my question is how to make the stick figure move and jump using the arrow keys. So far i made the character move and jump but i also want my walk animation to start when i press the arrow key and stop. I'm still a beginner and i was messing with some code and tutorials, but i can't get it to work properly. I have already made some simple platform game with a jumping ball which was quite easy and now i decided to expand my knowledge by making something more complicated. I would appreciate some help and explanation.



        • 1. Re: Need help with a game
          Ned Murphy Adobe Community Professional & MVP

          If your frame-by-frame animations are just for making the body movement, and not to actually have body changing location, then to make the object move you can use code and adjust/increment the _x and _y properties for that.


          Here is some code that would make the figure move based on the arrow keys on the keyboard...  In this code, "figure is the name of the movieclip that contaons all of the body movement animations.  If the animation you show above is on the main timeline, then you need to move it inside the figure movieclip....



          var increment = 3;  // adjust for speed of movement


          var keyListener:Object = new Object();


          keyListener.onKeyDown = function(){
              if(Key.getCode() == 38) figure._y -= increment;  // up key
              if(Key.getCode() == 40) figure._y += increment;  // down key
              if(Key.getCode() == 37) figure._x -= increment; // left key

              if(Key.getCode() == 39) figure._x += increment; // right key


          • 2. Re: Need help with a game
            Acaryus Level 1

            Thanks Ned! I will definitely try this