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

Screen scaling problems #609

Open
Jacic opened this issue Oct 23, 2018 · 1 comment
Open

Screen scaling problems #609

Jacic opened this issue Oct 23, 2018 · 1 comment

Comments

@Jacic
Copy link
Contributor

Jacic commented Oct 23, 2018

  • HaxePunk version: 4.0.1, git
  • Target(s): Linux
  • Haxe version: 3.4.7
  • OpenFL/Lime or NME version: OpenFL 8.4.1 Lime 6.4.0

I'm trying to scale my game based on the resolution of the device it's running on, and based on the ScreenScale demo, it looks like I want to do something like this:

HXP.screen.scaleMode = new haxepunk.screen.ScaleMode();
HXP.screen.scaleMode.setBaseSize(800, 600);
HXP.resize(HXP.screen.width, HXP.screen.height);

However, the end result is not what I would have expected. The non-scaled version looks like this:
noscaling
But the scaled version appears like this (scaled to 1200x900):
badscaling
Also notice the mouse position shown in the console. In both screenshots the mouse is in the top left corner, but when the game is scaled everything seems to be offset by at least 100 pixels vertically and horizontally.

I've tried various ScreenScaleModes but to no effect. Am I missing something obvious or is this broken? Until somewhat recently HaxePunk allowed accessing the stage object so I scaled apps using that; this is the first time I've had to use HXP.resize().

@XANOZOID
Copy link
Member

What devices are you trying this on? Are you expecting the size of the window to change?

Take a look into this if you can and tell me if this allows you to achieve what you're looking for:
NME: nme.Lib.stage.resize( WIDTH, HEIGHT );

I'm not sure about openFL. It seems that if Lime is in the target then the OpenFL window class inherits from the Lime window. So when you get the current window you can do something like this

#if lime
window.resize( ... );
#end

You can find more about the window resizing with openfl and lime here . . .
resize function in lime: https://github.com/openfl/lime/blob/develop/src/lime/ui/Window.hx#L420
openfl window class: https://github.com/openfl/openfl/blob/develop/src/openfl/display/Window.hx

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

2 participants