我有以下代码:
- (void)panning:(UIPanGestureRecognizer *)recognizer {
CGPoint position;
//CGPoint velocity;
//velocity = [recognizer velocityInView:[CCDirector sharedDirector].view];
switch( recognizer.state ) {
case UIGestureRecognizerStatePossible:
break;
case UIGestureRecognizerStateBegan:
{
position = [recognizer locationInView:[CCDirector sharedDirector].view];
for (CCSprite *sprite in movableSprites) {
if (CGRectContainsPoint(sprite.boundingBox, position)) {
selSprite = sprite;
break;
}
}
break;
}
case UIGestureRecognizerStateChanged:
{
position = [recognizer locationInView:[CCDirector sharedDirector].view];
CGPoint yInvertedPosition = CGPointMake(position.x, -position.y);
[selSprite setPosition:position];
break;
}
case UIGestureRecognizerStateFailed:
break;
case UIGestureRecognizerStateEnded:
break;
case UIGestureRecognizerStateCancelled:
break;
}
}
当我拖动一个精灵时,它在 X 轴上移动正常,但它在 Y 轴上倒置。
我怎样才能转换它?
CGPoint yInvertedPosition = CGPointMake(position.x, -position.y);
这不起作用