本文整理汇总了C++中CCNode::addChild方法的典型用法代码示例。如果您正苦于以下问题:C++ CCNode::addChild方法的具体用法?C++ CCNode::addChild怎么用?C++ CCNode::addChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCNode
的用法示例。
在下文中一共展示了CCNode::addChild方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addSkillExp
//----------------------------------------------------------
//
//
void PetDatablock::addSkillExp( int skillExp, CCPoint pos )
{
petskillexppond += skillExp;
if( petskillexppond >= MAX_SKILL_EXP )
{
petskillexppond = MAX_SKILL_EXP;
}
CCNode *pNode = CCNode::node();
string path = GetGameImagesPath();
path = path + "upskillexp.png";
CCSprite* pSpriteBG = CCSprite::spriteWithFile( path.c_str() );
pSpriteBG->setPosition( pos );
pNode->addChild( pSpriteBG, 100 );
char buffer[128];
sprintf( buffer,"+%d", skillExp );
CCLabelTTF *pLabelTTF = CCLabelTTF::labelWithString( buffer, kFontSystem[FONT_MED].fontName, kFontSystem[FONT_MED].fontSize );
pLabelTTF->setPosition( ccp( pSpriteBG->getPosition().x + pSpriteBG->getTextureRect().size.width / 2, pSpriteBG->getPosition().y ) );
pLabelTTF->setAnchorPoint( ccp( 0,0.5 ) );
pNode->addChild( pLabelTTF,100 );
CCDirector::sharedDirector()->getRunningScene()->addChild( pNode, 100 );
pSpriteBG->runAction(CCFadeOut::actionWithDuration(3.0));
pLabelTTF->runAction(CCFadeOut::actionWithDuration(3.0));
CCMoveBy *pMoveBy = CCMoveBy::actionWithDuration( 2.0, ccp( 0, CCDirector::sharedDirector()->getWinSize().height / 3 ) );
pNode->runAction( pMoveBy );
}
示例2: initData
void HudUILayer::initData()
{
// 英雄和敌人的状态显示
m_pRoleState = CharacterState::createRole();
this->addChild(m_pRoleState);
m_pRobotState = CharacterState::createRobot();
this->addChild(m_pRobotState);
CCNode* joyPad = CCNode::create();
// 英雄控制器
m_roleJoyPad = RoleJoyPad::create();
m_roleJoyPad->setPosition(ccpSub(m_ptCenter, ccp( 288, 404)));
joyPad->addChild(m_roleJoyPad);
// 敌人控制器
m_enemyJoyPad = EnemyJoyPad::create();
m_enemyJoyPad->setPosition(ccpAdd(m_ptCenter, ccp(132, 290)));
joyPad->addChild(m_enemyJoyPad);
// 结算UI
m_gameOver = GameOver::create();
this->addChild(m_gameOver, 4);
this->addChild(joyPad);
}
示例3: addPetMoney
//-----------------------------------------------------------
//
//
void PetDatablock::addPetMoney( int data, CCPoint pos )
{
petmoney += data;
CCNode *pNode = CCNode::node();
string path = GetGameImagesPath();
path = path + "upmoney.png";
CCSprite* pSpriteBG = CCSprite::spriteWithFile( path.c_str() );
pSpriteBG->setPosition( pos );
pNode->addChild( pSpriteBG, 100 );
char buffer[128];
sprintf( buffer,"+%d", data );
CCLabelTTF *pLabelTTF = CCLabelTTF::labelWithString( buffer, kFontSystem[FONT_MED].fontName, kFontSystem[FONT_MED].fontSize );
pLabelTTF->setPosition( ccp( pSpriteBG->getPosition().x + pSpriteBG->getTextureRect().size.width / 2, pSpriteBG->getPosition().y ) );
pLabelTTF->setAnchorPoint( ccp( 0,0.5 ) );
pNode->addChild( pLabelTTF,100 );
CCDirector::sharedDirector()->getRunningScene()->addChild( pNode, 100 );
pSpriteBG->runAction(CCFadeOut::actionWithDuration(3.0));
pLabelTTF->runAction(CCFadeOut::actionWithDuration(3.0));
CCMoveBy *pMoveBy = CCMoveBy::actionWithDuration( 2.0, ccp( 0, CCDirector::sharedDirector()->getWinSize().height / 3 ) );
pNode->runAction( pMoveBy );
if( CCUserDefault::sharedUserDefault()->getBoolForKey( "sound" ) )
{
CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("data/audio/money.mp3", false);
}
}
示例4: addPlayerMoney
//--------------------------------------------------------------
//
//
void PetDatablock::addPlayerMoney( int data, CCPoint pos )
{
playershoppingmallmoney += data;
CCNode *pNode = CCNode::node();
string path = GetGameImagesPath();
path = path + "upPlayerMoney.png";
CCSprite* pSpriteBG = CCSprite::spriteWithFile( path.c_str() );
pSpriteBG->setPosition( pos );
pNode->addChild( pSpriteBG, 100 );
char buffer[128];
sprintf( buffer,"+%d", data );
CCLabelTTF *pLabelTTF = CCLabelTTF::labelWithString( buffer, kFontSystem[FONT_MED].fontName, kFontSystem[FONT_MED].fontSize );
pLabelTTF->setPosition( ccp( pSpriteBG->getPosition().x + pSpriteBG->getTextureRect().size.width / 2, pSpriteBG->getPosition().y ) );
pLabelTTF->setAnchorPoint( ccp( 0,0.5 ) );
pNode->addChild( pLabelTTF,100 );
CCDirector::sharedDirector()->getRunningScene()->addChild( pNode, 100 );
pSpriteBG->runAction(CCFadeOut::actionWithDuration(3.0));
pLabelTTF->runAction(CCFadeOut::actionWithDuration(3.0));
CCMoveBy *pMoveBy = CCMoveBy::actionWithDuration( 2.0, ccp( 0, CCDirector::sharedDirector()->getWinSize().height / 3 ) );
pNode->runAction( pMoveBy );
}
示例5: updateShowArea
void CHandBookPanel::updateShowArea()
{
CCNode* pLayer = m_ui;
if(m_pHeroLayer) m_pHeroLayer->setVisible(false);
if(m_pMonsterLayer) m_pMonsterLayer->setVisible(false);
if(m_pEquipLayer)m_pEquipLayer->setVisible(false);
switch (m_iType)
{
case HandBookTabHero:
{
if(!m_pHeroLayer)
{
m_pHeroLayer = CHandBookHeroLayer::create();
m_pHeroLayer->setTouchPriority(LayerManager::instance()->getPriority()-1);
pLayer->addChild(m_pHeroLayer);
m_pHeroLayer->setPosition(pLayer->convertToNodeSpace(m_pHeroLayer->getPosition()));
AskForHandBook(m_iType);
}
else
{
m_pHeroLayer->setVisible(true);
}
}
break;
case HandBookTabMonster:
{
if(!m_pMonsterLayer)
{
m_pMonsterLayer = CHandBookMonsterLayer::create();
m_pMonsterLayer->setTouchPriority(LayerManager::instance()->getPriority()-1);
pLayer->addChild(m_pMonsterLayer);
m_pMonsterLayer->setPosition(pLayer->convertToNodeSpace(m_pMonsterLayer->getPosition()));
AskForHandBook(m_iType);
}
m_pMonsterLayer->setVisible(true);
}
break;
case HandBookTabEquip:
{
if(!m_pEquipLayer)
{
m_pEquipLayer = CHandBookEquipLayer::create();
m_pEquipLayer->setTouchPriority(LayerManager::instance()->getPriority()-1);
pLayer->addChild(m_pEquipLayer);
m_pEquipLayer->setPosition(pLayer->convertToNodeSpace(m_pEquipLayer->getPosition()));
AskForHandBook(m_iType);
}
m_pEquipLayer->setVisible(true);
}
break;
case HandBookTabMax:
break;
default:
break;
}
}
示例6: getAction
TextLayer::TextLayer(void)
{
initWithColor( ccc4(32,32,32,255) );
float x,y;
CGSize size = CCDirector::sharedDirector()->getWinSize();
x = size.width;
y = size.height;
CCNode* node = CCNode::node();
CCActionInterval* effect = getAction();
node->runAction(effect)
;
addChild(node, 0, kTagBackground);
CCSprite *bg = CCSprite::spriteWithFile(s_back3);
node->addChild(bg, 0);
bg->setAnchorPoint( CGPointZero );
CCSprite* grossini = CCSprite::spriteWithFile(s_pPathSister2);
node->addChild(grossini, 1);
grossini->setPosition( CGPointMake(x/3,y/2) );
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(s_pPathSister1);
node->addChild(tamara, 1);
tamara->setPosition( CGPointMake(2*x/3,y/2) );
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((effectsList[actionIdx]).c_str(), "Marker Felt", 32);
label->setPosition( CGPointMake(x/2,y-80) );
addChild(label);
label->setTag( kTagLabel );
CCMenuItemImage *item1 = CCMenuItemImage::itemFromNormalImage(s_pPathB1, s_pPathB2, this, menu_selector(TextLayer::backCallback) );
CCMenuItemImage *item2 = CCMenuItemImage::itemFromNormalImage(s_pPathR1, s_pPathR2, this, menu_selector(TextLayer::restartCallback) );
CCMenuItemImage *item3 = CCMenuItemImage::itemFromNormalImage(s_pPathF1, s_pPathF2, this, menu_selector(TextLayer::nextCallback) );
CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL);
menu->setPosition( CGPointZero );
item1->setPosition( CGPointMake( size.width/2 - 100,30) );
item2->setPosition( CGPointMake( size.width/2, 30) );
item3->setPosition( CGPointMake( size.width/2 + 100,30) );
addChild(menu, 1);
schedule( schedule_selector(TextLayer::checkAnim) );
}
示例7: LoadParkingId
void ParkingViewScene::LoadParkingId()
{
CCNode* node = this->getChildByTag(250);
char s[20] ;
sprintf(s, "%d.png", this->wayPointID);
CCSprite *sprtEstabelecimento = CCSprite::create(s);
if( sprtEstabelecimento == 0)
sprtEstabelecimento = CCSprite::create("ModeloWayPointFoto.png");
sprtEstabelecimento->setAnchorPoint(ccp(0,0));
sprtEstabelecimento->setPosition(ccp(0,217));
node->addChild(sprtEstabelecimento);
//Waypoints do estacionamentos sao referidos como retirada de veiculos, de acordo
//com o id, aqui o texto é alterado.
switch(wayPointID)
{
case 19:
insertLabel(ccc3(72, 72, 72), ccp(20, 180), true, "Bloco A1", node, 16);
break;
case 51:
insertLabel(ccc3(72, 72, 72), ccp(20, 180), true, "Bloco B", node, 16);
break;
case 89:
insertLabel(ccc3(72, 72, 72), ccp(20, 180), true, "Bloco D/E", node, 16);
break;
}
//Cria um label ( aqui vira descricao do estacionamento)
insertLabel(ccc3(72, 72, 72), ccp(20, 160), false, "Auditorio Moise Safra", node, 12);
CCSprite *btnHorarioSelected = CCSprite::create("btnShowRotaEstacionmanto.png"); // botao pressionado
CCSprite *btnHorarioUnSelected = CCSprite::create("btnShowRotaEstacionmanto.png");//botao nao pressionado
CCMenuItemSprite *itembtnHorario = CCMenuItemSprite::create(btnHorarioSelected, btnHorarioUnSelected, btnHorarioSelected, menu_selector(ParkingViewScene::btnRotaCallBack));
itembtnHorario->setAnchorPoint(ccp(0, 0));
itembtnHorario->setPosition(ccp(40, 0));
CCMenu* options = CCMenu::create();
options->addChild(itembtnHorario,0,wayPointID);
options->setPosition(ccp(230, 171) );
node->addChild(options);
CCSprite *sprtFundoEstabelecimento = CCSprite::create("SombraMagica.png");
sprtFundoEstabelecimento->setAnchorPoint(ccp(0,0));
sprtFundoEstabelecimento->setPosition(ccp(72, 200));
node->addChild(sprtFundoEstabelecimento);
}
示例8: createRadioButton
CCMenuItemSprite* BetControler::createRadioButton(const char* label,const char* normal,const char* selected,const char* disabled/*=NULL*/,const char* disabledLabel/*=NULL*/){
if(normal==NULL){
return NULL;
}
CCNode* node = CCNode::create();
CCSprite* sprite = ResourceManager::getInstance()->createSprite(this, normal);
CCSprite* labelSprite = ResourceManager::getInstance()->createSprite(this, label);
node->setContentSize(CCSizeMake(90+labelSprite->getContentSize().width, 110));
node->addChild(sprite);
node->addChild(labelSprite);
LayoutUtil::layoutParentLeft(sprite);
LayoutUtil::layoutParentLeft(labelSprite,90);
CCNode* downNode=node;
if(selected!=NULL){
downNode = CCNode::create();
CCSprite* downSprite = ResourceManager::getInstance()->createSprite(this, selected);
CCSprite* labeldownSprite = ResourceManager::getInstance()->createSprite(this, label);
downNode->setContentSize(CCSizeMake(90+labeldownSprite->getContentSize().width, 110));
downNode->addChild(downSprite);
downNode->addChild(labeldownSprite);
LayoutUtil::layoutParentLeft(downSprite);
LayoutUtil::layoutParentLeft(labeldownSprite,90);
}
CCNode* disabledNode=NULL;
if(disabled!=NULL){
disabledNode = CCNode::create();
disabledNode->setContentSize(CCSizeMake(104, 104));
CCSprite* disabledSprite = ResourceManager::getInstance()->createSprite(this, disabled);
CCSprite* labelDisabledSprite = ResourceManager::getInstance()->createSprite(this, disabledLabel);
disabledNode->addChild(disabledSprite);
disabledNode->addChild(labelDisabledSprite);
LayoutUtil::layoutParentLeft(disabledSprite);
LayoutUtil::layoutParentLeft(labelDisabledSprite,90);
}
CCMenuItemSprite* button=NULL;
if(disabledNode==NULL){
button=CCMenuItemSprite::create(node,downNode, this, menu_selector(BetControler::radioButtonsCallback));
}else{
button=CCMenuItemSprite::create(node,downNode,disabledNode, this, menu_selector(BetControler::radioButtonsCallback));
}
registerMenuItem(button);
this->addChild(button);
//button->unselected();
button->setVisible(false);
return button;
}
示例9: initWithColor
TextLayer::TextLayer(void)
{
initWithColor( ccc4(32,128,32,255) );
CCNode* node = CCNode::create();
CCActionInterval* effect = getAction();
node->runAction(effect);
addChild(node, 0, kTagBackground);
CCSprite *bg = CCSprite::create(s_back3);
node->addChild(bg, 0);
// bg->setAnchorPoint( CCPointZero );
bg->setPosition(VisibleRect::center());
CCSprite* grossini = CCSprite::create(s_pPathSister2);
node->addChild(grossini, 1);
grossini->setPosition( ccp(VisibleRect::left().x+VisibleRect::getVisibleRect().size.width/3,VisibleRect::center().y) );
CCActionInterval* sc = CCScaleBy::create(2, 5);
CCActionInterval* sc_back = sc->reverse();
grossini->runAction( CCRepeatForever::create(CCSequence::create(sc, sc_back, NULL) ) );
CCSprite* tamara = CCSprite::create(s_pPathSister1);
node->addChild(tamara, 1);
tamara->setPosition( ccp(VisibleRect::left().x+2*VisibleRect::getVisibleRect().size.width/3,VisibleRect::center().y) );
CCActionInterval* sc2 = CCScaleBy::create(2, 5);
CCActionInterval* sc2_back = sc2->reverse();
tamara->runAction( CCRepeatForever::create(CCSequence::create(sc2, sc2_back, NULL)) );
CCLabelTTF* label = CCLabelTTF::create((effectsList[actionIdx]).c_str(), "Marker Felt", 32);
label->setPosition( ccp(VisibleRect::center().x,VisibleRect::top().y-80) );
addChild(label);
label->setTag( kTagLabel );
CCMenuItemImage *item1 = CCMenuItemImage::create(s_pPathB1, s_pPathB2, this, menu_selector(TextLayer::backCallback) );
CCMenuItemImage *item2 = CCMenuItemImage::create(s_pPathR1, s_pPathR2, this, menu_selector(TextLayer::restartCallback) );
CCMenuItemImage *item3 = CCMenuItemImage::create(s_pPathF1, s_pPathF2, this, menu_selector(TextLayer::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);
schedule( schedule_selector(TextLayer::checkAnim) );
}
示例10:
CCNode *APSSprite::createNode() {
CCNode *node = APSGraphic::createNode();
APSImageHolder *ih = this->getImageHolder();
CCSize contentSize;
CCSize targetSize = APSPlatform::sharedPlatform()->convertSizeToPixels(this->getSize());
if (ih) {
this->m_spriteNode = new CCSprite;
if (this->getIsAnimatable()) {
// Create animation sprite
APSSpriteSheetHolder *sh = (APSSpriteSheetHolder *)ih;
CCSpriteFrame *spriteFrame = sh->getCCSpriteFrameAtIndex(((APSGraphicGroup *)this->getParent())->getDisplayedFrameIndex());
#if COCOS2D_VERSION >= 0x00020000
CCSpriteBatchNode *spriteSheet = CCSpriteBatchNode::createWithTexture(ih->getTexture(), sh->getCount());
#else
CCSpriteBatchNode *spriteSheet = CCSpriteBatchNode::batchNodeWithTexture(ih->getTexture(), sh->getCount());
#endif//APS_SKIP
this->m_node->addChild(spriteSheet);
this->m_spriteNode->initWithSpriteFrame(spriteFrame);
spriteSheet->addChild(this->m_spriteNode);
CCSize size = this->m_spriteNode->getContentSize();
contentSize = APSPlatform::sharedPlatform()->convertSizeToPixels(size);
} else {
// Check if there is a sprite frame in sprite frame cache.
CCSpriteFrame *frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(this->getImageHolder()->getRuntimeFilename().c_str());
if (frame) {
// Use the sprite frame
this->m_spriteNode->initWithSpriteFrame(frame);
contentSize = frame->getOriginalSizeInPixels();
node->addChild(this->m_spriteNode);
} else {
// Normal sprite
this->m_spriteNode->initWithTexture(ih->getTexture());
contentSize = ih->getTexture()->getContentSizeInPixels();
node->addChild(this->m_spriteNode);
}
}
// scale the sprite to match the sizes of texture and sprite
this->m_spriteNode->setScaleX(targetSize.width/contentSize.width);
this->m_spriteNode->setScaleY(targetSize.height/contentSize.height);
}
return node;
}
示例11: init
bool CCControlPotentiometerTest::init()
{
if (CCControlScene::init())
{
CCSize screenSize = CCDirector::sharedDirector()->getWinSize();
CCNode *layer = CCNode::create();
layer->setPosition(ccp (screenSize.width / 2, screenSize.height / 2));
this->addChild(layer, 1);
double layer_width = 0;
// Add the black background for the text
CCScale9Sprite *background = CCScale9Sprite::create("extensions/buttonBackground.png");
background->setContentSize(CCSizeMake(80, 50));
background->setPosition(ccp(layer_width + background->getContentSize().width / 2.0f, 0));
layer->addChild(background);
layer_width += background->getContentSize().width;
this->setDisplayValueLabel(CCLabelTTF::create("", "HelveticaNeue-Bold", 30));
m_pDisplayValueLabel->setPosition(background->getPosition());
layer->addChild(m_pDisplayValueLabel);
// Add the slider
CCControlPotentiometer *potentiometer = CCControlPotentiometer::create("extensions/potentiometerTrack.png"
,"extensions/potentiometerProgress.png"
,"extensions/potentiometerButton.png");
potentiometer->setPosition(ccp (layer_width + 10 + potentiometer->getContentSize().width / 2, 0));
// When the value of the slider will change, the given selector will be call
potentiometer->addTargetWithActionForControlEvents(this, cccontrol_selector(CCControlPotentiometerTest::valueChanged), CCControlEventValueChanged);
layer->addChild(potentiometer);
layer_width += potentiometer->getContentSize().width;
// Set the layer size
layer->setContentSize(CCSizeMake(layer_width, 0));
layer->setAnchorPoint(ccp (0.5f, 0.5f));
// Update the value label
this->valueChanged(potentiometer, CCControlEventValueChanged);
return true;
}
return false;
}
示例12: createGameScene
cocos2d::CCNode* ComponentsTestLayer::createGameScene()
{
CCNode *root = NULL;
do
{
CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();
CCSprite *player = CCSprite::create("components/Player.png", CCRectMake(0, 0, 27, 40) );
player->setPosition( ccp(origin.x + player->getContentSize().width/2,
origin.y + visibleSize.height/2) );
root = cocos2d::CCNode::create();
root->addChild(player, 1, 1);
CCMenuItemFont *itemBack = CCMenuItemFont::create("Back", this, menu_selector(ComponentsTestLayer::toExtensionsMainLayer));
itemBack->setColor(ccc3(0, 0, 0));
itemBack->setPosition(ccp(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25));
CCMenu *menuBack = CCMenu::create(itemBack, NULL);
menuBack->setPosition(CCPointZero);
addChild(menuBack);
}while (0);
return root;
}
示例13: 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;
}
示例14: createGameScene
cocos2d::CCNode* SceneEditorTestLayer::createGameScene()
{
CCNode *pNode = CCSSceneReader::sharedSceneReader()->createNodeWithSceneFile("scenetest/FishJoy2.json");
if (pNode == NULL)
{
return NULL;
}
m_pCurNode = pNode;
//fishes
CCArmature *pBlowFish = getFish(10008, "blowFish");
CCArmature *pButterFlyFish = getFish(10009, "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;
}
示例15: loadAnimation
void Image::loadAnimation(const char* filename, int capacity)
{
imageFile = filename;
spriteSheet = CCSpriteBatchNode::create(imageFile.append(".png").c_str(), capacity);
imageFile.erase(imageFile.length() - 4, 4);
spriteSheet->retain();
CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile(imageFile.append(".plist").c_str());
imageFile.erase(imageFile.length() - 6, 6);
spritesName = CCArray::createWithCapacity(capacity);
spritesName->retain();
for(int i = 1; i <= capacity; i++)
{
/*char num[10];
sprintf(num, "%04d", i);*/
spritesName->addObject(ScreateF("%s_%02d.png", filename, i));//imageFile.append(num).append(".png")));
}
CCSpriteFrame* firstFrame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(((CCString*)spritesName->objectAtIndex(0))->getCString());
delegate->setDisplayFrame(firstFrame);
CCNode* parent = delegate->getParent();
parent->addChild(spriteSheet);
parent->removeChild(delegate, false);
spriteSheet->addChild(delegate);
runningAnimation = NULL;
}