Hi everyone,
I'm currently trying to get the Joystick input devices for pyglet 1.2
to play nicely with cocos. I've naively tried the following:
from cocos.director import director
from cocos import scene
from cocos import layer
from cocos import text
from pyglet import input
class JoystickTest(layer.Layer):
is_event_handler = True
def __init__(self):
super( JoystickTest, self ).__init__()
self.display = text.Label(
'--',
font_name='Times New Roman',
font_size=32,
anchor_x='center', anchor_y='center',
position = (320, 240),
)
self.add( self.display )
def on_enter(self):
super(JoystickTest, self).on_enter()
self.joy = input.get_joysticks()[0]
self.joy.on_joyaxis_motion = self.on_joyaxis_motion
self.joy.open()
def on_joyaxis_motion(self, joystick, axis, value):
self.update_text(axis)
def update_text(self, text):
print text
self.display.element.text = text
director.init()
director.run( scene.Scene( JoystickTest() ) )
The update_text call is printing to the console but the Label itself
isn't updating. I _thought_ using joystick.open() would be enough to
register it to the same event loop as cocos but I'm not entirely sure
if it is.
Any help would be greatly appreciated, thanks.
--
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.