fix: 循环地图显伤

This commit is contained in:
unanmed 2024-11-21 20:18:17 +08:00
parent a0f51092e2
commit 582fdf5fe9
6 changed files with 36 additions and 18 deletions

View File

@ -36,7 +36,7 @@ Mota.require('var', 'loading').once('coreInit', () => {
mapDraw.size(core._PX_, core._PY_);
floorChange.size(480, 480);
floorChange.setHD(true);
floorChange.setZIndex(10);
floorChange.setZIndex(50);
floorChange.setTips(tips);
pop.setZIndex(80);

View File

@ -337,7 +337,7 @@ export abstract class RenderItem<E extends ERenderItemEvent = ERenderItemEvent>
}
update(item: RenderItem<any> = this): void {
if (this.needUpdate) return;
if (this.needUpdate || this.hidden) return;
this.needUpdate = true;
this.cacheDirty = true;
this.parent?.update(item);

View File

@ -67,13 +67,11 @@ export class FloorDamageExtends
}
private onUpdate = (floor: FloorIds) => {
this.sprite.requestBeforeFrame(() => {
if (!this.floorBinder.bindThisFloor) {
ensureFloorDamage(floor);
core.status.maps[floor].enemy.calRealAttribute();
}
this.update(floor);
});
if (!this.floorBinder.bindThisFloor) {
ensureFloorDamage(floor);
core.status.maps[floor].enemy.calRealAttribute();
}
this.update(floor);
};
private onSetBlock = (x: number, y: number, floor: FloorIds) => {

View File

@ -33,7 +33,7 @@ export class MotaRenderer extends Container {
}
update(item: RenderItem = this) {
if (this.needUpdate) return;
if (this.needUpdate || this.hidden) return;
this.needUpdate = true;
this.requestRenderFrame(() => {
this.refresh(item);

View File

@ -178,8 +178,28 @@ export class Transform {
}
/**
*
* @param transform
*
* @param x
* @param y
*/
transformed(x: number, y: number) {
return multiplyVec3(this.mat, [x, y, 1]);
}
/**
*
* @param x
* @param y
*/
untransformed(x: number, y: number) {
const invert = mat3.create();
mat3.invert(invert, this.mat);
return multiplyVec3(invert, [x, y, 1]);
}
/**
*
* @param transform
* @param x
* @param y
*/
@ -188,8 +208,8 @@ export class Transform {
}
/**
*
* @param transform
*
* @param transform
* @param x
* @param y
*/

View File

@ -27,12 +27,12 @@ function createLayer() {
const damage = new FloorDamageExtends();
const detail = new FloorItemDetail();
group.id = 'layer-loop';
group.extends(damage);
group.extends(detail);
loopLayer = group;
group.setZIndex(20);
group.id = 'layer-loop';
}
function enableLoopMapElement(floorId: FloorIds) {
@ -61,18 +61,18 @@ function enableLoopMapElement(floorId: FloorIds) {
loopLayer.removeTicker(delegation);
delegation = loopLayer.delegateTicker(() => {
const [x1] = Transform.transformed(transform, 0, 0);
const [x1] = transform.transformed(0, 0);
const camera = loopLayer.camera;
if (x1 > 0) {
// 这个是计算循环地图应该显示在哪
const [, y2] = Transform.transformed(transform, x1 - testPos, 0);
const [, y2] = transform.transformed(x1 - testPos, 0);
camera.reset();
camera.translate(core._PX_ - testPos, y2);
loopLayer.pos(transform.x - core._PX_, 0);
loopLayer.show();
loopLayer.update(loopLayer);
} else {
const [x2, y2] = Transform.transformed(transform, testPos, 0);
const [x2, y2] = transform.transformed(testPos, 0);
if (x2 < core._PX_) {
// 这个不用做其他运算,可以直接显示
camera.reset();