Beispiel #1
0
ZwoptexGenericTest::~ZwoptexGenericTest()
{
    sprite1->release();
    sprite2->release();
    auto cache = SpriteFrameCache::getInstance();
    cache->removeSpriteFramesFromFile("zwoptex/grossini.plist");
    cache->removeSpriteFramesFromFile("zwoptex/grossini-generic.plist");
}
Beispiel #2
0
LayerMain::~LayerMain() {
    //sampleではonExitでやってたけど。
    auto cache = SpriteFrameCache::getInstance();
    cache->removeSpriteFramesFromFile("majo.plist");
}
Beispiel #3
0
bool BaseActionSprite::init(int index, int id, int spd, int aspd, int hp, Kind kind, VectorManager* manager)
{
	if (!Sprite::init())
		return false;

	_nowHp = hp;
	_kind = kind;
	_manager = manager;
	_dataIndex = index;
	

	_actionList.reserve(ACTION_COUNT);

	auto sfCache =  SpriteFrameCache::getInstance();

	if (kind & Kind::Soldier)
		sfCache->addSpriteFramesWithFile(String::createWithFormat("res\\s\\%d.plist", index)->getCString());
	else if (kind & Kind::Enemy)
		sfCache->addSpriteFramesWithFile(String::createWithFormat("res\\e\\%d.plist", index)->getCString());

	cocos2d::Action* action = nullptr;

	//¼ÓÔØÐÐ×߶¯»­
	Vector<cocos2d::SpriteFrame*> walk;
	walk.pushBack(sfCache->getSpriteFrameByName("move1.png"));
	walk.pushBack(sfCache->getSpriteFrameByName("move2.png"));
	walk.pushBack(sfCache->getSpriteFrameByName("move3.png"));
	walk.pushBack(sfCache->getSpriteFrameByName("move4.png"));
	walk.pushBack(sfCache->getSpriteFrameByName("move5.png"));
	walk.pushBack(sfCache->getSpriteFrameByName("move6.png"));
	action = RepeatForever::create(Animate::create(Animation::createWithSpriteFrames(walk, WALK_ACTION_TIME)));
	_actionList.pushBack(action);


	//¼ÓÔØÕ¾Á¢¶¯»­
	Vector<cocos2d::SpriteFrame*> stand;
	stand.pushBack(sfCache->getSpriteFrameByName("stand1.png"));
	stand.pushBack(sfCache->getSpriteFrameByName("stand2.png"));
	action = RepeatForever::create(Animate::create(Animation::createWithSpriteFrames(stand, STAND_ACTION_TIME)));
	_actionList.pushBack(action);

	//¼ÓÔصȴý¶¯»­
//	Vector<cocos2d::SpriteFrame*> stand;
//	stand.pushBack(sfCache->getSpriteFrameByName("stand1.png"));
//	stand.pushBack(sfCache->getSpriteFrameByName("stand2.png"));
	action = Spawn::createWithTwoActions((RepeatForever*)action,
										Sequence::createWithTwoActions(DelayTime::create(ASPD_FOR_DELAY_TIME / aspd)
																	, CallFunc::create(std::bind(&BaseActionSprite::_waitActionRecall,this))));
	_actionList.pushBack(action);

	//¼ÓÔع¥»÷¶¯»­
	Vector<cocos2d::SpriteFrame*> attack;
	attack.pushBack(sfCache->getSpriteFrameByName("attack1.png"));
	attack.pushBack(sfCache->getSpriteFrameByName("attack2.png"));
	attack.pushBack(sfCache->getSpriteFrameByName("attack3.png"));
	attack.pushBack(sfCache->getSpriteFrameByName("attack4.png"));
	action = Sequence::createWithTwoActions(Animate::create(Animation::createWithSpriteFrames(attack, ATTACK_ACTION_TIME))
										, CallFunc::create(std::bind(&BaseActionSprite::_attackActionRecall, this)));
	_actionList.pushBack(action);

	//¼ÓÔØÊÜ»÷¶¯»­
	Vector<cocos2d::SpriteFrame*> injure;
	injure.pushBack(sfCache->getSpriteFrameByName("injure1.png"));
	injure.pushBack(sfCache->getSpriteFrameByName("injure2.png"));
	action = Sequence::create(Animate::create(Animation::createWithSpriteFrames(injure, INJURE_ACTION_TIME))
							, DelayTime::create(INJURE_DELAY_TIME)
							, CallFunc::create(std::bind(&BaseActionSprite::_injureActionRecall, this))
							, nullptr);
	_actionList.pushBack(action);

	//¼ÓÔØËÀÍö¶¯»­
	Vector<cocos2d::SpriteFrame*> death;
	death.pushBack(sfCache->getSpriteFrameByName("die1.png"));
	death.pushBack(sfCache->getSpriteFrameByName("die2.png"));
	death.pushBack(sfCache->getSpriteFrameByName("die3.png"));
	action = Sequence::createWithTwoActions(Spawn::createWithTwoActions(Animate::create(Animation::createWithSpriteFrames(death, DEATH_ACTION_TIME))
																		 ,FadeOut::create(DEATH_FADEOUT_TIME))
											,CallFunc::create(std::bind(&BaseActionSprite::_deathActionRecall, this)));
	_actionList.pushBack(action);

	//¼ÓÔزù³ý¶¯»­
	if (kind == Soldier)
	{
		Vector<cocos2d::SpriteFrame*> remove;
		remove.pushBack(sfCache->getSpriteFrameByName("moveout1.png"));
		remove.pushBack(sfCache->getSpriteFrameByName("moveout2.png"));
		remove.pushBack(sfCache->getSpriteFrameByName("moveout3.png"));
		action = Sequence::createWithTwoActions(Spawn::createWithTwoActions(Animate::create(Animation::createWithSpriteFrames(remove, REMOVE_ACTION_TIME))
																			,FadeOut::create(REMOVE_FADEOUT_TIME))
												,CallFunc::create(std::bind(&BaseActionSprite::_removeActionRecall, this)));
		_actionList.pushBack(action);
	}

	sfCache->removeSpriteFramesFromFile("res\\i\\1.plist");
	return true;
}