public class FrameImage
{
	public int frameWidth;

	public int frameHeight;

	public int nFrame;

	private Image imgFrame;

	private int[] pos;

	private int totalHeight;

	private bool isRotate;

	public FrameImage(Image img, int width, int height)
	{
		imgFrame = img;
		frameWidth = width;
		frameHeight = height;
		totalHeight = mGraphics.getImageHeight(img);
		nFrame = totalHeight / height;
		pos = new int[nFrame];
		for (int i = 0; i < nFrame; i++)
		{
			pos[i] = i * height;
		}
	}

	public void drawRegionFrame(int idx, int x, int y, int trans, int anchor, mGraphics g, int bulletID, int n)
	{
		g.drawRegion(imgFrame, 0, (bulletID * n + idx) * mGraphics.getImageWidth(imgFrame), mGraphics.getImageWidth(imgFrame), mGraphics.getImageWidth(imgFrame), trans, x, y, anchor, false);
	}

	public void drawFrame(int idx, int x, int y, int trans, int anchor, mGraphics g, bool isClip)
	{
		if (!isRotate)
		{
			if (idx >= 0 && idx < nFrame)
			{
				g.drawRegion(imgFrame, 0, pos[idx], frameWidth, frameHeight, trans, x, y, anchor, isClip);
			}
		}
		else if (idx >= 0 && idx < nFrame)
		{
			switch (idx * (360 / nFrame))
			{
			case 0:
				g.drawImage(imgFrame, x, y, 3, isClip);
				break;
			case 90:
				g.drawRegion(imgFrame, 0, 0, frameWidth, frameHeight, 5, x, y, anchor, isClip);
				break;
			case 270:
				g.drawRegion(imgFrame, 0, 0, frameWidth, frameHeight, 6, x, y, anchor, isClip);
				break;
			case 180:
				g.drawRegion(imgFrame, 0, 0, frameWidth, frameHeight, 3, x, y, anchor, isClip);
				break;
			}
		}
	}

	public void drawFrame(int idx, float x, float y, int trans, int anchor, mGraphics g, bool isClip)
	{
		if (!isRotate)
		{
			if (idx >= 0 && idx < nFrame)
			{
				g.drawRegion(imgFrame, 0, pos[idx], frameWidth, frameHeight, trans, x, y, anchor, isClip);
			}
		}
		else if (idx >= 0 && idx < nFrame)
		{
			switch (idx * (360 / nFrame))
			{
			case 0:
				g.drawImage(imgFrame, x, y, 3, isClip);
				break;
			case 90:
				g.drawRegion(imgFrame, 0, 0, frameWidth, frameHeight, 5, x, y, anchor, isClip);
				break;
			case 270:
				g.drawRegion(imgFrame, 0, 0, frameWidth, frameHeight, 6, x, y, anchor, isClip);
				break;
			case 180:
				g.drawRegion(imgFrame, 0, 0, frameWidth, frameHeight, 3, x, y, anchor, isClip);
				break;
			}
		}
	}

	public void unload()
	{
		imgFrame = null;
		pos = null;
	}
}
