Jump to content

Phaser endless runner question


ThunderRay
 Share

Recommended Posts

Hi everyone:

I am new to phaser framework ,i decided to make an endless runner game, i have an question : how can i create random platforms with random distance and move to the left of the screen.

i tried to use  game.time.events.loop , but turns out it gaves me constant distance

then i used game.add.tween which not working well, so i am so confused now, i couldn't find any online source to teach me this

Anyone helps me?

Thank you so much

Link to comment
Share on other sites

hi, maybe something like this inside a function (Obviously this can be better with the use of groups and a pool of objects)

 

//RANDOM ALTITUDE

var altitude = game.rnd.integerInRange(0, game.world.bounds.height);

 

//ADD SPRITE TO GAME

var platform = game.add.sprite(game, altitude, 'platform');

 

 

//TWEEN X POSITION (CAN BE RANDOM TIME ALSO)

var t = game.add.tween(platform);
t.to({x: 0}, 5000, Phaser.Easing.Linear.None, true);
t.start();

Link to comment
Share on other sites

  • 4 weeks later...

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...
 Share

  • Recently Browsing   0 members

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