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


C++ CCSprite::addChild方法代码示例

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


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

示例1: _integralPro

/*玩家积分比例*/
CCSprite* GuoZhanLayer::_integralPro(const float green, const float blue) {
    if (green < 0.0f || green > 100.0f) {
        return NULL;
    }
    if (blue < 0.0f || blue > 100.0f) {
        return NULL;
    }
    
    CCSprite* bg = CCSprite::createWithSpriteFrameName("gz_box_small.png");
    bg->setAnchorPoint(CCPointZero);
    CCSprite* bgPre = CCSprite::createWithSpriteFrameName("gz_box_small.png");
    bgPre->setAnchorPoint(CCPointZero);
    bgPre->setPosition(ccp(0.0f, 0.0f));
    bg->addChild(bgPre, 4);
    
    CCSprite* pGreen = CCSprite::createWithSpriteFrameName("gz_s_gre.png");
    pGreen->setAnchorPoint(CCPointZero);
    pGreen->setPosition(ccp(8.0f, 5.0f));
    pGreen->setScaleX(green / 100.0f);
    bg->addChild(pGreen, 3);
    
    CCSprite* pBlue = CCSprite::createWithSpriteFrameName("gz_s_blu.png");
    pBlue->setAnchorPoint(CCPointZero);
    pBlue->setPosition(ccp(8.0f, 5.0f));
    pBlue->setScaleX((green + blue) / 100.0f);
    bg->addChild(pBlue, 2);
    
    CCSprite* pOrange = CCSprite::createWithSpriteFrameName("gz_s_ora.png");
    pOrange->setAnchorPoint(CCPointZero);
    pOrange->setPosition(ccp(8.0f, 5.0f));
    bg->addChild(pOrange, 1);
    
    return bg;
}
开发者ID:qjsy,项目名称:QjGit,代码行数:35,代码来源:GuoZhanLayer.cpp

示例2: initBackgroundAndButton

//初始化背景图片和按钮
void WeaponNotEnoughLayer::initBackgroundAndButton()
{
    CCSprite* background = CCSprite::create("ZF_Shoot_GameScene_weaponNE.png");
    background->setPosition(CCPointMake(this->getContentSize().width/2, this->getContentSize().height/2));
    this->addChild(background);
    
    //添加相应的按钮
    CCScale9Sprite* buttonBackground1 = CCScale9Sprite::create("ZF_Shoot_Button_bg3.png");
    goToMallButton = CCControlButton::create(CCLabelTTF::create("Go shop","Georgia-BoldItalic", 25), buttonBackground1);
    goToMallButton->setPosition(ccp(background->getContentSize().width/4, 100));
    goToMallButton->setAnchorPoint(ccp(0.5, 0.5));
    goToMallButton->setPreferredSize(CCSizeMake(250, 100));
    goToMallButton->addTargetWithActionForControlEvents(this, cccontrol_selector(WeaponNotEnoughLayer::menuCloseCallback), CCControlEventTouchUpInside);
    goToMallButton->setTag(4);
    goToMallButton->setTouchEnabled(true);
    background->addChild(goToMallButton,1);
    
    CCScale9Sprite* buttonBackground2 = CCScale9Sprite::create("ZF_Shoot_Button_bg3.png");
    giveUpButton = CCControlButton::create(CCLabelTTF::create("Never mind","Georgia-BoldItalic", 25), buttonBackground2);
    giveUpButton->setPosition(ccp(background->getContentSize().width*3/4, 100));
    giveUpButton->setAnchorPoint(ccp(0.5, 0.5));
    giveUpButton->setPreferredSize(CCSizeMake(250, 100));
    giveUpButton->addTargetWithActionForControlEvents(this, cccontrol_selector(WeaponNotEnoughLayer::menuCloseCallback), CCControlEventTouchUpInside);
    giveUpButton->setTag(5);
    giveUpButton->setTouchEnabled(true);
    background->addChild(giveUpButton,1);
}
开发者ID:valentman,项目名称:ShootMM-9-4-,代码行数:28,代码来源:WeaponNotEnoughLayer.cpp

示例3: getActive

