Jump to content

Collection In A Set Order


fedora
 Share

Recommended Posts

I am at the point where I feel comfortable with all the core features of Phaser having played with and created some small games as well as dissected the "how to" of numerous others.   Now I am moving forward with an idea of a new game but have a question and I hope someone has tackled what I think is a straight forward problem.  

 

I know how to have a player collect coins/objects, but I do not know how to have a player collect coins/object in a set order.  I want to set the system so that the player has to collect in a certain order.  If this does not occur (ie player jumps from coin/object 1 to 3)  the coin/object three does not remove until coin/object 2 has been collected.  Any guidance and or sample would be appreciated.  I searched but was unsuccessful in locating one. 

 

Thank you in advance for any assistance.

Link to comment
Share on other sites

To me this is game logic, there is no magic. When creating your coins assign them an "order id", and in the onOverlap/onCollide callback function, check that the order is correct (you could put validly collected ids into an array and check against that array).

Link to comment
Share on other sites

give each coin an id and compare it against a counter you keep track of

 

i'll assume you're using arcade overlap for now.. so in your overlap function just check the id of the object that you've hit and compare with your running counter.

 

counter: 0

hit coin id: 2 => is coin id = counter+1? ... no => don't remove

counter: 0 

hit coin id: 1 => is coin id = counter+1? ... yes => remove, then add 1 to counter

counter = 1

hit coin id: 2 => is coin id = counter+1? ... yes => remove, then add 1 to counter

Link to comment
Share on other sites

Sorry for the delayed response.

 

Thank you both for the feedback -- I will be working on this week and definitely update on how it is going.  I am using Titles so I feel comfortable in assigning an id to the objects -- not 100% sure jmp909 about combining a counter and id -- because I have not done this -- but I will be taking a crack and will post my efforts -- 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...