本文来自http://blog.youkuaiyun.com/runaying ,引用必须注明出处!
cocos2d-x节点(CCEventListenerKeyboard.h)API
温馨提醒:为了大家能更好学习,强烈推荐大家看看本人的这篇博客 Cocos2d-X权威指南笔记
键盘事件监听
///cocos2d/cocos2d-x-3.0alpha0/cocos2dx/event_dispatcher
//键盘事件监听
#ifndef __cocos2d_libs__CCKeyboardEventListener__
#define __cocos2d_libs__CCKeyboardEventListener__
#include "CCEventListener.h"
#include "CCEventKeyboard.h"
NS_CC_BEGIN
class Event;
class EventListenerKeyboard : public EventListener
{
public:
static EventListenerKeyboard* create();
/// Overrides
virtual EventListenerKeyboard* clone() override;
virtual bool checkAvaiable() override;
std::function<void(EventKeyboard::KeyCode, Event* event)> onKeyPressed;
std::function<void(EventKeyboard::KeyCode, Event* event)> onKeyReleased;
private:
EventListenerKeyboard();
bool init();
};
NS_CC_END
#endif /* defined(__cocos2d_libs__CCKeyboardEventListener__) */