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


C++ CCNode类代码示例

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


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

示例1: update

void CameraZoomTest::update(ccTime dt)
{
	CCNode *sprite;
	CCCamera *cam;
	
	m_z += dt * 100;
	
	sprite = getChildByTag(20);
	cam = sprite->getCamera();
	cam->setEyeXYZ(0, 0, m_z);
	
	sprite = getChildByTag(40);
	cam = sprite->getCamera();
	cam->setEyeXYZ(0, 0, m_z);	
}
开发者ID:issamux,项目名称:WebGame,代码行数:15,代码来源:CocosNodeTest.cpp

示例2: toolbarpos

CCPoint HelloWorld::toolbarpos(int pos)
{
    CCSize WinSize = CCDirector::sharedDirector()->getWinSize();
    CCNode *pNode = (CCNode *)getChildByTag(TAG_TOOLBAR);
    CCSize nodesize = pNode->getContentSize();
    if (pos == POS_IN)
    {
        return ccp(0, WinSize.height-nodesize.height);
        
    }
    else
    {
        return ccp(0, WinSize.height);
    }
}
开发者ID:zlm731,项目名称:ibubblebreaker,代码行数:15,代码来源:HelloWorldScene.cpp

示例3: getChildren

void SchedulerUpdate::removeUpdates(ccTime dt)
{
    CCArray* children = getChildren();
    CCNode* pNode;
    CCObject* pObject;
    CCARRAY_FOREACH(children, pObject)
    {
        pNode = (CCNode*)pObject;

        if (! pNode)
        {
            break;
        }
        pNode->unscheduleAllSelectors();
    }
开发者ID:issamux,项目名称:WebGame,代码行数:15,代码来源:SchedulerTest.cpp

示例4: ShowAbout

void HelloWorld::ShowAbout(bool bEnable)
{
    float fduration = 0.1;
    CCNode *pNode = (CCNode *)getChildByTag(TAG_ABOUT);
    CCActionInterval*  action = NULL;
    if (bEnable)
    {
        action = CCMoveTo::create(fduration, aboutpos(POS_IN));
    }
    else
    {
        action = CCMoveTo::create(fduration, aboutpos(POS_OUT));
    }
    pNode->runAction(action);
}
开发者ID:zlm731,项目名称:ibubblebreaker,代码行数:15,代码来源:HelloWorldScene.cpp

示例5: ccp

void MainMenu::update(float dt)
{
	CCLayer::update(dt);
	CCPoint bgVel = ccp(-1000,0);
	bgSpace->setPosition( ccpAdd(bgSpace->getPosition(), ccpMult(bgVel,dt)) );
	CCArray* bgs = CCArray::create(stars1,stars2,NULL);
	CCObject* obj = NULL;
	CCARRAY_FOREACH(bgs,obj)
	{
		CCNode* node = (CCNode*)obj;
		if(bgSpace->convertToWorldSpace(node->getPosition()).x < -node->getContentSize().width/2)
		{
			bgSpace->incrementOffset(ccp(2*node->getContentSize().width,0),node);
		}
	}
开发者ID:salmanqureshi,项目名称:ecaHack_spacegame,代码行数:15,代码来源:MainMenu.cpp

示例6: 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::sharedTriggerMng()->addArmatureMovementCallBack(pAr, this, movementEvent_selector(ArmatureActionState::animationEvent));
	} while (0);
	
	return true;
}
开发者ID:pipu,项目名称:CocoStudioConnector,代码行数:15,代码来源:cons.cpp

示例7: refresh

void GUISpinView::refresh()
{
    m_mainNode->removeAllChildren();
    m_itemCount = m_delegate->itemsCountForSpinView(this);
    for (int i = 0; i < m_itemCount; i++) {
        CCNode * node = m_delegate->createItemForSpinView(this, i);
        m_mainNode->addChild(node, 0, i);
        node->setAnchorPoint(ccp(0, 0.5f));
        CCPoint p = ccp(0, - m_itemHeight * i);
        if (p.y + m_itemHeight * 0.5f < - m_viewFrame.size.height * 0.5f) {
            p.y = m_itemHeight * (m_itemCount - i);
        }
        node->setPosition(p);
    }
}
开发者ID:rockingdice,项目名称:IceCreamJam,代码行数:15,代码来源:GUISpinView.cpp

示例8: BeginContact

