private void setupCamera() { this.defaultCamera = new C2dCamera(this.engineConfig.width, this.engineConfig.height); }
@Override public int getValues(C2dCamera target, int tweenType, float[] returnValues) { switch (tweenType) { case Zoom: returnValues[0] = target.zoom; return 1; case XY: returnValues[0] = target.position.x; returnValues[1] = target.position.y; return 2; case ROTATION: returnValues[0] = target.getRotate(); return 1; default: assert false; return -1; } }
@Override public void resize(int width, int height) { if (this.engineConfig.resizeSync) { this.engineConfig.width = width; this.engineConfig.height = height; this.defaultCamera.resize(width, height); } }
public void resize(float width, float height) { this.viewportWidth = width; this.viewportHeight = height; this.position.set(width / 2, height / 2, 0); this.update(); }
@Override public void setValues(C2dCamera target, int tweenType, float[] newValues) { switch (tweenType) { case Zoom: target.zoom = newValues[0]; break; case XY: target.position.x = newValues[0]; target.position.y = newValues[1]; break; case ROTATION: target.setRotate(newValues[0]); break; default: assert false; } }
public final static Vector2 screenToWorld(float x, float y) { // ray = instance.defaultCamera.getPickRay(x, y); // Intersector.intersectRayPlane(ray, xzPlane, intersection); instance.defaultCamera.unproject(unproject.set(x, y, 0)); // screenCoords.x = Vector3.tmp.x; // screenCoords.y = Vector3.tmp.y; return new Vector2(unproject.x, unproject.y); }
@Override public void render(float delta) { outgoing.render(delta); if(null!=incoming){ targetCamera.update(); Engine.getSpriteBatch().setProjectionMatrix(targetCamera.combined); incoming.render(delta); } }
@Override public void render(float delta) { incoming.render(delta); targetCamera.position.set(this.targetPositionOffset()); targetCamera.update(); Engine.getSpriteBatch().setProjectionMatrix(targetCamera.combined); outgoing.render(delta); }
@Override protected void doTransition(int halfDurationMillis ) { this.targetCamera = new C2dCamera(Engine.getWidth(), Engine.getHeight()); //add the init offset this.targetCamera.position.add(this.iniTargetPositionOffset()); outgoing.hide(); Tween .to(targetCamera, C2dCameraAccessor.XY, halfDurationMillis*2).target(Engine.getWidth()/2, Engine.getHeight()/2) .setCallback(new TweenCallback() { @Override public void onEvent(int type, BaseTween<?> source) { doSetMainScene(incoming); Gdx.input.setInputProcessor(incoming.getInputProcessor()); incoming.show(); Engine.getDefaultCamera().position.set(Engine.getWidth()/2, Engine.getHeight()/2,Engine.getHeight()/2); reset(); } }).start(Engine.getTweenManager()); }
this.defaultCamera.update(); this.spriteBatch.setProjectionMatrix(this.defaultCamera.combined); if (startupLoading.isLoaded()) {
@Override protected void doTransition(int halfDurationMillis) { this.targetCamera = new C2dCamera(Engine.getWidth(), Engine.getHeight()); final Vector3 positionBak = Engine.getDefaultCamera().position.cpy(); outgoing.hide(); Engine.getDefaultCamera().position.set(orgiPosition().x, orgiPosition().y, positionBak.z); Tween .to(Engine.getDefaultCamera(), C2dCameraAccessor.XY, halfDurationMillis*2).target(positionBak.x,positionBak.y) .setCallback(new TweenCallback() { @Override public void onEvent(int type, BaseTween<?> source) { doSetMainScene(incoming); Gdx.input.setInputProcessor(incoming.getInputProcessor()); incoming.show(); Engine.getDefaultCamera().position.set(positionBak); reset(); } }).start(Engine.getTweenManager()); }