我正在使用 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/