本文整理汇总了C++中EventDispatcher::addEventListenerWithSceneGraphPriority方法的典型用法代码示例。如果您正苦于以下问题:C++ EventDispatcher::addEventListenerWithSceneGraphPriority方法的具体用法?C++ EventDispatcher::addEventListenerWithSceneGraphPriority怎么用?C++ EventDispatcher::addEventListenerWithSceneGraphPriority使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EventDispatcher
的用法示例。
在下文中一共展示了EventDispatcher::addEventListenerWithSceneGraphPriority方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
bool FriendLayer::init()
{
if ( !Layer::init() )
{
return false;
}
auto friendLayer=CSLoader::createNode("FriendLayer.csb");
this->addChild(friendLayer);
Button * closeButton = static_cast<Button*>(friendLayer->getChildByName("CloseButton"));
Button * okButton = static_cast<Button*>(friendLayer->getChildByName("Button_OK"));
fname = static_cast<TextField*>(friendLayer->getChildByName("TextField_Fname"));
fshow = static_cast<Text*>(friendLayer->getChildByName("Text_show"));
closeButton->addTouchEventListener(this, toucheventselector(FriendLayer::closeEvent));
okButton->addTouchEventListener(this, toucheventselector(FriendLayer::okEvent));
EventDispatcher* eventDispatcher = Director::getInstance()->getEventDispatcher();
EventListenerTouchOneByOne* listener= EventListenerTouchOneByOne::create();
listener->setSwallowTouches(true);
listener->onTouchBegan = [](Touch* touch, Event* event){return true;};
listener->onTouchMoved = [](Touch* touch, Event* event){};
listener->onTouchEnded = [](Touch* touch, Event* event){};
listener->onTouchCancelled = [](Touch* touch , Event* event){};
eventDispatcher->addEventListenerWithSceneGraphPriority(listener, friendLayer); //代码为了设置模态窗口
return true;
}
示例2: registerEventHandlers
void GameLayer::registerEventHandlers() {
Director* director = Director::getInstance();
EventDispatcher* eventDispatcher = director->getEventDispatcher();
EventListenerTouchOneByOne* eventListener = EventListenerTouchOneByOne::create();
eventListener->setSwallowTouches(true);
eventListener->onTouchEnded = [=](Touch* touch, Event* event){
if (!getAcceptInput()) {
return;
}
Vec2 position = m_tileLayer->convertTouchToNodeSpace(touch);
for (auto iterator = m_tileLayer->getChildren().begin(); iterator != m_tileLayer->getChildren().end(); iterator++) {
auto child = *iterator;
GameTileView* gameTileView = dynamic_cast<GameTileView*>(child);
if(gameTileView->getBoundingBox().containsPoint(position)) {
if (gameTileView->getGameTile()->getCanMove()) {
doSelectGameTileView(gameTileView);
}
break;
}
}
};
eventListener->onTouchBegan = [](Touch* touch, Event* event){
return true;
};
eventListener->onTouchMoved = [](Touch* touch, Event* event){};
eventListener->onTouchCancelled = [](Touch* touch, Event* event){};
eventDispatcher->addEventListenerWithSceneGraphPriority(eventListener, m_tileLayer);
}
示例3: init
bool PauseLayer::init()
{
if (!AlertLayer::init())
{
return false;
}
auto board = this->getBoard();
auto title = Sprite::createWithSpriteFrameName(s_pause_txt);
title->setPosition(Vec2(board->getContentSize().width / 2, board->getContentSize().height));
board->addChild(title);
// 继续按钮
auto resumeSprite = Sprite::createWithSpriteFrameName(s_resume_btn);
auto resumeSpriteActive = Sprite::createWithSpriteFrameName(s_resume_btn_a);
auto resumeItem = MenuItemSprite::create(resumeSprite, resumeSpriteActive,
CC_CALLBACK_1(PauseLayer::resumeCallBack, this));
resumeItem->setAnchorPoint(Vec2::ZERO);
resumeItem->setScale(0.7f);
resumeItem->setPosition(Vec2(40, 50));
// 重开按钮
auto restartSprite = Sprite::createWithSpriteFrameName(s_restart_btn);
auto restartSpriteActive = Sprite::createWithSpriteFrameName(s_restart_btn_a);
auto restartItem = MenuItemSprite::create(restartSprite, restartSpriteActive,
CC_CALLBACK_1(PauseLayer::restartCallBack, this));
restartItem->setAnchorPoint(Vec2::ZERO);
restartItem->setScale(0.7f);
restartItem->setPosition(Vec2(140, 50));
// 回首页按钮
auto goHomeSprite = Sprite::createWithSpriteFrameName(s_go_home_btn);
auto goHomeSpriteActive= Sprite::createWithSpriteFrameName(s_go_home_btn_a);
auto goHomeItem = MenuItemSprite::create(goHomeSprite, goHomeSpriteActive,
CC_CALLBACK_1(PauseLayer::goHomeCallBack, this));
goHomeItem->setAnchorPoint(Vec2::ZERO);
goHomeItem->setScale(0.7f);
goHomeItem->setPosition(Vec2(240, 50));
auto menu = Menu::create(resumeItem, restartItem, goHomeItem, NULL);
menu->setPosition(Vec2::ZERO);
board->addChild(menu);
EventDispatcher *eventDispatcher = Director::getInstance()->getEventDispatcher();
auto listener = EventListenerTouchOneByOne::create();
listener->setSwallowTouches(true); // 是否吞掉事件让下面的层无法响应
listener->onTouchBegan = CC_CALLBACK_2(PauseLayer::onTouchBegan, this);
listener->onTouchMoved = CC_CALLBACK_2(PauseLayer::onTouchMoved, this);
listener->onTouchEnded = CC_CALLBACK_2(PauseLayer::onTouchEnded, this);
eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
return true;
}
示例4: setEventHadlers
void ChatScene::setEventHadlers()
{
EventDispatcher* pDispatcher = Director::getInstance()->getEventDispatcher();
EventListenerTouchOneByOne* pEventListener = EventListenerTouchOneByOne::create();
pEventListener->setSwallowTouches(true);
pEventListener->onTouchBegan = CC_CALLBACK_2(ChatScene::onTouchBegan, this);
pEventListener->onTouchMoved = CC_CALLBACK_2(ChatScene::onTouchMoved, this);
pEventListener->onTouchEnded = CC_CALLBACK_2(ChatScene::onTouchEnded, this);
pDispatcher->addEventListenerWithSceneGraphPriority(pEventListener, this);
}
示例5: registerHandler
void GameLayer::registerHandler(Node* node, std::function<void(Touch*, Event*)> onTouchEnded) {
Director* director = Director::getInstance();
EventDispatcher* eventDispatcher = director->getEventDispatcher();
EventListenerTouchOneByOne* eventListener = EventListenerTouchOneByOne::create();
eventListener->setSwallowTouches(true);
eventListener->onTouchEnded = onTouchEnded;
eventListener->onTouchBegan = [](Touch* touch, Event* event){
return true;
};
eventDispatcher->addEventListenerWithSceneGraphPriority(eventListener, node);
}
示例6: init
bool SceneGame::init()
{
if (!Layer::init())
{
return false;
}
Size visibleSize = Director::getInstance()->getVisibleSize();
Vec2 origin = Director::getInstance()->getVisibleOrigin();
_c = new std::vector<Chess*>();
_c->resize(1000);
_steps = new std::vector<Step*>();
_steps->reserve(1000);
createPlate();
Chess::_d = Director::getInstance()->getWinSize().height / 10;
Chess::_offx = Chess::_d;
Chess::_offy = Chess::_d / 2;
for (int i = 0; i < 32; i++)
{
_c->at(i) = Chess::create();
_c->at(i)->initChess(i);
addChild(_c->at(i));
}
EventDispatcher *eventDispatcher = Director::getInstance()->getEventDispatcher();
auto listener = EventListenerTouchOneByOne::create();
listener->onTouchBegan = CC_CALLBACK_2(SceneGame::onTouchBegan, this);
listener->onTouchEnded = CC_CALLBACK_2(SceneGame::onTouchEnd, this);
eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
_selectid = 1;
_selectSprite = Sprite::create("selected.png");
_selectSprite->setVisible(false);
addChild(_selectSprite);
_selectSprite->setScale(0.6f);
_selectSprite->setZOrder(100);
_bRedTurn = true;
_steps->clear();
addCtrlPanel();
return true;
}
示例7: init
bool CaiKuangLayer::init()
{
if ( !Layer::init() )
{
return false;
}
auto caiKuangLayer=CSLoader::createNode("CaiKuangLayer.csb");
addChild(caiKuangLayer);
tt = time(NULL);
t =localtime(&tt); //取到当前时间
// std::cout<<t->tm_hour<<std::endl;
// std::cout<<t->tm_min<<std::endl;
Button * closeButton = static_cast<Button*>(caiKuangLayer->getChildByName("CloseButton"));
cStartButton = static_cast<Button*>(caiKuangLayer->getChildByName("ClassStart"));
inviteButton = static_cast<Button*>(caiKuangLayer->getChildByName("invite"));
inviteButton->addTouchEventListener(this, toucheventselector(CaiKuangLayer::inviteEvent));
// cEndButton = static_cast<Button*>(jiaoXueLayer->getChildByName("ClassOver"));
sStartButton = static_cast<Button*>(caiKuangLayer->getChildByName("StudyStart"));
// sEndButton = static_cast<Button*>(jiaoXueLayer->getChildByName("StudyOver"));
closeButton->addTouchEventListener(this, toucheventselector(CaiKuangLayer::closeEvent));
cStartButton->addTouchEventListener(this, toucheventselector(CaiKuangLayer::classEvent));
sStartButton->addTouchEventListener(this, toucheventselector(CaiKuangLayer::studyEvent));
EventDispatcher* eventDispatcher = Director::getInstance()->getEventDispatcher();
EventListenerTouchOneByOne* listener= EventListenerTouchOneByOne::create();
listener->setSwallowTouches(true);
listener->onTouchBegan = [](Touch* touch, Event* event){return true;};
listener->onTouchMoved = [](Touch* touch, Event* event){};
listener->onTouchEnded = [](Touch* touch, Event* event){};
listener->onTouchCancelled = [](Touch* touch , Event* event){};
eventDispatcher->addEventListenerWithSceneGraphPriority(listener, caiKuangLayer); //代码为了设置模态窗口
return true;
}
示例8: onEnter
void CLayer::onEnter()
{
Layer::onEnter();
log("HelloWorld onEnter");
auto listener = EventListenerKeyboard::create();
listener->onKeyPressed = [](EventKeyboard::KeyCode keyCode, Event* event) {
log("Key with keycode %d pressed", keyCode);
};
listener->onKeyReleased = [](EventKeyboard::KeyCode keyCode, Event* event) {
log("Key with keycode %d released", keyCode);
};
EventDispatcher* eventDispatcher = Director::getInstance()->getEventDispatcher();
eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
}
示例9: build
void BaseLayerBuilder::build() {
this->rootLayer->addChild(uiLayer, 1, BaseLayer::UI_LAYER_TAG);
EventListenerTouchAllAtOnce* listener = EventListenerTouchAllAtOnce::create();
listener->setEnabled(true);
for (std::map<std::string, std::function<void(const std::vector<Touch*>&, Event*)>>::iterator it = this->touchEventHandlerMap.begin(); it != this->touchEventHandlerMap.end(); ++it) {
if ("touchBegan" == it->first) {
listener->onTouchesBegan = it->second;
} else if ("touchMove" == it->first) {
listener->onTouchesMoved = it->second;
listener->onTouchesCancelled = it->second;
} else if ("touchEnd" == it->first) {
listener->onTouchesEnded = it->second;
}
}
EventDispatcher* dip = Director::getInstance()->getEventDispatcher();
dip->addEventListenerWithSceneGraphPriority(listener, this->rootLayer);
return;
}
示例10: init
bool MyScene::init()
{
if (!Layer::init())
{
return false;
}
auto bg = Sprite::create("HelloWorld.png");
bg->setPosition(Vec2(480, 320));
addChild(bg);
bg->setVisible(false);
/*
SpriteFrameCache::getInstance()->addSpriteFramesWithFile("a.plist");
Vector<SpriteFrame *> vec;
char fileName[10];
for (int i = 1; i<=10; i++)
{
sprintf(fileName, "0%d.png",i);
SpriteFrame * frame = SpriteFrameCache::getInstance()->getSpriteFrameByName(fileName);
vec.pushBack(frame);
}
Animation * animation = Animation::createWithSpriteFrames(vec);
animation->setDelayPerUnit(0.1);
animation->setLoops(1);
Animate * animate = Animate::create(animation);
RepeatForever * repeatAction = RepeatForever::create(animate);
bg->runAction(repeatAction);
*/
EventDispatcher * dispatcher = Director::getInstance()->getEventDispatcher();
EventListenerTouchAllAtOnce * listener = EventListenerTouchAllAtOnce::create();
listener->onTouchesBegan = CC_CALLBACK_2(MyScene::onTouchesBegan, this);
listener->onTouchesMoved = CC_CALLBACK_2(MyScene::onTouchesMoved, this);
listener->onTouchesEnded = CC_CALLBACK_2(MyScene::onTouchesEnded, this);
dispatcher->addEventListenerWithSceneGraphPriority(listener, this);
//EventListenerTouchOneByOne * listener2 = listener->clone();
//dispatcher->addEventListenerWithSceneGraphPriority(listener2, bg);
return true;
}
示例11: init
bool Scene_Title::init()
{
auto background = CCSprite::create("title/main.png");
background->setAnchorPoint(ccp(0, 0));
this->addChild(background, 0);
EventDispatcher* dispatcher = Director::getInstance()->getEventDispatcher();
auto* touchListener = EventListenerTouchOneByOne::create();
touchListener->setSwallowTouches(true);
touchListener->onTouchBegan = CC_CALLBACK_2(Scene_Title::onTouchBegan, this);
touchListener->onTouchMoved = CC_CALLBACK_2(Scene_Title::onTouchMoved, this);
touchListener->onTouchEnded = CC_CALLBACK_2(Scene_Title::onTouchEnded, this);
dispatcher->addEventListenerWithSceneGraphPriority(touchListener, this);
CDataManager::getInstance()->LoadPlayerData();
SimpleAudioEngine::sharedEngine()->playBackgroundMusic("music/title.mp3", true);
return true;
}
示例12: init
bool LogoScene::init()
{
if ( !Layer::init() )
{
return false;
}
CocosDenshion::SimpleAudioEngine::sharedEngine()->playBackgroundMusic("sounds/LoadingBG.mp3");
this->setTouchEnabled(true);
EventDispatcher* eventDispatcher = Director::getInstance()->getEventDispatcher();
auto listen = EventListenerTouchOneByOne::create();
listen->onTouchBegan = CC_CALLBACK_2(LogoScene::onTouchBegan, this);
eventDispatcher->addEventListenerWithSceneGraphPriority(listen, this);
auto logo1 = Sprite::create("logos/logo_1.jpg");
auto logo2 = Sprite::create("logos/logo_2.jpg");
auto logo3 = Sprite::create("logos/logo_3.jpg");
auto logo4 = Sprite::create("logos/logo_4.png");
auto logo5 = Sprite::create("logos/logo_5.jpg");
vecLogo.pushBack(logo1);
vecLogo.pushBack(logo2);
vecLogo.pushBack(logo3);
vecLogo.pushBack(logo4);
vecLogo.pushBack(logo5);
nLogoNum = 0;
isEndLogo = false;
isEndAddResource = false;
visibleSize = Director::getInstance()->getVisibleSize();
loadingSprite = Sprite::create("logos/loading.png");
loadingSprite->setPosition(visibleSize / 2);
addChild(loadingSprite, 1);
loadingSprite->setVisible(false);
changeLogo();
addResource();
return true;
}
示例13: init
// on "init" you need to initialize your instance
bool PuzzleScene::init()
{
//////////////////////////////
// 1. super init first
if ( !Layer::init() )
{
return false;
}
Size visibleSize = Director::getInstance()->getVisibleSize();
Point origin = Director::getInstance()->getVisibleOrigin();
/////////////////////////////
// 2. add a menu item with "X" image, which is clicked to quit the program
// you may modify it.
// add a "close" icon to exit the progress. it's an autorelease object
auto closeItem = MenuItemImage::create(
"CloseNormal.png",
"CloseSelected.png",
CC_CALLBACK_1(PuzzleScene::menuCloseCallback, this));
closeItem->setPosition(Point(origin.x + visibleSize.width - closeItem->getContentSize().width/2 ,
origin.y + closeItem->getContentSize().height/2));
// create menu, it's an autorelease object
auto menu = Menu::create(closeItem, NULL);
menu->setPosition(Point::ZERO);
this->addChild(menu, 1);
/////////////////////////////
// 3. add your codes below...
// add a label shows "Hello World"
// create and initialize a label
auto label = LabelTTF::create("Hello World", "Arial", 24);
// position the label on the center of the screen
label->setPosition(Point(origin.x + visibleSize.width/2,
origin.y + visibleSize.height - label->getContentSize().height));
// add the label as a child to this layer
this->addChild(label, 1);
// add "PuzzleScene" splash screen"
auto sprite = Sprite::create("HelloWorld.png");
// position the sprite on the center of the screen
sprite->setPosition(Point(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y));
// add the sprite as a child to this layer
this->addChild(sprite, 0);
// タイルエディターで作った画像の作成
mTMXObject = TMXManager::getInstance()->CreateTMXObject("mapdata/map1.tmx");
this->addChild(mTMXObject->GetTMXTiledMap(), 0);
this->scheduleUpdate();
// タッチイベント登録らしい
EventDispatcher* dispatcher = Director::getInstance()->getEventDispatcher();
EventListenerTouchOneByOne* listener = EventListenerTouchOneByOne::create();
listener->onTouchBegan = CC_CALLBACK_2(PuzzleScene::onTouchBegan, this);
listener->onTouchMoved = CC_CALLBACK_2(PuzzleScene::onTouchMoved, this);
listener->onTouchEnded = CC_CALLBACK_2(PuzzleScene::onTouchEnded, this);
listener->onTouchCancelled = CC_CALLBACK_2(PuzzleScene::onTouchCancelled, this);
dispatcher->addEventListenerWithSceneGraphPriority(listener, this);
// マルチタッチ。忘れないように書いておくだけ
//EventDispatcher* dispatcher2 = Director::getInstance()->getEventDispatcher();
//EventListenerTouchAllAtOnce* listener2 = EventListenerTouchAllAtOnce::create();
//listener2->onTouchesBegan = CC_CALLBACK_2(PuzzleScene::onTouchesBegan, this);
//listener2->onTouchesMoved = CC_CALLBACK_2(PuzzleScene::onTouchesMoved, this);
//listener2->onTouchesCancelled = CC_CALLBACK_2(PuzzleScene::onTouchesCancelled, this);
//listener2->onTouchesEnded = CC_CALLBACK_2(PuzzleScene::onTouchesEnded, this);
//dispatcher2->addEventListenerWithSceneGraphPriority(listener2, this);
SpriteCreator::getInstance()->AddSpriteFrameCache("putobject/sample_texturepacker.plist");
return true;
}
示例14: init
//.........这里部分代码省略.........
// menuLayer->addChild(scrollView, 1);
// scrollView->setContentOffset(Vec2(0, (-1 * userListLayer->getContentSize().height)), false);
/*
auto moveChannel = MenuItemImage::create(
"channel_list.png",
"channel_list.png",
CC_CALLBACK_1(LobbyScene::GetChannelList, this));
moveChannel->setAnchorPoint(ccp(0, 0));
moveChannel->setPosition(0, 1000);
auto userList = MenuItemImage::create(
"user_list.png",
"user_list.png",
CC_CALLBACK_1(LobbyScene::GetUserList, this));
userList->setAnchorPoint(ccp(0, 0));
userList->setPosition(0, 900);
auto friendList = MenuItemImage::create(
"friend_list.png",
"friend_list.png",
CC_CALLBACK_1(LobbyScene::GetFriendList, this));
friendList->setAnchorPoint(ccp(0, 0));
friendList->setPosition(0, 800);
auto roomList = MenuItemImage::create(
"room_list.png",
"room_list.png",
CC_CALLBACK_1(LobbyScene::GetRoomList, this));
roomList->setAnchorPoint(ccp(0, 0));
roomList->setPosition(0, 700);
auto requestList = MenuItemImage::create(
"request_list.png",
"request_list.png",
CC_CALLBACK_1(LobbyScene::GetRequestList, this));
requestList->setAnchorPoint(ccp(0, 0));
requestList->setPosition(0, 600);
int reqCount = GameClient::GetInstance().requestInfoCount;
std::string reqCountStr;
GameClient::intToString(reqCountStr, reqCount);
requestCountLabel = LabelTTF::create(reqCountStr, "Arial", 24);
requestCountLabel->setColor(Color3B(0, 0, 0));
requestCountLabel->setPosition(500, 650);
menuLayer->addChild(requestCountLabel, 101);
Menu* menu1 = Menu::create(moveChannel, userList, friendList, roomList, requestList, NULL);
menu1->setAnchorPoint(ccp(0, 0));
menu1->setPosition(ccp(0, 0));
menuLayer->addChild(menu1, 100, TAG_MENU);
channelListLayer = ChannelListLayer::create();
channelListLayer->retain();
userListLayer = UserListLayer::create();
userListLayer->retain();
roomListLayer = RoomListLayer::create();
roomListLayer->retain();
RoomInfo roomInfo[3];
memset(roomInfo, 0, sizeof(roomInfo));
for (int i = 0; i < 3; i++)
{
roomInfo[i].roomNo = i;
memcpy(roomInfo[i].roomName, "room", sizeof(5));
}
roomListLayer->SetRoomList(3, roomInfo);
requestListLayer = RequestListLayer::create();
requestListLayer->retain();
requestListLayer->SetRequestList();
*/
EventDispatcher* dispatcher = Director::getInstance()->getEventDispatcher();
//터치 위치를 알려주는 리스너. 단일 터치.
//바로 만들어쓰는 식별자는 auto를 사용한다.
auto positionListener = EventListenerTouchOneByOne::create();
//zOrder에 따라 밑에 깔린애도 동작할지 아닐지를 결정한다.
positionListener->setSwallowTouches(true);
//콜백 함수 대입
positionListener->onTouchBegan = CC_CALLBACK_2(LobbyScene::onTouchBegan, this);
//디스패처를 이용해 객체와 리스너를 이어준다. 화면 전체를 터치할 수 있게 만들어야 하므로 객체는 this
dispatcher->addEventListenerWithSceneGraphPriority(positionListener, this);
return true;
}
示例15: onEnter
//.........这里部分代码省略.........
auto scoreSpire = (Label *)this->getChildByTag(100);
scoreSpire->setString(String::createWithFormat("HP:%d", blood_for_man)->_string);
auto * system = ParticleSystemQuad::create("particle_texture.plist");
if (tag1 == 104) {
system->setPosition(vec1);
this->addChild(system);
spriteA->removeFromParent();
}
else {
system->setPosition(vec2);
this->addChild(system);
spriteB->removeFromParent();
}
}
else if (tag1 + tag2 == 207 || tag1 + tag2 == 111) {//当人物和可碰撞鱼碰撞后
Magic += 3;
auto * system = ParticleSystemQuad::create("particle_texture.plist");
if (tag1 == 105) {
system->setPosition(vec1);
this->addChild(system);
spriteA->removeFromParent();
}
else {
system->setPosition(vec2);
this->addChild(system);
spriteB->removeFromParent();
}
if (getTypeSkill() == 3) {
manscale = manscale * 0.9;
speed_for_man++;
if (manscale < 0.4) {
manscale = 0.4;
}
if (speed_for_man > 10) {
speed_for_man = 10;
}
man->setScale(manscale);
}
}
else if (tag1 + tag2 == 112) {//当Boss被武器一击中时
blood_for_boss -= weapon_eff;
auto * system = ParticleSystemQuad::create("particle_texture.plist");
if (tag1 == 1) {
system->setPosition(vec1);
this->addChild(system);
spriteA->removeFromParent();
}
else {
system->setPosition(vec2);
this->addChild(system);
spriteB->removeFromParent();
}
// 发出音效
SimpleAudioEngine::getInstance()->playEffect("music/boom.mp3");
//更新boss的血量
auto scoreSpire = (Label *)this->getChildByTag(121);
scoreSpire->setString(String::createWithFormat("HP:%d", blood_for_boss)->_string);
if (blood_for_boss <= 0) {
//这里要有Bosss死亡的特效
win();
}
}
else if (tag1 + tag2 == 113) {//当Boss被武器二击中时
blood_for_boss --;
auto * system = ParticleSystemQuad::create("particle_texture.plist");
if (tag1 == 2) {
system->setPosition(vec1);
this->addChild(system);
spriteA->removeFromParent();
}
else {
system->setPosition(vec2);
this->addChild(system);
spriteB->removeFromParent();
}
//更新boss的血量
auto scoreSpire = (Label *)this->getChildByTag(121);
scoreSpire->setString(String::createWithFormat("HP:%d", blood_for_boss)->_string);
if (blood_for_boss <= 0) {
//这里要有Bosss死亡的特效
win();
}
}
return true;
};
//注册监听器
EventDispatcher * eventDispatcher = Director::getInstance()->getEventDispatcher();
eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
}