求一个摇杆控制角色碰撞的思路

发现摇杆碰撞和键盘碰撞,完全不一样。。。。键盘每次都只有一次输入,要么x移动,要么y移动。但是摇杆属于复合键,这样又怎么判断物体的碰撞方向呢?根据我下面的代码,我发现左边碰撞会和上边碰撞起冲突,右边碰撞回合下边碰撞起冲突

onCollisionStay: function (other, self) {

    var selfAabb = self.world.aabb;
    var otherAabb = other.world.aabb;
  
    if(cc.Intersection.rectRect(selfAabb,otherAabb)){
   
        if(this.node.x <0 && selfAabb.xMax > otherAabb.xMax){
           // console.log("左边碰撞");
            this.node.x = otherAabb.xMax+selfAabb.width/2;
        }else if(this.node.x > 0 && selfAabb.xMin < otherAabb.xMin){
            // console.log("右边碰撞");
            this.node.x = otherAabb.xMin-selfAabb.width/2;
        }else if(this.node.y > 0 && selfAabb.yMin < otherAabb.yMin){
             //console.log("上边碰撞");
            this.node.y = otherAabb.yMin-selfAabb.height/2;
        }else if(this.node.y < 0 && selfAabb.yMax > otherAabb.yMax){
             //console.log("下边碰撞");
            this.node.y = otherAabb.yMax+selfAabb.height/2;
        }
    }
}

分支設計不對
應該是
if
if
if
if
而不是
if
else if
else if
else if

或者

橫向
if
else
縱向
if
else