我是编程新手,我想弄清楚如何创建一个像这样的数字列表(5,10,15,20,25,一直到500)然后能够检查玩家得分是否等于这些数字中的任何一个
到目前为止,我的代码是这样的..它有效,但只有当分数为5时.
private void drawPower() {
if (myWorld.getScore() == 5) {
batcher.draw(Power, pipe3.getX(), pipe3.getY() + pipe3.getHeight()
+ 30, 20, -14);
}
}
Run Code Online (Sandbox Code Playgroud)
我需要知道需要做什么,而不是
if (myWorld.getScore() == 5) {
Run Code Online (Sandbox Code Playgroud)
这将是
if (myWorld.getScore() == "any number in the list") {
Run Code Online (Sandbox Code Playgroud)
我不会使用从5到100的5的倍数数组.
我只是检查它是否是5的倍数,如果它在5和之间500.
int score = myWorld.getScore();
if (score >= 5 && score <= 500 && score % 5 == 0) {
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1055 次 |
| 最近记录: |