How to change FlxG width and height, ResizeGame doesn't work - haxe

how do i change FlxG width and height in runtime as resizeGame doesn't do anything
i have the project by default set to 1600 x 900 and i have a state for settings where i can change the resolution and have managed to make it so that i can change what the width and height will be on startup however i want to be able to resize it during runtime so it will be higher/lower res.
the problem is since FlxG width and height aren't modifiable directly so resizeGame is the only option but it doesn't do anything, even after calling it and tracing FlxG width and height there is no difference nor is there any visual difference asside from the game being offset to the very top left corner of the window and messing up detecting where the mouse is until i maximise and restore down where it goes back to normal
does anyone have any idea why this isn't working and how i should go about fixing it
i'm compiling to c++ (windows)
edit: it has been a couple of months and i have started mostly rewriting the program and yet this issue is still a thing on a fresh start and i am in serious need of an answer

Related

Phaser - Change width and height Camera

In normal i have canvas size 500x500 and it will create camera size (500,500)
But when i change
game.camera.width=5;
game.camera.height=5;
then visible area it the same? what will happen when change width and height camera, how to understand that thanks
Based upon the documentation and an older post from the creator of Phaser on the HTML5 Game Dev Forum where he said:
You're not doing anything wrong, you just can't change the camera dimensions - they match the game size at the moment.
and then in 2015 on the same thread:
So you can tell if something is within the camera bounds or not. Which is impossible if the camera doesn't have a size.
suggesting that things haven't changed since 2013, and the camera doesn't resize as you're expecting.
Testing as well suggests that things haven't changed either.

Cbuilder XE3 scales (expands) form when edited in RAD IDE

I have some applications, but not all, that "magically" scale up forms by a factor of 1.23 when I open the forms in the RAD IDE. For example, a form width of 947 pixels suddenly jumps to 1166 pixels. It is suspiciously-close to a pixel ratio of 120/96 (a ratio of 1.25), but the scaling is consistently closer to 1.23 (as judged by larger integer ratios derived from, for example, the form width and height).
I can look at the .dfm file and see the original numbers, whereas in the IDE, the values have been altered (e.g. height and width expanded, control positions adjusted, and font sizes increased).
I know that scaling and dpi is a minefield, but I've not (to my knowledge) changed any related settings.
For both the affect and non-affected projects, forms have the Scaled property set to "true" and the PixelsPerInch property is set to 96. My development machine has its screen resolution set to 100%. This is the setup that is supposed to avoid these issues.
I have searched through the project and IDE configuration files in a fruitless effort to find out what might be different about a project that has this issue, vs one that does not.
The affected (and unaffected) projects are all ones that have been in development for years - it is only in the last week that I have observed this behaviour. To my knowledge (I am sole developer), I have not made any code/configuration changes that relate to scaling, dpi, etc.
Does anyone have any idea what might be happening?
Although I am using CBuilder XE3, I've tagged this question with Delphi XE3 as well since I'm thinking that this is a RAD Studio issue.
EDIT 1: I've also noticed that for each modified control, the IDE throws in the following additional lines (i.e. in addition to modifying Top, Left, Width, Height, and Font.Height):
Margins.Left = 4
Margins.Top = 4
Margins.Right = 4
Margins.Bottom = 4
and for TImages, it also adds
ExplicitWidth = <nnn>
ExplicitHeight = <nnn>
EDIT 2: Curiously, when the IDE scales the form it does not flag the form as modified - i.e. the form appears unmodified until a "real" change is made (for example, repositioning a control). If the form is opened a second time after saving with the modified scale, no further scaling occurs - it seems to be a one-time effect, but there does not seem to be a "unasked-for-scaling-accomplished" flag in any configuration file :)

SDL mouse range on resize

I am developing a SDL OpenGL application on Ubuntu and have noticed a problem with the mouse range when a new window size is set. The initiale size of my application is 600x400 and the mouse range (x,y) reflects this. However, when a user changes the screen to any other size (using given predefined sizes), the mouse range still only reflects a 600x400 screen size and causes issues with mouse location functionality.
To set the new resolution, I call:
SDL_SetVideoMode(Width, Height, 32, SDL_OPENGL); which to my understanding should handle the mouse range resizing but doesn't seem to do so in Linux. Can anyone give me a solution to this problem?
Note: Possible hack seem to be to exit SDL and re-initialize using SDL_Init(SDL_INIT_EVERYTHING);
After some digging, I found the problem was that I was calling SDL_GetMouseState(0,0) later after the size change was made which apparently was interfering with the recalculation of the mouse range. However, I've gone through the SDL source but I can't really determine how this would effect it so. There seems to be some mouse state switching that may be causing it.
Anytime i resize the window, I execute the following to refresh my viewport:
m_ParentWindow = SDL_SetVideoMode( m_width, m_height, m_depth, m_SDL_Vid_Flags );
glViewport(0,0,m_width,m_height);
Clear();
Where Clear calls:
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();

How do I display same "proportional" text size on different resolutions?

I draw some text on screen using ID3DXFont::DrawText. This text should be displayed the same regardless of screen resolution.
For example, if screen resolution is low, text wrapped and when it is higher text is not wrapped. How can I avoid such situation? I want text size to be connected to screen resolution so if resolution is lower I want the text to be relatively smaller so that no wrapping happens. Is there any way?
Thanks in advance
Below is a logical solution. It doesn't have any of the code or procedures needed to make work in direct X but having done something similar outside of DirectX I wanted to share the logic
Working on whatever default screen resolution you want set the font to be the size needed.
Find the percentage of the screen height the font size you chose takes up.
Then having stored that value when you go to render again, in the final version of the program, calculate the font size based on the screen size and the percentage
What I was working in had functions like GetTextHeight and properties on the font size to allow you to set the height (which in turn set the font size appropriately). So if can find anything similar to this in DirectX than this could be a route for you to take.

How do I change the Unit:Characters in Matlab?

For portability, I set the units of my GUIs to 'characters'. Now I have a user who wants to use Matlab on his netbook, and the GUI window is larger than the screen (and thus cropped at the top).
I think I could try and write something in the openingFcn of the GUI that measures screen size and then adjusts the GUI accordingly, but I'd rather avoid that, because I then need to deal with text that is bigger than the text boxes, etc.
What I'd rather like to do is somehow adjust the unit 'character' on his Matlab installation. None of the font sizes in the preferences seem to have an effect on unit:character, though. Does anyone know whether there's a setting for that, which can be changed from within Matlab (I don't mind if it's something that is reset at every reboot, since I can just put it into the startup script)?
Might I suggest an alternative to consider when designing your GUI:
Create all of your GUI objects with the 'FontUnits' property set to 'normalized'.
Create the figure with a default size, with everything set to look the way you want.
Set one or more of the CreateFcn/OpeningFcn/ResizeFcn functions so they will resize the GUI to fit the screen size.
When the GUI and its objects are resized, the text will resize accordingly, thus helping to avoid text that ends up bigger than the text boxes. One thing to keep note of is that normalized units for the font will interpret the value of 'FontSize' property as a fraction of the height of the uicontrol. I also make it a habit to set the 'FontName' property to 'FixedWidth' to help control the width of the text.

Resources