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)
Blaine