Skip to content

Commit

Permalink
Closed #283
Browse files Browse the repository at this point in the history
  • Loading branch information
mantou132 committed Nov 23, 2023
1 parent 6812ba0 commit b524133
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/webapp/src/modules/stage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
RefObject,
styleMap,
attribute,
state,
} from '@mantou/gem';
import JSZip from 'jszip';
import { hotkeys } from 'duoyun-ui/lib/hotkeys';
Expand Down Expand Up @@ -68,6 +69,9 @@ const style = createCSSSheet(css`
display: block;
background: black;
}
:host(:where(:--playing, :state(playing))) {
cursor: none;
}
.canvas {
position: absolute;
inset: 0;
Expand Down Expand Up @@ -116,6 +120,7 @@ export class MStageElement extends GemElement<State> {
@refobject audioRef: RefObject<HTMLAudioElement>;
@refobject chatRef: RefObject<MRoomChatElement>;
@attribute padding: string;
@state playing: boolean;

state: State = {
messages: [],
Expand Down Expand Up @@ -443,6 +448,7 @@ export class MStageElement extends GemElement<State> {
};

#onPointerMove = (event: PointerEvent) => {
this.playing = false;
if (!this.#gameInstance) return;
const [x, y, dx, dy] = positionMapping(event, this.canvasRef.element!);
if (this.#isHost) {
Expand All @@ -453,6 +459,9 @@ export class MStageElement extends GemElement<State> {
};

#pressButton = (player: Player, button: Button) => {
if (button !== Button.PointerPrimary && button !== Button.PointerSecondary) {
this.playing = true;
}
if (button === Button.Reset) {
this.#gameInstance?.reset();
} else {
Expand Down

0 comments on commit b524133

Please sign in to comment.