我的游戏中有一个角色,我可以左右移动并跳跃。我用触摸开始做这件事。但当我向左移动(不断触摸屏幕->使角色越来越快)时,它只会在我释放它时跳跃。我想一边跳一边向左移动。
以下是我的一些代码:
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
CGPoint point = [touch locationInView:self.view];
if((point.x < moveLeftButton.frame.size.width))
{
if((point.y > JumpButton.frame.size.height))
{
leftSide = YES;
sanchez.image = [UIImage imageNamed:@"characterL2"];
}
}
if((point.x) > (backGround.frame.size.width - moveRightButton.frame.size.width))
{
if((point.y > JumpButton.frame.size.height))
{
rightSide = YES;
sanchez.image = [UIImage imageNamed:@"characterR2"];
}
}
if( notJumping && (point.y < JumpButton.frame.size.height) && (sanchezStopAll == NO))
{
AudioServicesPlaySystemSound(jump);
sanchezJumping = 5.5;
notJumping = NO;
}
[self animation];
}
我没有使用buttonPressed,因为它们是隐藏的,我想你不能单击隐藏的按钮。
如果不隐藏,它的外观如下:
感谢您的帮助。