0
我有object1(紋理),它在我的手指下移動,我想如何。 但我不知道如何爲object2(紋理)設置條件來產生推送效果。 Object1的大小:128x64,Object2:128x128。 那我到目前爲止在x軸上效果很好。在y軸上沒有效果。object1在x軸上推物體2,但在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;}
在y軸的發言中,我刪除了一些X條件:
if(gameObject1.y<gameObject2.y)
{ gameObject2.y+=16; }
else
if(gameObject1.y>gameObject2.y)
{ gameObject2.y-=16;}
現在斜着向上移動端朝下,而不是街道X & Y軸