我是COCOS2D的新手,我现在正试图将CGPoint作为参数传递给线程函数.我不知道如何将它包裹在一个物体中.有人可以帮忙吗?提前谢谢〜
您可以使用CGPoint创建NSValue并将其作为withObject参数传递:
NSValue *value = [NSValue valueWithCGPoint:CGPointMake(1.2, 22.6)];
[self performSelectorInBackground:@selector(someSelector:) withObject:value];
Run Code Online (Sandbox Code Playgroud)
然后在你的选择器中,你可以访问NSValue中的CGPoint,如下所示:
CGPoint point = [value CGPointValue];
Run Code Online (Sandbox Code Playgroud)