Jump to content

Windows 8.1 store app visual studio 2013 randomly laggy without fps drop.


HueHueHue
 Share

Recommended Posts

Hi Everyone,

 

I'm experimenting with phaser and js windows store apps. I created a very simple app, just moving some sprites on the screen. What troubles me is quite often when i run the app on local machine from visual studio it lags. The sprites gently jump rather than move smoothly. This happens randomly. One time everything works smooth, next time it lags again (without changing the code or starting any other applications or anything). I use game.debug.text to draw fps to the screen and every time the game laggs i have 67 or 65 or 63. When game runs smoothly fps is equals 60. The extra few fps that happen in corelation with the laggy behavior happen even if  i use game.time.deltaCap = 1 / 60. Has anyone came accross something similar ? Any help appreciated :rolleyes:.

 

Thanks!

 

 

Code:

// For an introduction to the Blank template, see the following documentation:
// http://go.microsoft.com/fwlink/?LinkID=392286
(function () {
    "use strict";

    var app = WinJS.Application;
    var activation = Windows.ApplicationModel.Activation;
    // init for phaser;
    var game;
    var fishgroup;

    function preload() {

        //prealoaing assets
        game.load.image('xxx', 'images/test.png');

    }
    function create() {
        game.time.advancedTiming = true;
        game.physics.startSystem(Phaser.Physics.ARCADE);
        fishgroup = game.add.group();

        //game.stage.backgroundColor = '#ffffff';

        game.time.advancedTiming = true;
       // game.time.deltaCap = 1 / 60;
       
        for (var i = 0; i < 5; i++) {

            var f = fishgroup.create(game.world.randomY, game.world.randomY, 'xxx');
            game.physics.enable(f, Phaser.Physics.ARCADE);
            f.scale.setTo(2, 2);
            f.body.velocity.setTo(300, 0);

        }
    }
    function update() {
        for (var i = 0; i < fishgroup.length; i++) {

            var f = fishgroup.getAt(i);

            if (f.body.x > game.world.width) {
                f.reset(0 - f.body.width, f.body.y)
                //f.body.x = (0 - f.body.width);
                f.body.velocity.setTo(300, 0);

            } else if (f.body.x < 0 - f.body.width) {
                f.reset(game.world.width, f.body.y)
                // f.body.x = game.world.width;
                f.body.velocitysetTo(300, 0);
            }
        }
    }
    function render() {
        game.debug.text(game.time.fps + "---" + game.time.deltaCap + "---" + game.time.fpsMax, 100, 100);
    }

    app.onactivated = function (args) {
        if (args.detail.kind === activation.ActivationKind.launch) {
            if (args.detail.previousExecutionState !== activation.ApplicationExecutionState.terminated) {
                // TODO: This application has been newly launched. Initialize
                // your application here.
                
                
                game = new Phaser.Game(1600,900, Phaser.CANVAS, '',{ preload: preload, create: create, update: update, render: render});
                
               
            } else {
                // TODO: This application has been reactivated from suspension.
                // Restore application state here.

                // load , unpause
            }
            args.setPromise(WinJS.UI.processAll());
        }
    };

    app.oncheckpoint = function (args) {
        // TODO: This application is about to be suspended. Save any state
        // that needs to persist across suspensions here. You might use the
        // WinJS.Application.sessionState object, which is automatically
        // saved and restored across suspension. If you need to complete an
        // asynchronous operation before your application is suspended, call
        // args.setPromise().

    };

    app.start();
})();

Link to comment
Share on other sites

  • 1 month later...
Hello,

 

It seems I'm the only person with this issue. Has anyone even tried to use phaser with windows 8.1 store apps ? I'm running on visual studio 2013. The below version of the code is as simple as it gets could someone please try tu run it ? Most of the times it will run on more than 60 fps and display will be laggy( As explained in the original post). Once in a while fps is 60 and the app runs smoothly. I run the same code in a browser and it works perfectly, so I'm assuming there is an issue with using phaser for windows store apps. 

 

Any help welcome. 

 

WINDOWS 8.1 APP :

 

(function () {

    "use strict";

 

    var app = WinJS.Application;

    var activation = Windows.ApplicationModel.Activation;

 

    

    /** Main game holder.

    * 

    */

    var game;

    var group;

 

    function preload() {

 

        game.load.image('testimg', 'images/logo.scale-100.png');

 

    };

 

    function create() {

 

        game.time.advancedTiming = true;

 

        group = game.add.group();

 

        var f = group.create(0, 500, 'testimg');

        game.physics.enable(f, Phaser.Physics.ARCADE);

        f.body.velocity.setTo(300, 0);

 

    };

 

    function update() { };

 

    function render() {

 

        game.debug.text(game.time.fps + "---" + game.time.deltaCap + "---" + game.time.fpsMax, 100, 100);

 

    };

 

 

    app.onactivated = function (args) {

        if (args.detail.kind === activation.ActivationKind.launch) {

            if (args.detail.previousExecutionState !== activation.ApplicationExecutionState.terminated) {

                // TODO: This application has been newly launched. Initialize

                // your application here.

 

                game = new Phaser.Game(1600, 900, Phaser.CANVAS, '', { preload: preload, create: create, update: update, render: render });

 

            } else {

                // TODO: This application has been reactivated from suspension.

                // Restore application state here.

            }

            args.setPromise(WinJS.UI.processAll());

        }

    };

 

    app.oncheckpoint = function (args) {

        // TODO: This application is about to be suspended. Save any state

        // that needs to persist across suspensions here. You might use the

        // WinJS.Application.sessionState object, which is automatically

        // saved and restored across suspension. If you need to complete an

        // asynchronous operation before your application is suspended, call

        // args.setPromise().

    };

 

    app.start();

})();

 

NORMAL BROWSER VERSION


 

(function () {

    /** Main game holder.

    * 

    */

    var game;

    var group;

 

    function preload() {

 

        game.load.image('testimg', 'images/logo.scale-100.png');

 

    };

 

    function create() {

 

        game.time.advancedTiming = true;

 

        group = game.add.group();

 

        var f = group.create(0, 500, 'testimg');

        game.physics.enable(f, Phaser.Physics.ARCADE);

        f.body.velocity.setTo(300, 0);

 

    };

 

    function update() { };

 

    function render() {

 

        game.debug.text(game.time.fps + "---" + game.time.deltaCap + "---" + game.time.fpsMax, 100, 100);

 

    };

 

                game = new Phaser.Game(1600, 900, Phaser.CANVAS, '', { preload: preload, create: create, update: update, render: render });

})();

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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