CCSprite* AIButton::getActive()
{
    CCSprite* sprite = CCSprite::create();
    
    CCSprite* glow = CCSprite::create(IMG("glow_dark.png"));
    //glow->setVisible(false);
    
    sprite->addChild(glow);

    
    cocos2d::CCLabelTTF* rankLabel = createRank(rank);
    cocos2d::CCLabelTTF* nameLabel = createName(name);
    cocos2d::CCLabelTTF* difficultyLabel = createDifficulty(difficulty);
    
    float maxWidth = std::max(std::max(rankLabel->getContentSize().width, nameLabel->getContentSize().width), difficultyLabel->getContentSize().width);
    CCSize contentSize = CCSizeMake(maxWidth, FONT_DIFFICULTY + FONT_NAME + FONT_RANK);
    sprite->setContentSize(contentSize);
    
    glow->setPositionY(contentSize.height/2 + 10);
    rankLabel->setPositionY(contentSize.height/2 + PADDING);
    nameLabel->setPositionY(contentSize.height/2);
    difficultyLabel->setPositionY(contentSize.height/2 -PADDING);
    
    glow->setPositionX(contentSize.width/2);
    rankLabel->setPositionX(contentSize.width/2);
    nameLabel->setPositionX(contentSize.width/2);
    difficultyLabel->setPositionX(contentSize.width/2);
    
    sprite->addChild(rankLabel);
    sprite->addChild(nameLabel);
    sprite->addChild(difficultyLabel);
    
    return sprite;
}
开发者ID:Stals,项目名称:TilesFight,代码行数:34,代码来源:AIButton.cpp

示例4: showBuyCoin

void PrepareLayer::showBuyCoin()
{
	CCSize size = ToolsFun::sharedTools()->getSceneSize();
	CCSprite *bkg = CCSprite::create("DayReward/bkg.png");
	this->addChild(bkg,200,12313154);
	bkg->setPosition(ccp(size.width/2,size.height/2));

	CCSprite *tip1 = CCSprite::create("DayReward/50000coin.png");
	bkg->addChild(tip1);
	tip1->setPosition(ccp(bkg->getContentSize().width/2,bkg->getContentSize().height/2-50*gScaleY));

	CCMenu *menu = CCMenu::create();
	bkg->addChild(menu);
	menu->setPosition(CCPointZero);

	CCSprite *closeNml = CCSprite::create("ui/backUI/close0.png");
	CCSprite *closeSel = CCSprite::create("ui/backUI/close0.png");
	closeSel->setColor(ccc3(80,80,80));

	CCMenuItemSprite *itemClose = CCMenuItemSprite::create(closeNml,closeSel,NULL,this,menu_selector(PrepareLayer::showBuyCoinClose));

	itemClose->setPosition(ccp(bkg->getContentSize().width-40*gScaleX ,bkg->getContentSize().height-60*gScaleY));
	menu->addChild(itemClose);

	CCSprite *spNml = CCSprite::create("DayReward/button.png");
	CCSprite *spSel = CCSprite::create("DayReward/button.png");
	spSel->setColor(ccc3(80,80,80));
	CCMenuItemSprite *itemSp = CCMenuItemSprite::create(spNml,spSel,this,menu_selector(PrepareLayer::showBuyCoinSure));
	itemSp->setPosition(ccp(bkg->getContentSize().width/2 ,35*gScaleY));
	menu->addChild(itemSp);
}
开发者ID:xuqin,项目名称:tgp,代码行数:31,代码来源:PrepareLayer.cpp

示例5: getSpriteByScore

