Import javax. microedition. lcdui .*;
Public abstract class sprite {
Int X, Y; // the X and Y coordinates are not required.
/**/
Public int getx () {return X ;}
Public int Gety () {return y ;}
/**/
//////////////////////////////////////// ////
Int sequence []; // custom Sequence
Void setframesequence (INT [] SEQ ){
Sequence = new int [seq. Length];
For (INT I = 0; I <seq. length; I ++ ){
Sequence [I] = seq [I];
}}
Void setframe (INT t ){
Sequence = new int [1];
Sequence [0] = T;
If (sequence [0]> = framecount)
Sequence [0] = 0;
If (sequence [0] <0)
Sequence [0] = framecount ;}
Int framecount; // Number of watermark Images
Int COUNT = 0;
////////////////////
//// 2 constructors ///
///////////////////
Int N;
Image sprite;
Int width, height;
// Get Sprite from Image
Sprite (image IMG, int framewidth, int frameheight ){
This. Sprite = IMG;
This. width = framewidth;
This. Height = frameheight;
Int A = IMG. getwidth ()/width;
N =;
Int B = IMG. getheight ()/height;
Framecount = a * B ;}
Image IMG = NULL;
// Sprite
Sprite (image IMG ){
This. IMG = IMG ;}
////////////////////////
/// Visible ///
////////////////////////
Static Boolean visible = true; // visible by default
Void setvisible (Boolean visible ){
This. Visible = visible ;}
Boolean isvisible (){
Return visible ;}
///////////////////////////
//// // Depict part /////////
///////////////////////////
Public void setposition (int x, int y ){
This. x = x; this. Y = y;
}
Void paint (Graphics g ){
If (visible ){
If (IMG! = NULL)
G. drawimage (IMG, X, Y, 0 );
Else
If (sequence = NULL) {// default normal sequence
Int A = (count % framecount % N) * width;
Int B = (count % framecount/n) * height; // priority must be noted
Trans (G, X-a, Y-B, transform); // display with flip
Count ++;
} Else {
G. setclip (X, Y, width, height );
Int d = sequence. length;
Int c = count % d;
Trans (G, X-sequence [c] % N * width, Y-(sequence [c]/n) * height, transform );
Count ++;
}
}}
//////////////////////////////////////// /////
/// For technical consideration, only horizontal and vertical flip are written //
//////////////////////////////////////// ////
Int transform = 0; // throttling
Void trans (Graphics g, Int J, int K, int Transform ){
If (transform = 0) {// normal
G. setclip (X, Y, width, height );
G. drawimage (sprite, J, K, 0 );
}
If (transform = 1) {// horizontal
For (INT I = 0; I G. setclip (x + I, Y, 1, height );
G. drawimage (sprite, J-width + 2 * I + 1, K, 0 );
}}
If (transform = 2) {// vertical
For (INT I = 0; I <width; I ++ ){
G. setclip (X, Y + I, width, 1 );
G. drawimage (sprite, j, k-height + 2 * I + 1, 0 );
}}}
Void settransform (INT Transform) {// set flip 1 to horizontal 2 to vertical 0 to normal
This. Transform = transform;
If (this. Transform> 2 | this. Transform <0)
This. Transform = 0 ;}
////////////////////////////////
//// // Obtain the image ////////////
///////////////////////////////
Image tupian;
Image getimage (string Lujing ){
Try {
Tupian = image. createimage ("/" + Lujing + ". PNG ");
} Catch (exception e ){}
Return tupian ;}
}