所以我一直在玩弄构建游戏的想法,在这一点上,我只是想为基于图块的世界建立一个基本框架,就像在口袋妖怪或其他游戏中一样。
我现在遇到的问题很荒谬。在修复了其他几个错误之后,我仍然在两个不同的地方得到 ArgumentError #1063,在这两种情况下,我都传递了正确数量的参数(两者都是构造函数),错误告诉我我传递了 0。
这是第一个的相关代码:
public function Main()
{
stage.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler, false, 0, true);
stage.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler, false, 0, true);
stage.addEventListener(Event.ENTER_FRAME, act, false, 0, true);
key = new KeyObject(stage);
overWorld = new Map(stage);
stage.addChild(overWorld);
}
(overWorld
是一个Map
var,上面用 声明public var overWorld:Map;
)
和:
public function Map(stageRef:Stage)
{
key2 = new KeyObject(stageRef);
currentMap = MapArrays.testMap;
x = 0;
y = 0;
initializeTiles();
}
我Map()
用它需要的引用调用构造函数stage
,它把这个作为错误吐出来:
ArgumentError: Error #1063: Argument count mismatch on Map(). Expected 1, got 0.
at flash.display::Sprite/constructChildren()
at flash.display::Sprite()
at flash.display::MovieClip()
at Main()
此外,该initializeTiles()
函数包含这两个错误中的第二个。这是代码:
public function initializeTiles()
{
for(var i:int = 0; i < 25; i++)
{
for(var j:int = 0; j < 20; j++)
{
var temp:String = ("tile"+i+"_"+j);
this[temp] = new Tile(currentMap, (i+10), (j+10), (i * 30), (j * 30))
}
}
}
和Tile()
构造函数:
public function Tile(mapArr:Array, inX:int, inY:int, xpos:int, ypos:int)
{
mapArray = mapArr;
arrX = inX;
arrY = inY;
x = xpos;
y = ypos;
determineTile();
}
这是吐出的错误(500 次,20x25):
ArgumentError: Error #1063: Argument count mismatch on Tile(). Expected 5, got 0.
at flash.display::Sprite/constructChildren()
at flash.display::Sprite()
at flash.display::MovieClip()
at Map()
at Main()
只是为了解释一些,mapArr
//是描述活动地图集的整数数组,mapArray
/是地图中给定图块的位置(/当然是位置),并且只是图块在屏幕上的位置(每个平铺是 30 像素 x 30 像素)。只需查找 int并相应地更改 tile 的属性和图像。是我在课堂上创建和导入的currentMap
inX
arrX
x
inY
arrY
y
xpos
ypos
determineTile()
mapArray[arrX][arrY]
MapArrays
public dynamic class
Map
import MapArrays;
无论如何,对于这个问题的任何帮助将不胜感激。如果有人认为其他地方可能存在问题,我可以编辑以发布更多代码,但这些是调用构造函数的唯一地方,也是我输出中的前 501 错误(还有一些,但它们是因为这些构造函数失败因为它们是空引用错误)。我已经在这里停留了很长时间,稍微调整了一下,到目前为止没有任何效果,而且我没有看到其他任何地方有人在使用正确数量的参数时遇到此错误。
提前致谢。