CCSprite* FightInfoLayer::getSpriteByScore(long score,  CCPoint p,int kind)
{
    long temp = score;
    //位数,用于设置横坐标偏移量.
    int digit = 0;
    CCSprite* scroeSprite = CCSprite::create();
    scroeSprite ->setPosition(p);
    
    while (temp>0 || (digit==0 && temp==0)) {
        int remainder = temp % 10;
        temp = temp/10;
        CCSprite *m_Sprite;
        CCRect rc;
        CCString str;
		if(kind==2)
			str.initWithFormat("s_%d.png", remainder);
		else
			str.initWithFormat("f_%d.png", remainder);
        m_Sprite = CCSprite::createWithSpriteFrameName(str.getCString());
        if(kind==2)
			m_Sprite->setPosition(ccp((digit+(digit/3))*(-21), 0));
		else
			 m_Sprite->setPosition(ccp((digit+(digit/3))*(-15), -5));
       
        scroeSprite->addChild(m_Sprite);
        scroeSprite -> setPosition(ccp(scroeSprite->getPositionX() - 6, scroeSprite->getPositionY()));
		if(kind==2)
			m_Sprite->setScale(1.5);
        if (digit%3==0 && digit>0) {
			 CCSprite *comma;
			 if(kind==2)
			 {
				  comma= CCSprite::createWithSpriteFrameName("s_point.png");
				  comma->setPosition(ccp(m_Sprite->getPositionX()+25, -5));
				  scroeSprite->addChild(comma);
				  comma->setScale(1.5);
				  scroeSprite -> setPosition(ccp(scroeSprite->getPositionX() - 10, scroeSprite->getPositionY()));
			 }
			 else
			 {
				 comma= CCSprite::createWithSpriteFrameName("f_point.png");
				 comma->setPosition(ccp(m_Sprite->getPositionX()+19, -10));
				 scroeSprite->addChild(comma);
				 scroeSprite -> setPosition(ccp(scroeSprite->getPositionX() - 6, scroeSprite->getPositionY()));
			 }
        }
        digit++;
    }
    digit--;
    CCArray* array = scroeSprite->getChildren();
    for (int i=0; i<array->count(); i++) {
        CCPoint point = ((CCSprite*)array->objectAtIndex(i))->getPosition();
        point.x += (digit+(digit/3))*15.0;
        ((CCSprite*)array->objectAtIndex(i))->setPosition(point);
    }
    return scroeSprite;
}
开发者ID:anzhongliu,项目名称:SmallGame_Cocos2dx,代码行数:57,代码来源:FightInfoLayer.cpp

示例6: chargeNewDay

void GameLotteryLayer::chargeNewDay()
{
	// disable button according to lastLottery date
	if (!GameUtils::s_myInfo.getHasFreeLottery())
	{
		if (m_bIsFree)
		{
			m_iChoiceDiamond = decideDefaultSelect();
		}
		initBtnGo();
		selectBtnByIndex(m_iChoiceDiamond);
	}
	else
	{
		m_bIsFree = true;
		m_iChoiceDiamond = decideDefaultSelect();

		for (int i=0; i<CIRCLE_CONTENT_COUNT; i++)
		{
			m_ptrLbMutilply[i]->setString((LOCALIZED_STRING("multiplication_sign") 
				+ Utils::itoa(MUlTIPLE_COUNT[m_iChoiceDiamond])).c_str());
		}

		// init the free button
		// Normal Sprite
		CCSprite* ptrBtnFreeNormal = CREATE_SPRITE(this, "btn_go.png", true);
		CCSprite* ptrBtnFreeLight = CREATE_SPRITE(this,"btn_go_light.png",false);
		ptrBtnFreeLight->runAction(CCRepeatForever::create(
			CCSequence::create(CCFadeOut::create(1.0f),CCFadeIn::create(1.0f),NULL)));
		ptrBtnFreeNormal->addChild(ptrBtnFreeLight);
		LayoutUtil::layoutParentCenter(ptrBtnFreeLight, 0, 1);
		CCSprite* ptrBtnTxt = CREATE_SPRITE(this, "btn_txt_free.png", true);
		ptrBtnFreeNormal->addChild(ptrBtnTxt);
		LayoutUtil::layoutParentCenter(ptrBtnTxt);
		// Selected Sprite
		CCSprite* ptrBtnFreeSelected = CREATE_SPRITE(this, "btn_go_down.png", true);
		ptrBtnTxt = CREATE_SPRITE(this, "btn_txt_free_down.png", true);
		ptrBtnFreeSelected->addChild(ptrBtnTxt);
		LayoutUtil::layoutParentCenter(ptrBtnTxt);
		// Disabled Sprite
		CCSprite* ptrBtnFreeDisable = CREATE_SPRITE(this, "btn_go_down.png", true);
		ptrBtnTxt = CREATE_SPRITE(this, "btn_txt_free_down.png", true);
		ptrBtnFreeDisable->addChild(ptrBtnTxt);
		LayoutUtil::layoutParentCenter(ptrBtnTxt);
		// Menu
		m_ptrMenuGo = CCMenuItemSprite::create(ptrBtnFreeNormal, ptrBtnFreeSelected, ptrBtnFreeDisable, 
			this, menu_selector(GameLotteryLayer::onBtnGoCallback));
		m_ptrBg->addChild(m_ptrMenuGo);
		LayoutUtil::layoutCenter(m_ptrMenuGo, m_ptrCircle);
		registerMenuItem(m_ptrMenuGo);

		selectBtnByIndex(m_iChoiceDiamond);
		m_ptrBtnMinus->setEnabled(false);
		m_ptrBtnPlus->setEnabled(false);
	}
}
开发者ID:forappengine,项目名称:texasholdem,代码行数:56,代码来源:GameLotteryLayer.cpp

