📄 cardsprite.java
字号:
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.game.Sprite;
public class CardSprite extends Sprite{
public static final int CARD_BLACK = 0; //黑桃
public static final int CARD_RED = 1; //红桃
public static final int CARD_SQUARE = 2; //方块
public static final int CARD_CLUB = 3; //梅花
public static final int CARD_TYPE_NUM = 4;
private int m_nType = -1; //牌的种类
private int m_nValue = -1; //牌的面值
public CardSprite( Image image, int frameWidth, int frameHeight){
super(image, frameWidth, frameHeight);
defineReferencePixel(frameWidth / 2, frameHeight / 2);
setVisible(false);
}
//根据类型和面值设置纸牌的帧编号
//参数type是纸牌的类型,value是纸牌的面值
public void setCard( int type, int value ){
if( type < 0 || type >= CARD_TYPE_NUM )
return;
if( value < 1 || value > 13 )
return;
m_nValue = value;
m_nType = type;
setFrame( type * 13 + value - 1 );
setVisible(true);
}
//获取牌的种类
public int getType(){
return m_nType;
}
//获取牌的面值
public int getValue(){
return m_nValue;
}
//获取纸牌对应的分数
public int getScore(){
return m_nValue;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -