Class WeaponAbility
java.lang.Object
com.codename1.gaming.platformer.Ability
com.codename1.gaming.platformer.WeaponAbility
Firing on Input#FIRE: projectiles (a blaster, a bow) or a melee swing, with a
cooldown, optional ammunition and eight-way aiming from the held directions.
A melee weapon (speed 0) is a short-lived projectile that does not move,
placed in front of the actor, so one mechanism covers both.
-
Field Summary
FieldsModifier and TypeFieldDescriptionintRounds left; negative is unlimited.booleanWhether the trigger can be held for automatic fire.intTicks between shots.intDamage per hit.booleanWhether up/down aim the shot diagonally or vertically.intGravity on the projectile, 0 for straight shots.booleanWhether the shot is instant (a laser, a rifle): it travelsrangein the tick it is fired, stops at the first solid tile and hits the first actor of another team on the way.intTicks a projectile lives (its range).The projectile's art type.intHow far a hitscan shot reaches, fixed point.intProjectile size, fixed point.intProjectile speed, fixed point per tick; 0 makes a melee weapon. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlonghashState(long h) Mixes the ability's own state into a hash, so two runs that diverge inside an ability are caught.voidprocess(Actor c, PlatformWorld world) Sets velocity and claims aMovementState.voidreset()Forgets what the ability was in the middle of, when its actor respawns: a dash, a buffered jump or a grip does not outlive a death.Methods inherited from class Ability
earlyProcess, isEnabled, lateProcess, mix, setEnabled
-
Field Details
-
projectileType
The projectile's art type. -
speed
public int speedProjectile speed, fixed point per tick; 0 makes a melee weapon. -
size
public int sizeProjectile size, fixed point. -
gravity
public int gravityGravity on the projectile, 0 for straight shots. -
damage
public int damageDamage per hit. -
cooldownTicks
public int cooldownTicksTicks between shots. -
lifeTicks
public int lifeTicksTicks a projectile lives (its range). -
ammo
public int ammoRounds left; negative is unlimited. -
eightWay
public boolean eightWayWhether up/down aim the shot diagonally or vertically. -
automatic
public boolean automaticWhether the trigger can be held for automatic fire. -
hitscan
public boolean hitscanWhether the shot is instant (a laser, a rifle): it travelsrangein the tick it is fired, stops at the first solid tile and hits the first actor of another team on the way. No projectile is made. -
range
public int rangeHow far a hitscan shot reaches, fixed point.
-
-
Constructor Details
-
WeaponAbility
public WeaponAbility()
-
-
Method Details