P
P
Ping Wins2019-07-28 01:59:48
Corona SDK
Ping Wins, 2019-07-28 01:59:48

Why doesn't text change in Corona SDK?

I analyzed an example from the official Corona documentation (working with text). Wrote like this:

local weightGroup = display.newGroup()
local myWeight = display.newText(weightGroup, "MyText", display.contentCenterX, -7, 'SuezOne', 42):setFillColor(186/255, 98/255, 98/255)
myWeight.text = "Kek"

It gives me an error:
08:57:31.409  \main.lua:3: attempt to index local 'myWeight' (a nil value)
08:57:31.409  stack traceback:
08:57:31.409  	\main.lua:3: in main chunk

What could be the problem and how to solve it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Lerg, 2019-07-28
@PingWins

setFillColor() does not return an object. Divide into two lines - creating an object and applying color. Then it will work.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question