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


C++ CCSpriteFrameCache::spriteFrameByName方法代码示例

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


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

示例1:

void LevelGame05::updateGame(float dt)
{
	if(isMatch == true)
	{
		count=count - 2;
		CCSpriteFrameCache *cache = CCSpriteFrameCache::sharedSpriteFrameCache();

		CCMenu *pmenu=(CCMenu *)getChildByTag(100);
		pmenu->removeChildByTag(90+lastItemIndex);
		pmenu->removeChildByTag(90+curItemIndex);
	}
	else
	{
		CCSpriteFrameCache *cache = CCSpriteFrameCache::sharedSpriteFrameCache();
		CCMenu *pmenu=(CCMenu *)getChildByTag(100);
		CCMenuItemImage *Item1=(CCMenuItemImage *)pmenu->getChildByTag(90+lastItemIndex);
		CCMenuItemImage *Item2=(CCMenuItemImage *)pmenu->getChildByTag(90+curItemIndex);
		Item1->setNormalSpriteFrame(cache->spriteFrameByName("poker.png"));
		Item1->setSelectedSpriteFrame(cache->spriteFrameByName("poker.png"));
		Item2->setNormalSpriteFrame(cache->spriteFrameByName("poker.png"));
		Item2->setSelectedSpriteFrame(cache->spriteFrameByName("poker.png"));
	}
	isFinish = true;
	lastItemIndex = 0;
}
开发者ID:rockere6,项目名称:Test,代码行数:25,代码来源:LevelGame05.cpp

示例2: slowDown

void Planet::slowDown()
{
	// 当前的逻辑禁止在一个减速期间叠加另一个减速
	if(m_bSlowDowned)
		return;

	m_bSlowDowned = true;	

	if(!m_pSlowDownMark)
	{
		setSlowDownMark(CCSprite::create());
		m_pSlowDownMark->setPosition(ccp(113,65));
		this->addChild(m_pSlowDownMark);
	}

	m_pSlowDownMark->setVisible(true);	

	CCSpriteFrameCache* cache = CCSpriteFrameCache::sharedSpriteFrameCache();
	cache->addSpriteFramesWithFile("SlowDownMark.plist");
	CCAnimation* animation = CCAnimation::create();
	animation->addSpriteFrame(cache->spriteFrameByName("SlowDownMark_0.png"));	
	animation->addSpriteFrame(cache->spriteFrameByName("SlowDownMark_1.png"));	
	animation->addSpriteFrame(cache->spriteFrameByName("SlowDownMark_2.png"));	
	animation->addSpriteFrame(cache->spriteFrameByName("SlowDownMark_3.png"));	
	animation->addSpriteFrame(cache->spriteFrameByName("SlowDownMark_4.png"));	
	animation->addSpriteFrame(cache->spriteFrameByName("SlowDownMark_4.png"));
	animation->setDelayPerUnit(0.2f);
	CCAnimate* animate = CCAnimate::create(animation);
	m_pSlowDownMark->runAction(CCRepeatForever::create(animate));	

	this->scheduleOnce(schedule_selector(Planet::slowDownRestore) , SLOW_DOWN_DURATION);

	if(m_pFace)
		m_pFace->cry();
}
开发者ID:daoduchai,项目名称:DogsMustDie,代码行数:35,代码来源:Planet.cpp

示例3: init

