Trying to map a pointerup event to world coordinates.
My sprite coordinates are x,y = 180,312 and width,height are 120,140px
This is my pointerup pointer object with zoom = 1.
{
"id": 0,
"camera": {
"name": "",
"x": 0,
"y": 0,
"width": 1536,
"height": 334,
"zoom": 1,
"rotation": 0,
"roundPixels": false,
"scrollX": 0,
"scrollY": 0,
"backgroundColor": "rgba(0,0,0,0)"
},
"button": 0,
"buttons": 0,
"position": {
"x": 174,
"y": 290
},
"prevPosition": {
"x": 174,
"y": 290
},
"midPoint": {
"x": 180.4095352275107,
"y": 291.35913129895874
},
"velocity": {
"x": -6.409535227510702,
"y": -1.3591312989587436
},
"angle": -2.93263944713527,
"distance": 6.552051565770063,
"smoothFactor": 0,
"motionFactor": 0.2,
"worldX": 174,
"worldY": 290,
"moveTime": 4001.90500007011,
"downX": 174,
"downY": 290,
"downTime": 3983.5800000000745,
"upX": 174,
"upY": 290,
"upTime": 4071.155000012368,
"primaryDown": false,
"isDown": false,
"wasTouch": false,
"wasCanceled": false,
"movementX": 0,
"movementY": 0,
"identifier": 0,
"pointerId": null,
"active": true,
"time": 0,
"deltaX": 0,
"deltaY": 0,
"deltaZ": 0,
"event": {
"isTrusted": true
},
"downElement": {},
"upElement": {}
}
And my scene is created like so:
export default class RandomScene extends Phaser.Scene {
world;
constructor() {
super({ key: 'RandomScene'})
}
create() {
//this.scene.add('MainScene');
this.cameras.main.setViewport(0, 0, window.innerWidth, window.innerHeight);
this.physics.world.setBounds(-1200,0,3600, 4300);
let world = new ProceduralWorld(this, (new Date()).getTime());
world.createWorld();
}
update() {
}
}
Game config:
const config = {
backgroundColor: '#ffffff',
scale: {
parent: 'phaser-game',
mode: Phaser.Scale.FIT,
autoCenter: Phaser.Scale.CENTER_BOTH,
width: window.innerWidth,
height: window.innerHeight
},
scene: [PreloadScene],
physics: {
default: 'arcade',
arcade: {
debug: false,
gravity: { y: 0 }
}
}
}
Wondering of my game setup is throwing things off, as I don’t see why the point x is less than the sprite x at zoom = 1.