From d11b3956af5b6f842e002b9566653b654fe36514 Mon Sep 17 00:00:00 2001 From: Gnlow Date: Fri, 29 Dec 2023 14:30:01 +0900 Subject: [PATCH] impl: is_object_clicked --- src/Entry.ts | 3 +++ src/obj/EntryContainer.ts | 15 +++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/Entry.ts b/src/Entry.ts index c7daf3a..39499bb 100644 --- a/src/Entry.ts +++ b/src/Entry.ts @@ -662,6 +662,9 @@ export class Entry { is_clicked() { return this.isClicked } + is_object_clicked(obj: EntryContainer) { + return obj.isClicked + } is_press_some_key(keyCode: string) { return !!this.pressedKeys[Number(keyCode)] } diff --git a/src/obj/EntryContainer.ts b/src/obj/EntryContainer.ts index f124ceb..179578e 100644 --- a/src/obj/EntryContainer.ts +++ b/src/obj/EntryContainer.ts @@ -90,6 +90,21 @@ export abstract class EntryContainer extends EventEmitter { this.pixiSprite.alpha = 1 - (n / 100) } + _isClicked?: boolean + get isClicked() { + if (typeof this._isClicked == "undefined") { + this.setEventMode("static") + this.pixiSprite.on("pointerdown", () => { + this._isClicked = true + }) + this.pixiSprite.on("pointerup", () => { + this._isClicked = false + }) + this._isClicked = false + } + return this._isClicked + } + destroy() { this.pixiSprite.destroy() }