对 Andengine 坐标系感到困惑
当我在 (0,0) 创建一个精灵并且它位于屏幕中心时,我询问相机它的中心是什么(getCenterX 和 getCenterY),它说(640,400)。
我对 Andengine 还很陌生,所以显然有一些关于坐标的基本知识我不理解。
When I create a sprite at (0,0) and it is centered on the screen and I ask the camera what it's center is (getCenterX and getCenterY) it says (640,400).
I am pretty new with Andengine so there's clearly something basic about coordinates that I am not understanding.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
请注意,接受的版本不再有效。现在,AndEngine的坐标已经变成了屏幕的左下角,就像cocos-2d一样。
Note that the accepted version is is not valid anymore. Now, AndEngine coordinates have changed to the bottom-left corner of the screen, like cocos-2d.
如果您使用默认相机,则放置在 0,0 处的 Sprite 将位于屏幕的左上角。如果您移动了相机,0,0 当然可能位于屏幕的“中心”。
注意:缩放精灵会导致它向中心收缩(而不是左上角) - 因此,当缩小时,整个屏幕大小的精灵将出现在中心(而不是收缩到顶部)左角)
If you're using the default camera, a Sprite placed at 0,0 would be at the top-left corner of the screen. If you've moved the camera, 0,0 could be at the 'centre' of the screen of course.
Note: Scaling a sprite causes it to shrink towards it's centre (not it's top-left corner) - so a Sprite which is the whole size of the screen will appear in the centre when scaled-down (rather than shrink up into the top-left corner)