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

Dom elements get out of place when zooming #6607

Closed
luismolinav opened this issue Sep 7, 2023 · 4 comments
Closed

Dom elements get out of place when zooming #6607

luismolinav opened this issue Sep 7, 2023 · 4 comments

Comments

@luismolinav
Copy link

Version

  • Phaser Version: 3.55.2 / 3.60.0
  • Operating system: Windows 10
  • Browser: Chrome 116.0.5845.141

Description

The dom elements added to the scene get out of place when the zoom changes.

Example Test Code

Example by slightly modifying in the following link:
https://labs.phaser.io/edit.html?src=src/game%20objects%5Cdom%20element%5Cform%20input.js

class Example extends Phaser.Scene
{
preload ()
{
this.load.html('nameform', 'assets/text/loginform.html');
this.load.image('pic', 'assets/pics/turkey-1985086.jpg');
}

create ()
{
this.add.image(400, 300, 'pic');
const text = this.add.text(10, 10, 'Text', { color: 'white', fontFamily: 'Arial', fontSize: '32px '});
const element = this.add.dom(400, 300).createFromCache('nameform');
// Removed some code before and added this
this.cameras.main.zoomTo(0.5, 2000);
setTimeout(()=>{ this.cameras.main.zoomTo(1.5, 2000) },4000)
}
}

const config = {
type: Phaser.AUTO,
width: 800,
height: 600,
parent: 'phaser-example',
dom: { createContainer: true },
scene: Example
};

Additional Information

@photonstorm
Copy link
Collaborator

This issue has been mentioned on Phaser. There might be relevant details there:

https://phaser.discourse.group/t/dom-elements-get-out-of-place-when-using-zoom/13527/3

@luismolinav
Copy link
Author

Hello @photonstorm
Is the same, I'm the one that wrote that, and by suggestion there posted this issue.

@photonstorm
Copy link
Collaborator

@luismolinav those messages (about Discourse) are automatic, I don't write them personally.

@photonstorm
Copy link
Collaborator

You're right, they do - but without wanting to get into perspective handling and scaling the DOM container to match the camera zoom, I feel like this is a valid limitation. Frustrating, yes, but the DOM Game Objects are only really meant for very simple tasks (buttons, login form), anything more complex should consider something like our Vue Template.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants