Nikow

HELP - Camera Follow - Parallax

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

Share this post


Link to post
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 ?

Share this post


Link to post
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

Share this post


Link to post
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);

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.