@drincs/pixi-vn
Version:
Pixi'VN is a npm package that provides various features for creating visual novels.
1 lines • 1.76 kB
Source Map (JSON)
{"version":3,"sources":["../../src/classes/CanvasEvent.ts"],"names":[],"mappings":";;;AAsBA,IAAqB,cAArB,MAAoC;AAAA,EAChC,WAAc,GAAA;AAOd;AAAA;AAAA;AAAA,IAAkB,IAAA,CAAA,EAAA,GAAA,kBAAA,CAAA;AANd,IAAK,IAAA,CAAA,EAAA,GAAK,IAAK,CAAA,WAAA,CAAY,SAAU,CAAA,EAAA,CAAA;AAAA,GACzC;AAAA,EACA,EAAA,CAAG,QAA8B,QAAa,EAAA;AAAE,IAAM,MAAA,IAAI,MAAM,0DAA0D,CAAA,CAAA;AAAA,GAAE;AAKhI","file":"CanvasEvent.js","sourcesContent":["import { eventDecorator } from \"../decorators\";\nimport { getEventInstanceById } from \"../decorators/EventDecorator\";\nimport { CanvasEventNamesType } from \"../types\";\nimport { EventIdType } from \"../types/EventIdType\";\n\n/**\n * CanvasEvent is a class that is used to create a pixi event, and connect it to a canvas element, with on().\n * This class should be extended and the fn method should be overridden.\n * You must use the {@link eventDecorator} to register the event in the game.\n * @example\n * ```typescript\n * \\@eventDecorator() // this is equivalent to eventDecorator(\"EventTest\")\n * export class EventTest extends CanvasEvent<CanvasSprite> {\n * override fn(event: CanvasEventNamesType, sprite: CanvasSprite): void {\n * if (event === 'pointerdown') {\n * sprite.scale.x *= 1.25;\n * sprite.scale.y *= 1.25;\n * }\n * }\n * }\n * ```\n */\nexport default class CanvasEvent<C> {\n constructor() {\n this.id = this.constructor.prototype.id\n }\n fn(_event: CanvasEventNamesType, _element: C) { throw new Error(\"[Pixi'VN] The method CanvasEvent.fn() must be overridden\") }\n /**\n * Get the id of the event. This variable is used in the system to get the event by id, {@link getEventInstanceById}\n */\n id: EventIdType = 'event_id_not_set'\n}\n"]}