mirror of
https://github.com/photonstorm/phaser
synced 2024-12-23 11:33:28 +00:00
54 lines
No EOL
1.1 KiB
TypeScript
54 lines
No EOL
1.1 KiB
TypeScript
/// <reference path="../Game.ts" />
|
|
|
|
/**
|
|
* Phaser - Polygon
|
|
*
|
|
*
|
|
*/
|
|
|
|
module Phaser {
|
|
|
|
export class Polygon {
|
|
|
|
/**
|
|
*
|
|
**/
|
|
constructor(game: Game, points: Point[]) {
|
|
|
|
this.game = game;
|
|
this.context = game.stage.context;
|
|
|
|
this.points = [];
|
|
|
|
for (var i = 0; i < points.length; i++)
|
|
{
|
|
this.points.push(new Point().copyFrom(points[i]));
|
|
}
|
|
|
|
}
|
|
|
|
public points: Point[];
|
|
public game: Game;
|
|
public context: CanvasRenderingContext2D;
|
|
|
|
public render() {
|
|
|
|
this.context.beginPath();
|
|
this.context.strokeStyle = 'rgb(255,255,0)';
|
|
this.context.moveTo(this.points[0].x, this.points[0].y);
|
|
|
|
for (var i = 1; i < this.points.length; i++)
|
|
{
|
|
this.context.lineTo(this.points[i].x, this.points[i].y);
|
|
}
|
|
|
|
this.context.lineTo(this.points[0].x, this.points[0].y);
|
|
|
|
this.context.stroke();
|
|
this.context.closePath();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} |