camera.mapSize 支持左上顶点更改

This commit is contained in:
YHH
2020-08-08 15:09:10 +08:00
parent a39b98b5d9
commit 14b70b307c
7 changed files with 13 additions and 13 deletions
+1 -1
View File
@@ -476,7 +476,7 @@ declare module es {
deadzone: Rectangle; deadzone: Rectangle;
focusOffset: Vector2; focusOffset: Vector2;
mapLockEnabled: boolean; mapLockEnabled: boolean;
mapSize: Vector2; mapSize: Rectangle;
_targetEntity: Entity; _targetEntity: Entity;
_targetCollider: Collider; _targetCollider: Collider;
_desiredPositionDelta: Vector2; _desiredPositionDelta: Vector2;
+3 -3
View File
@@ -2189,7 +2189,7 @@ var es;
_this.deadzone = new es.Rectangle(); _this.deadzone = new es.Rectangle();
_this.focusOffset = es.Vector2.zero; _this.focusOffset = es.Vector2.zero;
_this.mapLockEnabled = false; _this.mapLockEnabled = false;
_this.mapSize = es.Vector2.zero; _this.mapSize = new es.Rectangle();
_this._desiredPositionDelta = new es.Vector2(); _this._desiredPositionDelta = new es.Vector2();
_this._worldSpaceDeadZone = new es.Rectangle(); _this._worldSpaceDeadZone = new es.Rectangle();
_this._minimumZoom = 0.3; _this._minimumZoom = 0.3;
@@ -2415,8 +2415,8 @@ var es;
} }
}; };
Camera.prototype.clampToMapSize = function (position) { Camera.prototype.clampToMapSize = function (position) {
var halfScreen = es.Vector2.multiply(new es.Vector2(this.bounds.width, this.bounds.height), new es.Vector2(0.5)); var halfScreen = es.Vector2.multiply(new es.Vector2(this.bounds.width, this.bounds.height), new es.Vector2(0.5)).add(new es.Vector2(this.mapSize.x, this.mapSize.y));
var cameraMax = new es.Vector2(this.mapSize.x - halfScreen.x, this.mapSize.y - halfScreen.y); var cameraMax = new es.Vector2(this.mapSize.width - halfScreen.x, this.mapSize.height - halfScreen.y);
return es.Vector2.clamp(position, halfScreen, cameraMax); return es.Vector2.clamp(position, halfScreen, cameraMax);
}; };
Camera.prototype.updateFollow = function () { Camera.prototype.updateFollow = function () {
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -476,7 +476,7 @@ declare module es {
deadzone: Rectangle; deadzone: Rectangle;
focusOffset: Vector2; focusOffset: Vector2;
mapLockEnabled: boolean; mapLockEnabled: boolean;
mapSize: Vector2; mapSize: Rectangle;
_targetEntity: Entity; _targetEntity: Entity;
_targetCollider: Collider; _targetCollider: Collider;
_desiredPositionDelta: Vector2; _desiredPositionDelta: Vector2;
+3 -3
View File
@@ -2189,7 +2189,7 @@ var es;
_this.deadzone = new es.Rectangle(); _this.deadzone = new es.Rectangle();
_this.focusOffset = es.Vector2.zero; _this.focusOffset = es.Vector2.zero;
_this.mapLockEnabled = false; _this.mapLockEnabled = false;
_this.mapSize = es.Vector2.zero; _this.mapSize = new es.Rectangle();
_this._desiredPositionDelta = new es.Vector2(); _this._desiredPositionDelta = new es.Vector2();
_this._worldSpaceDeadZone = new es.Rectangle(); _this._worldSpaceDeadZone = new es.Rectangle();
_this._minimumZoom = 0.3; _this._minimumZoom = 0.3;
@@ -2415,8 +2415,8 @@ var es;
} }
}; };
Camera.prototype.clampToMapSize = function (position) { Camera.prototype.clampToMapSize = function (position) {
var halfScreen = es.Vector2.multiply(new es.Vector2(this.bounds.width, this.bounds.height), new es.Vector2(0.5)); var halfScreen = es.Vector2.multiply(new es.Vector2(this.bounds.width, this.bounds.height), new es.Vector2(0.5)).add(new es.Vector2(this.mapSize.x, this.mapSize.y));
var cameraMax = new es.Vector2(this.mapSize.x - halfScreen.x, this.mapSize.y - halfScreen.y); var cameraMax = new es.Vector2(this.mapSize.width - halfScreen.x, this.mapSize.height - halfScreen.y);
return es.Vector2.clamp(position, halfScreen, cameraMax); return es.Vector2.clamp(position, halfScreen, cameraMax);
}; };
Camera.prototype.updateFollow = function () { Camera.prototype.updateFollow = function () {
+1 -1
View File
File diff suppressed because one or more lines are too long
+3 -3
View File
@@ -37,7 +37,7 @@ module es {
/** /**
* *
*/ */
public mapSize: Vector2 = Vector2.zero; public mapSize: Rectangle = new Rectangle();
public _targetEntity: Entity; public _targetEntity: Entity;
public _targetCollider: Collider; public _targetCollider: Collider;
public _desiredPositionDelta: Vector2 = new Vector2(); public _desiredPositionDelta: Vector2 = new Vector2();
@@ -385,8 +385,8 @@ module es {
* @param position * @param position
*/ */
public clampToMapSize(position: Vector2) { public clampToMapSize(position: Vector2) {
let halfScreen = Vector2.multiply(new Vector2(this.bounds.width, this.bounds.height), new Vector2(0.5)); let halfScreen = Vector2.multiply(new Vector2(this.bounds.width, this.bounds.height), new Vector2(0.5)).add(new Vector2(this.mapSize.x, this.mapSize.y));
let cameraMax = new Vector2(this.mapSize.x - halfScreen.x, this.mapSize.y - halfScreen.y); let cameraMax = new Vector2(this.mapSize.width - halfScreen.x, this.mapSize.height - halfScreen.y);
return Vector2.clamp(position, halfScreen, cameraMax); return Vector2.clamp(position, halfScreen, cameraMax);
} }