Package gameobjects
Class RectObject
java.lang.Object
gameobjects.GameObject
gameobjects.RectObject
A rectangle object.
If
If
generateColliders()
is called, it generates a RectCollider with id-prefix
"shotcollider_" and registers it for this RectObject.-
Field Summary
-
Constructor Summary
ConstructorDescriptionRectObject
(String id, Playground pg, double x, double y, double vx, double vy, double width, double height, Color color) Initializes the RectObject with a suitable RectArtist for drawing the RectObject. -
Method Summary
Modifier and TypeMethodDescriptiongenerates a newRectCollider
with id-prefix "shotcollider_" and registers it for 'this' [@link RectObject}.double
Getter for the heightdouble
getWidth()
Getter for the widthMethods inherited from class gameobjects.GameObject
addArtist, addCollider, addController, collisionDetection, draw, getGameTime, getId, getObjectController, getObjectFlag, getOrCreateObjectFlag, getPlayground, getVX, getVY, getX, getY, isActive, setActive, setColliders, setComponentProperty, setObjectController, setObjectFlag, setPlayground, setVX, setVY, setX, setY, updateObject
-
Constructor Details
-
RectObject
public RectObject(String id, Playground pg, double x, double y, double vx, double vy, double width, double height, Color color) Initializes the RectObject with a suitable RectArtist for drawing the RectObject.- Parameters:
id
- String unique name to be used.pg
-Playground
instance this RectObject belongs to (the level it belongs to).x
- position in horizontal direction in pixels (zero or positive number).y
- position in vertical direction in pixels (zero or positive number).vx
- speed/velocity in horizontal direction in pixels (negative, zero or positive number).vy
- speed/velocity in vertical direction in pixels (negative, zero or positive number).width
- in pixelsheight
- in pixelscolor
- solid color for the whole object, used to initialize an instance ofRectArtist
used for this RectObject.
-
-
Method Details
-
generateColliders
generates a newRectCollider
with id-prefix "shotcollider_" and registers it for 'this' [@link RectObject}. TheRectCollider
uses the same dimensions (width
andheight
) as this RectObject.- Overrides:
generateColliders
in classGameObject
- Returns:
- this RectObject itself
-
getWidth
public double getWidth()Getter for the width- Returns:
- double width value as set by constructor
-
getHeight
public double getHeight()Getter for the height- Returns:
- double height value as set by constructor
-