Tag Info

Hot answers tagged

9

Ok, that's awkward. My last edit revealed the answer to my problem (that I've been struggling with all day): QGraphicsView casts the camera x/y position to integers... This is the solution: void SceneView::centerOn(const QPointF &pos) { if (mScene) { mScene->setX(int(-(pos.x() - width() / 2))); mScene->setY(int(-(pos.y() - ...


2

When centering the camera using lookAt you need to clamp the y value to be the max of the body's y and the y of the ground plus half the viewport height (possibly adjusting for the height of the ground). Something like this might make sense; float x = body.getWorldCenter().x; float y = Math.max(body.getWorldCenter().y, ground.getWorldCenter().y + ...


2

It should work if you change these parts in show(): viewport = new ScalingViewport(Scaling.fillY, GAMESCREEN_WIDTH, GAMESCREEN_HEIGHT, camera = new OrthographicCamera()); and add a resize method: @Override public void resize(int width, int height) { int SCREEN_WIDTH = width; int SCREEN_HEIGHT = height; viewport.setWorldSize(GAMESCREEN_WIDTH, ...


1

GUI is actually rendered according to the screen view port and not according to the camera. In other words it is camera independent. You can try having a 3D text view or sprite in order to achieve the desired functionality. There are lot of other options also . Try Unity 5 GUI system or check out the NGUI plugin for unity. If you still want to use the ...


1

I had this class in previous project public class ExtendedCamera extends OrthographicCamera { public Player player; public ExtendedCamera(Player player) { super(Constants.WORLD_WIDTH, Constants.WORLD_HEIGHT); this.player = player; } public void followPlayer() { if (player.body.getPosition().x - position.x > ...


1

If you're using a tilemap, this transition is fairly easy to do. You will probably already have some sort of camera class. The thing is you only move the camera when the player reaches the edge. Suppose your screen is 20 tiles wide and 10 high, the camera shows 0, 0 to 19,9. If the character reaches the border of tile 19-20 set the camera to a 'transition ...


1

First, your entire map needs to be loaded (all "rooms/zones") like a single image. Next, you have a viewport that displays the Zone your in, say 0,0 to 50,50. next, you set collision to if player collides with zoneWallRight start a render loop that will render the map scroll in that direction. (move the view port x,y) at least, this is how I would do it. ...



Only top voted, non community-wiki answers of a minimum length are eligible