v0van1981 Posted October 27, 2014 Share Posted October 27, 2014 Bug? In IE 11 movement speed two times less than Firefox / Chromevar 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 comment Share on other sites More sharing options...
pixelpathos Posted October 27, 2014 Share Posted October 27, 2014 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 comment Share on other sites More sharing options...
v0van1981 Posted October 27, 2014 Author Share Posted October 27, 2014 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.htmlvelocityThe velocity in pixels per second sq. of the Body. Link to comment Share on other sites More sharing options...
Recommended Posts