diff --git a/components/packages/Platform/THPlatform.js b/components/packages/Platform/THPlatform.js index fa9a7b4..76ff18c 100644 --- a/components/packages/Platform/THPlatform.js +++ b/components/packages/Platform/THPlatform.js @@ -42,9 +42,9 @@ class THPlatform extends JlPlatform { this.codeGraphic.draw(); this.lozengeGraphic.draw(); if (this.datas.direction == 'down') { - this.doorGraphic.changePosition(); - this.codeGraphic.changePosition(); - this.lozengeGraphic.changePosition(); + this.doorGraphic.changePosition(this.position); + this.codeGraphic.changePosition(this.position); + this.lozengeGraphic.changePosition(this.position); } //门的状态 if (this.datas.hasdoor) { diff --git a/components/packages/Platform/common/JlPlatform.d.ts b/components/packages/Platform/common/JlPlatform.d.ts index b86138c..be5197a 100644 --- a/components/packages/Platform/common/JlPlatform.d.ts +++ b/components/packages/Platform/common/JlPlatform.d.ts @@ -1,5 +1,5 @@ import { JlGraphic, VectorText } from 'jl-graphic'; -import { Container, Graphics } from 'pixi.js'; +import { Container, Graphics, IPointData } from 'pixi.js'; import { IPlatformData, PlatformConstsConfig } from './PlatformConfig'; declare class RectGraphic extends Container { platformConsts: PlatformConstsConfig; @@ -16,7 +16,7 @@ export declare class DoorGraphic extends Container { stateFillColor?: string; constructor(platformConsts: PlatformConstsConfig); draw(): void; - changePosition(): void; + changePosition(platformPos: IPointData): void; clear(): void; } export declare class CodeGraphic extends Container { @@ -28,7 +28,7 @@ export declare class CodeGraphic extends Container { circle: Graphics; constructor(platformConsts: PlatformConstsConfig); draw(): void; - changePosition(): void; + changePosition(platformPos: IPointData): void; clear(): void; } export declare class LozengeGraphic extends Container { @@ -36,7 +36,7 @@ export declare class LozengeGraphic extends Container { lozenge: Graphics; constructor(platformConsts: PlatformConstsConfig); draw(): void; - changePosition(): void; + changePosition(platformPos: IPointData): void; clear(): void; } export declare class DoorCodeLozenge extends Container { @@ -45,7 +45,7 @@ export declare class DoorCodeLozenge extends Container { lozengeGraphic: LozengeGraphic; codeGraphic: CodeGraphic; constructor(platformConsts: PlatformConstsConfig); - draw(hasDoor: boolean, direction: string): void; + draw(hasDoor: boolean, direction: string, platformPos: IPointData): void; } export declare abstract class JlPlatform extends JlGraphic { static Type: string; diff --git a/components/packages/Platform/common/JlPlatform.js b/components/packages/Platform/common/JlPlatform.js index 196e46d..f00863b 100644 --- a/components/packages/Platform/common/JlPlatform.js +++ b/components/packages/Platform/common/JlPlatform.js @@ -64,8 +64,8 @@ class DoorGraphic extends Container { .lineTo(doorConsts.doorOpenSpacing, 0); this.position.set(0, -platformConsts.height / 2 - doorConsts.doorPlatformSpacing); } - changePosition() { - this.doorGraphic.position.copyFrom(calculateMirrorPoint(new Point(0, 0), this.position)); + changePosition(platformPos) { + this.position.copyFrom(calculateMirrorPoint(new Point(0, 0), platformPos)); } clear() { this.doorGraphic.clear(); @@ -141,7 +141,7 @@ class CodeGraphic extends Container { runTime.visible = false; this.position.set(0, 0); } - changePosition() { + changePosition(platformPos) { const platformConsts = this.platformConsts; const codeConsts = platformConsts.codeGraphic; const psChange = [ @@ -152,7 +152,7 @@ class CodeGraphic extends Container { ]; psChange.forEach((g) => { if (g) { - g.position.copyFrom(calculateMirrorPoint(new Point(0, 0), g.position)); + g.position.copyFrom(calculateMirrorPoint(new Point(0, 0), platformPos)); } }); this.circle.position.set(platformConsts.width / 2 + @@ -191,8 +191,8 @@ class LozengeGraphic extends Container { LozengeConsts.doorPlatformSpacing - platformConsts.height / 3); } - changePosition() { - this.position.copyFrom(calculateMirrorPoint(new Point(0, 0), this.position)); + changePosition(platformPos) { + this.position.copyFrom(calculateMirrorPoint(new Point(0, 0), platformPos)); } clear() { this.lozenge.clear(); @@ -213,7 +213,7 @@ class DoorCodeLozenge extends Container { this.codeGraphic = new CodeGraphic(this.platformConsts); this.addChild(this.codeGraphic); } - draw(hasDoor, direction) { + draw(hasDoor, direction, platformPos) { this.doorGraphic.clear(); if (hasDoor) { this.doorGraphic.draw(); @@ -221,9 +221,9 @@ class DoorCodeLozenge extends Container { this.codeGraphic.draw(); this.lozengeGraphic.draw(); if (direction == 'down') { - this.doorGraphic.changePosition(); - this.codeGraphic.changePosition(); - this.lozengeGraphic.changePosition(); + this.doorGraphic.changePosition(platformPos); + this.codeGraphic.changePosition(platformPos); + this.lozengeGraphic.changePosition(platformPos); } } } diff --git a/src/packages/Platform/THPlatform.ts b/src/packages/Platform/THPlatform.ts index 3df9aa8..a3930e9 100644 --- a/src/packages/Platform/THPlatform.ts +++ b/src/packages/Platform/THPlatform.ts @@ -88,9 +88,9 @@ export class THPlatform extends JlPlatform { this.codeGraphic.draw(); this.lozengeGraphic.draw(); if (this.datas.direction == 'down') { - this.doorGraphic.changePosition(); - this.codeGraphic.changePosition(); - this.lozengeGraphic.changePosition(); + this.doorGraphic.changePosition(this.position); + this.codeGraphic.changePosition(this.position); + this.lozengeGraphic.changePosition(this.position); } //门的状态 if (this.datas.hasdoor) { diff --git a/src/packages/Platform/common/JlPlatform.ts b/src/packages/Platform/common/JlPlatform.ts index c4c241b..5636e53 100644 --- a/src/packages/Platform/common/JlPlatform.ts +++ b/src/packages/Platform/common/JlPlatform.ts @@ -5,7 +5,14 @@ import { distance2, getRectangleCenter, } from 'jl-graphic'; -import { Container, Graphics, Rectangle, Color, Point } from 'pixi.js'; +import { + Container, + Graphics, + Rectangle, + Color, + Point, + IPointData, +} from 'pixi.js'; import { CodeConstsConfig, DoorConstsConfig, @@ -82,10 +89,8 @@ export class DoorGraphic extends Container { -platformConsts.height / 2 - doorConsts.doorPlatformSpacing, ); } - changePosition() { - this.doorGraphic.position.copyFrom( - calculateMirrorPoint(new Point(0, 0), this.position), - ); + changePosition(platformPos: IPointData) { + this.position.copyFrom(calculateMirrorPoint(new Point(0, 0), platformPos)); } clear(): void { this.doorGraphic.clear(); @@ -176,7 +181,7 @@ export class CodeGraphic extends Container { runTime.visible = false; this.position.set(0, 0); } - changePosition() { + changePosition(platformPos: IPointData) { const platformConsts = this.platformConsts; const codeConsts = platformConsts.codeGraphic as CodeConstsConfig; const psChange = [ @@ -187,7 +192,7 @@ export class CodeGraphic extends Container { ]; psChange.forEach((g) => { if (g) { - g.position.copyFrom(calculateMirrorPoint(new Point(0, 0), g.position)); + g.position.copyFrom(calculateMirrorPoint(new Point(0, 0), platformPos)); } }); this.circle.position.set( @@ -237,10 +242,8 @@ export class LozengeGraphic extends Container { platformConsts.height / 3, ); } - changePosition() { - this.position.copyFrom( - calculateMirrorPoint(new Point(0, 0), this.position), - ); + changePosition(platformPos: IPointData) { + this.position.copyFrom(calculateMirrorPoint(new Point(0, 0), platformPos)); } clear(): void { this.lozenge.clear(); @@ -262,7 +265,7 @@ export class DoorCodeLozenge extends Container { this.codeGraphic = new CodeGraphic(this.platformConsts); this.addChild(this.codeGraphic); } - draw(hasDoor: boolean, direction: string) { + draw(hasDoor: boolean, direction: string, platformPos: IPointData) { this.doorGraphic.clear(); if (hasDoor) { this.doorGraphic.draw(); @@ -270,9 +273,9 @@ export class DoorCodeLozenge extends Container { this.codeGraphic.draw(); this.lozengeGraphic.draw(); if (direction == 'down') { - this.doorGraphic.changePosition(); - this.codeGraphic.changePosition(); - this.lozengeGraphic.changePosition(); + this.doorGraphic.changePosition(platformPos); + this.codeGraphic.changePosition(platformPos); + this.lozengeGraphic.changePosition(platformPos); } } }