gamerecord.java
来自「j2me 小游戏」· Java 代码 · 共 54 行
JAVA
54 行
import javax.microedition.rms.*;
/*
*游戏rms;
*/
public class GameRecord
{
RecordStore rs;
public static byte[] score = (String.valueOf(Configure.score)).getBytes();
byte[] con = new byte[5];
public GameRecord()
{
try
{
rs = RecordStore.openRecordStore("config",true);
if (rs.getVersion()==0)
{
rs.addRecord(score,0,score.length);
}
System.out.println(rs.getVersion());
}
catch (Exception e)
{
e.printStackTrace();
}
}
public void writeRecord()
{
try
{
score = (String.valueOf(Configure.score)).getBytes();
rs.setRecord(2,score,0,score.length);
}
catch (Exception e)
{
e.printStackTrace();
}
}
public void readRecord()
{
try
{
con = rs.getRecord(1);
Configure.score = Integer.parseInt(new String(rs.getRecord(2)));
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?