Jump to content

Top down Endless Runner - Moving Platform


GideonSam
 Share

Recommended Posts

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

image.png.8fe8f4ebb50d8cd872a740433999461b.png

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

 Share

  • Recently Browsing   0 members

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