mirror of
https://github.com/unanmed/HumanBreak.git
synced 2025-01-19 12:49:25 +08:00
fix: 循环地图显伤
This commit is contained in:
parent
a0f51092e2
commit
582fdf5fe9
@ -36,7 +36,7 @@ Mota.require('var', 'loading').once('coreInit', () => {
|
|||||||
mapDraw.size(core._PX_, core._PY_);
|
mapDraw.size(core._PX_, core._PY_);
|
||||||
floorChange.size(480, 480);
|
floorChange.size(480, 480);
|
||||||
floorChange.setHD(true);
|
floorChange.setHD(true);
|
||||||
floorChange.setZIndex(10);
|
floorChange.setZIndex(50);
|
||||||
floorChange.setTips(tips);
|
floorChange.setTips(tips);
|
||||||
pop.setZIndex(80);
|
pop.setZIndex(80);
|
||||||
|
|
||||||
|
@ -337,7 +337,7 @@ export abstract class RenderItem<E extends ERenderItemEvent = ERenderItemEvent>
|
|||||||
}
|
}
|
||||||
|
|
||||||
update(item: RenderItem<any> = this): void {
|
update(item: RenderItem<any> = this): void {
|
||||||
if (this.needUpdate) return;
|
if (this.needUpdate || this.hidden) return;
|
||||||
this.needUpdate = true;
|
this.needUpdate = true;
|
||||||
this.cacheDirty = true;
|
this.cacheDirty = true;
|
||||||
this.parent?.update(item);
|
this.parent?.update(item);
|
||||||
|
@ -67,13 +67,11 @@ export class FloorDamageExtends
|
|||||||
}
|
}
|
||||||
|
|
||||||
private onUpdate = (floor: FloorIds) => {
|
private onUpdate = (floor: FloorIds) => {
|
||||||
this.sprite.requestBeforeFrame(() => {
|
if (!this.floorBinder.bindThisFloor) {
|
||||||
if (!this.floorBinder.bindThisFloor) {
|
ensureFloorDamage(floor);
|
||||||
ensureFloorDamage(floor);
|
core.status.maps[floor].enemy.calRealAttribute();
|
||||||
core.status.maps[floor].enemy.calRealAttribute();
|
}
|
||||||
}
|
this.update(floor);
|
||||||
this.update(floor);
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
private onSetBlock = (x: number, y: number, floor: FloorIds) => {
|
private onSetBlock = (x: number, y: number, floor: FloorIds) => {
|
||||||
|
@ -33,7 +33,7 @@ export class MotaRenderer extends Container {
|
|||||||
}
|
}
|
||||||
|
|
||||||
update(item: RenderItem = this) {
|
update(item: RenderItem = this) {
|
||||||
if (this.needUpdate) return;
|
if (this.needUpdate || this.hidden) return;
|
||||||
this.needUpdate = true;
|
this.needUpdate = true;
|
||||||
this.requestRenderFrame(() => {
|
this.requestRenderFrame(() => {
|
||||||
this.refresh(item);
|
this.refresh(item);
|
||||||
|
@ -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 x 横坐标
|
||||||
* @param y 纵坐标
|
* @param y 纵坐标
|
||||||
*/
|
*/
|
||||||
@ -188,8 +208,8 @@ export class Transform {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据摄像机的信息,将一个计算后的位置逆转换为原位置
|
* 根据变换矩阵的信息,将一个计算后的位置逆转换为原位置
|
||||||
* @param transform 摄像机
|
* @param transform 变换矩阵
|
||||||
* @param x 横坐标
|
* @param x 横坐标
|
||||||
* @param y 纵坐标
|
* @param y 纵坐标
|
||||||
*/
|
*/
|
||||||
|
@ -27,12 +27,12 @@ function createLayer() {
|
|||||||
|
|
||||||
const damage = new FloorDamageExtends();
|
const damage = new FloorDamageExtends();
|
||||||
const detail = new FloorItemDetail();
|
const detail = new FloorItemDetail();
|
||||||
|
group.id = 'layer-loop';
|
||||||
group.extends(damage);
|
group.extends(damage);
|
||||||
group.extends(detail);
|
group.extends(detail);
|
||||||
|
|
||||||
loopLayer = group;
|
loopLayer = group;
|
||||||
group.setZIndex(20);
|
group.setZIndex(20);
|
||||||
group.id = 'layer-loop';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function enableLoopMapElement(floorId: FloorIds) {
|
function enableLoopMapElement(floorId: FloorIds) {
|
||||||
@ -61,18 +61,18 @@ function enableLoopMapElement(floorId: FloorIds) {
|
|||||||
|
|
||||||
loopLayer.removeTicker(delegation);
|
loopLayer.removeTicker(delegation);
|
||||||
delegation = loopLayer.delegateTicker(() => {
|
delegation = loopLayer.delegateTicker(() => {
|
||||||
const [x1] = Transform.transformed(transform, 0, 0);
|
const [x1] = transform.transformed(0, 0);
|
||||||
const camera = loopLayer.camera;
|
const camera = loopLayer.camera;
|
||||||
if (x1 > 0) {
|
if (x1 > 0) {
|
||||||
// 这个是计算循环地图应该显示在哪
|
// 这个是计算循环地图应该显示在哪
|
||||||
const [, y2] = Transform.transformed(transform, x1 - testPos, 0);
|
const [, y2] = transform.transformed(x1 - testPos, 0);
|
||||||
camera.reset();
|
camera.reset();
|
||||||
camera.translate(core._PX_ - testPos, y2);
|
camera.translate(core._PX_ - testPos, y2);
|
||||||
loopLayer.pos(transform.x - core._PX_, 0);
|
loopLayer.pos(transform.x - core._PX_, 0);
|
||||||
loopLayer.show();
|
loopLayer.show();
|
||||||
loopLayer.update(loopLayer);
|
loopLayer.update(loopLayer);
|
||||||
} else {
|
} else {
|
||||||
const [x2, y2] = Transform.transformed(transform, testPos, 0);
|
const [x2, y2] = transform.transformed(testPos, 0);
|
||||||
if (x2 < core._PX_) {
|
if (x2 < core._PX_) {
|
||||||
// 这个不用做其他运算,可以直接显示
|
// 这个不用做其他运算,可以直接显示
|
||||||
camera.reset();
|
camera.reset();
|
||||||
|
Loading…
Reference in New Issue
Block a user