Phaser 中的旋转和 getBounds()

标签 rotation sprite bounds phaser-framework

我正在使用 Phaser 2.3.0,我想知道旋转 Sprite 的边界。

但是当我更改 sprite.rotation 时,sprite.getBounds() 的值不会更改:

sprite = game.add.sprite(0, 0, "img"); // game.load.spritesheet("img", "grid.png", 32, 32);
console.log(sprite.getBounds()); // Object { x: 0, y: 0, width: 32, height: 32, type: 22 }
sprite.rotation = 0.52; // 30°
console.log(sprite.getBounds()); // Object { x: 0, y: 0, width: 32, height: 32, type: 22 }

出了什么问题?

如何获得正确的边界?

最佳答案

据我所知,getBounds() 将返回对象适合的最小可能矩形,并且由于 Phaser.Rectangle 没有旋转属性,两次都会得到相同的矩形。

关于Phaser 中的旋转和 getBounds(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30792074/

相关文章:

Android OpenGL 以触摸移动的方向旋转立方体

actionscript-3 - 我的 Sprite 应该在 ActionScript 3 中共享位图吗?

c++ - 用 "layers"填充

java - LibGDX Sprite 渲染问题

Php Gd Sprite 创建

java - 为什么我收到此错误 "Exception in thread "main"java.lang.ArrayIndexOutOfBoundsException : 1"

ios - 旋转时更改 UIScreen 的大小

iphone - OpenGL ES : Rotating 3d model around itself

javascript - 在RaphaelJS中,如何将旋转的文本对齐到底部?

iphone - 如何在 iPhone 不自动旋转的情况下检测旋转?