Change x and y properties of a TextCandy object

Hi,

I am trying to reuse a text object, likes expressions recomends in their site, but I need to change its position runtime, and when I do:

[lua]MyTxt:setProperties({x = 825, y = 244})[/lua]

It crashes, please somebody knows why?

Thanks [import]uid: 40628 topic_id: 10717 reply_id: 310717[/import]

After you’ve declared it, you should be able to simply use:

MyTxt.x = (your x location)  
MyTxt.y = (your y location)  

Lemme know if you need more help, below is my function that updates all my text objects:

 -- Update our text label's position  
 local function UpdateTextPosition()  
 --print("Doing item "..gameBoard.numChildren)  
 for i=1,gameBoard.numChildren do  
 if(gameBoard[i].type=="ship")then  
 gameBoard[i].label.x = gameBoard[i].x + gameBoard.x  
 gameBoard[i].label.y = (gameBoard[i].y+50) + gameBoard.y  
 end  
 end  
 end  

where “gameBoard[i].label” is a TextCandy object. :slight_smile: [import]uid: 11636 topic_id: 10717 reply_id: 38892[/import]

Right, Text Candy text objects can be used like common display objects, so you can position and rotate them like any other display object:

MyText.x = 100
MyText.y = 150
MyText.rotation = 180 [import]uid: 10504 topic_id: 10717 reply_id: 38910[/import]

Ok, its working now thanks [import]uid: 40628 topic_id: 10717 reply_id: 38944[/import]

Still, setProperties should work…

I personnaly can’t make this work :

 myText:setProperties({  
 originX = param1,   
 originY = param2,   
 textFlow = param3,   
 })  

Note that myText:setText( txt ) just below works !?

It returns this error
"
Runtime error
…//code/projects//lib_text_candy.lua:1291: attempt to index local ‘Charset’ (a nil value)
stack traceback:
[C]: ?
…//code/projects//lib_text_candy.lua:1291: in function ‘PApplyProperties’
…//code/projects//lib_text_candy.lua:558: in function ‘setProperties’
"

Thx for any infos [import]uid: 9328 topic_id: 10717 reply_id: 95837[/import]

Antheor, please send us some small, stripped-down sample code and we’ll have a look at it. This is to ensure that there is no typo or any other reason that may cause the regarding issue. [import]uid: 10504 topic_id: 10717 reply_id: 96527[/import]