【发布时间】:2012-04-14 15:38:34
【问题描述】:
好的,那么
- 创建了新的 Zombie 变量。
private Zombie zombieA; -
僵尸变量已初始化
zombieA = new Zombie(1); -
在 Zombie 类中调用构造函数:
public Zombie(int type) { this.type = type; x=200; y=100; dx=1; paintA.setColor(Color.RED);}
基本上,我希望游戏类创建一个新的 Zombie,类型为 1,它将通过 switch 和 case 来确定要创建的僵尸类型(级别 1=10)。问题是当我运行它时,我的应用程序强制关闭并且出现错误:
zombieA = new Zombie(1);
从初始类和错误:
public Zombie(int type) {
来自僵尸类。我一遍又一遍地检查它,我只是看不到问题,有人注意到有什么问题吗?
【问题讨论】:
-
堆栈跟踪?我只是在阅读 LogCat,它说 java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
-
@AlexBath - 请完整的堆栈跟踪:行号、调用的类和方法。看不出问题,因为构造函数参数没有问题..
标签: java android class constructor