Cocos2d-x OneBy OneTouch 기본 Code

1393 단어 cocos2dx
TouchOneByOne 비고
먼저
scene.cpp-->file//touch listener set
auto touchListener=EventListenerTouchOneByOne::create();
//set touch
touchListener->setEnabled(true);
// touchbegan
touchListener->onTouchBegan = CC_CALLBACK_2(Scene::onTouchBegan,this);
touchListener->onTouchMoved = CC_CALLBACK_2(Scene::onTouchMoved,this);
touchListener->onTouchEnded = CC_CALLBACK_2(Scene::onTouchEnded,this);
touchListener->onTouchEnded = CC_CALLBACK_2(Scene::onTouchCancelled,this);
//set dispatcher
_eventDispatcher->addEventListenerWithSceneGraphPriority(touchListener, this);
scene.h-->file
    bool onTouchBegan(cocos2d::Touch *touch,cocos2d::Event *event);
    //onTouchMoved
    void onTouchMoved(cocos2d::Touch *touch,cocos2d::Event *event);
    //onTouchEnded
    void onTouchEnded(cocos2d::Touch *touch,cocos2d::Event *event);
    //onTouchCancelled
    void onTouchCancelled(cocos2d::Touch *touch,cocos2d::Event *event);
완성~

좋은 웹페이지 즐겨찾기