Skip to content

Commit

Permalink
impl: is_object_clicked
Browse files Browse the repository at this point in the history
  • Loading branch information
gnlow committed Dec 29, 2023
1 parent 283e256 commit d11b395
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
}
Expand Down
15 changes: 15 additions & 0 deletions src/obj/EntryContainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down

0 comments on commit d11b395

Please sign in to comment.