有人可以帮我转换这个 cocos2d-iphone 特定代码以与 cocos2d-mac 模板兼容吗?
场景中的精灵使用此代码,以便可以拖动它们。我在尝试弄清楚如何转换此代码以与 cocos2d-mac 模板兼容时遇到困难。我很感激任何帮助。
////////////////////////////////////////////////////
/////properties for touches moved
- (void)ccTouchMoved:(UITouch *)touch withEvent:(UIEvent *)event {
CGPoint touchLocation = [self convertTouchToNodeSpace:touch];
CGPoint oldTouchLocation = [touch previousLocationInView:touch.view];
oldTouchLocation = [[CCDirector sharedDirector] convertToGL:oldTouchLocation];
oldTouchLocation = [self convertToNodeSpace:oldTouchLocation];
CGPoint translation = ccpSub(touchLocation, oldTouchLocation);
[self panForTranslation:translation];
}
This code is used by sprites on the scene so they can be dragged. I am having trouble trying to figure out how to convert this code to be compatible with the cocos2d-mac template. I appreciate any help.
////////////////////////////////////////////////////
/////properties for touches moved
- (void)ccTouchMoved:(UITouch *)touch withEvent:(UIEvent *)event {
CGPoint touchLocation = [self convertTouchToNodeSpace:touch];
CGPoint oldTouchLocation = [touch previousLocationInView:touch.view];
oldTouchLocation = [[CCDirector sharedDirector] convertToGL:oldTouchLocation];
oldTouchLocation = [self convertToNodeSpace:oldTouchLocation];
CGPoint translation = ccpSub(touchLocation, oldTouchLocation);
[self panForTranslation:translation];
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
添加“CGPoint oldMouseLocation_;”伊瓦尔进入你的班级。
Add "CGPoint oldMouseLocation_;" ivar into your class.