当前位置: 首页>>代码示例>>C++>>正文


C++ CCNode::getComponent方法代码示例

本文整理汇总了C++中CCNode::getComponent方法的典型用法代码示例。如果您正苦于以下问题:C++ CCNode::getComponent方法的具体用法?C++ CCNode::getComponent怎么用?C++ CCNode::getComponent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CCNode的用法示例。


在下文中一共展示了CCNode::getComponent方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: createGameScene

cocos2d::CCNode* SceneEditorTestLayer::createGameScene()
{
    CCNode *pNode = CCJsonReader::sharedJsonReader()->createNodeWithJsonFile("FishJoy2.json");
	if (pNode == NULL)
	{
		return NULL;
	}
	m_pCurNode = pNode;

	//play back music
    CCComAudio *pAudio = (CCComAudio*)(pNode->getComponent("Audio"));
	pAudio->playBackgroundMusic(pAudio->getFile(), pAudio->getIsLoop());

	//fishes
	CCArmature *pBlowFish = getFish(5, "blowFish");
	CCArmature *pButterFlyFish = getFish(6, "butterFlyFish");
	pBlowFish->getAnimation()->playByIndex(0);
	pButterFlyFish->getAnimation()->playByIndex(0);

    CCMenuItemFont *itemBack = CCMenuItemFont::create("Back", this, menu_selector(SceneEditorTestLayer::toExtensionsMainLayer));
        itemBack->setColor(ccc3(255, 255, 255));
        itemBack->setPosition(ccp(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25));
        CCMenu *menuBack = CCMenu::create(itemBack, NULL);
        menuBack->setPosition(CCPointZero);
		menuBack->setZOrder(4);

    pNode->addChild(menuBack);
    
	//ui action
	cocos2d::extension::UIActionManager::shareManager()->PlayActionByName("startMenu_1.json","Animation1");

    return pNode;
}
开发者ID:chenxu111,项目名称:Cocos2d-x-For-CocoStudio,代码行数:33,代码来源:SceneEditorTestScene.cpp

示例2: init

// on "init" you need to initialize your instance
bool HelloWorld::init()
{
    //////////////////////////////
    // 1. super init first
    if ( !CCLayer::init() )
    {
        return false;
    }
    
    CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
    CCPoint origin = CCDirector::sharedDirector()->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
    CCMenuItemImage *pCloseItem = CCMenuItemImage::create(
                                        "CloseNormal.png",
                                        "CloseSelected.png",
                                        this,
                                        menu_selector(HelloWorld::menuCloseCallback));
    
	pCloseItem->setPosition(ccp(origin.x + visibleSize.width - pCloseItem->getContentSize().width/2 ,
                                origin.y + pCloseItem->getContentSize().height/2));

    // create menu, it's an autorelease object
    CCMenu* pMenu = CCMenu::create(pCloseItem, NULL);
    pMenu->setPosition(CCPointZero);
    this->addChild(pMenu, 1);

    /////////////////////////////
    // 3. add your codes below...
    CCNode* gameScene = SceneReader::sharedSceneReader()->createNodeWithSceneFile("DemoCowboy.json");
    addChild(gameScene);
    
    //Create player
    CCNode* playerNode = gameScene->getChildByTag(10004);
    player = new Player(playerNode);
    
    //Assign callbacks to the buttons
    CCNode* uiNode = gameScene->getChildByTag(10005);
    UILayer* ui = (UILayer*)uiNode->getComponent("GUIComponent")->getNode();
    
    UIButton* btnLeft = (UIButton*)ui->getWidgetByName("LeftButton");
    btnLeft->addTouchEventListener(this, toucheventselector(HelloWorld::onMoveLeft));
    
    UIButton* btnRight = (UIButton*)ui->getWidgetByName("RightButton");
    btnRight->addTouchEventListener(this, toucheventselector(HelloWorld::onMoveRight));
    
    UIButton* btnFire = (UIButton*)ui->getWidgetByName("FireButton");
//    btnFire->addReleaseEvent(this, coco_releaseselector(HelloWorld::onFire));
    btnFire->addTouchEventListener(this, toucheventselector(HelloWorld::onFire));
    
    //Enable update loop
    this->scheduleUpdate();
    
    return true;
}
开发者ID:NSJang,项目名称:CocoStudioSamples,代码行数:60,代码来源:HelloWorldScene.cpp

示例3: removeAll

void ArmatureActionState::removeAll()
{
	do 
	{
		CCNode *pNode = SceneReader::sharedSceneReader()->getNodeByTag(_nTag);
		CC_BREAK_IF(pNode == NULL);
		CCComRender *pRender = (CCComRender*)(pNode->getComponent(_ComName.c_str()));
		CC_BREAK_IF(pRender == NULL);
		CCArmature *pAr = (CCArmature *)(pRender->getNode());
		CC_BREAK_IF(pAr == NULL);
		TriggerMng::sharedTriggerMng()->removeArmatureMovementCallBack(pAr, this, movementEvent_selector(ArmatureActionState::animationEvent));
	} while (0);
}
开发者ID:pipu,项目名称:CocoStudioConnector,代码行数:13,代码来源:cons.cpp

示例4: done

void ArmaturePlayAction::done()
{
	do 
	{
		CCNode *pNode = SceneReader::sharedSceneReader()->getNodeByTag(_nTag);
		CC_BREAK_IF(pNode == NULL);
		CCComRender *pRender = (CCComRender*)(pNode->getComponent(_comName.c_str()));
		CC_BREAK_IF(pRender == NULL);
		CCArmature *pAr = (CCArmature *)(pRender->getNode());
		CC_BREAK_IF(pAr == NULL);
		pAr->getAnimation()->play(_aniname.c_str());
	} while (0);
}
开发者ID:harveyyang,项目名称:DragonBones_Learn,代码行数:13,代码来源:acts.cpp

示例5: init

bool ArmatureActionState::init()
{
	do 
	{
		CCNode *pNode = SceneReader::sharedSceneReader()->getNodeByTag(_nTag);
		CC_BREAK_IF(pNode == NULL);
		CCComRender *pRender = (CCComRender*)(pNode->getComponent(_comName.c_str()));
		CC_BREAK_IF(pRender == NULL);
		CCArmature *pAr = (CCArmature *)(pRender->getNode());
		CC_BREAK_IF(pAr == NULL);
		TriggerMng::getInstance()->addArmatureMovementCallBack(pAr, this, movementEvent_selector(ArmatureActionState::animationEvent));
	} while (0);
	
	return true;
}
开发者ID:harveyyang,项目名称:DragonBones_Learn,代码行数:15,代码来源:cons.cpp


注:本文中的CCNode::getComponent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。