E
- The entity type used.E2
- The source type used.public abstract class ProjectileGame<E extends EntityGame,E2 extends Surface> extends EntityGame
Constructor and Description |
---|
ProjectileGame(SetupSurfaceGame setup)
Create a new projectile.
|
Modifier and Type | Method and Description |
---|---|
boolean |
canBeAdded()
Check if projectile can be added in the handler (related to delay).
|
boolean |
canHitOnlyTarget()
Get the hit target only state.
|
E2 |
getOwner()
Get the owner.
|
int |
getProjectileId()
Get the id value.
|
E |
getTarget()
Get the target.
|
abstract void |
onHit(E entity,
int damages)
Action called when projectile hit an entity.
|
abstract void |
render(com.b3dgs.lionengine.Graphic g,
CameraGame camera)
Render the projectile.
|
void |
setCanHitTargetOnly(boolean hitTargetOnly)
Set the hit target properties.
|
void |
setDelay(long delay)
Set projectile delay (time before being added in the handler).
|
void |
setId(int id)
Set the id.
|
void |
setOwner(E2 owner)
Set the projectile owner.
|
void |
setTarget(E target)
Set the projectile target.
|
void |
start(int x,
int y,
int offX,
int offY,
double vecX,
double vecY)
Start projectile handling.
|
void |
update(double extrp)
Update the entity.
|
collide, collide, getCollisionBounds, getCollisionData, getCollisionRay, getDistance, getHeight, getLocationIntX, getLocationIntY, getLocationOffsetX, getLocationOffsetY, getLocationOldX, getLocationOldY, getLocationX, getLocationY, getMass, getMirror, getMirrorCancel, getWeight, getWidth, invertAxisY, mirror, moveLocation, moveLocation, renderCollision, resetGravity, setCollision, setGravityMax, setLocation, setLocationOffset, setLocationX, setLocationY, setMass, setMirrorCancel, setSize, teleport, teleportX, teleportY, updateCollision, updateGravity, updateMirror
destroy, getDataAnimation, getDataBoolean, getDataCollision, getDataDouble, getDataInteger, getDataRoot, getDataString, getId, isDestroyed, loadData
public final Damages damages
public ProjectileGame(SetupSurfaceGame setup)
<entity surface="projectile.png">
<size width="10" height="10"/>
<offset x="0" y="0"/>
</entity>
setup
- The entity setup.public abstract void render(com.b3dgs.lionengine.Graphic g, CameraGame camera)
g
- The graphic output.camera
- The camera reference.public abstract void onHit(E entity, int damages)
entity
- The entity hit.damages
- The damages.public void start(int x, int y, int offX, int offY, double vecX, double vecY)
x
- The horizontal location.y
- The vertical location.offX
- The horizontal location offset.offY
- The vertical location offset.vecX
- The horizontal vector.vecY
- The vertical vector.public void setTarget(E target)
target
- The entity target.public void setId(int id)
id
- The projectile id (when a projectile is destroyed, all projectiles with this id are also destroyed).
Can be -1 to ignore it.public void setCanHitTargetOnly(boolean hitTargetOnly)
hitTargetOnly
- true
to make the projectile hit only the target, false
to allows
other hits.public void setOwner(E2 owner)
owner
- The entity owner.public void setDelay(long delay)
delay
- The delay time.public E2 getOwner()
public E getTarget()
public int getProjectileId()
public boolean canHitOnlyTarget()
true
if can hit only the target, false
else.public boolean canBeAdded()
true
if can be added, false
else.public void update(double extrp)
EntityGame
update
in class EntityGame
extrp
- The extrapolation value.