Class Projectile
java.lang.Object
com.codename1.gaming.platformer.LevelEntity
com.codename1.gaming.platformer.Projectile
A bullet, arrow or fireball: flies at a fixed velocity, optionally falls, and
damages the first actor of another team it touches. It disappears on a
solid tile, on a hit, or when its range runs out.
-
Field Summary
Fields inherited from class LevelEntity
h, w, x, y -
Constructor Summary
ConstructorsConstructorDescriptionProjectile(String id, String type, int x, int y, int size, int vx, int vy, int gravity, int team, int damage, int lifeTicks) Creates a projectile. -
Method Summary
Modifier and TypeMethodDescriptionintgetVx()The horizontal speed, which the view uses to flip the sprite.longhashState(long h) Mixes the entity's play-relevant state into a hash.voidonTouch(PlatformWorld world, Actor c) Called each tick a living actor overlaps the entity.voidstep(PlatformWorld world) Advances one tick.Methods inherited from class LevelEntity
deactivate, getId, getPhase, getTouchMargin, getType, isActive, onAdded
-
Constructor Details
-
Projectile
public Projectile(String id, String type, int x, int y, int size, int vx, int vy, int gravity, int team, int damage, int lifeTicks) Creates a projectile.
Parameters
id: the idtype: the kind, for the art ("bullet","arrow","slash")x: left, fixed pointy: top, fixed pointsize: width and height, fixed pointvx: horizontal speed, fixed point per tickvy: vertical speed, fixed point per tickgravity: downward acceleration, 0 for a straight shotteam: the shooter's team; it never hurts its owndamage: hit points removed on a hitlifeTicks: ticks before it expires
-
-
Method Details
-
getVx
public int getVx()The horizontal speed, which the view uses to flip the sprite.
Returns
the speed, fixed point per tick
-
step
Description copied from class:LevelEntityAdvances one tick. The default does nothing.
Parameters
world: the world
- Overrides:
stepin classLevelEntity
-
onTouch
Description copied from class:LevelEntityCalled each tick a living actor overlaps the entity.
Parameters
world: the worldc: the actor
- Overrides:
onTouchin classLevelEntity
-
hashState
public long hashState(long h) Description copied from class:LevelEntityMixes the entity's play-relevant state into a hash. The default mixes the position and whether it is active.
Parameters
h: the running hash
Returns
the updated hash
- Overrides:
hashStatein classLevelEntity
-