Nikow Posted June 16, 2016 Share Posted June 16, 2016 Hi Everybody ! I'm working on a game with camera follow, and many plans on background. Is there a solution to make them moved at differents speeds ? To create parallax effect :). Thank you !! And sorry for my english ^^.. Link to comment Share on other sites More sharing options...
in mono Posted June 16, 2016 Share Posted June 16, 2016 You can do that by relying on camera movement only for the plan closest to the camera and manually move the other plans along x at different speeds. Link to comment Share on other sites More sharing options...
Nikow Posted June 16, 2016 Author Share Posted June 16, 2016 How can i relying the camera movement with one sprite ? Link to comment Share on other sites More sharing options...
Nikow Posted June 16, 2016 Author Share Posted June 16, 2016 *And i Need to make parallax elements moove only when camera is mooving ? Thank you Link to comment Share on other sites More sharing options...
LTNGames Posted June 16, 2016 Share Posted June 16, 2016 Alot of these questions are in the examples section for phaser, you will need to use the tiling sprite for the parallax background effect. Tiling sprite Example: http://phaser.io/examples/v2/tile-sprites/tiling-sprite you could also lock the tiling sprite to the camera like so. this.background.fixedToCamera = true; Link to comment Share on other sites More sharing options...
Nikow Posted June 16, 2016 Author Share Posted June 16, 2016 3 minutes ago, LTNGames said: Alot of these questions are in the examples section for phaser, you will need to use the tiling sprite for the parallax background effect. Tiling sprite Example: http://phaser.io/examples/v2/tile-sprites/tiling-sprite you could also lock the tiling sprite to the camera like so. this.background.fixedToCamera = true; I know that... But when camera is following a sprite, first the sprite is moving to the center of the screen, after that, the camera is mooving , and last, the camera stoped and sprite is moving again. How could i create the parallax effect only when the camera is moving ? Link to comment Share on other sites More sharing options...
LTNGames Posted June 16, 2016 Share Posted June 16, 2016 This is what I do for my tiling sprite background which only moves when the camera moves. var x = this.stage._bounds.width; var y = this.stage._bounds.height; this.background = this.add.tileSprite(x, y, 1000, 750, 'level1bg'); this.background.fixedToCamera = true; this.game.camera.follow(this.player, null, 0.1, 0.1); Final effect Link to comment Share on other sites More sharing options...
Nikow Posted June 16, 2016 Author Share Posted June 16, 2016 Your character is everytimes on the center of the screen ? Link to comment Share on other sites More sharing options...
LTNGames Posted June 16, 2016 Share Posted June 16, 2016 No sorry, just where I was when I made the gif, here is another one that will show you the effects better. Link to comment Share on other sites More sharing options...
Nikow Posted June 16, 2016 Author Share Posted June 16, 2016 I have the same result as you for now, but no parallax in your gif ? Link to comment Share on other sites More sharing options...
LTNGames Posted June 16, 2016 Share Posted June 16, 2016 My background is parallax effect, I forgot to show you the code the ties it to the camera, it's a subtle effect but you can see it if you look at the trees being cut off as the player moves. // I set the y value to 0 because I don't need my background to move up and down just left and //right. This line goes in an update function. this.background.tilePosition.set(-this.game.camera.x, 0); Link to comment Share on other sites More sharing options...
Nikow Posted June 16, 2016 Author Share Posted June 16, 2016 Interesting ! Thank you, i will try with this function ! Link to comment Share on other sites More sharing options...
Recommended Posts