Package collider
Class CircleCollider
java.lang.Object
collider.Collider
collider.CircleCollider
Collider for round objects
-
Field Summary
-
Constructor Summary
ConstructorDescriptionCircleCollider
(String id, GameObject o, double radius) Constructor which sets the radius to be respected for collisions. -
Method Summary
Modifier and TypeMethodDescriptionboolean
calculates the collission of this with other colliderboolean
collidesWith
(Collider other) checks the collission with another collider instance.toString()
simple concatenation of all attributes (x,y,r)Methods inherited from class collider.Collider
getId, getX, getY, setController, setObject, setOffsets, setPlayground
-
Constructor Details
-
CircleCollider
Constructor which sets the radius to be respected for collisions.- Parameters:
id
- String unique name for the collider instanceo
- GameObject it belongs toradius
- radius in pixels to use as a size
-
-
Method Details
-
toString
simple concatenation of all attributes (x,y,r) -
checkCollisionCircCirc
calculates the collission of this with other collider- Parameters:
_c2
- the other collider- Returns:
- true if a collision was detected
- Throws:
Exception
- in case the math operations are invalid (due to illegal values of x y or radius)
-
collidesWith
Description copied from class:Collider
checks the collission with another collider instance.- Specified by:
collidesWith
in classCollider
- Parameters:
other
- the instance to compare to- Returns:
- true if the colliders collide (touch or overlap)
-