Resizing the game


(Linck) #1

Hi, I was wondering how can I achieve something like this:

Resize your browser window and you’ll see the game resizing along.

I’ve tryed this listener:

stage.addEventListener(Event.RESIZE, onResize); 

And it works. It does trigger when my window resizes. But the problem is I don’t know where to find the window’s width and height to use FP.screen.scale to resize accordingly. If I do for instance a FP.stage.width, the value will always be 1920.

So how do I get the current width and height of the window. Or is it the wrong approach?


(Ultima2876) #2

Try FP.stage.stageWidth and FP.stage.stageHeight :slight_smile:


(Linck) #3

Oh, just that =D Thanks!

I’m still having some issues I’ll post here on tuesday. But thanks a lot.

And am I going with the right approach? Listening to a resize and using FP.screen.scale to fit the game?


(Ultima2876) #4

Yeah, that’s a perfectly good way of handling it; that’s how I do it in Stage3DPunk pretty much :slight_smile:


(Linck) #5

So the resizing on my game seems to be working fine now, but there is two things I wanted to ask that I believe it is possible that there is no solution for them:

1- There is a big loss in quality when I resize my image. I searched a little bit to find something that could maintain the quality and I’ve found the smoothing property of Graphic, which works really nicely, but it’s not perfect. Let me illustrate:

This is a piece of the image I’m using in my game, and you can see that although the black outline of the pink thing seems perfect with smoothing, the line in the middle is sort of striped. So I don’t know if there is a simple way to fix it, or it’s a perfectly normal issue that almost every game has to deal with.

2- My FP console does not resize along with the Screen scale. I noticed that if I press the “~” (which is the default key for showing hitboxes and stuff), and press it again, the output field adjusts itself in the Screen size, but there is still some elements that don’t, they stand in the same scale they were when ran my game. So is there any way to update the scale of the console or something?


(Zachary Lewis) #6
  1. That’s just a problem with resizing images. You can either deal with that compression or you can make all your assets pixel-perfect at different resolutions (that’s what iOS applications do).
  2. The console is a developer tool and isn’t designed to “fit” with all FlashPunk games. It’s just a simple utility to help you debug your game while it’s running. There may be a way, but it wasn’t designed with that functionality in mind.

(Ultima2876) #7

You can try messing with the stage.quality setting:

//in Main.as
public override function setStageProperties(): void
{
  super.setStageProperties();
  stage.quality = StageQuality.BEST; //remember to import Flash.Display.StageQuality
}

BEST stage quality may improve the antialiasing level that is used for smoothing.


(Linck) #8

Allright, that loss of quality was not so intense anyway. Thanks for your answers

On BEST quality my game really is smoother Ultima2876, but the fps drop to 24 or so. I hope that’s expected.


(Ultima2876) #9

Yeah, that sounds about right. Unfortunately the tradeoff with BEST quality is that it makes every ‘smoothed’ draw a lot more expensive (it’s antialiasing it using 8x supersampling; ie drawing many times the number of pixels).