Answer the question
In order to leave comments, you need to log in
How to fix a bug in Corona SDK?
When I added an event listener to the green circle (boostButton) Corona started throwing an error.
Here is the code:
local score = 0
local boost = 1
display.setDefault( "background", 10/225, 10/225, 10/225)
display.setStatusBar(display.HiddenStatusBar)
local circle = display.newCircle(display.contentCenterX, display.contentCenterY, 50 )
local scoreText = display.newText(score, display.contentCenterX, 90, native.systemFont, 24)
local boostButton = display.newCircle(display.contentCenterX, 400, 30 ):setFillColor(40/225, 60/225, 30/225)--зелёный бустер
local function pushCircle()
score = score + 1*boost
scoreText.text = score
end
circle:addEventListener("tap", pushCircle);
local function scoreBoost()
boost = boost + 1
end
boostButton:addEventListener('tap', scoreBoost)
Answer the question
In order to leave comments, you need to log in
Remove setFillColor, make it a separate line. It turns out that you are assigning to the boostButton variable not a button object, but the result of the setFillColor function, which is nil, which is what the error tells you about.
local boostButton = display.newCircle(display.contentCenterX, 400, 30 )
local test = boostButton:setFillColor(40/225, 60/225, 30/225)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question