在缩小状态下玩游戏有好处吗?
我正在开发一个带有大障碍物和精灵的游戏(在iPhone的cocos2d+box2d中),然后在缩小我的精灵和图层(通过增加cameraZ)后,我让我的游戏由用户玩,这会导致触摸检测出现一些问题的动态对象。
这可以说是一种很好的合作方式吗?如果否,那么正常工作的解决方案是什么(考虑到我已经采用这种方法到目前为止)?
注意:[self.camera setEyeX:0 eyeY:0 eyeZ:180];
(我使用这条线进行缩小,通过增加相机距离我的精灵z)
I'm developing a game with large obstacle and sprites(in cocos2d+box2d for iPhone), then after zooming out my sprites and layer (by increasing cameraZ), I make my game to play by user, which causes some problem in touch detection of dynamic objects.
Can it be said a good approach to work with? If No then what will be the solution to work properly(consider that I have traveled so far with this approach)?
NOTE:[self.camera setEyeX:0 eyeY:0 eyeZ:180];
(i'm using this line for zooming out, putting camera far from my sprites by increasing z)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您使用相机进行缩放,那么 cocos2d 将不再正确地将您的触摸位置转换为 opengl 坐标,因为它不会反转相机变换。我建议在对象所在的图层上使用比例来实现缩放。这使您可以精确控制缩放系数,并且当您使用方法将触摸从屏幕空间转换为节点空间时,触摸将被正确转换。
If you use a camera for zooming then cocos2d will no longer correctly convert your touch locations to opengl coordinates, since it doesn't invert the camera transform. I would recommend using scale on the layer that your objects reside on to implement zooming. This gives you precise control over the zoom factor and touches will be correctly transformed when you use methods to convert touches from screen space to node space.