Actionscript 3 Flash CS6 AS3:为什么碰撞是远程传送而不是阻塞

Actionscript 3 Flash CS6 AS3:为什么碰撞是远程传送而不是阻塞,actionscript-3,collision-detection,flash-cs6,side-scroller,Actionscript 3,Collision Detection,Flash Cs6,Side Scroller,所以我不知道这个问题怎么说——如果有人有更好的想法,请随意:) 但本质上,我的侧卷轴的碰撞行为异常。我在开始位置的左侧有一个“边框”框(\u bounders),以防止字符在开始时向左移动。以前,它工作得很好(不过其他东西坏了)。在解决了许多其他碰撞问题(如从地板上掉下来、卡在地板上、重力表现异常)后,左侧碰撞大部分时间都停止工作 如果你从超过5-10像素的位置撞到墙,你将“传送”到墙顶并继续前进,而不是被阻挡/阻止移动。如果您的距离小于5-10像素,并开始移动,您将被阻止。我已经提供了一个图像

所以我不知道这个问题怎么说——如果有人有更好的想法,请随意:)

但本质上,我的侧卷轴的碰撞行为异常。我在开始位置的左侧有一个“边框”框(
\u bounders
),以防止字符在开始时向左移动。以前,它工作得很好(不过其他东西坏了)。在解决了许多其他碰撞问题(如从地板上掉下来、卡在地板上、重力表现异常)后,左侧碰撞大部分时间都停止工作

如果你从超过5-10像素的位置撞到墙,你将“传送”到墙顶并继续前进,而不是被阻挡/阻止移动。如果您的距离小于5-10像素,并开始移动,您将被阻止。我已经提供了一个图像(通过链接)的布局是什么

但是我如何修复我的侧卷轴代码,使墙总是阻塞(没有一个可笑的巨大碰撞框/区域)。或者,有没有更好的方法来处理所有碰撞

冲突代码:

private function processCollisions():void
    {

            //Respawn if fell off stage
            if(_player.y > stage.stageHeight)
            {
                _player.x = _startMarker.x;
                _player.y = _startMarker.y;
                _boundaries.x = 0;
                _boundaries.y = 0;
                _vy = 0;
            }

            //Otherwise process collisions with boundaries
            else
            {   

            var testX = _player.x
            var testY = _player.y - (_player.height / 2);
            var vCollision:Boolean = false;

                if(moveLeft){                   
                    testX -= horizMove;                     
                    if(_boundaries.hitTestPoint((testX - _player.width / 2), _player.y-5, true))
                    {
                        moveLeft = false;
                        trace("PING");
                    }
                }

                if(moveRight){                  
                    testX += horizMove;     
                    if(_boundaries.hitTestPoint((testX + _player.width / 2), _player.y-5, true))
                    {
                        moveRight = false;
                        trace("PONG");
                    }
                }

                if(jump){                   
                    testY += vertMove;                      
                    if(_boundaries.hitTestPoint(_player.x, (testY - _player.height / 2), true))
                    {
                        jump = false;
                        trace("PANG");
                    }
                }

                //if(_vy > 0){
                    testY += _vy;
                    if(_boundaries.hitTestPoint(_player.x, (testY + _player.height / 2), true))
                    {
                        vCollision = true;
                    }

                    if(vCollision)
                    {
                        while(vCollision)
                        {
                            _player.y -= 0.1;
                            vCollision = false;

                            if(_boundaries.hitTestPoint(_player.x, _player.y, true))
                            {
                                vCollision = true;
                            }
                        }
                        _vy = 0;
                    }

             }
         movement();
    }
移动代码:

private function movement():void
    {
        if(moveLeft)
        {               
            _vx = -5;                                   

            faceLeft = true;
            faceRight = false;                          
        }
        else if(moveRight)
        {
             _vx = 5;                                   

            faceLeft = false;
            faceRight = true;       
        }

        else if(jump)
        {
            //_player.y += vertMove;    
            _vy = -15;
        }
    }
在哪里使用它:

private function enterFrameHandler(e:Event):void
    {
        //Upon entering a frame;
        //Gravitate Player
        _vy += 1.75;

        //Move Player
        _player.x += _vx;
        _player.y += _vy;

        //Process Collisions for Player
        processCollisions();

        //Scroll map
        scrollStage();
    }

您的
\u player.y-=0.1在while循环中与此有关吗?可能,但我不确定如何着手修复它。因为这意味着将它们推到地板上方(即反重力)。等我修好闪光灯的时候,我马上要玩一玩。