Skip to main content
Participant
July 21, 2011
Question

flipping character movieclip to shoot

  • July 21, 2011
  • 1 reply
  • 326 views

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;

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
July 21, 2011

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

Participant
July 21, 2011

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

kglad
Community Expert
Community Expert
July 21, 2011

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