5 Replies Latest reply on Jul 21, 2011 6:27 PM by kglad

    flipping character movieclip to shoot

    sk8rbum247

      actionscript 2.0

      Got a charcter movie clip(guy) on frame 1, inside the symbol are 2 more clips for left(guyl) and right(guyr) movement. i placed the code to shoot on frame 1 of the original movie clip and the character shoots to the right but when turned to the left the bullet clip continues to come from the right. so then i tried inserting the code to shoot on the movieclips inside the symbol(the left and right symbols) but the bullet stays at the top left of the screen. any help/suggestions? thanks.

      code for bullet

      this.onEnterFrame=function()

      {

      this._x +=12;

      if (this._x>550)

      {

      this.removeMovieClip();

      }

      }

       

      code to shoot

      var i=1;

      if(Key.isDown(Key.SPACE))

      {

      i++;

      _root.attachMovie("bullet","bullet"+i,_root.getNextHighestDepth());

      _root["bullet"+i]._x=guyr._x+35;

      _root["bullet"+i]._y=guyr._y-5;

        • 1. Re: flipping character movieclip to shoot
          kglad Adobe Community Professional & MVP

          adjust the position of the attached bullet when shooting to the left.

          1 person found this helpful
          • 2. Re: flipping character movieclip to shoot
            sk8rbum247 Level 1

            yea but the thing is that if i put the code to shoot in frame one of the main timeline it works, but it only goes right not left. if i enter the symbol and insert the shoot code into the clip thats facing right, it shoots but it shoots from the top left not from the movieclip so.. yea i dont know what to do about that

            • 3. Re: flipping character movieclip to shoot
              kglad Adobe Community Professional & MVP

              you should be using one symbol for your right and for your left character.   and the code should be attached to your main timeline, not the character's timeline.

               

              if you do that, and your character's instance name is mc on the main timeline, you can use:

               

              mc._xscale=-100;  // face left

               

              mc._xscale=100;  // face right

              1 person found this helpful
              • 4. Re: flipping character movieclip to shoot
                sk8rbum247 Level 1

                ive got it in the right position and shooting but its shooting in both directions at once

                var i = 1; stop();

                this.onEnterFrame = function()

                {

                if (Key.isDown(Key.LEFT))

                {

                guy._x -= 5;

                }

                if (Key.isDown(Key.RIGHT))

                {           guy._x += 5;

                }

                if (Key.isDown(Key.SPACE)&&(Key.LEFT))

                {

                i++;           _root.attachMovie("bullet2","bullet2" + i,_root.getNextHighestDepth());

                _root["bullet2" + i]._x = guy._x + -50;           _root["bullet2" + i]._y = guy._y - 5;

                var shoot_sound = new Sound();

                shoot_sound.attachSound("shot");

                shoot_sound.start();

                }

                if (Key.isDown(Key.SPACE)&&(Key.RIGHT))

                {

                i++;           _root.attachMovie("bullet","bullet" + i,_root.getNextHighestDepth());

                _root["bullet" + i]._x = guy._x + 35;

                _root["bullet" + i]._y = guy._y - 5;

                var shoot_sound = new Sound();

                shoot_sound.attachSound("shot");

                shoot_sound.start();

                }

                };

                what can i do to fix this? (sorry and thank you for the pacience)

                • 5. Re: flipping character movieclip to shoot
                  kglad Adobe Community Professional & MVP

                  it doesn't look like you're using one "guy" and if you are, i don't see where he's flipping to face left/right.