Animation* CharacterAnimation::CreateAnimationMove(PlayerInfo cPInfo, DirectionKind dir)
{
	std::string frameName = "spear_";
	Animation* animation = Animation::create();
	animation->setDelayPerUnit(0.1f);

	if (cPInfo == PLAYER_RED)
	{
		frameName += "R_";
	}
	else if (cPInfo == PLAYER_BLUE)
	{
		frameName += "B_";
	}

	std::string direction = GetDirectionName(dir);
	frameName += direction;
	frameName += "_move";

	std::array<SpriteFrame*, 2> frameArray =
	{
		SpriteFrameCache::getInstance()->getSpriteFrameByName(frameName + "_00.png"),
		SpriteFrameCache::getInstance()->getSpriteFrameByName(frameName + "_01.png")
	};

	animation->addSpriteFrame(frameArray[0]);
	animation->addSpriteFrame(frameArray[1]);

	animation->setLoops(5);
	return animation;
}
예제 #2
0
파일: phone.cpp 프로젝트: love1cat/PhoneSim
	void Phone::MoveForward(double distance) {
		// Compute destination point following current moving direction.
		// The destination may be out of region.
		log << "Move forward (towards " << GetDirectionName(moving_direction_) << ".)" << distance << ".\n";
		if (moving_direction_ == LEFT) {
			location_.x -= distance;
		} else if (moving_direction_ == RIGHT) {
			location_.x += distance;
		} else if (moving_direction_ == UP) {
			location_.y += distance;
		} else {
			location_.y -= distance;
		}
	}