mirror of
https://github.com/wassname/phaser.git
synced 2026-07-27 11:25:30 +08:00
25 lines
487 B
TypeScript
25 lines
487 B
TypeScript
// Interface
|
|
interface IPoint {
|
|
getDist(): number;
|
|
}
|
|
|
|
// Module
|
|
module Shapes {
|
|
|
|
// Class
|
|
export class Point implements IPoint {
|
|
// Constructor
|
|
constructor (public x: number, public y: number) { }
|
|
|
|
// Instance member
|
|
getDist() { return Math.sqrt(this.x * this.x + this.y * this.y); }
|
|
|
|
// Static member
|
|
static origin = new Point(0, 0);
|
|
}
|
|
|
|
}
|
|
|
|
// Local variables
|
|
var p: IPoint = new Shapes.Point(3, 4);
|
|
var dist = p.getDist(); |