Added Line
This commit is contained in:
parent
c7a5df7923
commit
bbe0923523
9
lib/Line.js
Normal file
9
lib/Line.js
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
class Line {
|
||||||
|
constructor(x1, y1, x2, y2, style = "#000000") {
|
||||||
|
this.pos = { x: x1, y: y1 };
|
||||||
|
this.target = { x: x2, y: y2 };
|
||||||
|
this.style = style;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = Line;
|
@ -10,6 +10,7 @@ var AnimManager = require("./AnimManager.js"),
|
|||||||
State = require("./State.js"),
|
State = require("./State.js"),
|
||||||
Sound = require("./sound/Sound.js"),
|
Sound = require("./sound/Sound.js"),
|
||||||
Rect = require("./Rect.js"),
|
Rect = require("./Rect.js"),
|
||||||
|
Line = require("./Line.js"),
|
||||||
KeyControls = require("./controls/KeyControls.js"),
|
KeyControls = require("./controls/KeyControls.js"),
|
||||||
MouseControls = require("./controls/MouseControls.js"),
|
MouseControls = require("./controls/MouseControls.js"),
|
||||||
Sprite = require("./Sprite.js"),
|
Sprite = require("./Sprite.js"),
|
||||||
@ -35,6 +36,7 @@ module.exports = {
|
|||||||
State,
|
State,
|
||||||
Sound,
|
Sound,
|
||||||
Rect,
|
Rect,
|
||||||
|
Line,
|
||||||
KeyControls,
|
KeyControls,
|
||||||
MouseControls,
|
MouseControls,
|
||||||
Sprite,
|
Sprite,
|
||||||
|
@ -91,6 +91,11 @@ class CanvasRenderer {
|
|||||||
ctx.fillStyle = gradient;
|
ctx.fillStyle = gradient;
|
||||||
|
|
||||||
ctx.fill();
|
ctx.fill();
|
||||||
|
} else if (child.style && child.target) {
|
||||||
|
ctx.moveTo(0,0);
|
||||||
|
ctx.lineTo(child.target.x, child.target.y);
|
||||||
|
ctx.strokeStyle = child.style;
|
||||||
|
ctx.stroke();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle children with children
|
// Handle children with children
|
||||||
|
Loading…
Reference in New Issue
Block a user