Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
HoPGoldy opened this issue Jul 6, 2024 · 0 comments
Open

Comments

@HoPGoldy
Copy link

HoPGoldy commented Jul 6, 2024

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 HoPGoldy changed the title PIXI8 tilemap moves the wrong distance when app.stage.position updated PIXI 8 tilemap moves the wrong distance when app.stage.position updated Jul 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant