Found it! Nevermind. Future googlers: self.title.element.content_width
(see: dir(self.title.element)) On Wednesday, November 7, 2012 10:38:25 AM UTC-5, Blaine wrote: > > Hi guys. > > I've got a Label and I want to make it scroll off the screen, then repeat. > With MoveTo() the scrolling isn't a problem, but I am having a heck of a > time figuring out when the entire label is off screen. I imagine I can just > take the x position (which will be negative), plus the width (or width/2 if > we use center point) of the label, and restart it when this value is < 0. > > However, I can't figure out how to tell the width of the Label. > Pyglet.text.Label has content_width, but I can't find out how to access > that either. > > Hopefully it's something obvious. What do you say? > > class ScrollingTextLayer(cocos.layer.Layer): > is_event_handler = True > def __init__(self, caption): > super(ScrollingTextLayer, self).__init__() > x, y = director.get_window_size() > self.title = text.Label( > caption, (x/2, y-50), font_name = 'Gill Sans', > font_size = 64, anchor_x='center', anchor_y='center' ) > self.add( self.title ) > > def on_enter(self): > super(ScrollingTextLayer,self).on_enter() > move = MoveBy((-800, 0), 1) > self.title.do( move ) > > Blaine > -- You received this message because you are subscribed to the Google Groups "cocos2d discuss" group. To view this discussion on the web visit https://groups.google.com/d/msg/cocos-discuss/-/PVn9dDG72XsJ. 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.
