Best way to do random reward of coins?
Hi all
In one of my games, I would like to give the player a random reward of coins. I did use the scratchcard way but the images weren't playing ball (long story)
Instead, I have made a coin 'drop'. So an actor falls from the sky etc and the user then clicks on the coin for it to generate their random amount of coins.
I have managed to use a table to generate my random coin amounts (1-10 different amounts) and I have images for each amount.
However, instead of using Display text to display the coins awarded, I wanted to use the custom images I have and I have tried so many ways of doing this and its just not working.
I have created a 'self random' inter attribute on the dropped coin which is changed attribute self.random to Table cell value 1/1 then using the random expression to call the random number). All that works fine.
I just wanted to change the coin drop image to spawn the awarded amount of coins. I've tried using the self.random linked to change image to the amount, but its not changing.
Any thoughts would be great!
Like Balls? Then click here! We've 100 coming soon
Comments
If you have a table set up to reward a certain amount of coins, just put the image filename in the second column and change attribute self.Image to tableCellValue(tableName,self.random,2).
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
thanks. that displays the images but they are also random and don't match the displayed number
Like Balls? Then click here! We've 100 coming soon
Okay... perhaps you can explain this a bit more. What I'm imagining is that you have a table with values like this:
Integer | Text
48 | 48.png
9 | 9.png
61 | 61.png
18 | 18.png
7 | 7.png
The formatting's a little messed up but that's just to show the two columns of data. The .png is optional but I included it to differentiate between columns 1 and 2. Then you'd import a file named 48.png that somehow visually represents the number 48.
Is that what you're wanting to do? Or are you talking about a custom font where "48" is displayed using two actors, 4.png and 8.png?
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
The imaging table is just as you have it. I have used a 'text' attribute in the table, because I can't type the image names if it was an interger. The images all display, but if 20 coins was awarded it might display the image for 200, or 40, 20, so it randoms the images too.
Im probably going to scrap this idea of doing it, because i need then to figure out, how to take that random amount and add it to their current coin tally! So will probably try another way! thanks though
Like Balls? Then click here! We've 100 coming soon
I know tables confuse many people but... what you're trying to do is actually very simple. I would stick with it!
Instead of going back and forth post by post, I'll make you a demo that will hopefully clear things up a bit.
Are you using a custom font with individual digits (1.png, 2.png, 3.png, etc.) or are you using a single image for each random value (e.g. for the value "75" you would import an image like http://www.ondergoedwinkel.nl/shared/fsimages/10016540gr.gif)?
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Here's a demo: http://forums.gamesalad.com/discussion/comment/519566/#Comment_519566.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Thanks you're a star!
I will have a look. Im not using a custom image currently. I just added a display text so i can see the numbers and test.
Its just been one of those days where something that should be simple has taken me a few hours. What really annoyed me was getting the coin to spawn. It just wasn't. No reason for it. Shut everything down, went back a few hours later and the bloody thing worked! lol
Like Balls? Then click here! We've 100 coming soon