More questions about arrays!

I’m finally getting the hang of working with multiple classes, yays :smiley:

I’m making a platform game like the old mario games and i want to add coins to it. I figured the best solution would be to store all the coins in an array and hit test the hero against it. Right?

Anyways, this leads to two questions

  1. What would be the best way to position all the coins in the right place?

I want them to be in different x and y coordinates, should i position them on the stage first and then add them to the array? or should i position them dynamically from the array, and in that case, how?

  1. Is there a way to hit test against one particular instance without using it’s position in the array?
if (hero.hitTestObject(coinArray[0]))
{
    //remove
    //add to score

}

this would lead to a whole lot of code! I need something like

if hero hit test a coin, remove that coin and add to score

Ideas, anyone? :slight_smile: Thanks in advance!