【发布时间】:2012-05-24 12:49:22
【问题描述】:
我正在开发一款游戏,如果子弹分别在单击和双击上,我会尝试发射两种不同类型的子弹。
这是我在触摸开始方法中所做的:
- (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 中触摸的点的坐标(因为我正在使用NSDictionary)
我只想知道..我们如何将这些点转换为 CGPoints..?
知道我该怎么做吗?
任何帮助将不胜感激。
【问题讨论】:
标签: iphone cocos2d-iphone nsdictionary cgpoint