resize main window (stage container) in Windows build?

756 views
Skip to first unread message

Mark

unread,
Sep 24, 2014, 8:49:06 AM9/24/14
to haxe...@googlegroups.com
hi guys,

Trying to set bigger resolution than 800x600 for a windows build, with nme & openfl. If I touch "stage.scaleMode", everything turns into a mess. It looks like hxcpp is buggy.
Not touching the mentioned setting I can work in 1280x720 resolution, however, the window size is still 800x600 on startup.

Questions:
1. How can I resize window -from code- (to set it to 1280x720)? Tried to change project files, window still in 800x600
    1.b. How can I disable WindowBorder or even set it to ToolBoxWindow (ie disable manual window resizing)?
2. How can I make nme/openFL to scale the window size to the desktop?
    E.g. I write a game in 1920x1080, but user's screen is 1024x768 only (as well as different aspect ratio as you can see from this example). What I want is to let 'the system' automatically scale down the game, so it can run either windowed or full screen on a 1024x768 display without trouble, as it would run on my fullHD screen (at worst sprites/text/etc will be smaller).


Thank you for the help in advance.
Mark

Benjamin Dubois

unread,
Sep 24, 2014, 4:00:46 PM9/24/14
to haxe...@googlegroups.com
Have you tried with
Lib.current.stage.scaleMode ?

--
To post to this group haxe...@googlegroups.com
http://groups.google.com/group/haxelang?hl=en
---
You received this message because you are subscribed to the Google Groups "Haxe" group.
For more options, visit https://groups.google.com/d/optout.

Rafael Oliveira

unread,
Sep 24, 2014, 6:48:43 PM9/24/14
to haxe...@googlegroups.com
To disable the manual window resizing, set resizable="false" in the window option in project.xml:
<window if="desktop" orientation="landscape" resizable="false" />


Hugh

unread,
Sep 25, 2014, 1:10:42 AM9/25/14
to haxe...@googlegroups.com
Hi,
So you should be able to call stage.resize(width, height) to set the stage, once the program is running.
The values in the build.xml are the suggested starting size for the window.
If the user resizes/maximised the window, you will get a resize event.
You can try to let the system scale your window for you, but generally, it is better to do this yourself - mainly so you can deal with the "black bar" region yourself.
This is pretty easy.  Say you have designed your game for 1920x1080, on startup and on a resize event, set the transform of you root node.  You can generally use "var root = nme.Lib.current" for this.

first calculate the screen-to-design scale for x and y:
var xScale = 1920/stage.stageWidth;
var yScale = 1080/stage.stageHeight;
If you take the smaller scale, everythign will fit on the screen:
var scale = Math.min(xScale,yScale);
root.scaleX = root.scaleY = scale

So this does the scaling so one dimension will fit exactly, and one may have some space.
Generally, you might then want to centre the active zone:
root.x = (stage.stageWidth - 1920*scale)  /2;
 root.y = (stage.stageHeight - 1080*scale)  /2; 

You then might want to think about drawing something interesting in these areas - but that is up to you.

So it is only a few lines of code to get the scaling how you want it, and doing it yourself gives you a few more options.

(note: programming without compiling - probably an error somewhere)

Hugh

Mark

unread,
Sep 25, 2014, 4:43:16 AM9/25/14
to haxe...@googlegroups.com
Thank you for all the answers guys. Related to scaling, I will go by "manual" as hxcpp is buggy (stage.scaleMode.SHOW_ALL messes up everything if build app against Windows).

Related to the base-problem I tried to describe (and failed :), my issue is with the window's size (CreateWindowEx if you know what I mean), not the stage size. Stage is scalable. The window, the container of stage however is 800x600 and I can't figure out where and how to resize it programatically.

Here's a screen for a better understand: http://tinypic.com/r/2lm43z6/8

thank you again ;)

Hugh

unread,
Sep 26, 2014, 12:45:16 AM9/26/14
to haxe...@googlegroups.com
Are you using nme or openfl?  The git version nme "stage" has a "resize" method on it (ie, SetWindowSize) - can't remember when it was added.
The startup size is set from the build.xml.

Hugh

Mark

unread,
Sep 26, 2014, 4:15:30 AM9/26/14
to haxe...@googlegroups.com
aaaand it works! :)

thank you Hugh ;)
Reply all
Reply to author
Forward
0 new messages