-
Notifications
You must be signed in to change notification settings - Fork 7.1k
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
pageAlignHorizontally and pageAlignVertically set too late: game jumps to center #2311
Comments
Nice to see this is marked as 'feature request', but to me this is also an issue/bug and I was hoping this was fixed in the next Phaser, but unfortunately it isn't. This bug looks like a difficult thing to avoid/work around without changing the Phaser code, even if I do my own resizing. Will this be in the pipeline to fix anytime soon in Phaser? |
It has worked in this manner for a long time now. You've the ability to On Saturday, 26 March 2016, Friksel notifications@github.com wrote:
Photon Storm Ltd. Skype: richard.davey Registered in England and Wales. |
Thanks for your reaction @photonstorm . I guess we have a misunderstanding here. You wrote that it has worked in this manner for a long time. I wish that was the case, but unfortunately according to the forum there seems to be more people facing this issue. An alternative option for me would be to be able to set an existing canvas as a destination for Phaser. But I can't find any documentation/code on that, so it looks like Phaser always creates its own canvas by javascript. In short: I can't find a way to fix this without changing Phaser itself. Anyway, I can understand you have a lot on your mind right now and that you are really busy. You have your company, the upcoming Lazer project, newsletters, your website, forum, issues, your book and so on. So I can understand if you have other priorities on the moment, but if you can find a minute someday in the future to look at this that would mean the world to me! |
Hey @Friksel, in reference to @photonstorm's post, this is a really easy fix if you just write your own CSS to center your game container.
|
@anthonysapp Please read my posts. |
Using your own canvas element is now supported in the dev branch. |
@anthonysapp is right. The fourth argument when creating a new If it's jumping for some reason, you can default it to |
@rjungemann It's all good, this is closed. Rich enabled passing your own canvas element now, even though this issue could have been solved by writing some custom CSS and setting the game's "width" and "height" properties to "100%" in the gameConfig and using some custom Phaser ScaleManager settings. |
I posted this issue to help you guys make Phaser better, but I didn't expect this. This is getting ridiculous by now. Lots of users are using Phaser to not have to invent the wheel again. Ofcoarse it's open source and free and I'm happy that you guys put so much efford in this. I wonder if you guys even looked in the code to fix it, 'cause to me it seems to be only a matter of sequencial order that is going wrong inside the lib, like I wrote before. It's really nice Phaser has a scalemanager and it seems to be well thought through. But what's the use of having a scalemanager if it's not working correctly? And I have to switch it off and create my own functions/css on a wrapper? Building in the option to be able to use an already existing canvas-object could have been a workaround I could be more satisfied with. But even with that canvas option available, I hate to tell you it's still not working. The ResetCanvas function (in the latest DEV) of Phaser is ALWAYS resetting canvas width, height and margins (lines 77103 to 77121), no matter how I setup the gameconfig object (even on NO_SCALE and not setting alignments). Yes, I could put another wrapper around the canvas to even avoid this issue and all build in phaser code. But I do everything to optimize my code on projects where I can and write clean code and this just doesn't feel right. With chosing Phaser I thought I could rely on a lib where issues at least are taken seriously. |
Neither myself or @rjungemann actually work on this project, we're just users like you. From what I have seen, issues are taken extremely seriously and Rich and team do their best to be active in the community and fix issues. I definitely don't think threatening to use another library is going to make a difference in the long run. Before, I was simply trying to point out that there are methods to get around this issue using CSS. It is, after all, a game framework for web games, so I don't think it's "dirty" or reinventing the wheel to use other web technologies to achieve what you want to. I wasn't trying to offend but clearly I have. The issue is closed now so this'll be my last reply. See you on the Slack channel and the forums. |
Even if you set pageAlignHorizontally/pageAlignVertically inside the very first function of the first state (boot state, init function) there is always an ugly visible jump of the game going from left to center.
I think this is a bug; it seems like scaleManagers 'pageAlignHorizontally' and 'pageAlignVertically' are set too late (somewhere after puting the canvas inside the dom and/or rendering the canvas for the first time).
(There is also a visible scaling of elements at initial state by the way)
When looking inside phaser-2.4.4.js it seems like it's going wrong inside the 'boot'-function. Because when I set the align-values just before this.setUpRenderer(): (line 34330 in phaser-2.4.4.js) it's not jumping anymore:
As said above it seems like there is also something going wrong with scaling at initialisation. But can't find the time at the moment to look at that more closely now.
But my preference would be to be able to set the alignment-values next to the scaling mode from inside the gameconfig. That would be great!
Example code where the game 'jumps' from left to center:
The text was updated successfully, but these errors were encountered: