iPad 和 iPhone 的坐标系有什么区别?
我正在尝试在 cocos2d 中制作一个可以在多个平台(iPad、iPhone、iPod touch)上使用的应用程序。假设我将一个点设置为 (360,160)。该点将显示在 iPhone 屏幕左侧四分之三处和屏幕中间位置。它是否也会在 ipad 上执行此操作,或者我是否必须将点设置为 (768,384) 才能实现此结果?或者它是否拉伸屏幕。我想我必须这样做,但我不确定,因为当我在 iPhone 或 iPad 模拟过程中获得屏幕尺寸时,无论如何我总是得到 480x320。
I'm trying to make an application in cocos2d that can be used on multiple platforms (iPad, iPhone, iPod touch). Let's say I set a point to (360,160). The point would show up three fourths from the left and half way up the screen on the iPhone. Would it also do this on the ipad, or would I have to set the point to (768,384) to achieve this result? or does it stretch the screen. I figured I would have to, but am unsure because when I get the size of the screen during an iPhone OR iPad simulation, I always get 480x320 regardless.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
暂时忽略 iPhone 4,设备将其屏幕与其坐标空间 1:1 映射,因此 iPhone 的坐标空间大小为 320x480(或横向模式下为 480x320),而 iPad 的坐标空间大小为 768x1024(或横向模式下为 1024x768。)
当然,iPhone 4 使设备像素增加了四倍,但保持了与其他 iPhone 相同的坐标空间,并缩放绘图以匹配屏幕的分辨率。
Ignoring the iPhone 4 for the moment, the devices map their screens 1:1 with their coordinate spaces, so the iPhone has a coordinate space with size 320x480 (or 480x320 in landscape mode) while the iPad has a coordinate space with size 768x1024 (or 1024x768 in landscape mode.)
The iPhone 4, of course, quadruples the device pixels, but maintains an identical coordinate space to other iPhones and scales drawing to match the screen's resolution.
注意:如果您在 iPad 模拟器上运行时获得相同的分辨率,则意味着您没有将项目转换为 iPad 项目。或者您没有将其作为本机 iPad 应用程序启动,而是将其作为 iPad 模拟器中的 iPhone 应用程序启动。
确保您已完成将目标升级到 iPad -> Xcode:项目菜单,选择 iPad 的升级目标
在模拟器中运行时,请确保选择 iPad 模拟器作为活动可执行文件。
Note: if you get the same resolution running on the iPad Simulator it means you did not convert your project as an iPad project. Or you did not start it as a native iPad application but rather the iPhone App within the iPad Simulator.
Make sure you have gone through upgrading your target to iPad -> Xcode: Project menu, choose Upgrade Target for iPad
When running in the Simulator make sure you chose iPad Simulator as Active Executable.