I’m trying to do a simple touch and move based on this wiki entry, but the program crashes right away with “Assertion failed” error, with a reason “CCEventListenerTouch.cpp, Line 89, Expression: false”.
Here’s the code I wrote:
bool MainLayer::init()
{
Sprite* tile = Sprite::create("tile.png");
this->addChild(tile);
auto listener = EventListenerTouchOneByOne::create();
listener->setSwallowTouches(true);
listener->onTouchMoved = [](Touch* touch, Event* event)
{
tile->setPosition(tile->getPosition() + touch->getDelta());
};
// If I comment this line out, it won't crash but touch won't work either...
_eventDispatcher->addEventListenerWithSceneGraphPriority(listener, tile);
return true;
}
What could be causing the crash?
EDIT: I’m using Cocos2D-X 3.2. It crashes on both Win32 and WP8, haven’t tried any other ports.