One makes objects interactive with setInteractive().
Apparently this code can only be executed once on an object? Afterwards have to set
this.setInteractive({ draggable: false, cursor: "pointer" })
doesn’t seem to work (?)
this.input.cursor = "grab"
this does work but it doesn’t seem proper (default / scene scope…) ?
scene.input.setDefaultCursor("grabbing")
More on this here, but it seems dated:
https://rexrainbow.github.io/phaser3-rex-notes/docs/site/cursor/
Additionally I wonder why my cursor resets when clicking:
samme
July 2, 2020, 3:50pm
2
No good way for this, I guess. Try
var input = this.input;
input.on('dragstart', function () {
input.manager.setCursor({ cursor: 'grabbing' });
});
input.on('dragend', function () {
input.manager.resetCursor({ cursor: true });
});
samme
July 3, 2020, 5:37pm
3
I think that may be best as long as you avoid setting per-game object cursors (e.g., in setInteractive()
), which would override the default cursor.
Hi,
i got a similar problem.
I’m using this code on interactive elements:
this.on('cell.over', function (cellContainer, cellIndex, pointer) {
this.scene.input.setDefaultCursor('url(images/system/cursor_hero.png), pointer');
this.glow( cellContainer );
}, this)
It works. But in network-manager i see each time the cursor is changed to this image, a new request to my website:
Can i set an CSS-Class for this cursor style?
I cant find any solution to give the page a default cursor style for each different cursor state.
Currently i only apply this via css:
html, body {
cursor: url(/images/system/cursor_normal.png) 0 0 , default;
}
The same way i want to say “use this image if cursor change to ‘grabbing’ or ‘moving’ or what ever”
Is this somehow possible?
Thx!
Greetings.
samme
January 21, 2022, 6:41pm
5
You could do
canvas.normal { cursor: url(normal.png); }
canvas.pointer { cursor: url(pointer.png); }
const { classList } = this.game.canvas;
classList.remove('normal');
classList.add('pointer');
But I don’t if that will change the network activity at all. On a dev web server with caching disabled I think multiple requests are normal.