Skip to main content
added 237 characters in body
Source Link
Opoe
  • 149
  • 4
  • 10

I hope you can help me with the following problem:

I made a character in Illustrator. The player sees the character from above. When you press the left arrow key character.gotoAndStop('left'); the character moves to the left. (Same goes for the right direction with label 'right' When you release the left or right arrow key (upKey) the character goes back to the label 'up'.

I'm trying to accomplish the following: When the character is facing down ('down'). the left key should go to the ("facingdownleft") label and on release back to the label ('down'). (Same for the right direction)

enter image description here

stage.addEventListener(KeyboardEvent.KEY_DOWN, downKey);
function downKey(event:KeyboardEvent)
{
 if(event.keyCode==39){
 isRight=true;
 character.gotoAndStop('right');}
 if(event.keyCode==37){
 isLeft=true;
 character.gotoAndStop('left');}
 if(event.keyCode==38){
 isUp=true;
 character.gotoAndStop('up');
 }
 if(event.keyCode==40){
 isDown=true;
 facingdown=true;
 character.gotoAndPlay('down');}
}

if( facingdown == true && isLeft == true)
{ 
 character.gotoAndPlay('downleft');
}


stage.addEventListener(KeyboardEvent.KEY_UP, upKey);
function upKey(event:KeyboardEvent){
 if(event.keyCode==39){
 isRight=false;
 character.gotoAndPlay('up')}
 if(event.keyCode==37){
 isLeft=false
 character.gotoAndPlay('up')}
 if(event.keyCode==38){
 isUp=false;}
 if(event.keyCode==40){
 isDown=false}
 }

I made a boolean for facingdown. and an if statement for downleft:

  if( facingdown == true && isLeft == true)
    { 
     character.gotoAndPlay('downleft');
    }

But before I make numerous amounts of if statements again, I would like to know if I'm on the right track and if you can help me accomplish this? Thank you so much in advance and feel free to ask questions.

enter image description here

I hope you can help me with the following problem:

I made a character in Illustrator. The player sees the character from above. When you press the left arrow key character.gotoAndStop('left'); the character moves to the left. (Same goes for the right direction with label 'right' When you release the left or right arrow key (upKey) the character goes back to the label 'up'.

I'm trying to accomplish the following: When the character is facing down ('down'). the left key should go to the ("facingdownleft") label and on release back to the label ('down'). (Same for the right direction)

enter image description here

stage.addEventListener(KeyboardEvent.KEY_DOWN, downKey);
function downKey(event:KeyboardEvent)
{
 if(event.keyCode==39){
 isRight=true;
 character.gotoAndStop('right');}
 if(event.keyCode==37){
 isLeft=true;
 character.gotoAndStop('left');}
 if(event.keyCode==38){
 isUp=true;
 character.gotoAndStop('up');
 }
 if(event.keyCode==40){
 isDown=true;
 facingdown=true;
 character.gotoAndPlay('down');}
}

if( facingdown == true && isLeft == true)
{ 
 character.gotoAndPlay('downleft');
}


stage.addEventListener(KeyboardEvent.KEY_UP, upKey);
function upKey(event:KeyboardEvent){
 if(event.keyCode==39){
 isRight=false;
 character.gotoAndPlay('up')}
 if(event.keyCode==37){
 isLeft=false
 character.gotoAndPlay('up')}
 if(event.keyCode==38){
 isUp=false;}
 if(event.keyCode==40){
 isDown=false}
 }

I made a boolean for facingdown. But before I make numerous amounts of if statements again, I would like to know if I'm on the right track and if you can help me accomplish this? Thank you so much in advance and feel free to ask questions

I hope you can help me with the following problem:

I made a character in Illustrator. The player sees the character from above. When you press the left arrow key character.gotoAndStop('left'); the character moves to the left. (Same goes for the right direction with label 'right' When you release the left or right arrow key (upKey) the character goes back to the label 'up'.

I'm trying to accomplish the following: When the character is facing down ('down'). the left key should go to the ("facingdownleft") label and on release back to the label ('down'). (Same for the right direction)

enter image description here

stage.addEventListener(KeyboardEvent.KEY_DOWN, downKey);
function downKey(event:KeyboardEvent)
{
 if(event.keyCode==39){
 isRight=true;
 character.gotoAndStop('right');}
 if(event.keyCode==37){
 isLeft=true;
 character.gotoAndStop('left');}
 if(event.keyCode==38){
 isUp=true;
 character.gotoAndStop('up');
 }
 if(event.keyCode==40){
 isDown=true;
 facingdown=true;
 character.gotoAndPlay('down');}
}

if( facingdown == true && isLeft == true)
{ 
 character.gotoAndPlay('downleft');
}


stage.addEventListener(KeyboardEvent.KEY_UP, upKey);
function upKey(event:KeyboardEvent){
 if(event.keyCode==39){
 isRight=false;
 character.gotoAndPlay('up')}
 if(event.keyCode==37){
 isLeft=false
 character.gotoAndPlay('up')}
 if(event.keyCode==38){
 isUp=false;}
 if(event.keyCode==40){
 isDown=false}
 }

I made a boolean for facingdown and an if statement for downleft:

  if( facingdown == true && isLeft == true)
    { 
     character.gotoAndPlay('downleft');
    }

But before I make numerous amounts of if statements again, I would like to know if I'm on the right track and if you can help me accomplish this? Thank you so much in advance and feel free to ask questions.

enter image description here

edited title
Link
Opoe
  • 149
  • 4
  • 10

As3 Character movement in diffrent directions with labels?

Source Link
Opoe
  • 149
  • 4
  • 10

As3 Character movement with labels

I hope you can help me with the following problem:

I made a character in Illustrator. The player sees the character from above. When you press the left arrow key character.gotoAndStop('left'); the character moves to the left. (Same goes for the right direction with label 'right' When you release the left or right arrow key (upKey) the character goes back to the label 'up'.

I'm trying to accomplish the following: When the character is facing down ('down'). the left key should go to the ("facingdownleft") label and on release back to the label ('down'). (Same for the right direction)

enter image description here

stage.addEventListener(KeyboardEvent.KEY_DOWN, downKey);
function downKey(event:KeyboardEvent)
{
 if(event.keyCode==39){
 isRight=true;
 character.gotoAndStop('right');}
 if(event.keyCode==37){
 isLeft=true;
 character.gotoAndStop('left');}
 if(event.keyCode==38){
 isUp=true;
 character.gotoAndStop('up');
 }
 if(event.keyCode==40){
 isDown=true;
 facingdown=true;
 character.gotoAndPlay('down');}
}

if( facingdown == true && isLeft == true)
{ 
 character.gotoAndPlay('downleft');
}


stage.addEventListener(KeyboardEvent.KEY_UP, upKey);
function upKey(event:KeyboardEvent){
 if(event.keyCode==39){
 isRight=false;
 character.gotoAndPlay('up')}
 if(event.keyCode==37){
 isLeft=false
 character.gotoAndPlay('up')}
 if(event.keyCode==38){
 isUp=false;}
 if(event.keyCode==40){
 isDown=false}
 }

I made a boolean for facingdown. But before I make numerous amounts of if statements again, I would like to know if I'm on the right track and if you can help me accomplish this? Thank you so much in advance and feel free to ask questions