1
0
Fork 0
spacetac/src/ui/common/UIOverlay.ts

25 lines
817 B
TypeScript
Raw Normal View History

2018-06-06 17:09:31 +00:00
module TK.SpaceTac.UI {
export interface UIOverlayOptions {
color: number,
alpha?: number,
on_click?: Function
}
/**
* UI component to display a semi-transparent overlay that fills the whole view and captures inputs
*/
export class UIOverlay extends UIGraphics {
constructor(view: BaseView, options: UIOverlayOptions) {
super(view, "overlay");
let rect = { x: 0, y: 0, width: view.getWidth(), height: view.getHeight() };
this.addRectangle(rect, options.color, undefined, undefined, options.alpha);
2018-06-12 21:40:33 +00:00
this.setInteractive({
hitArea: rect,
hitAreaCallback: Phaser.Geom.Rectangle.Contains,
});
2018-06-06 17:09:31 +00:00
this.on("pointerup", options.on_click || nop);
}
}
}