var config = {
type: Phaser.AUTO,
width: 800,
height: 600,
backgroundColor: ‘#2d2d2d’,
parent: ‘phaser-example’,
scale: {
mode: Phaser.Scale.FIT,
parent: ‘phaser-example’,
width: 800,
height: 600
},
dom: {
createContainer: true
},
scene: {
create: create
}
};
var game = new Phaser.Game(config);
function create ()
{
var element2 = this.add.dom(500, 200, ‘div’, ‘background: linear-gradient(to bottom, rgba(30,87,153,0) 0%,rgba(30,87,153,0.8) 15%,rgba(30,87,153,1) 19%,rgba(30,87,153,1) 20%,rgba(41,137,216,1) 50%,rgba(30,87,153,1) 80%,rgba(30,87,153,1) 81%,rgba(30,87,153,0.8) 85%,rgba(30,87,153,0) 100%); width: 220px; height: 100px; font: 48px Arial; font-weight: bold; color: white; user-select: none;pointer-events: none !important’, ‘Phaser 3’);
// element2.setBlendMode(‘HUE’);
element2.setInteractive({ useHandCursor: true, draggable: true });
// let startX = -element2.originX * element2.displayWidth;
// let startY = -element2.originY * element2.displayHeight;
// element2.input.hitArea = new Phaser.Geom.Rectangle(startX, startY, element2.displayWidth, element2.displayHeight)
element2.on(“drag”, (, dragX, dragY) => {
element2.x = dragX;
element2.y = dragY;
});
}
when i set interactive for a dom element, dom hit area not true. So a reset hit area as comment lines. But i get an error when mouse inside dom element and i drag element, drag event not fire! Even when i comment the lines.
The lab link: https://labs.phaser.io/edit.html?src=src/game%20objects/dom%20element/blend%20mode.js&v=3.24.1