ThunderRay Posted December 19, 2014 Share Posted December 19, 2014 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 distancethen 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 thisAnyone helps me?Thank you so much Link to comment Share on other sites More sharing options...
rvizcaino Posted December 19, 2014 Share Posted December 19, 2014 hi, maybe something like this inside a function (Obviously this can be better with the use of groups and a pool of objects) //RANDOM ALTITUDEvar altitude = game.rnd.integerInRange(0, game.world.bounds.height); //ADD SPRITE TO GAMEvar 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(); ThunderRay 1 Link to comment Share on other sites More sharing options...
shmikucis Posted December 20, 2014 Share Posted December 20, 2014 I think that tweens isn't the best solution here. You can enable physics and add velocity to platformsplatform.body.velocity.x = -300;and add gravity to running charactercharacter.body.gravity.y = 1000; ThunderRay 1 Link to comment Share on other sites More sharing options...
domrein Posted December 23, 2014 Share Posted December 23, 2014 I wrote an endless runner game in phaser just recently as a secret santa gift. The source code is available here https://github.com/domrein/SecretSanta2014 . That should be a good example of a simple endless runner. ThunderRay 1 Link to comment Share on other sites More sharing options...
ThunderRay Posted January 20, 2015 Author Share Posted January 20, 2015 Sorry for the late response , its solved , thank you all!!!! Link to comment Share on other sites More sharing options...
ThunderRay Posted January 20, 2015 Author Share Posted January 20, 2015 The game is amazing, thank you!!! Link to comment Share on other sites More sharing options...
ThunderRay Posted January 20, 2015 Author Share Posted January 20, 2015 Yeah, I used group and velocity,thank you! Link to comment Share on other sites More sharing options...
Recommended Posts