There’s quite a lot of ways of handling this.
I’ve personally preferred using a set of sliders paired a few preset colours to choose from. Whichever you want to go with, the approach is pretty much the same, e.g.
local widget = require( "widget" ) local object = display.newRect( display.contentCenterX, display.contentCenterY, 120, 120 ) object.rgb = { r = 1, g = 1, b = 1 } local function sliderListener( event ) if event.target.id == 1 then -- red object.rgb.r = event.value / 100 elseif event.target.id == 2 then -- green object.rgb.g = event.value / 100 else -- blue object.rgb.b = event.value / 100 end object:setFillColor( object.rgb.r, object.rgb.g, object.rgb.b ) end local slider = {} for i = 1, 3 do slider[i] = widget.newSlider( { x = display.contentCenterX, y = display.contentCenterY + 60 + 40 \* i, id = i, width = 200, value = 100, listener = sliderListener } ) end
Now, if you wanted to just give the player a few predetermined colours to choose from, then you could just create a few buttons and assign each button a value for red, green and blue. The button function would then simply take those three values from whatever button is pressed and use them in like in my sliderListener above.