How can I access a text object contained in a group by name and later manipulate x,y position?
Seems like a basic question but I must be missing something obvious and easy.
I started by creating this function in a class. pGroup is the group that the text object will reside in. pText is the actual text. pName is the reference name of the text object. The other parameters are obvious.
[lua]
insertText = function(pGroup,pText,pName,pFont,pFontSize,pX,pY,pWidth,pColor,pRef)
local pText = display.newText( pGroup, pText, pX, pY, pFont, pFontSize )
pText.name = pName
pText:setReferencePoint(pRef)
pText:setTextColor(pColor[1], pColor[2], pColor[3])
pGroup:insert(pText)
return pGroup
end
– END CODE -------------------------------------------------------------------------------------------
I called the function in main.lua like this:
– CODE --------------------------------------------------------------------------------------------------
gCardGroup = uiObj.insertText(gCardGroup,gRecord.title,“title”,“Papyrus”,16,
(display.contentWidth*.5),82,31,{0, 0, 0},display.CenterReferencePoint)
– END CODE -------------------------------------------------------------------------------------------
[/lua]
gCardGroup is the group object
This all works so far but I want to move the text object named “title” by adding a listener. Basically, a scrolling text field in the object. How can I reference the specific text object to alter its y position. What does not appear to work
gCardGroup[“title”].x
gCardGroup.title.x
Any help would be GREATLY appreciated.