API Docs for: 0.3.0
Show:

Collision.CollisionBox Class

The CollisionBox class allow you to declare a bounding box to test collisions between other collisions boxes and collisions circles.

Constructor

Collision.CollisionBox

(
  • x
  • y
  • w
  • h
)

Parameters:

  • x Number

    the x coordinate of the collision box

  • y Number

    the y coordinate of the collision box

  • w Number

    the width of the collision box

  • h Number

    the height of the collision box

Methods

isCollidingBox

(
  • box
)
Boolean

The isCollidingBox method allow you to test if the current CollisionBox object is colliding the CollisionBox object given in parameter.

Parameters:

  • box CollisionBox

    the CollisionBox object to test the collision with

Returns:

Boolean: return true if the box object is colliding the this object.

isCollidingCircle

(
  • circle
)
Boolean

The isCollidingCircle method allow you to test if the current CollisionBox is colliding the CollisionCircle object.

Parameters:

  • circle CollisionCircle

    the CollisionCircle object to test the collision with.

Returns:

Boolean: if the current CollisionBox is colliding the CollisionCircle object, then the isCollidingCircle function will return true otherwise it will return false.

isPointInside

(
  • px
  • py
)
Boolean

The isPointInside method allow you to test if a point is inside the bouncing box.

Parameters:

  • px Number

    the x coordinate of the point

  • py Number

    the y coordinate of the point

Returns:

Boolean: true if the point is inside the box, else return false.

isSegmentCollidingCircle

(
  • ax
  • ay
  • bx
  • by
  • circle
)
Boolean

The isSegmentCollidingCircle method allow you to test if a segment is colliding a circle

Parameters:

  • ax Number

    the x coordinate of the first point of the segment

  • ay Number

    the y coordinate of the first point of the segment

  • bx Number

    the x coordinate of the second point of the segment

  • by Number

    the y coordinate of the second point of the segment

  • circle CollisionCircle

    the CollisionCircle object to test collision with the segment

Returns:

Boolean: return true if circle and the segment are colliding, else return false.

Properties

height

Number

type

String

type of Collision object

width

Number