-
Notifications
You must be signed in to change notification settings - Fork 64
Open
Description
I added the following code in examples/demo/basic.js to make it support mouse dragging, but the tilemap moved incorrectly by twice the distance.
await app.init({
width: 800,
height: 600,
preference: searchParams.get('preference') || 'webgl',
hello: true
});
const tilemap = new PIXI.tilemap.CompositeTilemap();
// ------------------------------------------------- added code -------------------------------------------------
let panPos = undefined;
app.canvas.addEventListener('mousemove', (e) => {
if (!panPos) return;
app.stage.position.x += e.pageX - panPos.x;
app.stage.position.y += e.pageY - panPos.y;
panPos = { x: e.pageX, y: e.pageY };
});
app.canvas.addEventListener('mousedown', (e) => {
panPos = { x: e.pageX, y: e.pageY };
});
app.canvas.addEventListener('mouseup', (e) => {
panPos = undefined;
});
// ------------------------------------------------- added code end -------------------------------------------------
document.body.appendChild(app.canvas);
app.stage.addChild(tilemap);examples of issue
It can be found that the Sprite added directly on the stage can follow the movement of the mouse very well, but the tilemap moves at twice the distance. After my test, modifying the stage.scale also has similar problems.
ivanpopelyshev, Zolo101 and aedan-phntm
Metadata
Metadata
Assignees
Labels
No labels
