You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, I've been searching for a solution of this problem for some days. I've found it by working on some ideas.
When the camera is set with this.cameras.main.startFollow(...) to something and it moves, the activePointer is not updating his worldX and Y position. It only gets updated when the cursor is moved.
You can easly check this behaviour with this sample code. Just open the inspector and read the console.log() in the console. You'll see how the worldX/Y position doesn't update when the camera is moving, only when the pointer(mouse) moves.
I expected to get thouse worldX/Y values get updated when the camera moves, therefore changing the position the pointer respect to the world coords.
Example Test Code
//Based on: https://labs.phaser.io/edit.html?src=src\camera\follow%20user%20controlled%20sprite.js
var config = {
type: Phaser.AUTO,
parent: 'phaser-example',
physics: {
default: 'arcade',
},
scene: {
preload: preload,
create: create,
update: update
}
};
var player;
var cursors;
var game = new Phaser.Game(config);
function preload ()
{
this.load.image('bg', 'assets/pics/the-end-by-iloe-and-made.jpg');
this.load.image('block', 'assets/sprites/block.png');
}
function create ()
{
// Set the camera and physics bounds to be the size of 4x4 bg images
this.cameras.main.setBounds(0, 0, 1920 * 2, 1080 * 2);
this.physics.world.setBounds(0, 0, 1920 * 2, 1080 * 2);
// Mash 4 images together to create our background
this.add.image(0, 0, 'bg').setOrigin(0);
this.add.image(1920, 0, 'bg').setOrigin(0).setFlipX(true);
this.add.image(0, 1080, 'bg').setOrigin(0).setFlipY(true);
this.add.image(1920, 1080, 'bg').setOrigin(0).setFlipX(true).setFlipY(true);
cursors = this.input.keyboard.createCursorKeys();
player = this.physics.add.image(400, 300, 'block');
player.setCollideWorldBounds(true);
this.cameras.main.startFollow(player, true, 0.05, 0.05);
}
function update ()
{
player.setVelocity(0);
if (cursors.left.isDown)
{
player.setVelocityX(-500);
}
else if (cursors.right.isDown)
{
player.setVelocityX(500);
}
if (cursors.up.isDown)
{
player.setVelocityY(-500);
}
else if (cursors.down.isDown)
{
player.setVelocityY(500);
}
console.log(this.input.activePointer.worldY)
}
Additional Information
The issue is seen in the ´console.log()´ of the example code. You can also see the behavior in this gif of my mockup. The cursor point of the green line is not getting updated with the mouse position when the camera is moving.
The text was updated successfully, but these errors were encountered:
Version
Description
Hello, I've been searching for a solution of this problem for some days. I've found it by working on some ideas.
When the camera is set with
this.cameras.main.startFollow(...)
to something and it moves, the activePointer is not updating his worldX and Y position. It only gets updated when the cursor is moved.You can easly check this behaviour with this sample code. Just open the inspector and read the console.log() in the console. You'll see how the worldX/Y position doesn't update when the camera is moving, only when the pointer(mouse) moves.
I expected to get thouse worldX/Y values get updated when the camera moves, therefore changing the position the pointer respect to the world coords.
Example Test Code
Additional Information
The issue is seen in the ´console.log()´ of the example code. You can also see the behavior in this gif of my mockup. The cursor point of the green line is not getting updated with the mouse position when the camera is moving.
The text was updated successfully, but these errors were encountered: