Fill Color

I am new in corona so please help me.
I have a background image , this image have a different different white shape.shape has different different size.if i will used setFillColor.then

I want if we click in this shape then fill color in selected shape.and I want to fill different different color in different different shape. [import]uid: 107104 topic_id: 27484 reply_id: 327484[/import]

I’m having a little trouble understanding your question. Do you mean you have a white background and on top of that a white shape and when you tap the shape on top of the background you want the shape’s color to change? [import]uid: 52491 topic_id: 27484 reply_id: 111965[/import]

I think he has a background image with different shapes of different sizes, and when he clicks on a certain shape he wants it to setFillColor to a specific color.
Depending on what shapes you have on your background image you may or may not be able to do it with simple squares or circles. In case your shapes are more complicated than your normal shapes you might have to use a program like PhysicsEditor, otherwise if it’s only polygon’s or simple stuff check out this link on how to create custom collision models:
http://developer.anscamobile.com/content/game-edition-physics-bodies#Complex_body_construction

Here is sample code on how it’d work for simple shapes.

local square = display.newRect( 50,50,50,50 )  
local circle = display.newCircle( 150,150,50 )  
  
local function changeColor( event )  
 if event.phase == "began" then  
 object = event.target  
 end  
 if event.phase == "ended" or event.phase == "cancelled" then  
 if object == circle then  
 object:setFillColor(255,0,0)  
 elseif object == square then  
 object:setFillColor(0,255,0)  
 end  
 end  
end  
square:addEventListener( "touch", changeColor )  
circle:addEventListener( "touch", changeColor )  

[import]uid: 77199 topic_id: 27484 reply_id: 111998[/import]

Maybe so, good point “ihatethinkingofnames” :slight_smile:

moasif, how did you get on? [import]uid: 52491 topic_id: 27484 reply_id: 112133[/import]