KDbool AnalogStick::init ( KDvoid )
{
	if ( !TouchableSprite::init ( ) )
	{
		return KD_FALSE;
	}

	this->setScale ( 0.5f );
		
	m_tPressedVector = ccp ( 0, 0 );
	m_nDirection = AS_NO_DIRECTION;
		
	CCSpriteFrameCache*		pCache = CCSpriteFrameCache::sharedSpriteFrameCache ( );
	pCache->addSpriteFramesWithFile ( "analog_stick.plist" );
		
	// Set the sprite display frame
	this->setDisplayFrame ( pCache->spriteFrameByName ( "analog_pad.png" ) );
		
	// Init the bar, set position and display frame
	m_pBar = CCSprite::create ( );
	m_pBar->setDisplayFrame ( pCache->spriteFrameByName ( "analog_bar.png" ) );
	this->repositionBarWithPoint ( this->getPosition ( ) );
	this->addChild ( m_pBar );
	
	// Init the nub, set position and display frame
	m_pNub = CCSprite::create ( );
	this->repositionNub ( );
	m_pNub->setDisplayFrame ( pCache->spriteFrameByName ( "analog_nub.png" ) );
	this->addChild ( m_pNub );	

	return KD_TRUE;
}
开发者ID:mcodegeeks,项目名称:OpenKODE-Framework,代码行数:32,代码来源:AnalogStick.cpp

示例4: adjustScrollView

void FirstLayer::adjustScrollView(float offset)
{
	CCSize s = CCDirector::sharedDirector()->getWinSize();
	CCSpriteFrameCache *pCache =  CCSpriteFrameCache::sharedSpriteFrameCache();
	CCSprite *pPoint = (CCSprite *)this->getChildByTag(m_nCurPage);
	pPoint->setDisplayFrame(pCache->spriteFrameByName(PIC_POINT_NORMAL));
	if (offset<0)
	{
		m_nCurPage ++;
	}else
	{
		m_nCurPage --;
	}

	if (m_nCurPage <1)
	{
		m_nCurPage = 1;
	}

	if(m_nCurPage > 3)
	{
		game_process.firstPlay = false;
		CCSetBool("firstPlay", false);
		CCUserDefault::sharedUserDefault()->flush();
		SceneManager::goPlay();
	}
	else
	{
		pPoint = (CCSprite *)this->getChildByTag(m_nCurPage);
		pPoint->setDisplayFrame(pCache->spriteFrameByName(PIC_POINT_SELECTED));
		CCPoint adjustPos = ccp(-s.width * (m_nCurPage-1), 0);
		m_scroll->setContentOffset(adjustPos, true);
	}
}
开发者ID:wyklion,项目名称:pogoda,代码行数:34,代码来源:FirstLayer.cpp

示例5: processTouch

void RCDPad::processTouch(cocos2d::CCPoint point)
{
	CCSpriteFrameCache *cache = CCSpriteFrameCache::sharedSpriteFrameCache();
	setColor(ccc3(255,200,200));
	m_pressed = true;
	CCPoint center = ccp( rect().origin.x+rect().size.width/2, rect().origin.y+rect().size.height/2 );
	if(distanceBetweenPoints(point, center) < rect().size.width/10){
        setDisplayFrame(cache->spriteFrameByName("d_pad_normal.png"));
		setRotation(0);
		m_pressedVector = ccp(0,0);
		m_direction = kDPadNoDirection;
		return;
	}
	float radians = vectorToRadians( ccp(point.x-center.x, point.y-center.y) );
	float degrees = radiansToDegrees(radians) + 90;
    float sin45 = 0.7071067812f;
	if(degrees >= 337.5 || degrees < 22.5){
		setDisplayFrame(cache->spriteFrameByName("d_pad_horizontal.png"));
		setRotation(180);
        m_pressedVector = ccp(-1,0);
        m_direction = kDPadLeft;
	}else if(degrees >= 22.5 && degrees < 67.5){
		setDisplayFrame(cache->spriteFrameByName("d_pad_diagonal.png"));
		setRotation(-90);
        m_pressedVector = ccp(-sin45,sin45);
        m_direction = kDPadUpLeft;
	}else if(degrees >= 67.5 && degrees < 112.5){
		setDisplayFrame(cache->spriteFrameByName("d_pad_horizontal.png"));
		setRotation(-90);
        m_pressedVector = ccp(0,1);
        m_direction = kDPadUp;
	}else if(degrees >= 112.5 && degrees < 157.5){
		setDisplayFrame(cache->spriteFrameByName("d_pad_diagonal.png"));
		setRotation(0);
        m_pressedVector = ccp(sin45,sin45);
        m_direction = kkDPadUpRight;
	}else if(degrees >= 157.5 && degrees < 202.5){
		setDisplayFrame(cache->spriteFrameByName("d_pad_horizontal.png"));
		setRotation(0);
        m_pressedVector = ccp(1,0);
        m_direction = kkDPadRight;
	}else if(degrees >= 202.5 && degrees < 247.5){
		setDisplayFrame(cache->spriteFrameByName("d_pad_diagonal.png"));
		setRotation(90);
        m_pressedVector = ccp(sin45,-sin45);
        m_direction = kDPadDownRight;
	}else if(degrees >= 247.5 && degrees < 292.5){
		setDisplayFrame(cache->spriteFrameByName("d_pad_horizontal.png"));
		setRotation(90);
        m_pressedVector = ccp(0,-1);
        m_direction = kDPadDown;
	}else{
		setDisplayFrame(cache->spriteFrameByName("d_pad_diagonal.png"));
		setRotation(180);
        m_pressedVector = ccp(-sin45,-sin45);
        m_direction = kDPadDownLeft;
	}

}
开发者ID:ryanflees,项目名称:TileMapDemo,代码行数:59,代码来源:RCDPad.cpp