示例7: init

bool CustomPop::init(){
    if(!CCLayerColor::initWithColor(ccc4(0, 0, 0, 180))){
        return false;
    }
    
    this->setTouchEnabled(true);
    
    
    CCSize size=CCDirector::sharedDirector()->getWinSize();
    this->setContentSize(size);
    
    
    CCSprite *bkg = CCSprite::create("common_pop_bkg.png");
    bkg->setPosition(ccp(size.width/2, size.height/2)); 
    this->addChild(bkg);
    CCSize sz = bkg->getContentSize();
    
    ccColor3B black1 = ccc3(236, 190, 108);
    ccColor3B black = ccc3(27, 18, 6);
    
    CCLabelTTF* title = CCLabelTTF::create("提  示", "hycc.ttf", 28);
    title->setColor(black);
    title->setAnchorPoint(ccp(0.5, 1));
    title->setPosition(ccp(sz.width/2+1, sz.height-23));
    bkg->addChild(title);
    CCLabelTTF* title1 = CCLabelTTF::create("提  示", "hycc.ttf", 28);
    title1->setColor(black1);
    title1->setAnchorPoint(ccp(0.5, 1));
    title1->setPosition(ccp(sz.width/2, sz.height-22));
    bkg->addChild(title1);
    
    
    
    desc = CCLabelTTF::create("", "hycc.ttf", 25,CCSizeMake(400, 0),kCCTextAlignmentCenter);
    
    desc->setColor(black);
//    desc->setAnchorPoint(ccp(0.5, 1));
    desc->setPosition(ccp(sz.width/2, sz.height/2+10));
    bkg->addChild(desc);
    
    
    CCMenuItemImage* bz = CCMenuItemImage::create("common_btn_ok_1.png", "common_btn_ok_2.png", this, menu_selector(CustomPop::close));
//    bz->setAnchorPoint(ccp(0,0));
    
//    bz->setPosition(ccp(sz.width/2, 30));
    bz->setScale(1.3);
    
    btnsMenu = CCMenu::create(bz,NULL);
    btnsMenu->setPosition(ccp(sz.width/2,80));
    
    bkg->addChild(btnsMenu);
    

    return true;
}
开发者ID:GeekMobileShop,项目名称:diabloWorld,代码行数:55,代码来源:CustomPop.cpp

示例8: onEnter

void EffectAdvanceTextLayer::onEnter(void)
{
	CCLayer::onEnter();
	float x,y;
	
	CGSize size = CCDirector::sharedDirector()->getWinSize();
	x = size.width;
	y = size.height;
	
	CCSprite *bg = CCSprite::spriteWithFile("Images/background3.png");
	addChild(bg, 0, kTagBackground);
	bg->setPosition( ccp(x/2,y/2) );
	
	CCSprite* grossini = CCSprite::spriteWithFile("Images/grossinis_sister2.png");
	bg->addChild(grossini, 1, kTagSprite1);
	grossini->setPosition( ccp(x/3.0f,200) );
	CCActionInterval* sc = CCScaleBy::actionWithDuration(2, 5);
	CCActionInterval* sc_back = sc->reverse();
	grossini->runAction( CCRepeatForever::actionWithAction( (CCActionInterval*)(CCSequence::actions(sc, sc_back, NULL)) ) );

	CCSprite* tamara = CCSprite::spriteWithFile("Images/grossinis_sister1.png");
	bg->addChild(tamara, 1, kTagSprite2);
	tamara->setPosition( ccp(2*x/3.0f,200) );
	CCActionInterval* sc2 = CCScaleBy::actionWithDuration(2, 5);
	CCActionInterval* sc2_back = sc2->reverse();
	tamara->runAction( CCRepeatForever::actionWithAction( (CCActionInterval*)(CCSequence::actions(sc2, sc2_back, NULL)) ) );
	
	CCLabelTTF* label = CCLabelTTF::labelWithString(title().c_str(), "Marker Felt", 28);
	
	label->setPosition( ccp(x/2,y-80) );
	addChild(label);
	label->setTag( kTagLabel );

	std::string strSubtitle = subtitle();
	if( ! strSubtitle.empty() ) 
	{
		CCLabelTTF* l = CCLabelTTF::labelWithString(strSubtitle.c_str(), "Thonburi", 16);
		addChild(l, 101);
		l->setPosition( ccp(size.width/2, size.height-80) );
	}	

	CCMenuItemImage *item1 = CCMenuItemImage::itemFromNormalImage("Images/b1.png", "Images/b2.png", this, menu_selector(EffectAdvanceTextLayer::backCallback) );
	CCMenuItemImage *item2 = CCMenuItemImage::itemFromNormalImage("Images/r1.png","Images/r2.png", this, menu_selector(EffectAdvanceTextLayer::restartCallback) );
	CCMenuItemImage *item3 = CCMenuItemImage::itemFromNormalImage("Images/f1.png", "Images/f2.png", this, menu_selector(EffectAdvanceTextLayer::nextCallback) );

	CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL);

	menu->setPosition( CGPointZero );
	item1->setPosition( ccp( size.width/2 - 100,30) );
	item2->setPosition( ccp( size.width/2, 30) );
	item3->setPosition( ccp( size.width/2 + 100,30) );
	
	addChild(menu, 1);	
}
开发者ID:geniikw,项目名称:myFirst2DGame,代码行数:54,代码来源:EffectsAdvancedTest.cpp

