Fixed typings #6

Merged
arne merged 2 commits from corner-typings-patch into master 2020-05-26 15:33:40 +02:00

24
lib/index.d.ts vendored
View File

@ -2,6 +2,11 @@ export as namespace asdf;
type Coordinates = {x: number, y: number}; type Coordinates = {x: number, y: number};
class Renderable {
visible?: boolean;
dead?: boolean
}
/** /**
* TileSpriteXML class * TileSpriteXML class
*/ */
@ -158,13 +163,13 @@ interface TextStyleOptions {
/** /**
* Text class * Text class
*/ */
export class Text { export class Text extends Renderable {
pos: Coordinates; pos: Coordinates;
text: string; text: string;
visible: boolean; visible: boolean;
update?: (dt?: number, t?: number) => void; update?: (dt?: number, t?: number) => void;
style: TextStyleOptions' style: TextStyleOptions;
/** /**
* Prints styled text on canvas * Prints styled text on canvas
@ -219,15 +224,13 @@ export class SpriteSheetXML {
/** /**
* Sprite class * Sprite class
*/ */
export class Sprite { export class Sprite extends Renderable {
texture: Texture; texture: Texture;
pos: Coordinates; pos: Coordinates;
anchor: Coordinates; anchor: Coordinates;
scale: Coordinates; scale: Coordinates;
pivot: Coordinates; pivot: Coordinates;
visible: boolean;
rotation: number; rotation: number;
dead: boolean;
update?: (dt?: number, t?: number) => void; update?: (dt?: number, t?: number) => void;
@ -246,6 +249,7 @@ export class Game {
h: number; h: number;
renderer: CanvasRenderer; renderer: CanvasRenderer;
scene: Container<unknown>; scene: Container<unknown>;
paused: boolean;
/** /**
* Set the games parameters * Set the games parameters
@ -260,14 +264,14 @@ export class Game {
* Start game loop * Start game loop
* @param gameUpdate Function to run next to scene updates such as debug logging, etc. * @param gameUpdate Function to run next to scene updates such as debug logging, etc.
*/ */
run(gameUpdate: (dt?: number, t?: number) => void): void; run(gameUpdate?: (dt?: number, t?: number) => void): void;
} }
/** /**
* Container class * Container class
*/ */
export class Container<T> { export class Container<T> {
pos: {x: number, y: number}; pos: Coordinates;
children: T[]; children: T[];
constructor(); constructor();
@ -409,7 +413,7 @@ export class KeyControls {
* @param value Value to set to key * @param value Value to set to key
* @return Value of key * @return Value of key
*/ */
key(key: number, value: boolean): boolean; key(key: number, value?: boolean): boolean;
/** /**
* Resets default value (false) to all keys * Resets default value (false) to all keys
@ -574,8 +578,8 @@ export class Camera extends Container<unknown> {
} }
interface SoundOptions { interface SoundOptions {
loop: boolean, loop?: boolean,
volume: number volume?: number
} }
export class Sound { export class Sound {