I'm working on an AS3 game right now, and have it set up so that the player sprite can collect coins. This is done by rendering the 'coin' movie clip invisible when it detects collision with the player, and incrementing the coin count by one.
Right now, I have the following loop.
if (coin1Collected == false){
if (player.hitTestObject(level.coin1)){
level.coin1.visible = false;
coin1Collected = true;
coinsCollected++;
soundChannel = coinSound.play();
}
}
I don't want to set up one of these for each individual coin movie clip and coin collected boolean, however I haven't been able to find a way to put them all into a for loop. Is there any way to concatenate a variable with an incremental value inside a for loop? Thank in advance and sorry if this is a dumb thing to ask.