mirror of
https://github.com/wassname/phaser.git
synced 2026-08-16 11:25:21 +08:00
Preparing for new release
This commit is contained in:
@@ -1,76 +1,81 @@
|
||||
/// <reference path="../../Game.ts" />
|
||||
/// <reference path="Mouse.ts" />
|
||||
/// <reference path="Keyboard.ts" />
|
||||
/// <reference path="Touch.ts" />
|
||||
|
||||
class Input {
|
||||
/**
|
||||
* Phaser
|
||||
*/
|
||||
|
||||
constructor(game: Game) {
|
||||
module Phaser {
|
||||
|
||||
this._game = game;
|
||||
export class Input {
|
||||
|
||||
this.mouse = new Mouse(this._game);
|
||||
this.keyboard = new Keyboard(this._game);
|
||||
this.touch = new Touch(this._game);
|
||||
constructor(game: Game) {
|
||||
|
||||
this._game = game;
|
||||
|
||||
this.mouse = new Mouse(this._game);
|
||||
this.keyboard = new Keyboard(this._game);
|
||||
this.touch = new Touch(this._game);
|
||||
|
||||
}
|
||||
|
||||
private _game: Game;
|
||||
|
||||
public mouse: Mouse;
|
||||
public keyboard: Keyboard;
|
||||
public touch: Touch;
|
||||
|
||||
public x: number = 0;
|
||||
public y: number = 0;
|
||||
|
||||
public scaleX: number = 1;
|
||||
public scaleY: number = 1;
|
||||
|
||||
public worldX: number = 0;
|
||||
public worldY: number = 0;
|
||||
|
||||
public update() {
|
||||
|
||||
this.x = Math.round(this.x);
|
||||
this.y = Math.round(this.y);
|
||||
|
||||
this.worldX = this._game.camera.worldView.x + this.x;
|
||||
this.worldY = this._game.camera.worldView.y + this.y;
|
||||
|
||||
this.mouse.update();
|
||||
this.touch.update();
|
||||
|
||||
}
|
||||
|
||||
public reset() {
|
||||
|
||||
this.mouse.reset();
|
||||
this.keyboard.reset();
|
||||
this.touch.reset();
|
||||
|
||||
}
|
||||
|
||||
public getWorldX(camera?: Camera = this._game.camera) {
|
||||
|
||||
return camera.worldView.x + this.x;
|
||||
|
||||
}
|
||||
|
||||
public getWorldY(camera?: Camera = this._game.camera) {
|
||||
|
||||
return camera.worldView.y + this.y;
|
||||
|
||||
}
|
||||
|
||||
public renderDebugInfo(x: number, y: number, color?: string = 'rgb(255,255,255)') {
|
||||
|
||||
this._game.stage.context.fillStyle = color;
|
||||
this._game.stage.context.fillText('Input', x, y);
|
||||
this._game.stage.context.fillText('Screen X: ' + this.x + ' Screen Y: ' + this.y, x, y + 14);
|
||||
this._game.stage.context.fillText('World X: ' + this.worldX + ' World Y: ' + this.worldY, x, y + 28);
|
||||
this._game.stage.context.fillText('Scale X: ' + this.scaleX.toFixed(1) + ' Scale Y: ' + this.scaleY.toFixed(1), x, y + 42);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private _game: Game;
|
||||
|
||||
public mouse: Mouse;
|
||||
public keyboard: Keyboard;
|
||||
public touch: Touch;
|
||||
|
||||
public x: number = 0;
|
||||
public y: number = 0;
|
||||
|
||||
public scaleX: number = 1;
|
||||
public scaleY: number = 1;
|
||||
|
||||
public worldX: number = 0;
|
||||
public worldY: number = 0;
|
||||
|
||||
public update() {
|
||||
|
||||
this.x = Math.round(this.x);
|
||||
this.y = Math.round(this.y);
|
||||
|
||||
this.worldX = this._game.camera.worldView.x + this.x;
|
||||
this.worldY = this._game.camera.worldView.y + this.y;
|
||||
|
||||
this.mouse.update();
|
||||
this.touch.update();
|
||||
|
||||
}
|
||||
|
||||
public reset() {
|
||||
|
||||
this.mouse.reset();
|
||||
this.keyboard.reset();
|
||||
this.touch.reset();
|
||||
|
||||
}
|
||||
|
||||
public getWorldX(camera?: Camera = this._game.camera) {
|
||||
|
||||
return camera.worldView.x + this.x;
|
||||
|
||||
}
|
||||
|
||||
public getWorldY(camera?: Camera = this._game.camera) {
|
||||
|
||||
return camera.worldView.y + this.y;
|
||||
|
||||
}
|
||||
|
||||
public renderDebugInfo(x: number, y: number, color?: string = 'rgb(255,255,255)') {
|
||||
|
||||
this._game.stage.context.fillStyle = color;
|
||||
this._game.stage.context.fillText('Input', x, y);
|
||||
this._game.stage.context.fillText('Screen X: ' + this.x + ' Screen Y: ' + this.y, x, y + 14);
|
||||
this._game.stage.context.fillText('World X: ' + this.worldX + ' World Y: ' + this.worldY, x, y + 28);
|
||||
this._game.stage.context.fillText('Scale X: ' + this.scaleX.toFixed(1) + ' Scale Y: ' + this.scaleY.toFixed(1), x, y + 42);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user