PDA

View Full Version : Making something face left AND right


Ultimatepuff
11-20-2007, 06:19 PM
I'm working on a game right now and...
I made a movie clip "char." In it I put walking (left and right arrows), jumping (up arrow), punch (Control), Special attack #1 (Shift), Special attack #2 (Insert). With the jumping, punch, special attack, and special attack 2 it only faces the right. I want it to face right when the character is facing the right and I want it to face the left when the character is facing the left. Anyone know my problem?:confused:

Noct
11-20-2007, 06:28 PM
Welcome aboard,
You can use xscale to flip (mirror) your clips. Just toggle it back and forth on your keypresses.

//Mirror image
myMc._xscale = -100;
//Back to "normal"
myMc._xscale = 100;

Ultimatepuff
11-20-2007, 06:47 PM
Welcome aboard,
You can use xscale to flip (mirror) your clips. Just toggle it back and forth on your keypresses.

//Mirror image
myMc._xscale = -100;
//Back to "normal"
myMc._xscale = 100;


...and how can I do that?
Sorry for sounding so newbish, I just started experimenting with flash about 2 weeks ago.

Noct
11-20-2007, 09:52 PM
Make all of your character's animation facing in one direction only, and then toggle the xscale property of that clip in the event that is triggering the walk in different directions.

You mentioned keys before, have you written the script for those keypresses yet?

Ultimatepuff
11-20-2007, 11:56 PM
Make all of your character's animation facing in one direction only, and then toggle the xscale property of that clip in the event that is triggering the walk in different directions.

You mentioned keys before, have you written the script for those keypresses yet?

The AS for the character is onClipEvent(load)
{
var fight=false;
}
onClipEvent(enterFrame)
{

if(fight==false){
if(Key.isDown(Key.RIGHT)) {
gotoAndStop(2);
{
_x+=5;
_xscale=100;
}
}
if(Key.isDown(Key.LEFT)){
gotoAndStop(4);
{
_x-=5;
_xscale=100;
}
}
}
if(Key.isDown(Key.UP)){
gotoAndStop(5);
}
if(Key.isDown(Key.INSERT)){
gotoAndStop(7);
}
if(Key.isDown(Key.CONTROL)){
gotoAndStop(3);
fight=true;
}
else
if(Key.isDown(Key.SHIFT)){
gotoAndStop(6);
fight=true;
}
else fight=false;
}

Noct
11-21-2007, 02:38 PM
Well, for one thing I would suggest learning how to code on the timeline if you're making a game, symbol coding is an older practice that makes creating games a bit more difficult IMO. Anyways, I don't know if the rest of your stuff is working or not in this script, but the character flip just needs a -100 on one of the xscales and you've got it.
Try this:

onClipEvent (load) {
var fight:Boolean = false;
}
onClipEvent (enterFrame) {
if (fight == false) {
if (Key.isDown(Key.RIGHT)) {
this.gotoAndStop(2);
{
this._x += 5;
this._xscale = 100;
}
};
if (Key.isDown(Key.LEFT)) {
this.gotoAndStop(4);
{
this._x -= 5;
this._xscale = -100;
}
}
};
if (Key.isDown(Key.UP)) {
this.gotoAndStop(5);
}
if (Key.isDown(Key.INSERT)) {
this.gotoAndStop(7);
}
if (Key.isDown(Key.CONTROL)) {
this.gotoAndStop(3);
fight = true;
} else if (Key.isDown(Key.SHIFT)) {
this.gotoAndStop(6);
fight = true;
} else {
fight = false;
}
}