I’m start learning Lua and Corona SDK and wanna make a simple project today- just a clicker with to button, 1) money=money+wokers and 2) -10 money +1 worker. But i have some problems with it,because i dont know why, but it work wrong. Maybe someone can help me with this problem?
–add button
local platform = display.newImageRect( “img/worker.png”, 300, 50)
platform.x = display.contentCenterX
platform.y = display.contentHeight+10
local balloon = display.newImageRect ( “img/coin.png”, 112, 112)
balloon.x = display.contentCenterX
balloon.y = display.contentCenterY
–step 1
local money=0
local workers=1
–text
local tapText= display.newText( “workers”, display.contentCenterX,100,native.systemFont, 40)
local tapText= display.newText( workers, display.contentCenterX,130,native.systemFont, 40)
local tapText= display.newText( “money”, display.contentCenterX,-5,native.systemFont, 40)
local tapText= display.newText( money, display.contentCenterX,50,native.systemFont, 40)
–step 2
local function earn()
money=money+workers
tapText.text = money
end
local function buy()
if money >= 10
then money=money-10
tapText.text = money
workers=workers+1
tapText.text = workers
end
end
–step 3
balloon:addEventListener( “tap”, earn)
platform:addEventListener( “tap”, buy)