void GamePhysicsContactListener::BeginContact(b2Contact* contact)
{
    // 衝突した双方の物体を取得
    b2Body* bodyA = contact->GetFixtureA()->GetBody();
    b2Body* bodyB = contact->GetFixtureB()->GetBody();

    CCNode* nodeA = (CCNode*)bodyA->GetUserData();
    CCNode* nodeB = (CCNode*)bodyB->GetUserData();

    if( nodeA != NULL && nodeB != NULL ){
        //
        if( nodeA->getTag() == NODE_TAG_BALL ){
            Ball* pBall = (Ball*)nodeA;
            pBall->contactWith(nodeB);
        }
        else if( nodeB->getTag() == NODE_TAG_BALL ){
            Ball* pBall = (Ball*)nodeB;
            pBall->contactWith(nodeA);
        }
    }

#if 0
    // 物体にひもづくSpriteを取得
    PhysicsSprite* spriteA = (PhysicsSprite*)bodyA->GetUserData();
    PhysicsSprite* spriteB = (PhysicsSprite*)bodyB->GetUserData();

    // 地面との衝突は無視する
    if (spriteA->getTag() == Config::kTag_Ground ||
        spriteB->getTag() == Config::kTag_Ground)
    {
        return;
    }

    // 衝突時の加速度を取得
    b2Vec2 velocityA = bodyA->GetLinearVelocity();
    b2Vec2 velocityB = bodyB->GetLinearVelocity();
    CCLOG("[BeginContact] A(%f, %f) B(%f, %f)", velocityA.x, velocityA.y, velocityB.x, velocityB.y);

    // 加速度が一定上の大きさだったら、ぶつかられた方を削除する
    float threshold = 3;
    if (pow(velocityA.x, 2) + pow(velocityA.y, 2) > pow(threshold, 2)) {
        spriteB->setDeleteFlag(true);
    }
    if (pow(velocityB.x, 2) + pow(velocityB.y, 2) > pow(threshold, 2)) {
        spriteA->setDeleteFlag(true);
    }
#endif
}
开发者ID:cocos2dx-team-e,项目名称:breakdown,代码行数:48,代码来源:GamePhysicsContactListener.cpp

示例9: btnPriceCallback

void MultiPriceMatch::btnPriceCallback(Ref* pSender, ui::Widget::TouchEventType eEventType){
	/*if (eEventType != ui::Widget::TouchEventType::BEGAN)*/

	CCNode* node = (CCNode*) pSender;
	int tag = node->getTag();
	bool bSel = false;

	for (int i = 0; i < 3;i++){
		if (tag == (BTN_PRICE_1 + i)) bSel = true;
	}

	if (bSel == false) return;

	cocos2d::log("button's tag is %d",tag);
	auto button = (Button*) _SORT_UINode->getChildByTag(tag);
	AppDelegate *app = (AppDelegate*)Application::getInstance();


	switch (eEventType) {
		case ui::Widget::TouchEventType::BEGAN:
			cocos2d::log("btnPriceCallback Began");
			button->getTouchBeganPosition();
			button->setZOrder(99);
			break;
		case ui::Widget::TouchEventType::ENDED:
			cocos2d::log("btnPriceCallback Ended");
			if (app->getBGMstatus() == BGMusic_flag::ON){
				app->PlayEffect(SOUND_BUTTON_CLICK);

			}	
			button->setZOrder(1);
			MovetoPriceLabel(button);
			break;
		case ui::Widget::TouchEventType::MOVED:
			button->setPosition(button->getTouchMovePosition());
			cocos2d::log("btnPriceCallback Moving");
			break;
		case ui::Widget::TouchEventType::CANCELED:
			cocos2d::log("touch Cancel");
			button->setZOrder(1);
			break;
		default:
			cocos2d::log("touch Default");
			break;
	}
	return;

}
开发者ID:zhuanglm,项目名称:TweeBaaMobileApp,代码行数:48,代码来源:MultiPriceMatch.cpp

示例10: sizeof

bool T27ActionMore::init()
{
	BaseLayer::init();
	CCSize winSize = CCDirector::sharedDirector()->getWinSize();
	
	CCNode* c = CCNode::create();
	_c = c;
	int actionCount = sizeof(_actionName) / sizeof(*_actionName);
	
	for (int i = 0; i < actionCount; i++)
	{
		/*
		CCSprite* bg = CCSprite::create("HelloWorld.png");
		c->addChild(bg);
		bg->setPosition(ccp(winSize.width / 2 + i*winSize.width, winSize.height / 2));
		*/
		CCLayerColor* layer;
		if (i % 2 == 0)
		{
			layer = CCLayerColor::create(ccc4(192, 192, 192, 255), winSize.width, winSize.height);
		}
		else
		{
			layer = CCLayerColor::create(ccc4(128, 128, 128, 255), winSize.width, winSize.height);
		}
		c->addChild(layer);
		layer->setPosition(ccp(i*winSize.width, 0));

		/* 设置Title */
		const char* title = _actionName[i];
		CCLabelTTF* label = CCLabelTTF::create(title, "Arial", 36);
		layer->addChild(label);
		label->setPosition(ccp(winSize.width / 2, winSize.height - 80));
	}

	CCScrollView* view = CCScrollView::create(winSize, c);
	view->setDirection(kCCScrollViewDirectionHorizontal);
	view->setContentSize(CCSize(winSize.width*actionCount, winSize.height));
	addChild(view);

	c->setPositionX((1 - actionCount)*winSize.width);

	// 能触摸
	setTouchEnabled(true);
	setTouchMode(kCCTouchesOneByOne);

	return true;
}
开发者ID:dfwxb,项目名称:cocos_lesson2,代码行数:48,代码来源:T27ActionMore.cpp

