ThunderRay 0 Report post 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 Quote Share this post Link to post Share on other sites
rvizcaino 6 Report post 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(); 1 ThunderRay reacted to this Quote Share this post Link to post Share on other sites
shmikucis 31 Report post 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; 1 ThunderRay reacted to this Quote Share this post Link to post Share on other sites
domrein 1 Report post 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. 1 ThunderRay reacted to this Quote Share this post Link to post Share on other sites
ThunderRay 0 Report post Posted January 20, 2015 Sorry for the late response , its solved , thank you all!!!! Quote Share this post Link to post Share on other sites
ThunderRay 0 Report post Posted January 20, 2015 The game is amazing, thank you!!! Quote Share this post Link to post Share on other sites
ThunderRay 0 Report post Posted January 20, 2015 Yeah, I used group and velocity,thank you! Quote Share this post Link to post Share on other sites