Jump to content

Problem with XDK and ScaleManager


ldurniat
 Share

Recommended Posts

Hi,

 

I'm new to XDK and Phaser. Recently I started new project in XDK (VERY simple game). After that I replaced all files in /lib/phaser newer version of Phaser v2.4.2. and started emulator. This results in one error

Phaser v2.4.2 | Pixi.js v2.2.8 | WebGL | WebAudio | http://phaser.io phaser.js:38516Uncaught TypeError: undefined is not a function Game.js:45

Line 45 in Game.js

 this.scale.setScreenSize(true);

Game.js below

/* globals Phaser:false */// create BasicGame ClassBasicGame = {};// create Game function in BasicGameBasicGame.Game = function (game) {};// set Game function prototypeBasicGame.Game.prototype = {    init: function () {        // set up input max pointers    //this.input.maxPointers = 1;        // set up stage disable visibility change    //this.stage.disableVisibilityChange = true;        // Set up the scaling method used by the ScaleManager        // Valid values for scaleMode are:        // * EXACT_FIT        // * NO_SCALE        // * SHOW_ALL        // * RESIZE        // See http://docs.phaser.io/Phaser.ScaleManager.html for full document        this.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL;        // If you wish to align your game in the middle of the page then you can        // set this value to true. It will place a re-calculated margin-left        // pixel value onto the canvas element which is updated on orientation /        // resizing events. It doesn't care about any other DOM element that may        // be on the page, it literally just sets the margin.        this.scale.pageAlignHorizontally = true;        this.scale.pageAlignVertically = true;        // Force the orientation in landscape or portrait.        // * Set first to true to force landscape.         // * Set second to true to force portrait.        this.scale.forceOrientation(true, false);        // Sets the callback that will be called when the window resize event        // occurs, or if set the parent container changes dimensions. Use this         // to handle responsive game layout options. Note that the callback will        // only be called if the ScaleManager.scaleMode is set to RESIZE.    //this.scale.setResizeCallback(this.gameResized, this);        // Set screen size automatically based on the scaleMode. This is only        // needed if ScaleMode is not set to RESIZE.         this.scale.setScreenSize(true);        // Re-calculate scale mode and update screen size. This only applies if        // ScaleMode is not set to RESIZE.        this.scale.refresh();    },    preload: function () {        // Here we load the assets required for our preloader (in this case a         // background and a loading bar)        this.load.image('logo', 'asset/phaser.png');                //this.rect = new Rectangle(0, 0, 5, 4);    },    create: function () {        // Add logo to the center of the stage        this.logo = this.add.sprite(            this.world.centerX, // (centerX, centerY) is the center coordination            this.world.centerY,            'logo');        // Set the anchor to the center of the sprite        this.logo.anchor.setTo(0.5, 0.5);    },    gameResized: function (width, height) {        // This could be handy if you need to do any extra processing if the         // game resizes. A resize could happen if for example swapping         // orientation on a device or resizing the browser window. Note that         // this callback is only really useful if you use a ScaleMode of RESIZE         // and place it inside your main game state.    }};

I have tried diff approach but without luck:( After comment line 45 everythings works:)  Any body can help?

 

Link to comment
Share on other sites

Yes, it's deprecated but using .SHOW_ALL doesn't work that well. I mean this results in an problem with the screen size that lets the game Area expands beyond the Window 

create: function () {                game.stage.backgroundColor = '#555';        game.physics.startSystem(Phaser.Physics.ARCADE);                game.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL;                game.scale.minWidth = 300;        game.scale.minHeight = 600;        game.scale.maxWidth = 1000;        game.scale.maxHeight = 1200;                game.scale.pageAlignHorizontally = true;        game.scale.pageAlignVertically = true;                 //apply the setting we set up        game.state.start('Load');   //start the Preloader state    }
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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