setFillColor(1, 1, 1, nil) gives alpha 0?

Hello,

I came across this weird thing (bug?), I’m on Corona build 2014.2189.

local rect = display.newRect(0, 0, 200, 200) rect.x = display.contentCenterX rect.y = display.contentCenterY --rect:setFillColor(1, 1, 1) -- this makes alpha default to 1 rect:setFillColor(1, 1, 1, nil) -- this makes alpha default to 0???

That is odd.  One way to look at this is you passed a 4th parameter which means you intended to set the alpha.  And by default nothing is 1 so something should be something different.  Twisted logic I know.  If this is going into some C++ code, C treats null and 0 the same, unlike Lua where they have different meaning, which could be the real reason you’re seeing this behavior.

I’m not sure this is a bug worth pursing since there is a simple work around, don’t pass in nil.

Rob

That is odd.  One way to look at this is you passed a 4th parameter which means you intended to set the alpha.  And by default nothing is 1 so something should be something different.  Twisted logic I know.  If this is going into some C++ code, C treats null and 0 the same, unlike Lua where they have different meaning, which could be the real reason you’re seeing this behavior.

I’m not sure this is a bug worth pursing since there is a simple work around, don’t pass in nil.

Rob