Reputation:
Im just a new user of Corona SDK and Im following some exercises of a book. I tried to create a rectangle and color it, but if i put setFillColor(255,0,0) or put 255 in green or blue it works. The problem is when i try to mix colors like setFillColor(100,129,93) it just paints a white rectangle.
This is my main.lua:
rect_upperBackground = display.newRect(150, 150, 100, 50)
rect_upperBackground:setFillColor(49, 49, 49)
Upvotes: 4
Views: 4095
Reputation: 331
object:setFillColor() used to use values 0-255 but in the latest release of the SDK they changed that to 0-1 so they could handle larger color values. (Because 0-1 is a larger range than 0-255, you know.)
That means all books, video tutorials, etc., created before mid-November are wrong.
You'll also need to watch for object:setReferencePoint() because that has been deprecated. You'll now need to use object.anchorX and object.anchorY (defaults to the center of the object so if that's what you want, no tweaking needed).
Here's an article someone wrote explaining three big changes you'll need to watch out for: http://www.develephant.net/3-things-you-need-to-know-about-corona-sdk-graphics-2-0/
Those changes are as of build 2013.2076 of Corona SDK.
Upvotes: 2
Reputation: 8000
According to the documentation, setFillColor
requires colors in the range of [0, 1]
as opposed to [0, 255]
. So for example, you might try this instead.
rect_upperBackground:setFillColor(100 / 255, 129 / 255, 93 / 255)
rect_upperBackground:setFillColor(0.4, 0.2, 0.5)
Upvotes: 9