Jump to content

Best way to make the camera follow a sprite?


Recommended Posts

I want to make the camera follow my sprite around. (so my sprite is always in the center of the screen)

What's the best way to go about this? Does Pixi have built-in camera functions? I thought about just moving everything else relative to my sprite, but I thought this wouldn't be the best way.

I googled around a bit, but with no luck. 

Any tips or resources would be much appreciated. :)


Link to comment
Share on other sites

No, PIXI doesnt have camera functions.

That's the best substitution:

var app = new PIXI.Application(...)

world.position.set(app.screen.width/2, app.screen.height/2);
world.scale.set(whatever you want)
world.rotation = some_rotation


The idea is that you PIN "sprite.position" which is relative to the stage, to global center of the screen. That's how position+pivot combination works.

Link to comment
Share on other sites

  • 2 weeks later...

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.

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.


  • Recently Browsing   0 members

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