What am I doing wrong here?
I want to draw a 100px square in the top-left corner. The Phaser coordinate system has (0, 0) in the top-left, with x increasing rightward, and y increasing downward. So, you would expect the proper origin coordinates for the square to be (0, 0).
But, for me, it’s 400, 250. WTF.
Here’s the entire app:
const canvas = document.createElement('canvas')
document.body.appendChild(canvas)
class MyScene extends Phaser.Scene {
create() {
this.cameras.main.setBackgroundColor('rgba(255, 0, 0, 1)');
this.cameras.main.zoom = 1
let debugGraphics = new Phaser.GameObjects.Graphics(this, { x: 0, y: 0 })
debugGraphics.lineStyle(1, 0x00ffff, 1)
debugGraphics.fillStyle(0x555555, 1)
let squarePoints = [
{ x: 0, y: 0 },
{ x: 100, y: 0 },
{ x: 100, y: 100 },
{ x: 0, y: 100 }
]
debugGraphics.strokePoints(squarePoints, true, true)
debugGraphics.fillPoints(squarePoints, true, true)
debugGraphics.generateTexture('square')
this.add.sprite(405, 255, 'square') // this SHOULD be 0, 0
}
}
new Phaser.Game({
type: Phaser.CANVAS,
canvas,
width: 800, height: 500,
scene: [MyScene]
})
What am I doing wrong?