Groups
Groups
Sign in
Groups
Groups
cocos2d discuss
Conversations
About
Send feedback
Help
How to get and handler a key hold event?
28 views
Skip to first unread message
siy tong
unread,
Mar 18, 2013, 6:54:38 AM
3/18/13
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to cocos-...@googlegroups.com
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?
siy tong
unread,
Mar 18, 2013, 10:28:46 PM
3/18/13
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to cocos-...@googlegroups.com
use self.schedule(self.update)
Gerardo Marset
unread,
Jun 5, 2013, 2:08:36 PM
6/5/13
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to cocos-...@googlegroups.com
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.
Reply all
Reply to author
Forward
0 new messages