refactor: Camera::realOffset

This commit is contained in:
cha0s 2019-04-13 18:13:38 -05:00
parent c938b49fc6
commit 6cc01948be

View File

@ -25,7 +25,6 @@ appNode.addEventListener('touchmove', (event) => {
});
// Graphics stage.
const visibleSize = [320, 180];
const halfVisibleSize = Vector.scale(visibleSize, 0.5);
const visibleScale = [2, 2];
const stage = new Stage(Vector.mul(visibleSize, visibleScale));
stage.scale = visibleScale;
@ -85,8 +84,7 @@ room.on('entityAdded', (entity) => {
}
const {camera} = entity;
camera.on('realPositionChanged', () => {
const offset = Vector.sub(halfVisibleSize, camera.realPosition);
roomView.position = offset;
roomView.position = Vector.scale(selfEntity.camera.realOffset, -1);
});
// Avoid the initial 'lerp.
camera.realPosition = camera.position;
@ -110,7 +108,7 @@ function createMoveToNormal(position) {
const entityPosition = selfEntity.position;
const realEntityPosition = Vector.sub(
entityPosition,
Vector.sub(selfEntity.camera.realPosition, halfVisibleSize)
selfEntity.camera.realOffset,
);
const magnitude = Vector.magnitude(position, realEntityPosition);
if (magnitude < 4) {