Projectiles - mganzarcik/fabulae GitHub Wiki

Projectiles are temporary, moving game objects that have a defined origin and target. Every projectile can have an associated animation, particle effect, light and sounds. It also has a defined speed, start and end offsets and a scaling method to use for its particle effect.

Projectiles go through three separate phases during their life:

  • Creation – the projectile is not moving at this stage. Animation and creation particle effects are rendered, onStart sounds are played.
  • Projectile – the projectile is moving towards the target. Animation and projectile particle effects are rendered, during sounds are played.
  • Explosion – the projectile has hit the target and stops moving. Animation and explosion particle effects are rendered, onHit sounds are played.
`[toggle gif]`

Fabulae currently does not consider projectiles to be part of the game state and these are therefore not saved. As a result, Fabulae will not allow the game to be saved if there are any active projectiles.

Animation

Each projectile can have an associated animation defined by an animation file (frame sheet) and animation info file (which describes the frame sheet).

Animations currently do not distinguish between the different life phases of the projectile; they only consider the rotation of it. This means that you currently cannot define a different animation sequence for the Creation or Explosion phases – the same animation will be rendered for all.

Animations are also not scaled in any way.

They are therefore only suitable for simple projectiles like arrows, bullets and so on. If a more complex projectile is required, particle effects should be used instead of (or in conjunction with) an animation.

Particle Effect

The particle effect (PE) associated with a projectile should follow some basic conventions. In order for it to be rotated properly, it should be defined as if it was flying directly to the left in the LibGDX particle editor.

For the Creation stage, the PE can have one or more emitters defined that have their name prefixed with “Creation”. These are the initial effects that are displayed first, when the projectile is being created in the origin. The projectile will only start moving once all the Creation emitters are stopped.

For the Projectile phase, one or more emitters prefixed with “Projectile” can be defined. These will represent the actual projectile and will be moving. The duration of these emitters will be adjusted by Fabulae automatically to match the distance the projectile will need to travel and therefore the values set in the editor are for editing purposes only. It is currently not possible to have different duration for the Projectile emitters. Projectile emitters will also be rotated automatically according to the direction the projectile is traveling.

Once the projectile hits the target, the last phase, Explosion, starts. Again, the PE can have one or more emitters defined for this phase, prefixed with “Explosion”. These will automatically have their delays set to the total duration of the Creation and Projectile phases and in addition, will be automatically scaled using the chosen scaling method to match the target area. Explosion emitters should be defined as if they were affecting approximately a 1 tile area.

Scaling methods

Fabulae can currently scale Explosion emitters using two different methods:

  • Particle-based scaling (default): will scale the following emitter properties: particle size, particle velocity, spawn width, spawn height
  • Emission-based scaling: will scale the following emitter properties: min. particle count, max particle count, emission, particle velocity, spawn width, spawn height

The practical difference between the two is that particle based scaling will increase the size of particles, but not their number, while emission based scaling will increase their number, but not their size.

`[toggle gif]`

Sounds

Projectiles can define sounds of three types: onStart, during and onHit sounds. These play at the start of the creation phase, during the projectile phase and at the start of the explosion phase. All types can have delays specified in seconds if they should start at a lower time. Sounds can also be looped (this will probably be the case for most “during” sounds) by setting the loop attribute to true (default is false for all sound types).

Multiple sounds for the same type can be defined. Fabulae will pick a random sound from the list for each projectile created.

Offsets

Projectiles can have start and end offsets defined. These are defined in the camera coordinate system (they are therefore independent of the projection used) using tiles as units and modify the originating and target location of the projectile accordingly.

Speed

Speed is defined in tiles per second. If negative, the projectile will travel to the destination instantly, traversing from Creation straight to Explosion.

Light

Each projectile can have one light associated. The light will be rendered during the whole lifetime of the projectile, from Creation to Explosion, following the position of the projectile. During the Explosion phase, the light will be automatically scaled to match the size of the explosion.

Fixed projectiles

Fixed projectiles are a special kind of projectile that do not travel. They usually represent unmoving effects that originate from the originating location and reach the target location as a continuous stream. A good example would be a cone attack like “Frozen hands” that originates from the player characters in a cone – shaped area.

`[toggle gif]`

Fixed projectiles will always have negative speed (even if a different value is defined in the xml) and go from Creation straight to Explosion. Unlike normal projectiles, fixed projectiles will also rotate the Explosion emitters towards to the target position, which makes it possible to define a cone-shaped explosion particle effect that will always be correctly rotated.

Projectile examples:

https://github.com/mganzarcik/fabulae-showcase/blob/master/showcase/projectiles/Arrow.xml

https://github.com/mganzarcik/fabulae-showcase/blob/master/showcase/projectiles/Chillwind.xml

https://github.com/mganzarcik/fabulae-showcase/blob/master/showcase/projectiles/Fireball.xml

⚠️ **GitHub.com Fallback** ⚠️