Displaying text on an object

Hey,
I want to display text on some objects, each is a rectangle,all stacked on top of each other (as in each rectangle behind another), I'd like to display text on each of these rectangles in the most efficient way possible.
At the moment I'm thinking that if I turned the text into a display object then I could weld it to the rectangle instead of adding a runtime listener to update the text's coords based ont eh position of the rectangle.
Any help is greatly appreciated!
Cheers,
Ryan

If you want to keep it really simple I'd just have the text and rectangle as one image. Unless you need to update the text as you go, but I assume you don't as you already mentioned making the text an image.

If memory serves the credit example in SampleCode (in the CoronaSDK folder) might have something like this - let me know if not and I can try to find the sample I'm thinking of :)

Peach

Hello Peach,
Thanks very much for your reply, the text updates once you touch the rectangle, so having the rectangle and text as one image isn't a feasible solution.
I've looked through the sample code and can't find anything that would help unfortunately!
Thanks and regards,
Ryan

@ryan,
try to create a Group, a group that contains a Rect and text. so you can move both together like welded.

cheers,

?:)

Hey jayantv,
I forgot to post that I've resolved the issue by doing exactly that, basically what I did was have and array where the first value contains the code to draw the rectangle and print the text on said rectangle, the text being contained in a seperate array. So on the first rectangle it prints the text of the same value from the text array ( e.g. on myRect[1] the text from myText[1] is printed. The text is then turned into a physics body and welded to the card.
Much more efficient than a runtime event listener that updates the position of the text!
Thanks,
Ryan

views:1379 update:2011/9/28 21:38:26
corona forums © 2003-2011