On Tue, May 10, 2011 at 6:33 AM, Max P <[email protected]> wrote:
> Hello, > > I'm new to cocos and I currently try to find my way through tutorials > and API descriptions. > There i found the command for setting a the text of a label > "Label.element.text = 'some text'", but i can't find out where this > 'element' or 'element.text' comes from. I couldn't find any > corresponding attribute or inheritance, so why is this working or is > there an other way to set a labels text? > > Could somebody explain that issue to me? > > Thanks, > Max > > You are right that the documentation tells nothing about this. Text Elements: They combine the functionality of CocosNode and a pyglet text related object. the class cocos.text.TextElement define how this combination is done: . the TextElement instance will be a CocosNode . the pyglet text functionality is provided by a component named 'element', which will hold the appropriate pyglet text related object. The concrete subclasses of TextElement are cocos.text.HTMLLabel ( .element is a instance of pyglet.text.HTMLLabel ) cocos.text.Label ( .element an instance of pyglet.text.Label ) cocos.text.RichLabel (. element an instance of a subclass of pyglet.text.DocumentLabel) If text_element is an instance of one of the above, to access text specific functionality you must talk to text_element.element. And you know how it behaves by looking up the corresponding pyglet text documentation. To access CocosNode functionality, (placement, scheduling, animation...) you access directly text_element. By example, to change position text_element.position = (100, 100) Additionally to CocosNode functionality a text element has a 'opacity' property, which you can get/set. Feel free to ask for clarification. -- claudio -- You received this message because you are subscribed to the Google Groups "cocos2d discuss" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/cocos-discuss?hl=en.
