Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Actionscript 3 AS3精灵不在物体后面_Actionscript 3_Flash - Fatal编程技术网

Actionscript 3 AS3精灵不在物体后面

Actionscript 3 AS3精灵不在物体后面,actionscript-3,flash,Actionscript 3,Flash,我正在尝试与多面墙进行伪3D碰撞。它在一定程度上起作用: 我可以与每面墙的侧面碰撞 但是只有在其中一面墙上,如果我要到顶部,它会在矩形后面,就像在第二个矩形上,我会在它上面,就像我不知道为什么会发生这样的事情一样(我是AS3的初学者)。使用trace,它表示球员在第0层,而墙在第2层,但球仍在墙上方 编辑:我正在使用flashdevelop,以防更改任何内容 编辑:更改代码,可以正常工作,但忽略第二面墙,打印其名称,但不更改布尔值 for each (var wall in WallsL

我正在尝试与多面墙进行伪3D碰撞。它在一定程度上起作用: 我可以与每面墙的侧面碰撞

但是只有在其中一面墙上,如果我要到顶部,它会在矩形后面,就像在第二个矩形上,我会在它上面,就像我不知道为什么会发生这样的事情一样(我是AS3的初学者)。使用trace,它表示球员在第0层,而墙在第2层,但球仍在墙上方

编辑:我正在使用flashdevelop,以防更改任何内容

编辑:更改代码,可以正常工作,但忽略第二面墙,打印其名称,但不更改布尔值

    for each (var wall in WallsList)
    {
        trace(wall.name)
        if (wall.hitTestPoint(Character.x - hitRad+.995, Character.y, true)) //col right
        {
            Character.x+=CharacterSpeed;
        }
        if (wall.hitTestPoint(Character.x + hitRad-.995, Character.y, true)) //col left
        {
            Character.x-=CharacterSpeed;
        }
        if (wall.hitTestPoint(Character.x , Character.y- hitRad+25, true)) //col bottom
        {
            Character.y+=CharacterSpeed;
        }
        if (wall.hitTestPoint(Character.x, Character.y+hitRad-25, true)) //col top
        {
            Character.y -= CharacterSpeed;
        }
        if (wall.hitTestPoint(Character.x, Character.y+hitRad, true))  // col top #2
        {
            trace(wall.name) // prints for both walls
            Top = true; // only changes for 1 wall
        }
        if (!wall.hitTestPoint(Character.x, Character.y+hitRad, true))
        {
            Top = false;
        }
    }

将墙对象置于球上方:

setChildIndex(wallObject, this.numChildren - 1);

在col top中,您有
setChildIndex(Character,0)
,但在其他任何地方使用
setChildIndex(Character,2)
只需使其一致即可。不起作用。我做错什么了吗?将其作为setChildIndex(r,this.numChildren-1);如果希望墙对象始终位于角色上方,请执行以下操作:
对于每个对象(var r:Shape in this.WallList){if(r.hitTestPoint(character.x,character.y+hitRad-1,true)){setChildIndex(r,this.numChildren-1);}else{setChildIndex(character,this.numChildren-1);}
如果不想在上面添加字符,只需删除else语句仍不起作用。现在它只在底部和顶部上方,而我应该只在顶部的矩形后面。更改
if(r.hitTestPoint(Character.x,Character.y+hitRadius-25,true))
如果有一个矩形可以正常工作,但是如果有多个矩形,只有一个可以正常工作。