UNPKG

duckengine

Version:
74 lines (73 loc) 2.41 kB
import { Duck } from '../../../index'; import Game from '../../game'; import Scene from '../../scene'; import Text from './text'; import UI from './ui'; /** * @class Button * @classdesc Creates a DuckEngine Button * @description The Button Class. Acts like a Button * @extends UI * @since 1.0.0 */ export default class Button extends UI<'either'> { /** * @memberof Button * @description Shape of the button * @type Duck.Types.UI.Button.Shape * @since 1.0.0 */ shape: Duck.Types.UI.Button.Shape; /** * @memberof Button * @description Text of the button, Text instance * @type Text * @since 1.0.0 */ text: Text; /** * @memberof Button * @description Hovering state * @type boolean * @since 1.0.0 */ hovering: boolean; /** * @constructor * @description Creates a Button instance * @param {Duck.Types.UI.Button.Shape} shape Shape of the button, 'rect', 'roundrect', or 'sprite' * @param {number} x X position * @param {number} y Y position * @param {number} w Width * @param {number} h Height * @param {number} r Radius * @param {string} fillColorOrIMGPath Fill Color or Image path of the button * @param {Text} text Text instance to render on top of the button * @param {Game} game Game instance * @param {Scene} scene Scene instance * @since 1.0.0 */ constructor(shape: Duck.Types.UI.Button.Shape, x: number, y: number, w: number, h: number, r: number, fillColorOrIMGPath: string, text: Text, game: Game, scene: Scene); /** * @description Draws the button. * * DO NOT CALL MANUALLY, CALLED IN GAME LOOP USING SCENE.displayList * */ _draw(): void; /** * @memberof Button * @description Adds an event listener to the button * @param {Duck.Types.UI.Button.ListenerType} type Listener Type, type of event * @param {Duck.Types.UI.Button.ListenerFunc} func Callback function, called on event * @since 1.0.0 */ on(type: Duck.Types.UI.Button.ListenerType, func: Duck.Types.UI.Button.ListenerFunc): void; /** * @memberof Button * @description Removes an event listener from the button * @param {Duck.Types.UI.Button.ListenerType} type Listener Type, type of event * @since 1.0.0 */ off(type: Duck.Types.UI.Button.ListenerType): void; }