2 daffodilgirl DaffodilGirl 于 2013.04.11 11:29 提问

NSDictionary 到 CGPoint

正在开发一个游戏,其中需要子弹单击和双击分别出现不同的效果。

在touch开始方法中:

- (void)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event 
{
    for( UITouch *touch in touches ) 
    {

        CGPoint location = [touch locationInView: [touch view]];
        location = [[CCDirector sharedDirector] convertToGL: location];

        NSLog(@"TOUCH LOCATION IN TOUCH BEGAN  = (%f , %f)", location.x , location.y);

        NSUInteger tapCount = [touch tapCount];

        switch (tapCount)
        {
            case 1:
            {
                NSDictionary * touchloc = [NSDictionary dictionaryWithObject:[NSValue valueWithCGPoint:location] forKey:@"location"];
                [self performSelector:@selector(startTimer:) withObject:touchloc afterDelay:3];
                break;
            }   
            case 2:
            {
                [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(startTimer) object:nil];
                [self performSelector:@selector(removeBall) withObject:nil afterDelay:1];
                break;
            }
            default:
            {
                break;
            }
        }
  }

现在在perform selector(startTimer:)得到NSPoint触屏的坐标点。我想知道怎么将这些坐标点转换成CGPoints?

1个回答

g989_1314125
g989_1314125   2013.04.11 15:48
已采纳

CGPointCreateDictionaryRepresentationCGPointMakeWithDictionaryRepresentation

Csdn user default icon
上传中...
上传图片
插入图片