fedora Posted November 6, 2015 Share Posted November 6, 2015 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 More sharing options...
Skeptron Posted November 6, 2015 Share Posted November 6, 2015 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 More sharing options...
jmp909 Posted November 6, 2015 Share Posted November 6, 2015 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: 0hit coin id: 2 => is coin id = counter+1? ... no => don't removecounter: 0 hit coin id: 1 => is coin id = counter+1? ... yes => remove, then add 1 to countercounter = 1hit coin id: 2 => is coin id = counter+1? ... yes => remove, then add 1 to counter ekeimaja 1 Link to comment Share on other sites More sharing options...
fedora Posted November 11, 2015 Author Share Posted November 11, 2015 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 More sharing options...
Recommended Posts