tilemap icon indicating copy to clipboard operation
tilemap copied to clipboard

`PIXI 8` tilemap moves the wrong distance when `app.stage.position` updated

Open HoPGoldy opened this issue 1 year ago • 2 comments

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

example

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.

HoPGoldy avatar Jul 06 '24 11:07 HoPGoldy

I also hit this issue and the related PR fixes this. The composite tilemap wasn't following parent camera container position as it was previously. It only seemed to be an issue when I was changing the zIndex higher than the 'player' it was tracking against though which was unusual.

aedan-phntm avatar Aug 31 '25 23:08 aedan-phntm

I also hit this issue with a completely different scenario. If you add some pixi filter to a sprite, all CompositeTilemap sprites with a higher zIndex will be inverted offset of the filtered sprite. The PR referenced in this fix also resolves the issue.

https://github.com/user-attachments/assets/f52b5c20-f14d-4040-97f4-9d816b5b90ce

aceysmith avatar Oct 11 '25 00:10 aceysmith