I have a display group made up of 1 png and 2 text objects. (A word tile object)
I have a function that create the display group by adding the png and 2 text objects and then returns the display group itself.
[lua]local function display_letter_tile( letter_character, position_x, position_y, size, letter_value)
local tilegroup = display.newGroup()
local c = letter_character
local x = position_x
local y = position_y
local s = size
local v = letter_value
local tile = display.newImageRect(tilegroup,“circle.png”, s, s)
tile.x = x
tile.y = y
local letter = display.newEmbossedText( tilegroup, c, 0, 0, native.systemFontBold, 32)
letter.x = x
letter.y = y + 5
letter:setTextColor(0, 0, 0)
local value = display.newEmbossedText( tilegroup, v , 0 ,0, native.systemFont, 8)
value.x = x - (size/4)
value.y = y - (size/4)
value:setTextColor(0, 0, 0)
tilegroup:setReferencePoint(display.CenterReferencePoint)
return tilegroup
end[/lua]
I’d like to be able to change the text color of one of the objects.
Should I able to change it this way when the display group’s touch function.
[lua]local function on_tile_touch(event)
if event.phase == “began” then
display.getCurrentStage():setFocus(event.target)
local x = event.x
local y = event.y
test = event.target – display group gets passed here
test[2]:setTextColor(255) – assuming that the second child is the text object[/lua]
[import]uid: 9035 topic_id: 33162 reply_id: 333162[/import]
