UNPKG

@moderrkowo/jsgl

Version:

Client-side JavaScript library for creating web 2D games. Focusing at objective game.

22 lines (18 loc) 541 B
import { GameObjectSpawnEvent } from '../events/gameobject/GameObjectSpawnEvent'; import { Sprite } from './Sprite'; /** * @group Game Objects */ export class SimpleSprite extends Sprite { private readonly _imageResourceKey: string; public constructor(imageResourceKey: string) { super(); this._imageResourceKey = imageResourceKey; } public override Start(event: GameObjectSpawnEvent): void { this.texture = event.game.GetImage( this._imageResourceKey ) as HTMLImageElement; event.game.Update(); } }