www.pudn.com > MobiCraft_src.rar > UnitAnimatorSprite.java
// style: tabs, tabsize=4, style=ANSI
//+----------------------------------------------------------------------+
// Copyright (c) 2006 Company Name
// Made by Andrew and Zahar
//+----------------------------------------------------------------------+
// Filename: UnitAnimatorSprite.java
//+----------------------------------------------------------------------+
// Comment: extends Sprite, and supports x and y span on draw
//+----------------------------------------------------------------------+
package battle;
import java.io.*;
import javax.microedition.lcdui.*;
import javax.microedition.lcdui.game.*;
public class UnitAnimatorSprite extends Sprite
{
public final static int XSIZE = 40;
public final static int YSIZE = 40;
public int mWidth;
public int mHeight;
// Смещения при рисовании
public int mPosX;
public int mPosY;
// Количество кадров
public int mLength;
// Сколько миллисекунд надо на смену кадра.
public int mDelay;
public UnitAnimatorSprite(String s, int w, int h, int dx, int dy, int d, int l) throws IOException
{
super (Image.createImage(s), w, h);
mWidth = w;
mHeight = h;
mPosX = dx;
mPosY = dy;
mDelay = d;
mLength = l;
}
public void Draw(Graphics g, int x, int y, boolean bmirror)
{
if ( bmirror )
{
setTransform(TRANS_MIRROR);
setPosition(x+(XSIZE-mPosX-mWidth), y+mPosY);
}
else
{
setTransform(TRANS_NONE);
setPosition(x+mPosX, y+mPosY);
}
paint(g);
}
}