Jump to content

Scaling sprites and TilemapLayers using


jdnichollsc
 Share

Recommended Posts

Hello,

 

it looks like that you want to resize but keep showing the entire planned game content, am i right?

 

You might try to figure some "safezone" strategy arround ScaleManager.SHOW_ALL

 

also take a look at the template projects section in github, there are good samplecodes that if not solve your problem at least will give you a good hint about it:

 

https://github.com/photonstorm/phaser/tree/master/resources/Project%20Templates

Link to comment
Share on other sites

hello, 
 
I usually do it this way:
 
 var innerWidth = window.innerWidth;   var innerHeight = window.innerHeight;                  var gameRatio = innerWidth/innerHeight;                   h = 480;          w  = h*gameRatio;   var game = new Phaser.Game(w, h, Phaser.CANVAS,'game'); // width = 100% and height = 100%

and then in  preload function  add:

 

this.game.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL;this.scale.pageAlignHorizontally  = true;this.scale.pageAlignVertically  = true;this.scale.setScreenSize(true);

This will scale the game to fit any device screen irrespective of the screen size.

Link to comment
Share on other sites

Poor Nicholls, man. He keeps asking about RESIZE and people keep telling him to use SHOW_ALL. :) I did it, too!

 

I looked at your demo. What do you want it to do that it's not doing right now? It looks like it's resizing, but kind of jerky?

 

hahaha. I want to scale the TilemapLayers and all sprites in the game like RunPixieRunbut not how to do it, I need a guide. 

 

In this moment, when you resize the game the flowers size doesn't change :/

 

¿What need to do in resize function? Rich ignores me for my bad english hahahaha

 

Regards

Link to comment
Share on other sites

 

hello, 
 
I usually do it this way:
 
 var innerWidth = window.innerWidth;   var innerHeight = window.innerHeight;                  var gameRatio = innerWidth/innerHeight;                   h = 480;          w  = h*gameRatio;   var game = new Phaser.Game(w, h, Phaser.CANVAS,'game'); // width = 100% and height = 100%

and then in  preload function  add:

 

this.game.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL;this.scale.pageAlignHorizontally  = true;this.scale.pageAlignVertically  = true;this.scale.setScreenSize(true);

This will scale the game to fit any device screen irrespective of the screen size.

 

 

If you resize the game with this solution you will see blank spaces, I don't like it :)

 

Thanks for your response!

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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