Package collider
Class RectCollider
java.lang.Object
collider.Collider
collider.RectCollider
a
Collider
for Rectangles, usually used for RectObject
instances.- See Also:
-
Field Summary
-
Constructor Summary
ConstructorDescriptionRectCollider
(String id, GameObject o, double w, double h) initializes this RectCollider. -
Method Summary
Modifier and TypeMethodDescriptionboolean
checkCollisionRectCirc
(Collider other) checks collision with other Collider, which needs to be a CircleColliderboolean
checkCollisionRectRect
(Collider other) checks collision with other Collider, which needs to be a RectCollider, too.boolean
collidesWith
(Collider other) checks the collission with another collider instance.toString()
Methods inherited from class collider.Collider
getId, getX, getY, setController, setObject, setOffsets, setPlayground
-
Constructor Details
-
RectCollider
initializes this RectCollider. calls superclass constructor ofCollider(String, GameObject)
with params String id and GameObject o.- Parameters:
id
- String unique name for this RectCollidero
- GameObject instance this RectCollider belongs to (cannot be null)w
- width in pixels for the collider dimensions (> 0)h
- height in pixels for the collider dimensions (>0)
-
-
Method Details
-
toString
-
checkCollisionRectRect
checks collision with other Collider, which needs to be a RectCollider, too.- Parameters:
other
- RectCollider (is casted) to calculate collision with- Returns:
- true if collission is detected
-
checkCollisionRectCirc
checks collision with other Collider, which needs to be a CircleCollider- Parameters:
other
- CircleCollider (is casted) to calculate collision with- Returns:
- true if collission is detected
-
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)
-