GideonSam

Top down Endless Runner - Moving Platform

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;
}

Share this post


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.