Last active
May 18, 2016 20:50
-
-
Save indatawetrust/0f0fa8e505b8f54b5c2d3a4152a0bfd9 to your computer and use it in GitHub Desktop.
cocos2d-x sprite touch event run action
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
auto sprite = Sprite::create("HelloWorld.png"); | |
auto listener1 = EventListenerTouchOneByOne::create(); | |
listener1->onTouchBegan = [](Touch* touch, Event* event){ | |
auto sprite = event->getCurrentTarget(); | |
Point pt = touch->getLocation(); | |
Rect recTemp= sprite->boundingBox(); | |
if(recTemp.containsPoint(pt)) { | |
auto scaleTo = ScaleTo::create(2,2); | |
sprite->runAction(scaleTo); | |
} | |
return false; | |
}; | |
listener1->onTouchMoved = [](Touch* touch, Event* event){ | |
}; | |
listener1->onTouchEnded = [=](Touch* touch, Event* event){ | |
}; | |
_eventDispatcher->addEventListenerWithSceneGraphPriority(listener1, sprite); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment