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

  • Recently Browsing   0 members

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