excalibur
Version:
Excalibur.js is a simple JavaScript game engine with TypeScript bindings for making 2D games in HTML5 Canvas. Our mission is to make web game development as simple as possible.
53 lines (52 loc) • 1.51 kB
TypeScript
import { Graphic, GraphicOptions } from './Graphic';
import { ImageSource } from './ImageSource';
import { ExcaliburGraphicsContext } from './Context/ExcaliburGraphicsContext';
export type SourceView = {
x: number;
y: number;
width: number;
height: number;
};
export type DestinationSize = {
width: number;
height: number;
};
export interface SpriteOptions {
/**
* Image to create a sprite from
*/
image: ImageSource;
/**
* By default the source is the entire dimension of the {@apilink ImageSource}
*/
sourceView?: {
x: number;
y: number;
width: number;
height: number;
};
/**
* By default the size of the final sprite is the size of the {@apilink ImageSource}
*/
destSize?: {
width: number;
height: number;
};
}
export declare class Sprite extends Graphic {
private _logger;
image: ImageSource;
sourceView: SourceView;
destSize: DestinationSize;
private _dirty;
static from(image: ImageSource, options?: Omit<GraphicOptions & SpriteOptions, 'image'>): Sprite;
constructor(options: GraphicOptions & SpriteOptions);
get width(): number;
get height(): number;
set width(newWidth: number);
set height(newHeight: number);
private _updateSpriteDimensions;
protected _preDraw(ex: ExcaliburGraphicsContext, x: number, y: number): void;
_drawImage(ex: ExcaliburGraphicsContext, x: number, y: number): void;
clone(): Sprite;
}