Class Projectile

java.lang.Object
com.codename1.gaming.platformer.LevelEntity
com.codename1.gaming.platformer.Projectile

public class Projectile extends LevelEntity
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.
  • 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 id
      • type: the kind, for the art ("bullet", "arrow", "slash")
      • x: left, fixed point
      • y: top, fixed point
      • size: width and height, fixed point
      • vx: horizontal speed, fixed point per tick
      • vy: vertical speed, fixed point per tick
      • gravity: downward acceleration, 0 for a straight shot
      • team: the shooter's team; it never hurts its own
      • damage: hit points removed on a hit
      • lifeTicks: 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)
      Description copied from class: LevelEntity

      Advances one tick. The default does nothing.

      Parameters
      • world: the world
      Overrides:
      step in class LevelEntity
    • onTouch

      public void onTouch(PlatformWorld world, Actor c)
      Description copied from class: LevelEntity

      Called each tick a living actor overlaps the entity.

      Parameters
      • world: the world
      • c: the actor
      Overrides:
      onTouch in class LevelEntity
    • hashState

      public long hashState(long h)
      Description copied from class: LevelEntity

      Mixes 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:
      hashState in class LevelEntity