Apologies if this is not the place to ask this… this forum is frighteningly big
But I’m trying to build a very simple version of an ingame shop, where the player can exchange credits for items, but I’m having some difficulty with working with parameters
this is what I got so far:
display.setStatusBar( display.HiddenStatusBar )
local credits = 100
function buyItem(price)
print( credits )
end
local item1 = display.newRect( 0, 0, 50, 50 )
item1:setFillColor( 0, 0, 255 )
item1.x = display.contentCenterX
item1.y = display.contentCenterY
item1:addEventListener( "tap", buyItem )
function test(price)
print( credits - price )
end
test(50)
Now, the test function works as it should… but why cant I do the same for my event listener? When I try to use buyItem(50) I get an error I dont understand:
Runtime error
assertion failed
stack traceback:
[C]: ?
[C]: in function 'assert'
?: in function 'getOrCreateTable'
?: in function 'addEventListener'
?: in function'addEventListener'
etc, etc...
I have no idea how to fix this!
[import]uid: 200198 topic_id: 33910 reply_id: 333910[/import]