示例9: InitDialog

bool HSGoldInadequateDialog::InitDialog()
{
	CCSprite* pBackground = CCSprite::create("Image/SelectChannel/goumaijinbidikuang.png");
	pBackground->setPosition(ccp(307,480));
	this->addChild(pBackground);


	CCSprite* pGoldFrame = CCSprite::create("Image/SelectChannel/Mingziditu.png");
	pGoldFrame->setPosition(ccp(236,202));
	pBackground->addChild(pGoldFrame);

	CCSprite* pMoneyFrame = CCSprite::create("Image/SelectChannel/Mingziditu.png");
	pMoneyFrame->setPosition(ccp(520,202));
	pBackground->addChild(pMoneyFrame);

	const message::PropInfoData* pPropInfodata = HS_GAME_CACHE()->GetPropInfoData();

	for (int i =0;i<pPropInfodata->buygoldlist_size();++i)
	{
		int temp = pPropInfodata->buygoldlist(i).gold_number();
		if ((int)m_buyGold.gold_number() < temp)
		{
			m_buyGold = pPropInfodata->buygoldlist(i);
		}
		if (temp > HS_GAME_CACHE()->GetGold())
		{
			m_buyGold = pPropInfodata->buygoldlist(i);
			break;
		}
	}


	CCLabelTTF* pGoldTTF = CCLabelTTF::create(CCString::createWithFormat("%d",m_buyGold.gold_number())->getCString(),HS_FONT_HuaKang,36.f);
	pGoldTTF->setAnchorPoint(HS_ANCHOR_L_CENTER);
	pGoldTTF->setPosition(ccp(0,pGoldTTF->getContentSize().height - pGoldTTF->getFontSize() / 2.f));
	pGoldFrame->addChild(pGoldTTF);

	CCLabelTTF* pMoneyTTF = CCLabelTTF::create(CCString::createWithFormat("%d",m_buyGold.money())->getCString(),HS_FONT_HuaKang,36.f);
	pMoneyTTF->setAnchorPoint(HS_ANCHOR_L_CENTER);
	pMoneyTTF->setPosition(ccp(0,pMoneyTTF->getContentSize().height - pMoneyTTF->getFontSize() / 2.f));
	pMoneyFrame->addChild(pMoneyTTF);

	CCMenuItem* pGoRoomItem = CCMenuItemImage::create("Image/SelectChannel/dibeilvchang_01.png","Image/SelectChannel/dibeilvchang_02.png",this,menu_selector(HSGoldInadequateDialog::Call_GoRoom));
	pGoRoomItem->setPosition(ccp(169,322));
	this->PushMenu(pGoRoomItem);

	CCMenuItem* pBuyItem = CCMenuItemImage::create("Image/SelectChannel/goumai_01.png","Image/SelectChannel/goumai_02.png",this,menu_selector(HSGoldInadequateDialog::Call_Buy));
	pBuyItem->setPosition(ccp(456,322));
	this->PushMenu(pBuyItem);


	return true;
}
开发者ID:wanggan768q,项目名称:GameWork,代码行数:53,代码来源:HSGoldInadequateDialog.cpp

示例10: init

