Sha*_*esh 0 iphone nsdictionary cocos2d-iphone cgpoint
我正在开发一款游戏,其中我试图点击两种不同的类型,如果分别点击单击和双击.
继承人我在触摸开始的方法:
- (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;
}
}
}
Run Code Online (Sandbox Code Playgroud)
现在,perform selector(startTimer:)在我接触到的点的坐标NSPoint(我正在使用NSDictionary)所有我想知道的是......我们如何将这些点转换为CGPoints ...?
不知道怎么办呢?
任何帮助将得到真正的赞赏.
Him*_*dav 15
如果你正在使用,NSValue你可以CGPoint从那里使用CGPointValue.
例如
NSDictionary * touchloc = [NSDictionary dictionaryWithObject:[NSValue valueWithCGPoint:location] forKey:@"location"];
CGPoint points = [[touchloc valueForKey:@"location"] CGPointValue];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4069 次 |
| 最近记录: |