Jump to content

Different player movement speed in different browsers


Recommended Posts

Bug? In IE 11 movement speed two times less than Firefox / Chrome

var Player = (function (_super) {    __extends(Player, _super);    function Player(game, x, y) {        _super.call(this, game, x, y, 'simon', 0);        this.anchor.setTo(0.5, 0);        this.animations.add('walk', [0, 1, 2, 3, 4], 10, true);        this.game.physics.arcade.enableBody(this);        game.add.existing(this);    }    Player.prototype.update = function () {        this.body.velocity.x = 0;        if (this.game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {            this.body.velocity.x = -150;            this.animations.play('walk');            if (this.scale.x == 1) {                this.scale.x = -1;            }        } else if (this.game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {            this.body.velocity.x = 150;            this.animations.play('walk');            if (this.scale.x == -1) {                this.scale.x = 1;            }        } else {            this.animations.frame = 0;        }    };    return Player;})(Phaser.Sprite);

code from http://www.photonstorm.com/phaser/advanced-phaser-and-typescript-projects

Link to post
Share on other sites

Hi v0van1981,

 

Is your Player.prototype.update() function called directly from requestAnimationFrame() as part of your render loop? If so, you've tied your player movement directly to your frame rate i.e. if the frame rate drops, your player will slow down. (I've just spotted the following in the linked article: "Once the sprite is added to the game world its update function will be called every frame.")

 

This article describes some techniques about how to separate out sprite movement from frame rate.

 

Thanks,

 

Vince.

Link to post
Share on other sites

Hi v0van1981,

 

Is your Player.prototype.update() function called directly from requestAnimationFrame() as part of your render loop? If so, you've tied your player movement directly to your frame rate i.e. if the frame rate drops, your player will slow down. (I've just spotted the following in the linked article: "Once the sprite is added to the game world its update function will be called every frame.")

 

This article describes some techniques about how to separate out sprite movement from frame rate.

 

Thanks,

 

Vince.

 

I do no know. It is internal Phaser's loop. But from http://docs.phaser.io/Phaser.Physics.Arcade.Body.html

velocityThe velocity in pixels per second sq. of the Body.
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...