在 Actionscript 3 中收到错误。"Comparison between a value with a static type uint and a possibly unrelated type Array"
Receiving an error in Actionscript 3. "Comparison between a value with a static type uint and a possibly unrelated type Array"
见谅,我只是个高中生。对于一个学校项目,我的任务是通过 Actionscript 3 创建游戏。我决定制作 Brick Breaker,其中 objective 用于破坏舞台上的积木等。游戏的特点之一是屏幕上会生成不同类型的方块。红系一击灭,蓝系两击灭,紫系三击灭。这三个块已添加到 'blockArray'。
基本上,当球击中其中一个方块时,它会失去 1 点生命值。当方块的生命值 = 0 时,它将从舞台和阵列中移除。
球撞击方块的生成和碰撞正常进行。问题几乎出在其他所有方面。让我举个例子:
function checkHealth():void
for (var i:uint=0; i<blockArray.length; i++)
for (i = 0; i < blockArray; i++)
health = 1;
for (i = 1; i < blockArray; i++)
health = 2;
for (i = 2; i < blockArray; i++)
health = 3;
我从这段代码中收到一个错误,说 "Comparison between a value with a static type uint and a possibly unrelated type Array"
非常感谢对此的任何帮助,
谢谢。
此代码包含一些非常错误的做法,没有任何意义。
假设第二个for循环运行了50次,为什么要将相同的值赋给一个变量50次? "health = 1" 只能调用一次。调用它 100 万次不会改变结果。
此外,在 for 循环本身内修改索引值非常容易出错 :) 我不会那样做。
你能更好地解释你想要实现的目标吗?通过阅读这段代码是不可能猜到的。
见谅,我只是个高中生。对于一个学校项目,我的任务是通过 Actionscript 3 创建游戏。我决定制作 Brick Breaker,其中 objective 用于破坏舞台上的积木等。游戏的特点之一是屏幕上会生成不同类型的方块。红系一击灭,蓝系两击灭,紫系三击灭。这三个块已添加到 'blockArray'。
基本上,当球击中其中一个方块时,它会失去 1 点生命值。当方块的生命值 = 0 时,它将从舞台和阵列中移除。
球撞击方块的生成和碰撞正常进行。问题几乎出在其他所有方面。让我举个例子:
function checkHealth():void
for (var i:uint=0; i<blockArray.length; i++)
for (i = 0; i < blockArray; i++)
health = 1;
for (i = 1; i < blockArray; i++)
health = 2;
for (i = 2; i < blockArray; i++)
health = 3;
我从这段代码中收到一个错误,说 "Comparison between a value with a static type uint and a possibly unrelated type Array"
非常感谢对此的任何帮助, 谢谢。
此代码包含一些非常错误的做法,没有任何意义。
假设第二个for循环运行了50次,为什么要将相同的值赋给一个变量50次? "health = 1" 只能调用一次。调用它 100 万次不会改变结果。
此外,在 for 循环本身内修改索引值非常容易出错 :) 我不会那样做。 你能更好地解释你想要实现的目标吗?通过阅读这段代码是不可能猜到的。