我遇到了碰撞行为问题。我有 2 种类型的对象从屏幕底部落下并与屏幕底部的图像发生碰撞。碰撞效果很好,但是当我移动图像时,它会重新缩放并经常闪烁。感谢您的建议。
移动图像的代码。
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
//CGPoint svpt = [[touches anyObject] locationInView:self.view];
CGPoint pt = [[touches anyObject] locationInView:self.playerMove];
CGRect frame = [self.playerMove frame];
frame.origin.x += (pt.x - self.startLocation.x);
frame.origin.y += (pt.y - self.startLocation.y);
frame.origin.x = MIN(MAX(frame.origin.x, -10), 240);
frame.origin.y = MIN(MAX(frame.origin.y, 430), 430);
self.playerMove.frame = frame;
[_animator updateItemUsingCurrentState:self.playerMove];
}
碰撞代码。
_collision = [[UICollisionBehavior alloc]initWithItems:@[self.hammerImage,self.playerMove]];
[_animator addBehavior:_collision];