Hi. I’ve been having a hard time implemting a shop in my game. What I’m trying to do is have upgrades in the game whenever the person has enough money to pay for it. I’m struggling to have the money subtract when the person has enough money. Here is the code is also plug and play
[code]require( “ice” )
bank = ice:loadBox( “bank” )
local amount = 0
local box = display.newRect(160, 240, 30, 30)
local bankText = display.newText(“0”, 160, 30,“Arial”,20)
local function change ()
if amount > 5 then
amount = -1
bank:increment( “total”, amount )
print(“bought”)
end
end
box:addEventListener(“tap”, change)
function endGame( )
bank:save()
bankText.text = “$” … bank:retrieve( “total” )
end
Runtime:addEventListener(“enterFrame”, endGame ) [/code]
Please help anyone thanks
[import]uid: 17058 topic_id: 22073 reply_id: 322073[/import]