Skip to main content

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:

new Line(x, y, endX, endY, [strokeColor])

ParamTypeDefaultDescription
xnumber

The horizontal position in the world.

ynumber

The vertical position in the world.

endXnumber

The horizontal position of the end of the line.

endYnumber

The vertical position of the end of the line.

[strokeColor]number | string0x000000

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

ParamTypeDescription
xnumber

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

ParamTypeDescription
ynumber

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.

ParamTypeDescription
widthnumber

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.

ParamTypeDescription
heightnumber

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.

ParamTypeDescription
widthnumber

The new width.

heightnumber

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.

ParamTypeDescription
endXnumber

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.

ParamTypeDescription
endYnumber

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.

ParamTypeDescription
endXnumber

The new horizontal position.

endYnumber

The new vertical position.

Example

new Impacto.GameObjects.Line(400, 300, 450, 350).setEnd(500, 400);