0

我正在创建一个游戏,其中角色在行走时会留下一连串的移动剪辑(我称之为日志)。达到目标后,角色需要返回并拾取他留下的所有影片剪辑(不一定按照他离开的顺序)。我这样做的方式,它只拾取一个,我无法弄清楚我应该做什么才能拾取它们中的每一个。这是我生成日志的代码:

    this["log"+counter] = new _Log();
    addChild(this["log"+counter]);
    this["log"+counter] .x = char.x;
    this["log"+counter] .y = char.y;
    logCounter=0;
    counter ++;

以下是我挑选它们的方式:

    if(char.hitTestPoint(this["log"+(counter-1)] .x,this["log"+(counter-1)] .y, true)){
        this["log"+(counter-1)] .visible = false;
        this["log"+(counter-1)] .active = false;
    }

我的想法是,如果我可以在使用 hitTestPoint 函数时以某种方式同时测试 1 和当前计数器值之间的所有数字。我有什么办法吗?如果没有,你会建议我用什么其他方式来获取我的电影剪辑线索?

非常感谢

4

1 回答 1

2

根据您的代码,您需要在循环中检查所有必要日志的冲突:

for (var i:int=0; i<counter; i++)
    {
        if(char.hitTestPoint(this["log"+i].x,this["log"+i].y, true)){
            this["log"+i].visible = false;
            this["log"+i].active = false;
        }
    }
于 2013-01-15T20:01:22.793 回答