示例11: dovisit

void CCTextureWatcher::dovisit()
{
    if (m_bFresh)
    {
        if (m_pTextures)
        {
            m_pTextures->removeAllObjects();
            m_pTextures->release();
        }

        CCTextureCache::sharedTextureCache()->removeUnusedTextures();
        m_pTextures = CCTextureCache::sharedTextureCache()->snapshotTextures();
        m_nTotalPage = (m_pTextures->count() + NUM_PER_PAGE - 1) / NUM_PER_PAGE;
        if (m_pTextures->count() > 0)
        {
            m_bFresh = false;
            m_pList->reload();
        }
    }
    CCNode *pParent = m_pLayer->getParent();
    if (pParent)
    {
        if (pParent != CCDirector::sharedDirector()->getRunningScene())
        {
            pParent->removeChild(m_pLayer, true);
            CCDirector::sharedDirector()->getRunningScene()->addChild(m_pLayer, 9998);
            m_bFresh = true;
        }
    }
    else
    {
        CCDirector::sharedDirector()->getRunningScene()->addChild(m_pLayer, 9998);
    }

    pParent = m_menuHide->getParent();
    if (pParent)
    {
        if (pParent != CCDirector::sharedDirector()->getRunningScene())
        {
            pParent->removeChild(m_menuHide, true);
            CCDirector::sharedDirector()->getRunningScene()->addChild(m_menuHide, 9999);
        }
    }
    else
    {
        CCDirector::sharedDirector()->getRunningScene()->addChild(m_menuHide, 9999);
    }
}
开发者ID:Aaron-Teng,项目名称:AnalyticX,代码行数:48,代码来源:CCTextureWatcher.cpp

示例12: sortAllChildren

void CCNode::visit()
{
    // quick return if not visible. children won't be drawn.
    if (!m_bVisible)
    {
        return;
    }
//    kmGLPushMatrix();

    CCNode* pNode = NULL;
    unsigned int i = 0;

    if(m_Children.size() > 0)
    {
        sortAllChildren();
        // draw children zOrder < 0
		for( ; i < m_Children.size(); i++ )
        {
            pNode = (CCNode*) m_Children[i];

            if ( pNode && pNode->m_nZOrder < 0 ) 
            {
                pNode->visit();
            }
            else
            {
                break;
            }
        }
        // self draw
        this->draw();

        for( ; i < m_Children.size(); i++ )
        {
            pNode = (CCNode*) m_Children[i];
            if (pNode)
            {
                pNode->visit();
            }
        }        
    }
    else
    {
        this->draw();
    }

    //kmGLPopMatrix();
}
开发者ID:yinjimmy,项目名称:opengles-practice,代码行数:48,代码来源:CCNode.cpp

示例13: setScrollNode

	void setScrollNode(CCNode *n){
		if(_scrollNode){ _scrollNode->removeAllChildrenWithCleanup(true);}
		_scrollNode = n;
		if(n){
			addChild(n, 255);
		}
	}
开发者ID:13609594236,项目名称:quick-cocos2d-x,代码行数:7,代码来源:LuaTableView.hpp

示例14: CCBReader

bool CPKDlg::init()
{
    CCLayer::init();
    m_pLeftPhoto = m_pRightPhoto = NULL ;
    m_pDelegate = NULL ;
    
    CCNodeLoaderLibrary* plib = CCNodeLoaderLibrary::sharedCCNodeLoaderLibrary();
    CCBReader* pReader = new CCBReader(plib);
    CCNode* pnode =  pReader->readNodeGraphFromFile("PkDlg.ccbi",this);
    pnode->setPosition(ccpMult(ccpFromSize(getContentSize()), 0.5)) ;
    addChild(pnode) ;
    m_pAnimate = pReader->getAnimationManager() ;
    m_pAnimate->setDelegate(this);
    pReader->autorelease() ;
    return true ;
}
开发者ID:BillXu,项目名称:Project,代码行数:16,代码来源:PKDlg.cpp

示例15: aboutpos

CCPoint HelloWorld::aboutpos(int pos)
{
    CCSize WinSize = CCDirector::sharedDirector()->getWinSize();
    CCNode *pNode = (CCNode *)getChildByTag(TAG_ABOUT);
    CCSize nodesize = pNode->getContentSize();
    if (pos == POS_IN)
    {
        return ccp((WinSize.width-nodesize.width)/2,
                   (WinSize.height-nodesize.height)/2);
        
    }
    else
    {
        return ccp(WinSize.width, (WinSize.height-nodesize.height)/2);
    }
}
开发者ID:zlm731,项目名称:ibubblebreaker,代码行数:16,代码来源:HelloWorldScene.cpp


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