Package collider
Class Collider
java.lang.Object
collider.Collider
- Direct Known Subclasses:
CircleCollider
,RectCollider
abstract base class for all Colliders to detect collisions between GameObjects
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract boolean
collidesWith
(Collider other) checks the collission with another collider instance.getId()
returns the internal unique namedouble
getX()
returns the corresponding game objects X coordinate (center) plus this colliders offset in X (probably zero).double
getY()
returns the corresponding game objects Y coordinate (center) plus this colliders offset in Y (probably zero).void
setController
(ObjectController controller) setter for GameControllervoid
setObject
(GameObject gameObject) setter for corresponding GameObjectsetOffsets
(double dx, double dy) setter for offset values to be used relative to GameObject center. default is zero.void
setPlayground
(Playground playground) setter for Playground instance this collider belongs totoString()
-
Field Details
-
id
unique internal name for Collider
-
-
Constructor Details
-
Collider
- Parameters:
id
- unique name for Collider (internally)o
- GameObject instance it belongs to
-
-
Method Details
-
setOffsets
setter for offset values to be used relative to GameObject center. default is zero.- Parameters:
dx
- offset in X direction (default 0)dy
- offset in Y direction (default 0)- Returns:
- this instance of Collider
-
toString
-
getX
public double getX()returns the corresponding game objects X coordinate (center) plus this colliders offset in X (probably zero).- Returns:
- X value
-
getY
public double getY()returns the corresponding game objects Y coordinate (center) plus this colliders offset in Y (probably zero).- Returns:
- Y value
-
getId
returns the internal unique name- Returns:
- the String with the name
-
setObject
setter for corresponding GameObject- Parameters:
gameObject
- to be saved in attribute
-
setController
setter for GameController- Parameters:
controller
- to be saved in attribute
-
setPlayground
setter for Playground instance this collider belongs to- Parameters:
playground
- instance to be stored in attribute
-
collidesWith
checks the collission with another collider instance.- Parameters:
other
- the instance to compare to- Returns:
- true if the colliders collide (touch or overlap)
-