Reputation: 652
I have a problem with set color in corona. Acording to parameter, color should be set as gradient (if 0) or solid color. But if I set it to gradient, I could not set it to solid color after. Here is a part of the code:
local function fillColor(tile, color)
if color==0 then
local g = { type="gradient", color1={ 0, 0, 0 }, color2={ 0, 1, 0 } }
tile:setFillColor(g)
elseif color==1 then
tile:setFillColor(0.1,0.1,0.1)
elseif color==2 then
tile:setFillColor(0.5,0.5,0.5)
elseif color==3 then
tile:setFillColor(0.75,0.75,0.75)
end
Upvotes: 0
Views: 1291
Reputation: 69
In CoronaSDK setFillColor() with a gradient structure is done like this:
local gradient = {
type="gradient",
color1={ 1, 1, 1 },
color2={ 0.8, 0.8, 0.8 },
direction="down"
}
setFillColor(gradient)
I think you forgot the "direction" parameter.
Upvotes: 0
Reputation: 2288
If I understand correctly if the object gets filled by a gradient then you can never change it to a regular color. Is that correct?
If so then just have the other colors be a gradient but have color1 and color2 be the same value.
Upvotes: 1