Exemplo n.º 1
0
bool AnimationManager::initAnimationMap()
{

	// 添加 plist文件到缓存  
	// cache->addSpriteFramesWithFile("01.plist");  
	SpriteFrameCache *cache=SpriteFrameCache::getInstance();
	cache->addSpriteFramesWithFile("01.plist");  
	// 创建数组用来存放帧序列  
	//SpriteBatchNode *batchNode = SpriteBatchNode::create("01.png");  

	char temp[20];
	sprintf(temp, "%d", aDown);
	//加载勇士向下走的动画
	AnimationCache::sharedAnimationCache()->addAnimation(createHeroMovingAnimationByDirection(kDown), temp);
	sprintf(temp, "%d", aRight);
	//加载勇士向右走的动画
	AnimationCache::sharedAnimationCache()->addAnimation(createHeroMovingAnimationByDirection(kRight), temp);
	sprintf(temp, "%d", aLeft);
	//加载勇士向左走的动画
	AnimationCache::sharedAnimationCache()->addAnimation(createHeroMovingAnimationByDirection(kLeft), temp);
	sprintf(temp, "%d", aUp);
	//加载勇士向上走的动画
	AnimationCache::sharedAnimationCache()->addAnimation(createHeroMovingAnimationByDirection(kUp), temp);
	//加载战斗动画
	//sprintf(temp, "%d", aFight);
	//AnimationCache::sharedAnimationCache()->addAnimation(createFightAnimation(), temp);

	sprintf(temp, "%d", eDown);
	//加载怪物向下走的动画
	AnimationCache::sharedAnimationCache()->addAnimation(createEnemyMovingAnimationByDirection(kDown), temp);
	sprintf(temp, "%d", eRight);
	//加载怪物向下走的动画
	AnimationCache::sharedAnimationCache()->addAnimation(createEnemyMovingAnimationByDirection(kRight), temp);
	sprintf(temp, "%d", eLeft);
	//加载怪物向下走的动画
	AnimationCache::sharedAnimationCache()->addAnimation(createEnemyMovingAnimationByDirection(kLeft), temp);
	sprintf(temp, "%d", eUp);
	//加载怪物向下走的动画
	AnimationCache::sharedAnimationCache()->addAnimation(createEnemyMovingAnimationByDirection(kUp), temp);
	sprintf(temp, "%d", bullet);
	//子弹爆炸
	AnimationCache::sharedAnimationCache()->addAnimation(createBulletAnimation(), temp);

	//加载NPC动画
	//AnimationCache::sharedAnimationCache()->addAnimation(createNPCAnimation(), "npc0");
	return true;
}
bool AnimationManager::initAnimationMap()
{
	char temp[20];
	sprintf(temp, "%d", aDown);
	//加载勇士向下走的动画
	AnimationCache::getInstance()->addAnimation(createHeroMovingAnimationByDirection(kDown), temp);
	sprintf(temp, "%d", aRight);
	//加载勇士向右走的动画
	AnimationCache::getInstance()->addAnimation(createHeroMovingAnimationByDirection(kRight), temp);
	sprintf(temp, "%d", aLeft);
	//加载勇士向左走的动画
	AnimationCache::getInstance()->addAnimation(createHeroMovingAnimationByDirection(kLeft), temp);
	sprintf(temp, "%d", aUp);
	//加载勇士向上走的动画
	AnimationCache::getInstance()->addAnimation(createHeroMovingAnimationByDirection(kUp), temp);
	//加载战斗动画
	sprintf(temp, "%d", aFight);
	AnimationCache::getInstance()->addAnimation(createFightAnimation(), temp);
	//加载NPC动画
	AnimationCache::getInstance()->addAnimation(createNPCAnimation(), "npc0");
	return true;
}
bool AnimationManager::initAnimationMap()
{
	char temp[20];
	
	sprintf(temp, "%d", aRight);
	//加载勇士向右走的动画
	CCAnimationCache::sharedAnimationCache()->addAnimation(createHeroMovingAnimationByDirection(hright), temp);
	sprintf(temp, "%d", aLeft);
	//加载勇士向左走的动画
	CCAnimationCache::sharedAnimationCache()->addAnimation(createHeroMovingAnimationByDirection(hleft), temp);
	sprintf(temp, "%d", aDie);
	//加载勇士死亡的动画
	CCAnimationCache::sharedAnimationCache()->addAnimation(createHeroMovingAnimationByDirection(hdie), temp);
	 
	sprintf(temp, "%d", heroCry);
	
	CCAnimationCache::sharedAnimationCache()->addAnimation(createCryAnimation(), temp);

	sprintf(temp, "%d", victory);

	CCAnimationCache::sharedAnimationCache()->addAnimation(createVictoryAnimation(), temp);
	
	sprintf(temp, "%d", biqiSmile);

	CCAnimationCache::sharedAnimationCache()->addAnimation(createBiqiSmile(), temp);
	CCSpriteFrame *heronormal, *heroleftJump, *herorightJump;

	//第二个参数表示显示区域的x, y, width, height,根据direction来确定显示的y坐标

	CCTexture2D *heroTexture = CCTextureCache::sharedTextureCache()->addImage("Hero_image.png");
	heronormal = CCSpriteFrame::createWithTexture(heroTexture, cocos2d::CCRectMake(eSize*0, eSize*1, eSize, eSize));
	heroleftJump = CCSpriteFrame::createWithTexture(heroTexture, cocos2d::CCRectMake(eSize*0, eSize*2, eSize, eSize));
	herorightJump = CCSpriteFrame::createWithTexture(heroTexture, cocos2d::CCRectMake(eSize*1, eSize*2, eSize, eSize));
	CCSpriteFrame *controlLeft=CCSpriteFrame::create("Thumb_dpad_left.png",CCRectMake(0,0,90,90));
	CCSpriteFrame *controlLeftPressed=CCSpriteFrame::create("Thumb_dpad_left_pressed.png",CCRectMake(0,0,90,90));
	CCSpriteFrame *controlRight=CCSpriteFrame::create("Thumb_dpad_right.png",CCRectMake(0,0,90,90));
	CCSpriteFrame *controlRightPressed=CCSpriteFrame::create("Thumb_dpad_right_pressed.png",CCRectMake(0,0,90,90));
	CCSpriteFrame *controlJump=CCSpriteFrame::create("Thumb_dpad_jump.png",CCRectMake(0,0,135,90));
	CCSpriteFrame *controlJumpPressed=CCSpriteFrame::create("Thumb_dpad_jump_pressed.png",CCRectMake(0,0,135,90));
	sprintf(temp, "%d", heronormalkey);
	CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFrame(heronormal,temp);
	sprintf(temp, "%d", heroleftJumpkey);
	CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFrame(heroleftJump,temp);
	sprintf(temp, "%d", herorightJumpkey);
	CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFrame(herorightJump,temp);
	sprintf(temp, "%d", controlLeftkey);
	CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFrame(controlLeft,temp);
	sprintf(temp, "%d", controlLeftPressedkey);
	CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFrame(controlLeftPressed,temp);
	sprintf(temp, "%d", controlRightkey);
	CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFrame(controlRight,temp);
	sprintf(temp, "%d", controlRightPressedkey);
	CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFrame(controlRightPressed,temp);
	sprintf(temp, "%d", controlJumpkey);
	CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFrame(controlJump,temp);
	sprintf(temp, "%d", controlJumpPressedkey);
	CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFrame(controlJumpPressed,temp);
	CCTexture2D *tileTexture = CCTextureCache::sharedTextureCache()->addImage("Tile_source.png");
	CCSpriteFrame *whyBlock=CCSpriteFrame::createWithTexture(tileTexture, cocos2d::CCRectMake(0, 96, 48, 48));
	sprintf(temp, "%d", whyBlockKey);
	CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFrame(whyBlock,temp);
	CCSpriteFrame *firmBlock=CCSpriteFrame::createWithTexture(tileTexture, cocos2d::CCRectMake(240, 0, 48, 48));
	sprintf(temp, "%d", firmBlockKey);
	CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFrame(firmBlock,temp);
	CCSpriteFrame *gold=CCSpriteFrame::create("gold.png",CCRectMake(0,0,48,48));
	sprintf(temp, "%d", goldCoinkey);
	CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFrame(gold,temp);
	CCSpriteFrame *box=CCSpriteFrame::create("Navigator_tv.png",CCRectMake(0,0,527,418));
	sprintf(temp, "%d", failedboxkey);
	CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFrame(box,temp);

	CCSpriteFrame *cryFrame=CCSpriteFrame::create("Navigator_lose_image_1.png",CCRectMake(0,0,179,176));
	sprintf(temp, "%d", cryFramekey);
	CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFrame(cryFrame,temp);

	CCSpriteFrame *onFrame=CCSpriteFrame::create("Switch_on.png",CCRectMake(0,0,130,58));
	sprintf(temp, "%d", onkey);
	CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFrame(onFrame,temp);
	
	CCSpriteFrame *offFrame=CCSpriteFrame::create("Switch_off.png",CCRectMake(0,0,130,58));
	sprintf(temp, "%d", offkey);
	CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFrame(offFrame,temp);
	return true;
}