コード例 #1
0
ファイル: Animations.cpp プロジェクト: firefly2442/Thor
// Adds a range of frames, assuming they are aligned as rectangles in the texture.
// animation:      FrameAnimation to modify
// x:              Column index of the texture rectangle
// [yFirst,yLast]: Bounds for row indices (if yLast < yFirst, add frames in reverse order)
// duration:       Relative duration of current frame (1 by default)
void addFrames(thor::FrameAnimation& animation, int x, int yFirst, int yLast, float duration = 1.f)
{
	const int step = (yFirst < yLast) ? +1 : -1;
	yLast += step; // so yLast is excluded in the range

	for (int y = yFirst; y != yLast; y += step)
		animation.addFrame(duration, sf::IntRect(36*x, 39*y, 36, 39));
}
コード例 #2
0
	void addFrames(thor::FrameAnimation& animation, int y, int xFirst, int xLast, int xSep, int ySep, float duration) {
		if (y == 0)
			y = 0;
		else if (y == 1)
			y = 94;
		else if (y == 2)
			y = 188;

		for (int x = xFirst; x != xLast; x += 1)
			animation.addFrame(duration, sf::IntRect(xSep * x, y, xSep, ySep));
	}
コード例 #3
0
ファイル: Player.cpp プロジェクト: lasagnaphil/SFML-Bomberman
void Player::addFrame(thor::FrameAnimation& animation, int x, int y, float duration)
{
	animation.addFrame(duration, sf::IntRect(16 * x, 16 * y, 16, 16));
}
コード例 #4
0
ファイル: Player.cpp プロジェクト: lasagnaphil/SFML-Bomberman
void Player::addFrameFlipped(thor::FrameAnimation& animation, int x, int y, float duration)
{
	animation.addFrame(duration, sf::IntRect(16 * (x + 1), 16 * y, -16, 16));
}