bool PauseLayer::init(){

	CCSize size = CCDirector::sharedDirector()->getWinSize();

	do {
		CCSprite* PauseDialogBox = CCSprite::create("PauseDialogBox.png");
		CC_BREAK_IF(! PauseDialogBox);
		PauseDialogBox->setPosition(ccp(size.width/2, size.height/2));
		this->addChild(PauseDialogBox,3);

		// Label shows "Game Paused"
		CCLabelTTF* PauseLabel = CCLabelTTF::create("Paused", "Calibri", size.height/8);
		PauseLabel->setPosition(ccp(0.5*PauseDialogBox->getContentSize().width, 0.75*PauseDialogBox->getContentSize().height));
		PauseLabel->setColor(ccc3(185,218,22));
		PauseDialogBox->addChild(PauseLabel);

		// A resume button as a menu item
		CCMenuItemImage *pPauseBox_ResumeItem = CCMenuItemImage::create(
			"PauseBox_ResumeButton.png",
			"PauseBox_ResumeButtonSelected.png",
			this,
			menu_selector(PauseLayer::menuResumeCallback));
		CC_BREAK_IF(! pPauseBox_ResumeItem);

		pPauseBox_ResumeItem->setPosition(ccp(0.3*PauseDialogBox->getContentSize().width, 0.3*PauseDialogBox->getContentSize().height));

		CCMenu *pPauseBox_Resume = CCMenu::create(pPauseBox_ResumeItem, NULL);
		pPauseBox_Resume->setPosition(CCPointZero);
		CC_BREAK_IF(! pPauseBox_Resume);

		PauseDialogBox->addChild(pPauseBox_Resume);

		// A Back button as a menu item
		CCMenuItemImage *pPauseBox_MainMenuItem = CCMenuItemImage::create(
			"MainMenuButton.png",
			"MainMenuButtonSelected.png",
			this,
			menu_selector(PauseLayer::menuMainMenuCallback));
		CC_BREAK_IF(! pPauseBox_MainMenuItem);

		pPauseBox_MainMenuItem->setPosition(ccp(0.7*PauseDialogBox->getContentSize().width, 0.3*PauseDialogBox->getContentSize().height));

		CCMenu *pPauseBox_MainMenu = CCMenu::create(pPauseBox_MainMenuItem, NULL);
		pPauseBox_MainMenu->setPosition(CCPointZero);
		CC_BREAK_IF(! pPauseBox_MainMenu);

		PauseDialogBox->addChild(pPauseBox_MainMenu);

	} while (0);

	return true;
}
开发者ID:vinova-summer-school,项目名称:vss2013-03_ghost-house,代码行数:52,代码来源:PauseLayer.cpp

示例11: CCPointMake

CameraOrbitTest::CameraOrbitTest()
{
	CCSize s = CCDirector::sharedDirector()->getWinSize();

	CCSprite *p = CCSprite::spriteWithFile(s_back3);
	addChild( p, 0);
	p->setPosition( CCPointMake(s.width/2, s.height/2) );
	p->setOpacity( 128 );
	
	CCSprite* sprite;
	CCOrbitCamera* orbit;
	CCCamera* cam;
	CCSize ss;

	// LEFT
    s = p->getContentSize();
	sprite = CCSprite::spriteWithFile(s_pPathGrossini);
	sprite->setScale(0.5f);
	p->addChild(sprite, 0);		
	sprite->setPosition( CCPointMake(s.width/4*1, s.height/2) );
	cam = sprite->getCamera();
	orbit = CCOrbitCamera::actionWithDuration(2, 1, 0, 0, 360, 0, 0);
	sprite->runAction( CCRepeatForever::actionWithAction( orbit ) );
	
	// CENTER
	sprite = CCSprite::spriteWithFile(s_pPathGrossini);
	sprite->setScale( 1.0f );
	p->addChild(sprite, 0);		
	sprite->setPosition( CCPointMake(s.width/4*2, s.height/2) );
	orbit = CCOrbitCamera::actionWithDuration(2, 1, 0, 0, 360, 45, 0);
	sprite->runAction( CCRepeatForever::actionWithAction( orbit ) );
	
	
	// RIGHT
	sprite = CCSprite::spriteWithFile(s_pPathGrossini);
	sprite->setScale( 2.0f );
	p->addChild(sprite, 0);		
	sprite->setPosition( CCPointMake(s.width/4*3, s.height/2) );
	ss = sprite->getContentSize();		
	orbit = CCOrbitCamera::actionWithDuration(2, 1, 0, 0, 360, 90, -45),
	sprite->runAction( CCRepeatForever::actionWithAction(orbit) );
			
	
	// PARENT
	orbit = CCOrbitCamera::actionWithDuration(10, 1, 0, 0, 360, 0, 90);
	p->runAction( CCRepeatForever::actionWithAction( orbit ) );

	setScale( 1 );
}
开发者ID:issamux,项目名称:WebGame,代码行数:49,代码来源:CocosNodeTest.cpp

