//判断是否回答不正确
if(selectIndex != rightAnswer[index]){
Alert a = new Alert("猜谜语","回答错误,请仔细思考!",null,AlertType.INFO);
a.setTimeout(3000);
display.setCurrent(a);
//返回
return;
}
//如果不是最后一个题目,则显示下一题
if(index < question.length - 1){
index++;
//修改界面显示的内容
cgQuestion.setLabel(question[index]);
//修改选项的内容
for(int i = 0;i < 4;i++){
cgQuestion.set(i,answer[index][i],null);
}
}else{//显示成功界面
Alert a = new Alert("猜谜语","游戏成功!",null,AlertType.INFO);
a.setTimeout(Alert.FOREVER);
display.setCurrent(a);
}
}
}