2 Replies Latest reply on Aug 11, 2008 6:58 AM by shintashi

    4 direction animated Sprite?

    shintashi Level 1
      Hi, I've been working on this on and off for a week trying to get 4 short animated clips to exist for each of the four directions of the arrow keys, but I've not been able to get both the animated images and the movement to work together. I noticed chinmayagoyal's sprite question from last year vaguely addressed this, but huge portions of the "what to actually do" were missing.

      Notes: I'm specifically trying to avoid rotation as this is something like an old final fantasy NES/SNES effect and I would like the characters to simulate walking in the four directions. Knowing how to insert the four "stopped" directions" and "duck" directions might also help. Is there a tutorial for this kind of sprite motion/animation?
        • 1. Re: 4 direction animated Sprite?
          Level 7
          I think a simple key listener that attached your various walk/stop clips
          would do it. Does this help:

          var keyLis:Object = new Object();
          var lastKey:String;

          keyLis.onKeyDown = function() {
          switch (Key.getCode()) {
          case Key.LEFT :
          myChar.attachMovie("leftWalk", "guy", 1);
          break;
          case Key.UP :
          myChar.attachMovie("upWalk", "guy", 1);
          break;
          case Key.RIGHT :
          myChar.attachMovie("rightWalk", "guy", 1);
          break;
          case Key.DOWN :
          myChar.attachMovie("downWalk", "guy", 1);
          break;
          }
          };
          keyLis.onKeyUp = function() {
          switch (Key.getCode()) {
          case Key.LEFT :
          myChar.attachMovie("leftStop", "guy", 1);
          break;
          case Key.UP :
          myChar.attachMovie("upStop", "guy", 1);
          break;
          case Key.RIGHT :
          myChar.attachMovie("rightStop", "guy", 1);
          break;
          case Key.DOWN :
          myChar.attachMovie("downStop", "guy", 1);
          break;
          }
          }
          Key.addListener(keyLis);

          You'd just have an empty clip on stage 'myChar', that you could init with
          one of the stop clips. Since every clip attaches at depth 1 they just
          replace the previous one.

          --
          Dave -
          www.offroadfire.com
          Head Developer
          http://www.blurredistinction.com
          Adobe Community Expert
          http://www.adobe.com/communities/experts/


          • 2. Re: 4 direction animated Sprite?
            shintashi Level 1
            unfortunately I've been unable to make this work for the last four days. I did learn a great deal since then though :)

            ok, this is what I'm doing, maybe someone can see what parts I'm missing:

            step 0: I create eight+ non animated images in photoshop, four direction images, and four directions that look slightly different (for animated frames)
            step 1: I open flash AS 2 (because AS3 is much harder to get help for and intimidating as a newbie)
            step 2: I import the eight images to library
            step 3: I create 4 "two frame" length movieclip .swf files and save them after testing to see if they blink.
            step 4: I make a new fla document, and hit ctrl+f8 to make a movie clip and name it something, like "player" or whatever.
            step 5: I go into the movieclip from step 4 and make 8 blank keyframes
            step 6: I import the four base direction images from step 0 and the four movie clips from step 3 into library.
            step 7: I insert the four base directions, one in each frame 1-4
            step 8: I insert the four movie clips in similar order one in each frame, 5-8
            step 9: I go to each frame and hit f9, and insert stop();
            step 10: I FAIL.

            Step 10 has usually been a variety of attempts at different tutorials or saved code, unfortunately the instructions are often over my head. (I started learning flash around July 29th of this year).