Beispiel #1
0
void Monster::onEnter()
{
	Character::onEnter();

	schedule(schedule_selector(Monster::onUpdate));

	int MonsterIdx = m_iMonsterID - 1;

	setCurSpeed(GI.getMonsterConfig()[MonsterIdx].fMoveSpeed);
	setMaxSpeed(GI.getMonsterConfig()[MonsterIdx].fMoveSpeed);
	setMaxHealth(GI.getMonsterConfig()[MonsterIdx].iHP);
	setCurHealth(GI.getMonsterConfig()[MonsterIdx].iHP);

	setMoveVector(ccp(1, 0));

	sprintf(CMonster, "spirit/monster/Monster%d", m_iMonsterID);
	std::string StrMonster(CMonster);

	// 设置动画
	// 0.右 1.下 2.左 3.上 
	m_pWalkAnim[0] = CCAnimation::create();
	m_pWalkAnim[0]->retain();
	m_pWalkAnim[0]->addSpriteFrameWithFileName( (StrMonster + std::string("_R_1.png")).c_str() );
	m_pWalkAnim[0]->addSpriteFrameWithFileName( (StrMonster + std::string("_R_2.png")).c_str() );
	m_pWalkAnim[0]->setDelayPerUnit(0.5f / getCurSpeed());

	m_pWalkAnim[1] = CCAnimation::create();
	m_pWalkAnim[1]->retain();
	m_pWalkAnim[1]->addSpriteFrameWithFileName( (StrMonster + std::string("_D_1.png")).c_str() );
	m_pWalkAnim[1]->addSpriteFrameWithFileName( (StrMonster + std::string("_D_2.png")).c_str() );
	m_pWalkAnim[1]->setDelayPerUnit(0.5f / getCurSpeed());

	m_pWalkAnim[2] = CCAnimation::create();
	m_pWalkAnim[2]->retain();
	m_pWalkAnim[2]->addSpriteFrameWithFileName( (StrMonster + std::string("_L_1.png")).c_str() );
	m_pWalkAnim[2]->addSpriteFrameWithFileName( (StrMonster + std::string("_L_2.png")).c_str() );
	m_pWalkAnim[2]->setDelayPerUnit(0.5f / getCurSpeed());

	m_pWalkAnim[3] = CCAnimation::create();
	m_pWalkAnim[3]->retain();
	m_pWalkAnim[3]->addSpriteFrameWithFileName( (StrMonster + std::string("_U_1.png")).c_str() );
	m_pWalkAnim[3]->addSpriteFrameWithFileName( (StrMonster + std::string("_U_2.png")).c_str() );
	m_pWalkAnim[3]->setDelayPerUnit(0.5f / getCurSpeed());

	// 设置技能
	m_pSkill = Skill::create(GI.getMonsterConfig()[MonsterIdx].iSkillID);
	addChild(m_pSkill);

	// 冰冻
	m_bIsFrozen = false;
	m_bForceToStop = false;
	m_bDropItemAfterDeath = true;
}
Beispiel #2
0
void Hero::onEnter()
{
	Character::onEnter();

	schedule(schedule_selector(Hero::onUpdate));

	// 设置速度
	setCurSpeed(GI.HeroInitSpeed);
	setMaxSpeed(GI.HeroMaxSpeed);

	// 设置动画
	// 0.下 1.左 2.上 3.右
	m_pWalkAnim[0] = CCAnimation::create();
	m_pWalkAnim[0]->retain();
	m_pWalkAnim[0]->addSpriteFrameWithFileName("Hero1_1.png");
	m_pWalkAnim[0]->addSpriteFrameWithFileName("Hero1_2.png");
	m_pWalkAnim[0]->setDelayPerUnit(0.5 / getCurSpeed());
}