1 每隔一段时间显示一行,期间,按键也有同样的效果.
2 一个一个增加
3 一行一行渐亮出现
第一种效果:每隔一段时间显示一行,期间,按键也有同样的效果.
private String strIntrWord[]; //要显示的文字
private int startRowIntrWord; //每页文字的起始行的下标
private int endRowIntrWord; //每页文字的结束行的下标
private int increaseTimeIntrWord; //更新文字的记数
private int seqTimeIntrWord; //更新文字的频率
private int rowPerPageIntrWord; //每页显示的行数
//起始位置的X,Y坐标,行距,也需要指定,这里以0,0为起点,文字高度为行距
/*******************************************
* 得到指定资源里面的字符串数组
*/
private String[] ReadResStringArray(int id) {
String str[];
InputStream in = data_stream_create("/res.bin");
Data_Package_Seek(in, id);
Data_Read_Int(in, 2); //资源打包的时候多余的数据。
int num = Data_Read_Int(in, 1);
str = new String[num];
for (int i = 0; i < num; i++) {
str[i] = Data_Read_String(in);
}
return str;
}
/***************
* 初试化数据
*/
private void IntrWordInit(int id) {
//脚本里面只需要输入所有的文件,转换程序转换成长度未知的字符串,得到行数,读取每行
//的字符.
strIntrWord = ReadResStringArray(id);
startRowIntrWord = 0;
endRowIntrWord = 0;
increaseTimeIntrWord = 0;
seqTimeIntrWord = 10;
rowPerPageIntrWord = 5;
}
private void IntrWordRun() {
if (++increaseTimeIntrWord > seqTimeIntrWord ||
getKeyState(KEY_SINGLE) != 0) {
//清0
increaseTimeIntrWord = 0;
if (endRowIntrWord < strIntrWord.length - 1) {
//增加
if (++endRowIntrWord > rowPerPageIntrWord) {
startRowIntrWord++;
}
} else {
//对话播放完成,转换到下一个状态
ScriptRun();
}
}
}
private void IntrWordDraw() {
int height = 0;
for (int i = startRowIntrWord; i < endRowIntrWord; i++) {
drawString(strIntrWord[i], 0, height, 0, 0);
height += fontHeight;
}
}
2006-06-22 17:04:26
Views(1229)
Comments