示例6:

void LevelGame04::gameover(float dt)
{
	if(isMusic == true)
	{
		//SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic();
		SimpleAudioEngine::sharedEngine()->playEffect("lose.wav");
		/*scheduleOnce(schedule_selector(LevelGame04::updateMusic),2.0f);*/
	}
	  // 游戏失败  Color4B
	CCMenu *pmenu=(CCMenu *)getChildByTag(100);	//clickme禁止
	pmenu->setEnabled(false);
	CCMenu *pause=(CCMenu *)getChildByTag(104);//104是pause禁止
	pause->setEnabled(false);
	CCMenu *pmenu1=(CCMenu *)getChildByTag(103);	//menu禁止
	pmenu1->setEnabled(false);
	//屏蔽爆炸动画
	SWSpritePlayForTexturePacker *p_blowup = (SWSpritePlayForTexturePacker *)getChildByTag(105); 
	p_blowup->setVisible(false);
   
	CCSize size = CCDirector::sharedDirector()->getWinSize();  
    CCLayerColor *layer = CCLayerColor::create(ccc4(0, 0, 0, 200), size.width, size.height); 
	CCSprite *sp =CCSprite::create("bg-4-lose.png");  
    sp->setPosition(CCPoint(size.width*0.5, size.height*0.5));  
    layer->addChild(sp);

	//CCSprite* lose_cry =CCSprite::createWithSpriteFrameName("lose-cry.png"); 
   // lose_cry->setPosition(CCPoint(size.width*0.5-300,size.height*0.5)); 
   // layer->addChild(lose_cry);  

	CCSpriteFrameCache *cache = CCSpriteFrameCache::sharedSpriteFrameCache();  
	CCMenuItemImage *Item1 = CCMenuItemImage::create();
	Item1->setNormalSpriteFrame(cache->spriteFrameByName("win-lose-list-1.png"));
	Item1->setSelectedSpriteFrame(cache->spriteFrameByName("win-lose-list-2.png"));
	Item1->initWithTarget(this,menu_selector(LevelGame04::winloseCallback));
	Item1->setPosition(ccp(size.width*0.5-150, size.height*0.5-50));
    Item1->setTag(110); 
	CCMenuItemImage *Item2 = CCMenuItemImage::create();
	Item2->setNormalSpriteFrame(cache->spriteFrameByName("result-1.png"));
	Item2->setSelectedSpriteFrame(cache->spriteFrameByName("result-2.png"));
	Item2->initWithTarget(this,menu_selector(LevelGame04::resultCallback));
	Item2->setPosition(ccp(size.width*0.5+350, size.height*0.5-50));
    Item2->setTag(111); 
	CCMenu* menu= CCMenu::create(Item1,Item2, NULL);
    menu->setPosition(CCPointZero);
	menu->setTag(112);  
    layer->addChild(menu); 

	this->addChild(layer,2);
}
开发者ID:rockere6,项目名称:Test,代码行数:49,代码来源:LevelGame04.cpp

