Skip to main content
Participant
May 9, 2007
Answered

if inside if

  • May 9, 2007
  • 1 reply
  • 161 views
Game Specification:

im making a game and im having to track a users angle and the angle they face in changes what happens when they press the ,lets say up key.

Problem:

i need to know how to put an if inside and if

eg. if (Key.isDown(Key.UP) {
(here i need to do different actions accrding to the angle he is facing)... so i need an if inside an if...

}

any help highly appreciated

ANdy
This topic has been closed for replies.
Correct answer Newsgroup_User
You can nest if statements inside each other without issue:

if(Key.isDown(Key.UP)){
if(myAngle >= 0 && myAngle <= 90){
sprayFire();
}else if(myAngle > 90 && myAngle <=180){
sprayVomit();
}else {
sprayBlood();
}
}


Does that help?

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


1 reply

Newsgroup_UserCorrect answer
Inspiring
May 9, 2007
You can nest if statements inside each other without issue:

if(Key.isDown(Key.UP)){
if(myAngle >= 0 && myAngle <= 90){
sprayFire();
}else if(myAngle > 90 && myAngle <=180){
sprayVomit();
}else {
sprayBlood();
}
}


Does that help?

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