1
votes

I'm making a Flash game with FlashPunk. When I press Ctrl+F Flash goes fullscreen but the game stays at the original size, aligned to the top-left corner.

How can I specify to FlashPunk that I want the game scalled to the size of the screen? (keeping aspect ratio, off course)

Thanks

5

5 Answers

1
votes

You can control scaling in OBJECT attributes when you embed the Flash into HTML. Use scale=default to scale maintain aspect ratio. When you run the Flash in player, use menu item View->Show All which functions same as scale=default in OBJECT in HTML.

0
votes

Scaling your flash movie will decrease performance significantly. I urge you not to do this for any reason. I'm not sure what flash punk is, but try using this:

stage.scaleMode = StageScaleMode.SHOW_ALL;
0
votes

You could hook into the resize event and scale it in code

//put this in your initialization method

stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.addEventListener(Event.RESIZE, onResize); 
stage.dispatchEvent(new Event(Event.RESIZE));


public function onResize(event:Event=null):void
{       

    width = stage.stageWidth;
    height = stage.stageHeight;

    if (scaleX < scaleY)
        scaleY = scaleX;
    else
        scaleX = scaleY;

}
0
votes

The best way to do this, is to override the setStageProperties public function in your main class (in FlashPunk, your main class should be extending the Engine class)

override public function setStageProperties():void 
{
    super.setStageProperties();
    stage.scaleMode = StageScaleMode.SHOW_ALL;
}
0
votes

Take a look at the FP class in flashpunk. Specifically FP.screen.scale which lets you resize your entire game by a specified factor. For example, the code below will double the size of your game screen:

FP.screen.scale = 2;

If you need to worry about the aspect ratio, you can do X and Y separately with:

FP.screen.scaleY = 2;
FP.screen.scaleX = 3;

After you go to fullscreen, you can use the code below to get the correct aspect ratio for enlarging your screen:

  var scaleFactorX = stage.stageWidth / FP.screen.width;
  var scaleFactorY = stage.stageHeight / FP.screen.height;
  FP.screen.scaleX = scaleFactorX;
  FP.screen.scaleY = scaleFactorY;