在此代码中,我想删除垂直移动(我不希望用户能够在屏幕上向上或向下移动uibutton,但只能向左或向右移动) 我将如何继续这样做? 下面是代码:
- (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceration {
if (acceration.x < 0) {
XM += 1;
AccelPoint.x = XM;
character.center = AccelPoint;
}
if (acceration.x > 0) {
XM -= 1;
AccelPoint.x = XM;
character.center = AccelPoint;
}
if (acceration.y < 320) {
//60
YM += 1;
AccelPoint.y = YM;
character.center = AccelPoint;
}
if (acceration.y > 320) {
//60
YM -= 1;
AccelPoint.y = YM;
character.center = AccelPoint;
}
X = acceration.x*50;
XM += X;
AccelPoint.x = XM;
//58 for both
Y = acceration.y*50;
YM-= Y;
AccelPoint.y = YM;
character.center = AccelPoint;
if (AccelPoint.x < -5) {
AccelPoint.x = -5;
}
//320
if (AccelPoint.x > 325) {
AccelPoint.x = 325;
}
//0
character.center = AccelPoint;
if (AccelPoint.y < 0) {
AccelPoint.y = 0;
//15
}
if (AccelPoint.y > 240) {
//AccelPoint.y = 240;
//465
}
character.center = AccelPoint;
}