GideonSam Posted June 6, 2018 Share Posted June 6, 2018 Hi All I've been working on a top down endless runner , where the player jumps from one platform to another and should not leave the screen. How to make a platform move horizontally I'm spawning platforms and adding x and y velocity its working but is it a right of doing it ? if not how to make it look better this.initX = this.x; this.body.velocity.y = -200; platform.prototype.update = function () { if (this.moving) { if (this.x > (this.initX + this.width)) { this.speed = -200; } if (this.x < (this.initX)) { this.speed = 200; } this.body.velocity.x = this.speed; } Link to comment Share on other sites More sharing options...
Recommended Posts