Line.js
Line ⇐ Impacto.GameObjects.GameObject2D
Line is a class that will draw a line on the canvas.
Kind: global class
Extends: Impacto.GameObjects.GameObject2D
Constructors:
- Line ⇐
Impacto.GameObjects.GameObject2D
- new Line(x, y, endX, endY, [strokeColor])
- .width ⇒
number
- .height ⇒
number
- .x
- .y
- .x ⇒
number
- .y ⇒
number
- .getTop() ⇒
number
- .getBottom() ⇒
number
- .getLeft() ⇒
number
- .getRight() ⇒
number
- .getCenterX() ⇒
number
- .getCenterY() ⇒
number
- .getRealTop() ⇒
number
- .getRealBottom() ⇒
number
- .getRealLeft() ⇒
number
- .getRealRight() ⇒
number
- .getRealCenterX() ⇒
number
- .getRealCenterY() ⇒
number
- .setWidth(width) ⇒
Line
- .setHeight(height) ⇒
Line
- .setSize(width, height) ⇒
Line
- .setEndX(endX) ⇒
Line
- .setEndY(endY) ⇒
Line
- .setEnd(endX, endY) ⇒
Line
new Line(x, y, endX, endY, [strokeColor])
Param | Type | Default | Description |
---|---|---|---|
x | number | The horizontal position in the world. | |
y | number | The vertical position in the world. | |
endX | number | The horizontal position of the end of the line. | |
endY | number | The vertical position of the end of the line. | |
[strokeColor] | number | string | 0x000000 | The color of the border, i.e. 0x00ff00 for green. |
Example
const myLine = new Impacto.GameObjects.Line(400, 300, 450, 350, 0x00ff00);
Line.width ⇒ number
Kind: static property of Line
Returns: number
-
The width of the line.
Line.height ⇒ number
Kind: static property of Line
Returns: number
-
The height of the line.
Line.x
Sets the X position.
Kind: static property of Line
Param | Type | Description |
---|---|---|
x | number | The horizontal position in the world. |
Example
const myLine = new Impacto.GameObjects.Line(0, 0, 100, 100);
myLine.x = 200;
Line.y
Sets the Y position.
Kind: static property of Line
Param | Type | Description |
---|---|---|
y | number | The vertical position in the world. |
Example
const myLine = new Impacto.GameObjects.Line(0, 0, 100, 100);
myLine.y = 200;
Line.x ⇒ number
Kind: static property of Line
Returns: number
-
The horizontal position.
Line.y ⇒ number
Kind: static property of Line
Returns: number
-
The vertical position.
Line.getTop() ⇒ number
Returns the top side position of the Line.
Kind: static method of Line
Returns: number
-
The vertical position of this Line in the world relative to the origin.
Example
new Impacto.GameObjects.Line(400, 300, 450, 350).getTop(); // 300
Line.getBottom() ⇒ number
Returns the bottom side position of the Line.
Kind: static method of Line
Returns: number
-
The vertical position of this Line in the world relative to the origin.
Example
new Impacto.GameObjects.Line(400, 300, 450, 350).getBottom(); // 325
Line.getLeft() ⇒ number
Returns the left side position of the Line.
Kind: static method of Line
Returns: number
-
The horizontal position of this Line in the world relative to the origin.
Example
new Impacto.GameObjects.Line(400, 300, 450, 350).getLeft(); // 400
Line.getRight() ⇒ number
Returns the right side position of the Line.
Kind: static method of Line
Returns: number
-
The horizontal position of this Line in the world relative to the origin.
Example
new Impacto.GameObjects.Line(400, 300, 450, 350).getRight(); // 450
Line.getCenterX() ⇒ number
Returns the center X position of the Line.
Kind: static method of Line
Returns: number
-
The horizontal position of this Line in the world relative to the origin.
Example
new Impacto.GameObjects.Line(400, 300, 450, 350).getCenterX(); // 425
Line.getCenterY() ⇒ number
Returns the center Y position of the Line.
Kind: static method of Line
Returns: number
-
The vertical position of this Line in the world relative to the origin.
Example
new Impacto.GameObjects.Line(400, 300, 450, 350).getCenterY(); // 325
Line.getRealTop() ⇒ number
Returns the real top side position of the Line (not relative to the origin).
Kind: static method of Line
Returns: number
-
The vertical position of this Line in the world.
Example
new Impacto.GameObjects.Line(400, 300, 450, 350).getRealTop(); // 300
Line.getRealBottom() ⇒ number
Returns the real bottom side position of the Line (not relative to the origin).
Kind: static method of Line
Returns: number
-
The vertical position of this Line in the world.
Example
new Impacto.GameObjects.Line(400, 300, 450, 350).getRealBottom(); // 350
Line.getRealLeft() ⇒ number
Returns the real left side position of the Line (not relative to the origin).
Kind: static method of Line
Returns: number
-
The horizontal position of this Line in the world.
Example
new Impacto.GameObjects.Line(400, 300, 450, 350).getRealLeft(); // 400
Line.getRealRight() ⇒ number
Returns the real right side position of the Line (not relative to the origin).
Kind: static method of Line
Returns: number
-
The horizontal position of this Line in the world.
Example
new Impacto.GameObjects.Line(400, 300, 450, 350).getRealRight(); // 450
Line.getRealCenterX() ⇒ number
Returns the real center X position of the Line (not relative to the origin).
Kind: static method of Line
Returns: number
-
The horizontal position of this Line in the world.
Example
new Impacto.GameObjects.Line(400, 300, 450, 350).getRealCenterX(); // 425
Line.getRealCenterY() ⇒ number
Returns the real center Y position of the Line (not relative to the origin).
Kind: static method of Line
Returns: number
-
The vertical position of this Line in the world.
Example
new Impacto.GameObjects.Line(400, 300, 450, 350).getRealCenterY(); // 325
Line.setWidth(width) ⇒ Line
Sets the end position of the Line based on the width.
Kind: static method of Line
Returns: Line
-
This Line.
Param | Type | Description |
---|---|---|
width | number | The new width. |
Example
new Impacto.GameObjects.Line(400, 300, 450, 350).setWidth(100);
Line.setHeight(height) ⇒ Line
Sets the end position of the Line based on the height.
Kind: static method of Line
Returns: Line
-
This Line.
Param | Type | Description |
---|---|---|
height | number | The new height. |
Example
new Impacto.GameObjects.Line(400, 300, 450, 350).setHeight(100);
Line.setSize(width, height) ⇒ Line
Sets the end position of the Line based on the size.
Kind: static method of Line
Returns: Line
-
This Line.
Param | Type | Description |
---|---|---|
width | number | The new width. |
height | number | The new height. |
Example
new Impacto.GameObjects.Line(400, 300, 450, 350).setSize(100, 100);
Line.setEndX(endX) ⇒ Line
Sets the end horizontal position.
Kind: static method of Line
Returns: Line
-
This Line.
Param | Type | Description |
---|---|---|
endX | number | The new horizontal position. |
Example
new Impacto.GameObjects.Line(400, 300, 450, 350).setEndX(500);
Line.setEndY(endY) ⇒ Line
Sets the end vertical position.
Kind: static method of Line
Returns: Line
-
This Line.
Param | Type | Description |
---|---|---|
endY | number | The new vertical position. |
Example
new Impacto.GameObjects.Line(400, 300, 450, 350).setEndY(500);
Line.setEnd(endX, endY) ⇒ Line
Sets the end position of the Line.
Kind: static method of Line
Returns: Line
-
This Line.
Param | Type | Description |
---|---|---|
endX | number | The new horizontal position. |
endY | number | The new vertical position. |
Example
new Impacto.GameObjects.Line(400, 300, 450, 350).setEnd(500, 400);