本文整理汇总了C++中Touch::autorelease方法的典型用法代码示例。如果您正苦于以下问题:C++ Touch::autorelease方法的具体用法?C++ Touch::autorelease怎么用?C++ Touch::autorelease使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Touch
的用法示例。
在下文中一共展示了Touch::autorelease方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: generateTestFunctions
void TouchEventDispatchingPerfTest::generateTestFunctions()
{
TestFunction testFunctions[] = {
{ "OneByOne-scenegraph", [=](){
auto dispatcher = Director::getInstance()->getEventDispatcher();
if (_quantityOfNodes != _lastRenderedCount)
{
auto listener = EventListenerTouchOneByOne::create();
listener->onTouchBegan = [](Touch* touch, Event* event){
return false;
};
listener->onTouchMoved = [](Touch* touch, Event* event){};
listener->onTouchEnded = [](Touch* touch, Event* event){};
// Create new touchable nodes
for (int i = 0; i < this->_quantityOfNodes; ++i)
{
auto node = Node::create();
node->setTag(1000 + i);
this->addChild(node);
this->_nodes.push_back(node);
dispatcher->addEventListenerWithSceneGraphPriority(listener->clone(), node);
}
_lastRenderedCount = _quantityOfNodes;
}
Size size = Director::getInstance()->getWinSize();
EventTouch touchEvent;
touchEvent.setEventCode(EventTouch::EventCode::BEGAN);
std::vector<Touch*> touches;
for (int i = 0; i < 4; ++i)
{
Touch* touch = new (std::nothrow) Touch();
touch->autorelease();
touch->setTouchInfo(i, rand() % 200, rand() % 200);
touches.push_back(touch);
}
touchEvent.setTouches(touches);
CC_PROFILER_START(this->profilerName());
dispatcher->dispatchEvent(&touchEvent);
CC_PROFILER_STOP(this->profilerName());
} } ,
{ "OneByOne-fixed", [=](){
auto dispatcher = Director::getInstance()->getEventDispatcher();
if (_quantityOfNodes != _lastRenderedCount)
{
auto listener = EventListenerTouchOneByOne::create();
listener->onTouchBegan = [](Touch* touch, Event* event){
return false;
};
listener->onTouchMoved = [](Touch* touch, Event* event){};
listener->onTouchEnded = [](Touch* touch, Event* event){};
for (int i = 0; i < this->_quantityOfNodes; ++i)
{
auto l = listener->clone();
this->_fixedPriorityListeners.push_back(l);
dispatcher->addEventListenerWithFixedPriority(l, i+1);
}
_lastRenderedCount = _quantityOfNodes;
}
Size size = Director::getInstance()->getWinSize();
EventTouch touchEvent;
touchEvent.setEventCode(EventTouch::EventCode::BEGAN);
std::vector<Touch*> touches;
for (int i = 0; i < 4; ++i)
{
Touch* touch = new (std::nothrow) Touch();
touch->autorelease();
touch->setTouchInfo(i, rand() % 200, rand() % 200);
touches.push_back(touch);
}
touchEvent.setTouches(touches);
CC_PROFILER_START(this->profilerName());
dispatcher->dispatchEvent(&touchEvent);
CC_PROFILER_STOP(this->profilerName());
} } ,
{ "AllAtOnce-scenegraph", [=](){
auto dispatcher = Director::getInstance()->getEventDispatcher();
if (_quantityOfNodes != _lastRenderedCount)
{
auto listener = EventListenerTouchAllAtOnce::create();
listener->onTouchesBegan = [](const std::vector<Touch*> touches, Event* event){};
listener->onTouchesMoved = [](const std::vector<Touch*> touches, Event* event){};
listener->onTouchesEnded = [](const std::vector<Touch*> touches, Event* event){};
// Create new touchable nodes
for (int i = 0; i < this->_quantityOfNodes; ++i)
{
//.........这里部分代码省略.........