示例12: onEnter

void EffectAdvanceTextLayer::onEnter(void)
{
    CCLayer::onEnter();
    
    CCSprite *bg = CCSprite::create("Images/background3.png");
    addChild(bg, 0, kTagBackground);
    bg->setPosition( VisibleRect::center() );
    
    CCSprite* grossini = CCSprite::create("Images/grossinis_sister2.png");
    bg->addChild(grossini, 1, kTagSprite1);
    grossini->setPosition( ccp(VisibleRect::left().x+VisibleRect::getVisibleRect().size.width/3.0f, VisibleRect::bottom().y+ 200) );
    CCActionInterval* sc = CCScaleBy::create(2, 5);
    CCActionInterval* sc_back = sc->reverse();
    grossini->runAction( CCRepeatForever::create( (CCActionInterval*)(CCSequence::create(sc, sc_back, NULL)) ) );

    CCSprite* tamara = CCSprite::create("Images/grossinis_sister1.png");
    bg->addChild(tamara, 1, kTagSprite2);
    tamara->setPosition( ccp(VisibleRect::left().x+2*VisibleRect::getVisibleRect().size.width/3.0f,VisibleRect::bottom().y+200) );
    CCActionInterval* sc2 = CCScaleBy::create(2, 5);
    CCActionInterval* sc2_back = sc2->reverse();
    tamara->runAction( CCRepeatForever::create( (CCActionInterval*)(CCSequence::create(sc2, sc2_back, NULL)) ) );
    
    CCLabelTTF* label = CCLabelTTF::create(title().c_str(), "Marker Felt", 28);
    
    label->setPosition( ccp(VisibleRect::center().x,VisibleRect::top().y-80) );
    addChild(label);
    label->setTag( kTagLabel );

    std::string strSubtitle = subtitle();
    if( ! strSubtitle.empty() ) 
    {
        CCLabelTTF* l = CCLabelTTF::create(strSubtitle.c_str(), "Thonburi", 16);
        addChild(l, 101);
        l->setPosition( ccp(VisibleRect::center().x,VisibleRect::top().y-80) );
    }    

    CCMenuItemImage *item1 = CCMenuItemImage::create("Images/b1.png", "Images/b2.png", this, menu_selector(EffectAdvanceTextLayer::backCallback) );
    CCMenuItemImage *item2 = CCMenuItemImage::create("Images/r1.png","Images/r2.png", this, menu_selector(EffectAdvanceTextLayer::restartCallback) );
    CCMenuItemImage *item3 = CCMenuItemImage::create("Images/f1.png", "Images/f2.png", this, menu_selector(EffectAdvanceTextLayer::nextCallback) );

    CCMenu *menu = CCMenu::create(item1, item2, item3, NULL);

    menu->setPosition(CCPointZero);
    item1->setPosition(ccp(VisibleRect::center().x - item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
    item2->setPosition(ccp(VisibleRect::center().x, VisibleRect::bottom().y+item2->getContentSize().height/2));
    item3->setPosition(ccp(VisibleRect::center().x + item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
    
    addChild(menu, 1);    
}
开发者ID:ZheNanXu,项目名称:Billiard-2D,代码行数:49,代码来源:EffectsAdvancedTest.cpp

示例13: createPerson

CCSprite* CreditsScreen::createPerson(const std::string& name, const std::string& twitterLink, const std::string& fbLink)
{
    const float iconSize = 32;
    
    bool useTwitter = !twitterLink.empty();
    bool useFB = !fbLink.empty();
    
    CCSprite* person = CCSprite::create();
    
    CCLabelTTF* nameLabel = CCLabelTTF::create(name.c_str(), default_font.c_str(), FONT_SIZE_PERSON);
    nameLabel->setPositionX(nameLabel->getContentSize().width / 2);
    
    float totalWidth = nameLabel->getContentSize().width;
    float totalHeight = MAX(nameLabel->getContentSize().height, iconSize);
    
    if(useTwitter || useFB){
        totalWidth += PADDING_AFTER_NAME;
    }
    
    if(useTwitter){
        totalWidth += iconSize + PADDING_PERSON;
        
        urls.push_back(twitterLink);
        Button* twitterButton = ButtonFactory::imageButton(TWITTER_ICON_INACTIVE, TWITTER_ICON_PRESSED, new Handler(this, callfuncD_selector(CreditsScreen::openURL), (void*)(urls.size() - 1)), BUTTON_PRIORITY);
        twitterButton->setPositionX(nameLabel->getPositionX() + totalWidth - iconSize - nameLabel->getContentSize().width/2);
        twitterButton->setPositionY(totalHeight / 2);

        person->addChild(twitterButton);
    }
    
    if(useFB) {
        totalWidth += iconSize + PADDING_PERSON;

        urls.push_back(fbLink);
        Button* fbButton = ButtonFactory::imageButton(FB_ICON_INACTIVE, FB_ICON_PRESSED, new Handler(this, callfuncD_selector(CreditsScreen::openURL), (void*)(urls.size() - 1)), BUTTON_PRIORITY);
        
        fbButton->setPositionX(nameLabel->getPositionX() + totalWidth - iconSize - nameLabel->getContentSize().width/2);
        fbButton->setPositionY(totalHeight / 2);
        
        person->addChild(fbButton);
    }
    
    person->setContentSize(CCSizeMake(totalWidth, totalHeight));
    nameLabel->setPositionY(totalHeight / 2);
    person->addChild(nameLabel);
    
    return person;
}
开发者ID:Stals,项目名称:TilesFight,代码行数:48,代码来源:CreditsScreen.cpp

示例14: sprintf

 CCARRAY_FOREACH(antiArray, obj) {
     MyBattleBuilding* building = dynamic_cast<MyBattleBuilding*>(obj);
     
     float angle = Mathlib::getAngle(zhihuisuo->getPositionByTiled(), building->getPositionByTiled());
     int dir = (((int)(angle*180/3.141592654+22.5)+360)%360)/45 ;
     AoeDefendState* state =  dynamic_cast<AoeDefendState*>(building->fsm->getState(DefendStateTag));
     
     if (dir == 0) {
         sprintf(str, "antiTankfld (0).png");
     } else if (dir == 1) {
         sprintf(str, "antiTankfd (0).png");
     } else if (dir == 2) {
         sprintf(str, "antiTankfrd (0).png");
     } else if (dir == 3) {
         sprintf(str, "antiTankfr (0).png");
     } else if (dir == 4) {
         sprintf(str, "antiTankfru (0).png");
     } else if (dir == 5) {
         sprintf(str, "antiTankfu (0).png");
     } else if (dir == 6) {
         sprintf(str, "antiTankflu (0).png");
     } else if (dir == 7) {
         sprintf(str, "antiTankfl (0).png");
     }
     
     CCSprite* byItem =CCSprite::createWithSpriteFrameName(str);
     byItem->setAnchorPoint(ccp(0.5,0.5));
     CCSprite* zhendi = CCSprite::createWithSpriteFrameName("position.png");
     zhendi->setPosition(ccp(byItem->getContentSize().width/2,byItem->getContentSize().height/2));
     byItem->addChild(zhendi,-1);
     state->setItem(byItem);
     
 }
开发者ID:itita,项目名称:2-z-q-x-,代码行数:33,代码来源:NewbieMovieScene.cpp

示例15: onFlipFinished

void GuessSpellItem::onFlipFinished(CCNode *node,void *data)
{
    CardSprite *card = (CardSprite*)node;
    card->setVertexZ(0);
    if(m_won) {
        const std::vector<std::string> &props = ResourceMgr::getInstance()->propsNames();
        std::string anim,first;
        anim = props[m_selectNum];
        anim += "exec";
        first = anim;
        ResourceMgr::getInstance()->getFrameSpriteFirstFrame(first);
        m_anim = new BasAnimSprite(anim,first);
        if(m_anim->isLoaded()) {
            m_anim->setAnimFinishCB(this,callfuncND_selector(GuessSpellItem::onAnimFinished));
            CCSprite *front = card->frontSprite();
            CCSize size = front->getContentSize();
            front->addChild(m_anim);
            m_anim->setAnchorPoint(ccp(0.5,0.5));
            m_anim->setPosition(ccp(size.width/2,size.height/2));
            m_anim->playInLoop(1);
            CCSize animSize = m_anim->getContentSize();
            m_anim->setScale(size.width / animSize.width);
            m_won = false;
        } else {
            delete m_anim;
            m_anim = 0;
        }
    }
}
开发者ID:jonesgithub,项目名称:DirectFire-android,代码行数:29,代码来源:guessspellitem.cpp


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