mirror of
https://github.com/unanmed/HumanBreak.git
synced 2025-01-19 04:19:30 +08:00
fix: 视角同步问题 & delegateTicker执行时机
This commit is contained in:
parent
297b67da5b
commit
e5e0458891
@ -76,6 +76,7 @@ import './render/index';
|
|||||||
import * as RenderUtils from './render/utils';
|
import * as RenderUtils from './render/utils';
|
||||||
import '@/module';
|
import '@/module';
|
||||||
import { MotaOffscreenCanvas2D } from './fx/canvas2d';
|
import { MotaOffscreenCanvas2D } from './fx/canvas2d';
|
||||||
|
import { TextboxStore } from './render/index';
|
||||||
|
|
||||||
// ----- 类注册
|
// ----- 类注册
|
||||||
Mota.register('class', 'AudioPlayer', AudioPlayer);
|
Mota.register('class', 'AudioPlayer', AudioPlayer);
|
||||||
@ -163,7 +164,8 @@ Mota.register('module', 'Render', {
|
|||||||
LayerGroupFloorBinder,
|
LayerGroupFloorBinder,
|
||||||
Camera,
|
Camera,
|
||||||
MotaOffscreenCanvas2D,
|
MotaOffscreenCanvas2D,
|
||||||
Utils: RenderUtils
|
Utils: RenderUtils,
|
||||||
|
TextboxStore
|
||||||
});
|
});
|
||||||
Mota.register('module', 'Action', {
|
Mota.register('module', 'Action', {
|
||||||
HeroKeyMover
|
HeroKeyMover
|
||||||
|
@ -67,8 +67,10 @@ export class FloorViewport implements ILayerGroupRenderExtends {
|
|||||||
const halfHeight = core._PY_ / 2;
|
const halfHeight = core._PY_ / 2;
|
||||||
const cell = this.group.cellSize;
|
const cell = this.group.cellSize;
|
||||||
const half = cell / 2;
|
const half = cell / 2;
|
||||||
this.nx = -(nx - halfWidth + half) / this.group.cellSize;
|
this.applyPosition(
|
||||||
this.ny = -(ny - halfHeight + half) / this.group.cellSize;
|
-(nx - halfWidth + half) / this.group.cellSize,
|
||||||
|
-(ny - halfHeight + half) / this.group.cellSize
|
||||||
|
);
|
||||||
this.mutateTo(x, y);
|
this.mutateTo(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,8 +118,7 @@ export class FloorViewport implements ILayerGroupRenderExtends {
|
|||||||
if (!this.enabled) return;
|
if (!this.enabled) return;
|
||||||
const { x: nx, y: ny } = this.getBoundedPosition(x, y);
|
const { x: nx, y: ny } = this.getBoundedPosition(x, y);
|
||||||
this.group.removeTicker(this.transition, false);
|
this.group.removeTicker(this.transition, false);
|
||||||
this.nx = nx;
|
this.applyPosition(nx, ny);
|
||||||
this.ny = ny;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -198,8 +199,7 @@ export class FloorViewport implements ILayerGroupRenderExtends {
|
|||||||
|
|
||||||
const { x, y } = this.hero!.renderable;
|
const { x, y } = this.hero!.renderable;
|
||||||
const { x: nx, y: ny } = this.getBoundedPosition(x, y);
|
const { x: nx, y: ny } = this.getBoundedPosition(x, y);
|
||||||
this.nx = nx;
|
this.applyPosition(nx, ny);
|
||||||
this.ny = ny;
|
|
||||||
|
|
||||||
if (ending) {
|
if (ending) {
|
||||||
if (this.ox === xTarget && this.oy == yTarget) {
|
if (this.ox === xTarget && this.oy == yTarget) {
|
||||||
@ -264,41 +264,32 @@ export class FloorViewport implements ILayerGroupRenderExtends {
|
|||||||
const progress = fn((now - start) / time);
|
const progress = fn((now - start) / time);
|
||||||
const tx = dx * progress;
|
const tx = dx * progress;
|
||||||
const ty = dy * progress;
|
const ty = dy * progress;
|
||||||
this.nx = tx + sx;
|
this.applyPosition(tx + sx, ty + sy);
|
||||||
this.ny = ty + sy;
|
|
||||||
},
|
},
|
||||||
time,
|
time,
|
||||||
() => {
|
() => {
|
||||||
this.nx = x;
|
this.applyPosition(x, y);
|
||||||
this.ny = y;
|
|
||||||
this.inTransition = false;
|
this.inTransition = false;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private create() {
|
private applyPosition(x: number, y: number) {
|
||||||
let nx = this.nx;
|
if (!this.enabled) return;
|
||||||
let ny = this.ny;
|
if (x === this.nx && y === this.ny) return;
|
||||||
const halfWidth = core._PX_ / 2;
|
const halfWidth = core._PX_ / 2;
|
||||||
const halfHeight = core._PY_ / 2;
|
const halfHeight = core._PY_ / 2;
|
||||||
this.delegation = this.group.delegateTicker(() => {
|
|
||||||
if (!this.enabled) return;
|
|
||||||
if (this.nx === nx && this.ny === ny) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const cell = this.group.cellSize;
|
const cell = this.group.cellSize;
|
||||||
const half = cell / 2;
|
const half = cell / 2;
|
||||||
nx = this.nx;
|
this.nx = x;
|
||||||
ny = this.ny;
|
this.ny = y;
|
||||||
const { x: bx, y: by } = this.getBoundedPosition(nx, ny);
|
const { x: bx, y: by } = this.getBoundedPosition(x, y);
|
||||||
const rx = bx * cell - halfWidth + half;
|
const rx = bx * cell - halfWidth + half;
|
||||||
const ry = by * cell - halfHeight + half;
|
const ry = by * cell - halfHeight + half;
|
||||||
core.bigmap.offsetX = rx;
|
core.bigmap.offsetX = rx;
|
||||||
core.bigmap.offsetY = ry;
|
core.bigmap.offsetY = ry;
|
||||||
this.group.camera.setTranslate(-rx, -ry);
|
this.group.camera.setTranslate(-rx, -ry);
|
||||||
this.group.update(this.group);
|
this.group.update(this.group);
|
||||||
});
|
|
||||||
// this.createMoving();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private checkDependency() {
|
private checkDependency() {
|
||||||
@ -319,7 +310,6 @@ export class FloorViewport implements ILayerGroupRenderExtends {
|
|||||||
|
|
||||||
awake(group: LayerGroup): void {
|
awake(group: LayerGroup): void {
|
||||||
this.group = group;
|
this.group = group;
|
||||||
this.create();
|
|
||||||
adapter.add(this);
|
adapter.add(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user