I am building an example game for my year 9/10 Game Design Class and am stuck on something.
Basically, the game wants you to make a total of ten by shooting numbers that add up to ten.
Seems basic right, I agree.
I have done something wrong and am confused why when I shoot some numbers, they add to the total, but others just get destroyed and dont add to the total.
I have tried laying it out in three different ways but i get the exact same result each time.
Each time you spawn a new numeral, you lose track of the previous one of that value.
For example, let’s say you’ve created a “2.” When you make another “2,” the 2 variable only points to the most recent one and loses track of the first one. So, when you do your comparison in on destroyed, only the most recent “2” would get caught by the if statement.
You’ll want to use the sprite-data extension. Assign a value to the sprite’s data and then use that information when checking the destroyed sprite.
Gimme a few minutes and I’ll create a demo project for you.
See if this gets you there. Holler if you have any questions.
P.S. Always great to hear from educators outside of the U.S.!
There’s another way to do this that doesn’t use the sprite-util extension, and that’s to use the sprite’s image in a conditional; i.e., check if the image is a “1,” a “2,”, etc.
Here’s the same project as above, but without the sprite-util extension. This one is closer to the spirit of what you had attempted originally.