好。所以,我是一个孩子,试图编写一个很酷的小3D游戏,然后这个... 问题决定在接下来的几天采取废话。
我在我的IDE中使用Eclipse。当我插入controls.tick(forward, back, left, right, turnLeft, turnRight);
("控制"是,嗯,我的游戏的控件," tick"是与步骤,转弯,时间本身等相关联的时间。)Eclipse说"The method 'tick'(boolean, boolean, boolean, boolean, boolean) in the type 'Controller' is not applicable for the arguments (boolean, boolean, boolean, boolean, boolean, boolean)"
,我开始变得非常沮丧。 "前进,后退,左,右,右转,转右"是布尔语,设计为,布尔,并防止相机移动。他们是"链接"将键设置为true,以保持简短。 "控制器"是一个.class文件到" house"控制,旋转等。
那么,我做错了什么是深入的回应?重要的是,我不能从我拥有的东西中添加或删除任何布尔值。有没有办法解决这个问题,我可以进行一次演练吗?
这是完成工作的.class文件:
package com.mime.ocelot;
import java.awt.event.KeyEvent;
import com.mime.ocelot.input.Controller;
public class Game {
public int time;
public Controller controls;
public Game() {
}
public void tick(boolean[] key) {
time++;
boolean forward = key[KeyEvent.VK_W];
boolean back = key[KeyEvent.VK_S];
boolean left = key[KeyEvent.VK_A];
boolean right = key[KeyEvent.VK_D];
boolean turnLeft = key[KeyEvent.VK_LEFT];
boolean turnRight = key[KeyEvent.VK_RIGHT];
controls.tick(forward, back, left, right, turnLeft, turnRight);
}
}
这里是实际控制器的.class:
package com.mime.ocelot.input;
public class Controller {
public double x, z, rotation, xa, za, rotationa;
public void tick(boolean forward, boolean back, boolean right, boolean turnLeft, boolean turnRight) {
}
}
答案 0 :(得分:7)
tick()
的定义如下:
tick(boolean forward, boolean back, boolean right, boolean turnLeft, boolean turnRight)
它需要五个布尔参数。你这样称呼它:
tick(forward, back, left, right, turnLeft, turnRight);
你试图传递六个boolean
个参数。看起来你打算像这样定义它:
tick(boolean forward, boolean back, boolean left, boolean right, boolean turnLeft, boolean turnRight)
答案 1 :(得分:1)
tick方法签名需要5个布尔值,但是你传递的是6.将tick方法更改为:
public void tick(boolean forward, boolean back, boolean left, boolean right, boolean turnLeft, boolean turnRight)