Jump to content

HELP - Camera Follow - Parallax


Nikow
 Share

Recommended Posts

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

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

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

camera.gif

Link to comment
Share on other sites

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

 Share

  • Recently Browsing   0 members

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