public class CollidableModel extends TraitModel implements Collidable
The ObjectGame
owner must have the following Trait
:
The ObjectGame
owner must provide a valid Configurer
compatible
with CollisionConfig
.
The Services
must provide the following services:
If the ObjectGame
is a CollidableListener
, it will automatically
addListener(CollidableListener)
on it.
Constructor and Description |
---|
CollidableModel()
Create a collidable model.
|
Modifier and Type | Method and Description |
---|---|
void |
addCollision(Collision collision)
Add a collision to use.
|
void |
addIgnore(Collidable collidable)
Add a collidable to ignore list.
|
void |
addListener(CollidableListener listener)
Add a collision listener.
|
Collision |
collide(Collidable other)
Check if the collidable entered in collision with another one.
|
Iterable<Rectangle> |
getCollisionBounds()
Get the collisions bounds.
|
Iterable<Collision> |
getCollisions()
Get the declared collisions.
|
void |
notifyCollided(ObjectGame object)
Notify when a collision occurred with another
Collidable . |
void |
prepare(ObjectGame owner,
Services services)
Prepare the trait.
|
void |
render(Graphic g) |
void |
setCollisionVisibility(boolean visible)
Set the collision visibility.
|
void |
setEnabled(boolean enabled)
Set the collision enabled flag.
|
void |
setOrigin(Origin origin)
Set the origin to use.
|
void |
update(double extrp) |
getOwner
public void prepare(ObjectGame owner, Services services)
Trait
prepare
in interface Trait
prepare
in class TraitModel
owner
- The owner reference.services
- The services reference.public void addListener(CollidableListener listener)
Collidable
addListener
in interface Collidable
listener
- The listener reference.public void addCollision(Collision collision)
Collidable
addCollision
in interface Collidable
collision
- The collision to add.public void addIgnore(Collidable collidable)
Collidable
addIgnore
in interface Collidable
collidable
- The collidable to ignore on Collidable.collide(Collidable)
.public Collision collide(Collidable other)
Collidable
collide
in interface Collidable
other
- The collidable reference.null
if none.public void render(Graphic g)
render
in interface Renderable
public void setOrigin(Origin origin)
Collidable
setOrigin
in interface Collidable
origin
- The origin to use.public void setEnabled(boolean enabled)
Collidable
setEnabled
in interface Collidable
enabled
- true
to enable collision checking, false
else.public void setCollisionVisibility(boolean visible)
Collidable
setCollisionVisibility
in interface Collidable
visible
- true
if visible, false
else.public Iterable<Collision> getCollisions()
Collidable
getCollisions
in interface Collidable
public Iterable<Rectangle> getCollisionBounds()
Collidable
getCollisionBounds
in interface Collidable
public void notifyCollided(ObjectGame object)
CollidableListener
Collidable
.notifyCollided
in interface CollidableListener
object
- The collidable reference.Copyright © 2016 Byron 3D Games Studio. All rights reserved.