Sunday, 11 August 2013

Is there a way to make this function smaller?

Is there a way to make this function smaller?

this is the code with the problem a have a star animation when the score
is X the animation plays until a specific frame how to make this function
smaller with less ifs? as u can se the function is from 500 to 0.
addEventListener(Event.ENTER_FRAME, star);
function star(e:Event):void{
if (totalScore<= 500 && totalScore>490) {
if(GAME.stars.currentFrame == 51){
GAME.stars.stop();
}
}
if (totalScore<= 490 && totalScore>480) {
if(GAME.stars.currentFrame == 50){
GAME.stars.stop();
}
}
///...
if (totalScore= 0 && totalScore>10) {
if(GAME.stars.currentFrame == 1){
GAME.stars.stop();
}
}
}
thx!!!

No comments:

Post a Comment