Collecting powerstars..! Help!!

Hi,
My game is a side scrolling platformer. Now need to place 3 stars across each level. The player should collect them. And that forms the scoring system depending on the number of stars he should collect. I am not able to figure out the best way to do this. I tried considering the stars as physics bodies and remove them after the player collides with each one. But that looks too shabby.Is the any way to keep them as display objects only and destroy them as soon as the player passes touching them?
Thank you.

Try making them physics bodies but make them sensors - if it looked shabby my guess it your hero was bumping them? If so, making them sensors will prevent this.

When you say "the player only passes touching them" - yes. Use a sensor and event.phase == "ended" for that.

Peach :)

Perfect ..!!
I thought i had gone through all your tutorials. Wondering how did i miss this one.!! Anyways thanks Peach,for all your great tutorials. Loved it.!!

Really happy to hear that :) Thanks.

Let me know if you have any more difficulty.

Peach :)

yes. I have one more problem. Should I have to code separate listeners for each one or is there any way i could add a single listener the listens to all the 3 stars?

Each star will need a listener.

Peach :)

if your loading your stars into a table then yes. You can use the same function for all the stars if thats what your asking

Sorry, Danny has a good point - if you use a table then even though each star would still have a listener you'd only be adding it once.

Peach :)

views:1423 update:2011/11/17 9:28:17
corona forums © 2003-2011