Score did not update?
I have an integers attribute called coins, and i have a store to purchase items. I uses custom font for the number of coins. However, in the store, when i purchase an item, i have it change coins attribute to coins-500. But the number of coins in the scene did not change? It will only change when i change scene and then go back to that scene. Any help to make it change automatically without changing scene?
Best Answer
-
MotherHoose Posts: 2,456
the coinActor in the scene is not updating with the purchase …
though it is updating in the game … as it shows when you change scenes
somehow you have to code the coinActor to update during runTime
on coinActor:
add Attribute: currentCoins (index type!)
Rule: when
Attribute: self.currentCoins ≠ game.Coins
-changeAttribute: self.currentCoins To: game.Coins
and, have the display for coins use the self.currentCoins instead of game.CoinsMH
Answers
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Anyway what's the difference between index and integer?
indexTypes stores only positive whole numbers … allots the least bits/bytes for storage
for numbers such as coins/score/lives which you never want to be a negative number… use index
(all mathematical operations on index, integer, real type of numbers are handled the same
… but the storage for the valueRange is different …
for integer and index the computer rounds-off the values before storing)
EX:
indexType: coins = 1 … when changed to coins-3 … will result in 0
integerType: coins = 1 … when changed to coins-3 … will result in -2