【发布时间】:2012-01-26 21:43:00
【问题描述】:
在使用 hitTestObject 时遇到了一些问题,现在 Flash 告诉我它无法将我的船转换为显示对象。我的问题是船类从 Sprite 开始扩展,所以我不知道发生了什么:
编译错误显示如下:
TypeError: Error #1034: Type Coercion failed: cannot convert Ship$ to flash.display.DisplayObject.
at Control/controlgame()
Control/controlgame() 是这样的:
function controlgame(e:Event) {
for (var i = 0; i < wprojectiles.length; i ++) {
if (wprojectiles[i].x < -200 || wprojectiles[i].x > 750 || wprojectiles[i].y < -200 || wprojectiles[i].y > 600) {
parent.removeChild(wprojectiles[i]);
wprojectiles.splice(i,1);
}
if (wprojectiles[i].hitTestObject(Ship)) {
parent.removeChild(wprojectiles[i]);
wprojectiles.splice(i,1);
}
}
}
使用调试器,我得到这个错误:
TypeError: Error #1034: Type Coercion failed: cannot convert Ship$ to flash.display.DisplayObject.
at Control/controlgame()[C:\Users\Harry\Desktop\Flash Games\Games\Dodge\Control.as:29]
上面sn-p中看到的第29行是这样的:
if (wprojectiles[i].hitTestObject(Ship)) {
在这里扯我的头发,尝试了我能想到的一切,但我每次都收到这个错误,不管我做什么!非常感谢您的帮助!
提前致谢。
e:如果有相关性,这是我的文档类文件
【问题讨论】:
标签: actionscript-3