Jump to content

2D Camera


Sentinel
 Share

Recommended Posts

I've taken a look at pixi-viewport and I really like it except for the ease drag part and the fact that it can't return a PIXI.DisplayObject that I can add myself to the stage and render it.      t
So I have a Pixi.Container I want the camera to move around instead of it inheriting the render and using its own render loop.

Basically I want the same result as the Phaser.io Camera

 

Maybe the documentation is just confusing me, but I can't seem to get it to work like I want.

 

Is there any other way to do this? Because I want to have a GUI overlay.

Link to comment
Share on other sites

22 minutes ago, ivan.popelyshev said:

Search for "camera" in this subforum, I've made some simple solutions and people commented with their editions.

Found what I was looking for.

Is there any way I can implement a mouse drag event? So the camera follows the cursor position while dragging, and doesn't when drag has ended.

Link to comment
Share on other sites

I had that thing buried somewhere. Sorry, its lost. You have to look up all the threads about drag , and take closest solution.

Oh, wait, found one: http://pixijs.io/examples/#/projection/basic.js , good example of how to drag and click elements. Dont mind pixi-projection usage.

If it doesnt suit you, learn how toLocal/toGlobal and those things work, I'm sure you can find solution. I've used something like that for 2d maps and elements on them before.

Link to comment
Share on other sites

1 hour ago, ivan.popelyshev said:

I had that thing buried somewhere. Sorry, its lost. You have to look up all the threads about drag , and take closest solution.

Oh, wait, found one: http://pixijs.io/examples/#/projection/basic.js , good example of how to drag and click elements. Dont mind pixi-projection usage.

If it doesnt suit you, learn how toLocal/toGlobal and those things work, I'm sure you can find solution. I've used something like that for 2d maps and elements on them before.

Got it working from the projection example.

Thanks a lot for the spoonfeeding :D

Link to comment
Share on other sites

  • 3 years later...

That's default solution. You can also use "pivot" and not a position.

basically,

stage.position.set(renderer.screen.width/2, renderer.screen.height/2);
stage.scale.set(1.33);//scale it whatever you want
stage.pivot.set(myCharacter.x, myCharacter.y); //now character inside stage is mapped to center of screen

 

Link to comment
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...
 Share

  • Recently Browsing   0 members

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