On Monday, March 18, 2013 7:54:38 AM UTC-3, siy tong wrote:
>
> The cocos2d only supply on_key_press and on_key_release event hanlder ?
> I am making a rpg game . I want to move the sprite when I hold a key .
> How to implement that function?
>
Actually what you need is probably what's used in the platformer test
(test/test_platformer.py).
First, import key:
from pyglet.window import key
then get a key state handler:
keyboard = key.KeyStateHandler()
director.window.push_handlers(keyboard)
and then you can do something like:
if keyboard[key.SPACE]:
print "the space key is being held!"
Or you could just track the pressing and releasing of keys.
--
You received this message because you are subscribed to the Google Groups
"cocos2d discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/cocos-discuss?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.