PDA

View Full Version : if and else


wfz
10-13-2008, 08:57 PM
if condition 1 do something
else if condition 2
if sub-condition 2.1 do something
else if sub-condition 2.2 do something

I can't figure out why the following does not work

if (a == 1) {
// do something
} else if (a == 0) {
if (_currentFrame == endFrame) {
// do something
}else {
// do something
}
}

Nabren
10-14-2008, 05:31 PM
Which part doesn't work about it? Is it the outer If failing or the inner If? If the inner If is failing what is endFrame?

The only reason an If structure would fail is if you were not comparing what you thought you were. If the whole thing isn't running it is more than likely a is never 0 or 1.

snickelfritz
10-14-2008, 08:11 PM
if (a == 1) {
// do something
} else {
if (_currentFrame == endFrame) {
// do something
}else {
// do something
}
}

kemuri
10-15-2008, 10:56 PM
I don't see nothing wrong. What are you trying to achieve?

wfz
10-17-2008, 11:22 PM
I don't see nothing wrong. What are you trying to achieve?

turns out currentframe has to be all small letters.

thank you all for asnwering my question.