minor improvements
This commit is contained in:
@@ -47,19 +47,21 @@ public class CameraSystem extends IteratingSystem {
|
|||||||
*/
|
*/
|
||||||
private void calcTargetPosition(Vector2 entityPosition) {
|
private void calcTargetPosition(Vector2 entityPosition) {
|
||||||
float targetX = entityPosition.x;
|
float targetX = entityPosition.x;
|
||||||
float targetY = entityPosition.y + CAM_OFFSET_Y;
|
|
||||||
float camHalfW = camera.viewportWidth * 0.5f;
|
float camHalfW = camera.viewportWidth * 0.5f;
|
||||||
if (mapW > camHalfW) {
|
if (mapW > camHalfW) {
|
||||||
float min = Math.min(camHalfW, mapW - camHalfW);
|
float min = Math.min(camHalfW, mapW - camHalfW);
|
||||||
float max = Math.max(camHalfW, mapW - camHalfW);
|
float max = Math.max(camHalfW, mapW - camHalfW);
|
||||||
targetX = MathUtils.clamp(targetX, min, max);
|
targetX = MathUtils.clamp(targetX, min, max);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float targetY = entityPosition.y + CAM_OFFSET_Y;
|
||||||
float camHalfH = camera.viewportHeight * 0.5f;
|
float camHalfH = camera.viewportHeight * 0.5f;
|
||||||
if (mapH > camHalfH) {
|
if (mapH > camHalfH) {
|
||||||
float min = Math.min(camHalfH, mapH - camHalfH);
|
float min = Math.min(camHalfH, mapH - camHalfH);
|
||||||
float max = Math.max(camHalfH, mapH - camHalfH);
|
float max = Math.max(camHalfH, mapH - camHalfH);
|
||||||
targetY = MathUtils.clamp(targetY, min, max);
|
targetY = MathUtils.clamp(targetY, min, max);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.targetPosition.set(targetX, targetY);
|
this.targetPosition.set(targetX, targetY);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,8 +81,6 @@ public class CameraSystem extends IteratingSystem {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Transform transform = Transform.MAPPER.get(camEntity);
|
processEntity(camEntity, 0f);
|
||||||
calcTargetPosition(transform.getPosition());
|
|
||||||
camera.position.set(this.targetPosition.x, this.targetPosition.y, camera.position.z);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -231,7 +231,7 @@ public class TiledAshleyConfigurator {
|
|||||||
private void addEntityPhysic(MapObjects mapObjects, BodyType bodyType, Vector2 relativeTo, Entity entity) {
|
private void addEntityPhysic(MapObjects mapObjects, BodyType bodyType, Vector2 relativeTo, Entity entity) {
|
||||||
if (mapObjects.getCount() == 0) return;
|
if (mapObjects.getCount() == 0) return;
|
||||||
|
|
||||||
Transform transform = entity.getComponent(Transform.class);
|
Transform transform = Transform.MAPPER.get(entity);
|
||||||
Body body = createBody(mapObjects,
|
Body body = createBody(mapObjects,
|
||||||
transform.getPosition(),
|
transform.getPosition(),
|
||||||
transform.getScaling(),
|
transform.getScaling(),
|
||||||
|
|||||||
Reference in New Issue
Block a user