示例7: createAnimWithSingleFrameN

CCAnimation* AnimationUtil::createAnimWithSingleFrameN( const char* name, float delay, unsigned int iLoops) {
    CCSpriteFrameCache* cache = CCSpriteFrameCache::sharedSpriteFrameCache();

    CCArray* framesArray = CCArray::create();

    CCSpriteFrame* frame = NULL;
    int index = 1;
    do {
        frame = cache->spriteFrameByName(CCString::createWithFormat("%s%d.png", name, index++)->getCString());

        /* 不断地获取CCSpriteFrame对象,直到获取的值为NULL */
        if(frame == NULL) {
            break;
        }

        framesArray->addObject(frame);
    }while(true);

    CCAnimation* animation = CCAnimation::createWithSpriteFrames(framesArray);
    animation->setLoops(iLoops);
    animation->setRestoreOriginalFrame(true);
    animation->setDelayPerUnit(delay);

    return animation;
}
开发者ID:ruozigongzuoshi,项目名称:goddessemblem,代码行数:25,代码来源:AnimationUtil.cpp

示例8: hitAnimation

/* AnimatioinクラスhitAnimation関数定義
 * 返却型 : CCFiniteTimeAction
 * 仮引数 : int型変数count
 */
CCFiniteTimeAction* Animation::hitAnimation(int count) {
	CCDelayTime* delay = CCDelayTime::create(4);		//2秒ディレイ test用
	CCArray *animFrames = CCArray::create();			//CCArray型配列を初期化
	CCSpriteFrameCache *cache = CCSpriteFrameCache::sharedSpriteFrameCache();	//キャッシュより指定したファイル名のインスタンスを取得しCCSpriteFrame型のオブジェクトframeに代入
	/* 初期値0のint型変数iが
	 * count未満の間
	 * インクリメント
	 */
	for(int i=0; i<count; i++) {
		CCString* fileName =
				CCString::createWithFormat(count == 14 ? "hit%d.png" : "defeat%d.png", i);	//countが13と同値であればhit%d.pngの、違う場合はdefeat%d.pngのファイルネームを取得しfileNameに代入
		CCSpriteFrame *frame = cache->spriteFrameByName(fileName->getCString());	//キャッシュからインスタンスを取得

		//インスタンスが取得できない場合(初回読み込み時まだインスタンスが生成されていない為)
		if(!frame) {
			CCTexture2D *texture = CCTextureCache::sharedTextureCache()->addImage(fileName->getCString());			//fileNameに一致するファイルの取得
			CCRect bounds = CCRectMake(0, 0, texture->getContentSize().width, texture->getContentSize().height);	//インスタンスの座標とサイズを取得
			frame = CCSpriteFrame::createWithTexture(texture, bounds);	//テクスチャをframeに代入
		}
		animFrames->addObject(frame);	//インスタンスを配列に追加
	}
	CCAnimation* animation = CCAnimation::createWithSpriteFrames(animFrames, 0.1);	//CCSpriteFrameCacheクラスの配列を引数にCCAnimationクラスのインスタンスの生成 第二引数は1フレームの時間

	return CCAnimate::create(animation);	//CCAnimateクラスのアクションを生成して返却
}
开发者ID:usseeebaaaka,项目名称:sensuikan,代码行数:29,代码来源:Animation.cpp

示例9: addPig

