Client and backend. This class is shared: the same code is compiled into your app and into your server, so everything on this page works in both.
public class Projectile
- Object
- LevelEntity
- 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.
Constructors
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. |
Methods
public int getVx() | The horizontal speed, which the view uses to flip the sprite. |
public void step(PlatformWorld world) | Advances one tick. |
public void onTouch(PlatformWorld world, Actor c) | Called each tick a living actor overlaps the entity. |
public long hashState(long h) | Mixes the entity’s play-relevant state into a hash. |
Inherited fields
From LevelEntity
Inherited methods
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
idString- the id
typeString- the kind, for the art (
"bullet","arrow","slash") xint- left, fixed point
yint- top, fixed point
sizeint- width and height, fixed point
vxint- horizontal speed, fixed point per tick
vyint- vertical speed, fixed point per tick
gravityint- downward acceleration, 0 for a straight shot
teamint- the shooter’s team; it never hurts its own
damageint- hit points removed on a hit
lifeTicksint- 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
public void step(PlatformWorld world)Advances one tick. The default does nothing.
Parameters
worldPlatformWorld- the world
onTouch
public void onTouch(PlatformWorld world, Actor c)Called each tick a living actor overlaps the entity.
Parameters
worldPlatformWorld- the world
cActor- the actor
hashState
public long hashState(long h)Mixes the entity’s play-relevant state into a hash. The default mixes the
position and whether it is active.
Parameters
hlong- the running hash
Returns
the updated hash