我正在開發一款遊戲,其中我試圖分別在單擊和雙擊時分別觸發兩種不同類型的子彈。NSDictionary到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;
}
}
}
現在在我的perform selector(startTimer:)
我得到點的座標,我在NSPoint
觸摸(由於我使用NSDictionary
) 所有我想要的知道是..我們如何將這些點轉換爲CGPoints ..?
任何想法我該怎麼做?
任何幫助將得到真正的讚賞。
一個賈達夫:謝謝老兄:)它的工作就像魅力 – Shailesh
對於我來說,正確的功能保存並返回到cgpoint是NSDictionary的是: 的NSDictionary * touchloc = [NSDictionary dictionaryWithObject:[NSValue valueWi thPoint:cgPointPositionTouchPoint] forKey:@「location」]; CGPoint points = [[touchloc valueForKey:@「location」] pointValue]; –