void GameScene::addPig()
{
    const static int fameCount = 3;
    const static float animationDuration = 0.15f;

    CCSpriteFrameCache* cache = CCSpriteFrameCache::sharedSpriteFrameCache();
    cache->addSpriteFramesWithFile("pigs.plist");

    m_pPig = CCSprite::createWithSpriteFrameName("pig1");
    m_pPig->retain();
    m_pPig->setScale(0.7f);
    m_pPig->setZOrder(1);
    m_pPig->setPosition(ccp(m_VisibleOrigin.x + m_VisibleSize.width / 3, m_VisibleOrigin.y + m_VisibleSize.height / 2));
    addChild(m_pPig);

    CCArray *animFrames = CCArray::createWithCapacity(fameCount);
    for(int i = 1; i <= fameCount; i++)
    {
        CCSpriteFrame* frame = cache->spriteFrameByName(CCString::createWithFormat("pig%d", i)->getCString());
        animFrames->addObject(frame);
    }

    CCAction *action = CCRepeatForever::create(CCAnimate::create(CCAnimation::createWithSpriteFrames(animFrames, animationDuration)));
    action->setTag(kTagFlutter);
    m_pPig->runAction(action);
}
开发者ID:studio501,项目名称:fiypig,代码行数:26,代码来源:GameScene.cpp

示例10: init

bool CCActivityIndicator::init()
{
    CCSpriteFrameCache * spriteFramecache = CCSpriteFrameCache::sharedSpriteFrameCache();
    
    spriteFramecache->addSpriteFramesWithFile("ccactivityindicator.plist");
    CCSpriteBatchNode::initWithFile("ccactivityindicator.png", 1);
    
    CCSize winSize = CCDirector::sharedDirector()->getWinSize();
    indicator = CCSprite::createWithSpriteFrameName("ccactivityindicator_1.gif");
    indicator->setPosition(ccp(winSize.width/2,winSize.height/2));
    addChild(indicator);
    
    animating = false;
    hidesWhenStopped = true;
    
    spriteFrames = CCArray::create();
    spriteFrames->retain();
    
    //load all sprite frames into array
    for (int i=1; i<=kActivityIndicatorFramesCount; i++) {
        CCSpriteFrame * frame = spriteFramecache->spriteFrameByName(CCString::createWithFormat("ccactivityindicator_%d.gif",i)->getCString());
        spriteFrames->addObject(frame);
    }
    
    return true;
}
开发者ID:JLimqueco,项目名称:cocos2d-x-extensions,代码行数:26,代码来源:CCActivityIndicator.cpp

示例11: CCRectMake

/* CCTableViewDelegate */
void
MCSkillLayer::tableCellTouched(CCTableView *table, CCTableViewCell *cell)
{
    if (table != tableView_) {
        return;
    }
    
    if (selectedCell_) {
        selectedCell_->unselected();
    }
    selectedCell_ = dynamic_cast<MCTableViewTextFieldCell *>(cell);
    selectedCell_->selected();
    
    selectedSkill_ = dynamic_cast<MCSkill *>(skills_->objectAtIndex(cell->getIdx()));
    
    CCSpriteFrameCache *cache = CCSpriteFrameCache::sharedSpriteFrameCache();
    CCSpriteFrame *frame = cache->spriteFrameByName(selectedSkill_->getName()->getCString());
    if (! frame) {
        frame = CCSpriteFrame::create(selectedSkill_->getIcon()->getCString(),
                                      CCRectMake(0, 0, 64 / CC_CONTENT_SCALE_FACTOR(), 64 / CC_CONTENT_SCALE_FACTOR()));
        cache->addSpriteFrame(frame, selectedSkill_->getName()->getCString());
    }
    icon_->setDisplayFrame(frame);
    icon_->setVisible(true);
    
    contentTableView_->reloadData();
    contentTableView_->setVisible(true);
    proficiency_->setVisible(true);
}
开发者ID:edison9888,项目名称:__graduation_project,代码行数:30,代码来源:MCSkillLayer.cpp

示例12: ccp

