Android object1在x轴上推动object2,但在y轴上没有效果

Android object1在x轴上推动object2,但在y轴上没有效果,android,libgdx,Android,Libgdx,我有object1(纹理)和它在我手指下的移动方式。 但我不知道如何设置object2(纹理)具有推动效果的条件。对象1的大小:128x64,对象2的大小:128x128。 到目前为止,我在x轴上的效果很好。在y轴上没有影响 if(gameObject1.overlaps(gameObject2)){ if(gameObject1.x<gameObject2.x&&gameObject1.y<gameObject2.y+128&&gam

我有object1(纹理)和它在我手指下的移动方式。 但我不知道如何设置object2(纹理)具有推动效果的条件。对象1的大小:128x64,对象2的大小:128x128。 到目前为止,我在x轴上的效果很好。在y轴上没有影响

if(gameObject1.overlaps(gameObject2)){
        if(gameObject1.x<gameObject2.x&&gameObject1.y<gameObject2.y+128&&gameObject1.y>gameObject2.y-64){
            gameObject2.x+=16;
        }else
        if(gameObject1.x>gameObject2.x&&gameObject1.y<gameObject2.y+128&&gameObject1.y>gameObject2.y-64){
            gameObject2.x-=16;
        }

        if(gameObject1.y<gameObject2.y&&gameObject1.x>=gameObject2.x&&gameObject1.x+128<=gameObject2.x){
            gameObject2.y+=16;
        }else
        if(gameObject1.y>gameObject2.y&&gameObject1.x>=gameObject2.x&&gameObject1.x+128<=gameObject2.x){
            gameObject2.y-=16;}
if(gameObject1.重叠(gameObject2)){
if(gameObject1.xgameObject2.x&&gameObject1.ygameObject2.y-64){
gameObject2.x-=16;
}

如果(gameObject1.y=gameObject2.x&&gameObject1.x+128gameObject2.y&&gameObject1.x>=gameObject2.x&&gameObject1.x+128在y轴效果的语句中,您必须满足相同的条件:

gameObject1.x>=gameObject2.x
gameObject1.x+128<=gameObject2.x
gameObject1.x>=gameObject2.x
gameObject1.x+128
gameObject1.x>=gameObject2.x
gameObject1.x+128<=gameObject2.x