How to check whether both objects have a similar fill color

So let say I setFillColor two objects:

obj1:setFillColor(math.random(),math.random(),math.random()) obj2:setFillColor(math.random(),math.random(),math.random())

How can I check whether both objects have similar colors?

use variables which you need to keep track of and can compare

havent seen a direct way of accessing a display objects color settings

local c1=math.random()

local c2=math.random()

local c3=math.random()

local c4=math.random()

local c5=math.random()

local c6=math.random()

obj1:setFillColor(c1,c2,c3)

obj2:setFillColor(c4,c5,c6)

if c1==c4 then etc etc

there is also a different approach that may be easier to handle with numerous objects

in lua you can attach any property you like to a display object, so you could do this…

obj1=display.newImageRect()

obj1.r=math.random()

obj1.g=math.random()

obj1.b=math.random()

obj1:setFillColor(obj1.r,obj1.g,obj1.b)

obj2=display.newImageRect()

obj2.r=math.random()

obj2.g=math.random()

obj2.b=math.random()

obj2:setFillColor(obj2.r,obj2.g,obj2.b)

if obj1.r==obj2.r then etc etc

EDIT - adding any property you like to a display object is a very powerful and useful ability, for example:

obj1.status=“moving”

obj1.inFocus=false

obj1.tag=“my current object”

anything goes really, and as long as your object exist, so do the variables.

when the object is removed, so does all attached properties…nifty! 

Wow amazing! I will try this out

Muchos Gracias 

use variables which you need to keep track of and can compare

havent seen a direct way of accessing a display objects color settings

local c1=math.random()

local c2=math.random()

local c3=math.random()

local c4=math.random()

local c5=math.random()

local c6=math.random()

obj1:setFillColor(c1,c2,c3)

obj2:setFillColor(c4,c5,c6)

if c1==c4 then etc etc

there is also a different approach that may be easier to handle with numerous objects

in lua you can attach any property you like to a display object, so you could do this…

obj1=display.newImageRect()

obj1.r=math.random()

obj1.g=math.random()

obj1.b=math.random()

obj1:setFillColor(obj1.r,obj1.g,obj1.b)

obj2=display.newImageRect()

obj2.r=math.random()

obj2.g=math.random()

obj2.b=math.random()

obj2:setFillColor(obj2.r,obj2.g,obj2.b)

if obj1.r==obj2.r then etc etc

EDIT - adding any property you like to a display object is a very powerful and useful ability, for example:

obj1.status=“moving”

obj1.inFocus=false

obj1.tag=“my current object”

anything goes really, and as long as your object exist, so do the variables.

when the object is removed, so does all attached properties…nifty! 

Wow amazing! I will try this out

Muchos Gracias