KDbool Ch2_AnalogStick::init ( KDvoid )
{	
	if ( !Recipe::init ( ) )
	{
		return KD_FALSE;
	}

	CCSpriteFrameCache*		pCache = CCSpriteFrameCache::sharedSpriteFrameCache ( );
	pCache->addSpriteFramesWithFile ( "gunman.plist" );

	// Initialize gunman
	m_pGunman = SimpleAnimObject::createWithSpriteFrame ( pCache->spriteFrameByName ( "gunman_stand_down.png" ) );
	m_pGunman->setPosition ( ccp ( 240, 160 ) );
	m_pGunman->setVelocity ( ccp ( 0, 0 ) );
	this->addChild ( m_pGunman );
	m_nGunmanDirection = AS_DOWN;

	m_pMessage->setString ( "Analog Vector:" );
		
	// Initialize analog stick
	pCache->addSpriteFramesWithFile ( "analog_stick.plist" );
	m_pAnalogStick = AnalogStick::create ( );
	m_pAnalogStick->setPosition ( ccp ( 100, 100 ) );
	this->addChild ( m_pAnalogStick );

	// This sets off a chain reaction.
	this->animateGunman ( );

	this->schedule ( schedule_selector ( Ch2_AnalogStick::step ) );

	return KD_TRUE;
}
开发者ID:mcodegeeks,项目名称:OpenKODE-Framework,代码行数:32,代码来源:Ch2_AnalogStick.cpp

示例13: AddExploisionEff

float EffectLayer::AddExploisionEff(int enemySize, CCPoint p )
{
	int NUM_FRAME = 12;
	float TIME_ANIMATION = 0.1f;

	CCSpriteFrameCache* cache = CCSpriteFrameCache::sharedSpriteFrameCache();
	cache->addSpriteFramesWithFile("explosion_3.plist");

	CCString* strSpriteName = CCString::create("explosion_3 (1).png");
	CCSprite* m_pSprite1 = CCSprite::createWithSpriteFrameName(strSpriteName->getCString());

	m_pSprite1->setScale(enemySize/3.0f); //////////////////////////////////////////////////////////////////////////
	
	m_pSprite1->setPosition(p);
	this->addChild(m_pSprite1);

	CCArray* animFrames = CCArray::createWithCapacity(NUM_FRAME);
	for(int i = 1; i < NUM_FRAME; i++) 
	{
		strSpriteName = CCString::createWithFormat("explosion_3 (%d).png", i);
		CCSpriteFrame* frame = cache->spriteFrameByName( strSpriteName->getCString() );
		animFrames->addObject(frame);
	}

	CCAnimation* animation = CCAnimation::createWithSpriteFrames(animFrames, TIME_ANIMATION);
	m_pSprite1->runAction(
		CCSequence::create(
			CCAnimate::create(animation), 
			CCCallFuncN::create(this, callfuncN_selector(EffectLayer::RemoveEffCallback)),
			NULL
	));

	return NUM_FRAME * TIME_ANIMATION;
}
开发者ID:doanhtdpl,项目名称:dau-truong-tri-thuc,代码行数:34,代码来源:EffectLayer.cpp

示例14: addChild

