UNPKG

duckengine

Version:
90 lines (89 loc) 3.1 kB
import { Duck } from '../../index'; import Game from '../game'; import Texture from '../texture/texture'; import Scene from '../scene'; import PhysicsBody from '../physics/physicsBody'; /** * @class GameObject * @classdesc Creates a DuckEngine GameObject * @description The GameObject Class. All GameObjects extend this class * @since 1.0.0-beta */ export default class GameObject<textureType extends Duck.Types.Texture.Type> extends PhysicsBody<textureType> implements Duck.Types.Renderable { /** * @memberof GameObject * @description The texture of the GameObject * @type Texture * @since 1.0.0-beta */ texture: Texture<textureType>; /** * @memberof GameObject * @description Determines if a GameObject should be rendered or not (note: Camera.cull and autoCull overwrite this property) * @type boolean * @since 2.0.0 */ visible: boolean; /** * @memberof GameObject * @description Determines the depth or zIndex of a GameObject * @type number * @since 2.0.0 */ zIndex: number; /** * @memberof GameObject * @description Determines if the GameObject should be visible by the current scene's current camera * @type boolean * @since 2.1.0 */ culled: boolean; /** * @constructor * @description Creates a GameObject instance. * @param {Duck.Types.Collider.ShapeString} shape Shape of the gameobject * @param {number} x X position * @param {number} y Y position * @param {number} w Width * @param {number} h Height * @param {number} r Radius * @param {string} fillColor Fill color or Texture instance * @param {Game} game Game instance * @param {Scene} scene Scene instance * @since 1.0.0-beta */ constructor(shape: Duck.Types.Collider.ShapeString, x: number, y: number, w: number, h: number, r: number, texture: Texture<textureType>, game: Game, scene: Scene); /** * @memberof GameObject * @description Draws the gameobject. * * DO NOT CALL MANUALLY, CALLED IN GAME LOOP USING SCENE.displayList * * @since 1.0.0-beta */ _draw(): void; /** * @memberof GameObject * @description Sets the visible property and calls the game.renderer.pipeline.pool method to immediately update the visibility * * **Note: this calls Game.renderer.pipeline.pool to immediately update the visibility** * * @param {boolean} visible What to set the visible property to * @since 2.1.0 */ setVisible(visible: boolean): void; /** * @memberof GameObject * @description Sets the scale of the GameObject * @param {Duck.Types.Misc.Scale|number} scale Scale of the gameobject, can be a number to change the radius * @since 1.0.0-beta */ setScale(scale: Duck.Types.Misc.Scale | number): void; /** * @memberof GameObject * @description Sets the fill color of the GameObject * @param {string} fillColor Fill color * @since 1.0.0-beta */ setFillColor(fillColor: string): void; }