NITWIT Posted October 3, 2017 Share Posted October 3, 2017 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. Thanks. ivan.popelyshev 1 Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted October 3, 2017 Share Posted October 3, 2017 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 world.pivot.copy(sprite.position); 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. Gerente 1 Quote Link to comment Share on other sites More sharing options...
NITWIT Posted October 17, 2017 Author Share Posted October 17, 2017 Just wanted to say thanks! I messed around with your code snippet and got it working. ivan.popelyshev 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.