Jump to content

Scaling


Deathspike
 Share

Recommended Posts

I have a game that I initialize like this:

 

let game = new Phaser.Game(864, 486, Phaser.CANVAS, 'content');

 

So a canvas is created with 864x486 dimensions.

 

Now I want to show just a smaller part of the map (320x240) that is stretched up to the full size of the container. Essentially, I want to make smaller graphics appear larger to have the typical 8-bit SNES feeling. How do I go about doing this?

 

EDIT: Setting anti alias to off in the game constructor and following fariazz instructions *DOES* work. I actually had a flipped animation that is a different problem entirely. Following that up at http://www.html5gamedevs.com/topic/14705-blurry-sprite-when-flipped-on-x-axis/#entry83578

Edited by Deathspike
Link to comment
Share on other sites

When you create the Phaser.Game object, the size you enter there is the size of the game view in pixels, it's not necessarily the size will be shown. Depending on the Scale Manager options you enter when you initiate the game, it will show that size or it will stretch to occupy all the screen area.

 

If you do:

game = new Phaser.Game(320, 240, Phaser.CANVAS, 'content');

And then on your game state init or create method:

this.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL; //have the game centered this.scale.pageAlignHorizontally = true;this.scale.pageAlignVertically = true;

You will be showing a 320x420 game stretched to a much larger area (to fit your screen, or the fixed size of the parent DIV if you have one).

 

Take a look at this tutorial I wrote, section "Adapting for Mobile":  https://software.intel.com/en-us/articles/how-to-make-a-mobile-virtual-pet-game-with-html5-and-cordova

 

And also there is the Scale Manager ebook which explains it quite clear: https://leanpub.com/phaserscalemanager

Link to comment
Share on other sites

Thanks icp, I tried adding this but the scaling remains fuzzy and awkward.

 

I also did this, now:

 

let game = new Phaser.Game(512, 320, Phaser.CANVAS, 'content', null, false, false);

 

Which makes it slightly better, but the scaling is still pretty poor. Any further suggestions I can try?

Link to comment
Share on other sites

It seems that picking up Phaser a bit of a pointless endeavor for games that require better scaling then?

 

I had imagined that if MSPaint can scale properly, so would an advanced HTML5 2D rendering engine. I'm really trying to like this engine, and it has many good things, but would I be better off going for a different engine for a game that requires good scaling?

 

Sorry, it seems a bit preposterous to require a batch of hacks to get something this going. Just looking for advice on how to tackle this problem. Setting a fixed scale of, say, x4 as is done in the link you've provided, is not going to cut it for different screen resolutions nor touch interactivity without another batch of hacks.

Link to comment
Share on other sites

It seems that picking up Phaser a bit of a pointless endeavor for games that require better scaling then?

 

I had imagined that if MSPaint can scale properly, so would an advanced HTML5 2D rendering engine. I'm really trying to like this engine, and it has many good things, but would I be better off going for a different engine for a game that requires good scaling?

I think you're being a bit unfair on phaser, and PIXI, its current underlying renderer. The fuzzy scaling, as I understand it, is a result of the browser. They don't respond in a consistent way, or even at all, to attempts to stop them smoothing when scaled.

Link to comment
Share on other sites

 

I think you're being a bit unfair on phaser, and PIXI, its current underlying renderer. The fuzzy scaling, as I understand it, is a result of the browser. They don't respond in a consistent way, or even at all, to attempts to stop them smoothing when scaled.

After re-reading my earlier post, I completely agree. My earlier message was, indeed, quite unfair.

In my experience using a canvas context and other HTML5 game engines (specifically MelonJS as game engine example), both scale well when configured appropriately. It has always been a bad idea to scale with CSS. The width/height of the canvas has to be set on an element basis to obtain a context with the set height/width and drawing calls should take care of the 'virtual' resolution. This negates any browser-specific scaling issues.

What should I be looking for to properly scale individual drawing calls on the canvas (I don't care about WGL)? Or should I attempt hacking this into the core myself?

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...