In game shop
I have created a small shop in my game using tables, from
My game is where, the user collects money from the infinite runner game, which then they can use to purchase another playable character. I want to make it so, when the character has been purchased once, the user can no longer buy the same player again.
And when the player has been bought it changes into a selection, where the user can choose which player to play with
Buy now code:
http://prntscr.com/7wfprp
Table
http://prntscr.com/7wfqhq
Im new to tables and not sure how they work. I just need to find out how to only purchase a player once and not multiple times and when the player has been purchased it changes into a selection where the user can select any player they have purchased.
Best Answer
-
dustingriffie Posts: 57
You would need to make another table with data of characters. Say your character name is 'Bob', you need to make a table with 'Bob' being at cell 1,1 with an integer value of 0. If the users make the purchase, change the cell value to 1. Then save the table value. Next you want to constrain the table cell value to an integer attribute, I am going to call it newAttribute for now. Then what you can do is make a statement saying if newAttribute is 1, allow touch (selection) of your character.
The biggest thing you need to make sure is that you are SAVING the tables whenever someone makes a purchase or else you are gonna have some angry people who bought things and they disappear after closing the app.
Answers
And to make it so they can no longer purchase, put your WHOLE purchase function in a rule that says if newAttribute = 0 then allow them to purchase. If it is set to one, nothing will work and that is what you want.