v0van1981 0 Posted October 27, 2014 Report 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 Quote Link to post Share on other sites
pixelpathos 11 Posted October 27, 2014 Report 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. Quote Link to post Share on other sites
v0van1981 0 Posted October 27, 2014 Author Report 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. Quote Link to post Share on other sites
Recommended Posts
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.