setTouchEnabled method is deprecated, and now we have this redundant code everywhere:
_touchListener = EventListenerTouchOneByOne::create(); _touchListener->onTouchBegan = CC_CALLBACK_2(ScrollView::onTouchBegan, this); _touchListener->onTouchMoved = CC_CALLBACK_2(ScrollView::onTouchMoved, this); _touchListener->onTouchEnded = CC_CALLBACK_2(ScrollView::onTouchEnded, this); _touchListener->onTouchCancelled = CC_CALLBACK_2(ScrollView::onTouchCancelled, this); _eventDispatcher->addEventListenerWithSceneGraphPriority(_touchListener, this);
I mean… Why?? It is seriously cumbersome, and it would be great if cocos2d-x didn’t try to lamba enable EVERYTHING. If you want to, that’s OK, I guess, just at least provide a shortcut.
I have a
CCLayer subclass, I want to control the
touchEnabled property in a single line of readable code. This is not readable: