-
Notifications
You must be signed in to change notification settings - Fork 0
KeyboardInput
pjc0247 edited this page Oct 23, 2014
·
1 revision
auto keyboardListener = EventListenerKeyboard::create();
keyboardListener->onKeyPressed = CC_CALLBACK_2(Object::onKeyboardDown, this);
keyboardListener->onKeyReleased = CC_CALLBACK_2(Object::onKeyboardUp, this);
getEventDispatcher()->
addEventListenerWithSceneGraphPriority(keyboardListener, this);
void Object::onKeyboardDown(
cocos2d::EventKeyboard::KeyCode keycode, cocos2d::Event *event){
if(keycode == cocos2d::EventKeyboard::KeyCode::KEY_SPACE)
printf("space bar pressed\n");
}