TestController::TestController()
    : m_tBeginPos(CCPointZero)
{

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

    CCSprite * pbackground = CCSprite::spriteWithFile("metrobackground.png");
    pbackground->setPosition(CCPointMake(s.width/2,s.height/2));
    //addChild(pbackground);
    // add close menu
    CCMenuItemImage *pCloseItem = CCMenuItemImage::itemFromNormalImage(s_pPathClose, s_pPathClose, this, menu_selector(TestController::closeCallback) );
    CCMenu* pMenu =CCMenu::menuWithItems(pCloseItem, NULL);
    pMenu->setPosition( CCPointZero );
    pCloseItem->setPosition(CCPointMake( 30, s.height - 50));
    // add title COCOS2S-X
    CCLabelTTF* title = CCLabelTTF::labelWithString("COCOS2D-X-Metro", "Arial", 24);
    title->setAnchorPoint(CCPointMake(0,0.5));
    title->setPosition(CCPointMake(72,s.height - 50));
    addChild(title);
    // Load TestIcons
    CCSpriteFrameCache *cache = CCSpriteFrameCache::sharedSpriteFrameCache();
    cache->addSpriteFramesWithFile("metroIcons.plist", "metroIcons.png");
    char tmp[50];
    // add menu items for tests
    m_pItmeMenu = CCMenu::menuWithItems(NULL);
    int colorscount = sizeof(ccMetroColors) / sizeof(ccColor4B);

    for (int i = 0; i < TESTS_COUNT; ++i)
    {
#if (CC_TARGET_PLATFORM == CC_PLATFORM_MARMALADE)
        CCLabelBMFont* label = CCLabelBMFont::labelWithString(g_aTestNames[i].c_str(),  "fonts/arial16.fnt");
#else
        CCLabelTTF* label = CCLabelTTF::labelWithString(g_aTestNames[i].c_str(), "Arial", 24);
#endif
        // Create Metro MenuItem
        CCMenuItemMetro* pMenuItem = CCMenuItemMetro::itemWithMetro(label, this, menu_selector(TestController::menuCallback));
        pMenuItem->setAnchorPoint(CCPointMake(0,0));
        pMenuItem->setMetroSlyte(ccMetroColors[i % colorscount]);
        m_pItmeMenu->addChild(pMenuItem, i + 10000);
        pMenuItem->setPosition(CCPointMake(70 + (i / 3) * (MetroRectW + 10),((MetroRectH + 10)* 3) - (i % 3) * (MetroRectH + 10) - 85));
        //Icons
        sprintf(tmp, "metroicon%d.png", i);
        CCSpriteFrame* frame = cache->spriteFrameByName(tmp);
        CCSprite* pIcon = CCSprite::spriteWithSpriteFrame(frame);
        pMenuItem->addChild(pIcon);
        pIcon->setPosition(CCPointMake(80,60));
    }

    m_pItmeMenu->setContentSize(CCSizeMake((TESTS_COUNT / 3 + 1) * (MetroRectW + 10) - s.width, s.height));
    m_pItmeMenu->setPosition(s_tCurPos);
    addChild(m_pItmeMenu);

    setIsTouchEnabled(true);

    addChild(pMenu, 1);
}
开发者ID:Openxlive,项目名称:cocos2d-x-win8-tests-metro-style,代码行数:56,代码来源:controller.cpp

示例15: InitAnimation

void Player::InitAnimation()
{
	CCSpriteFrameCache* cache = CCSpriteFrameCache::sharedSpriteFrameCache();

	CCAnimation* runAnim = CCAnimation::create();
	char str[64] = {0};

	//Right.
	{
		runAnim = CCAnimation::create();

		for (int i = 0; i <= 2; i++) 
		{
			sprintf(str, "move_right%d.png", i);

			CCSpriteFrame* frame = cache->spriteFrameByName(str);
			runAnim->addSpriteFrame(frame);
		}
		runAnim->setDelayPerUnit(0.04f);
		runAnim->setRestoreOriginalFrame(true);

		walk_Right_Animate = CCRepeatForever::create(CCAnimate::create(runAnim));
		walk_Right_Animate->retain();
	}

	//Up.
	{
		runAnim = CCAnimation::create();

		for (int i = 0; i <= 1; i++) 
		{
			sprintf(str, "move_up%d.png", i);

			CCSpriteFrame* frame = cache->spriteFrameByName(str);
			runAnim->addSpriteFrame(frame);
		}
		runAnim->setDelayPerUnit(0.04f);
		runAnim->setRestoreOriginalFrame(true);

		flip_Animate = CCRepeatForever::create(CCAnimate::create(runAnim));
		flip_Animate->retain();
	}
}
开发者ID:YuYing-yy,项目名称:DownFloors,代码行数:43,代码来源:Player.cpp


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