UNPKG

duckengine

Version:
80 lines (79 loc) 2.72 kB
import Game from '../game'; import { Duck } from '../../index'; import GameObject from './gameObject'; import Scene from '../scene'; import AnimationManager from '../animation/animationManager'; import Animation from '../animation/animation'; /** * @class Sprite * @classdesc Creates a DuckEngine Sprite * @description The Sprite Class. Represents a gameobject image * @since 1.0.0-beta */ export default class Sprite extends GameObject<'image'> { /** * @memberof Sprite * @description The current row of the spritesheet texture, only if sprite texture is a spritesheet * @type number | undefined * @since 2.0.0 */ currentRow: number | undefined; /** * @memberof Sprite * @description The current column of the spritesheet texture, only if sprite texture is a spritesheet * @type number | undefined * @since 2.0.0 */ currentCol: number | undefined; /** * @memberof Sprite * @description The AnimationManager instance, if the texture is a spritesheet * @type AnimationManager | undefined * @since 2.0.0 */ anims: AnimationManager | undefined; /** * @memberof Sprite * @description The Default Animation instance, if the texture is a spritesheet * @type Animation | undefined * @since 2.0.0 */ defaultAnim: Animation | undefined; /** * @constructor Sprite * @description Creates a Sprite instance * @param {number} x X position * @param {number} y Y position * @param {number} w Width of Sprite * @param {number} h Height of Sprite * @param {string} textureKey Key of a preloaded texture sheet * @param {Game} game Game instance * @param {Scene} scene Scene instance * @param {number} [currentRow] The default row to use for the spritesheet texture * @param {number} [currentCol] The default column to use for the spritesheet texture * @since 1.0.0-beta */ constructor(x: number, y: number, w: number, h: number, textureKey: string, game: Game, scene: Scene, currentRow?: number, currentCol?: number); /** * @description Draws the sprite. * * DO NOT CALL MANUALLY, CALLED IN GAME LOOP USING SCENE.displayList * */ _draw(): void; /** * @memberof Sprite * @description Sets the scale of the Sprite * @param {Duck.Types.Misc.Scale} scale * @since 1.0.0-beta */ setScale(scale: Duck.Types.Misc.Scale): void; /** * @memberof Sprite * @description Sets the image path of the sprite * @param {string} imgpath Image Path * @since 1.0.0-beta */ setImagePath(imgpath: string): void; setFillColor(color: string): void; }