私は次のコードを持っています:
- (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);
これは機能しません