-
-
Notifications
You must be signed in to change notification settings - Fork 171
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
(phaser.d.ts) Config.width/height can be string? #25
Comments
Hello @gnesher! Strings are accepted as valid for game height and width because you might want to use percentages (f.e. 60% width and 100% height). Even though I haven't used this yet, I would leave it. Is that what you meant? Have a look at the official phaser code. |
Oh interesting. I've been following a simple tutorial (https://gamedevacademy.org/phaser-3-tutorial/) which tells you to put a sprite in the middle of the screen using this.sys.game.config.height / 2 which is now invalid. Not sure how to work around that except to manually cast these to number when I know the value |
That is true, this will be invalid. The best thing would be probably, that if you choose to use a string f.e. 20%, that the phaser framework would calculate the absolute size and save that as the width so you can access it with |
@gnesher Are you going to open a discussion in the official phaser repository or will you leave it as it is? |
Why are we accepting strings as valid values for the game height / width? It just means I have to cast them to whenever I want to perform arithmetic operations (otherwise I get the following error: [ts] The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type. [2362])
Happy to open a pull request, just didn't know if it's there for a reason
The text was updated successfully, but these errors were encountered: