refactor: Camera::realOffset
This commit is contained in:
parent
c938b49fc6
commit
6cc01948be
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user