//首先创建一个精灵,点击这精灵切换场景
auto * sprite = Sprite::create("HelloWorld.png");
sprite->setPosition(200, 200);
this->addChild(sprite);
//监听器
auto * listener = EventListenerTouchOneByOne::create();
listener->onTouchBegan = [ttf, sprite, this](Touch * t, Event * e){
if (sprite->getBoundingBox().containsPoint(t->getLocation())){//检测碰撞
//特效切换场景
//Director::getInstance()->replaceScene(TransitionFade::create(2,HelloWorld::createScene()));
//动作
auto * to = MoveTo::create(3, CCPoint(300,300));
//auto * re = Repeat::create(RotateBy::create(0.5, 18000), 3);
auto * ro = RotateBy::create(3, 180000);
//callfunc
auto * se = Sequence::create(to, ro, CallFunc::create([](){
MessageBox("callfunc", "lx");
}), NULL);
auto * sp = CCSpawn::create(to, ro, NULL);
//
ttf->runAction(se);
}
return false;
};
Director::getInstance()->getEventDispatcher()->addEventListenerWithSceneGraphPriority(listener, ttf);
//Director::getInstance()->replaceScene(GameScene::createScene());//切换到下一个场景,并关闭本场景
//Director::getInstance()->pushScene(HelpScene::createScene());//切换到下一场景,但不关闭本场景
//Director::getInstance()->popScene();//关闭本场景