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. [import]uid: 76873 topic_id: 17751 reply_id: 317751[/import]
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
[import]uid: 52491 topic_id: 17751 reply_id: 67696[/import]
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.!! [import]uid: 76873 topic_id: 17751 reply_id: 67704[/import]
Really happy to hear that
Thanks.
Let me know if you have any more difficulty.
Peach
[import]uid: 52491 topic_id: 17751 reply_id: 67709[/import]
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?
[import]uid: 76873 topic_id: 17751 reply_id: 67714[/import]
Each star will need a listener.
Peach
[import]uid: 52491 topic_id: 17751 reply_id: 67730[/import]
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 [import]uid: 84637 topic_id: 17751 reply_id: 67749[/import]
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
[import]uid: 52491 topic_id: 17751 reply_id: 67760[/import]