Reputation: 15941
Create a display object, set a fill color, draw a square, save the object reference, then later retrieve that object color?
Relevant code (from memory):
var disp = display.createRect(5,5) disp.setFillColor(255,128,64) ... otherObject.setFillColor(disp.getFillColor()) -- this is I want to do
Upvotes: 0
Views: 1158
Reputation: 26048
There is no method for retrieving an object's color in Corona SDK. However, you can save the color of an object in a variable (or table). See:
-- Table containing the RGB values of object 1 color:
local obj1Color = { r = 255, g = 0, b = 0 }
-- Draw a square at point (0,0) with side = 50px:
local obj1 = display.newRect(0, 0, 50, 50)
obj1:setFillColor(obj1Color.r, obj1Color.g, obj1color.b)
-- You can set and get the alpha value using dot notation:
print(obj1.alpha) -- will print 1
obj1.alpha = 0.5 -- set the opacity of obj1 to 50%
Upvotes: 2