Animated Buff Timer Indicator - UQdeco2800/2022-studio-2 GitHub Wiki
Summary
This wiki page will explain the implementation of how when there is a buff applied to a weapon, there will be an animated timer at the top of the screen showing the current buff applied.
This implementation uses the buff timer animations documented here.
This implementation is an extension/improvement on the already existing Aura Implementation's Displaying Currently Applied Aura Indicator
AnimatedImage
Located in: source/core/src/main/com/deco2800/game/components/combatitemscomponents/AnimatedImage.java
This is a class that extends the Image class of the game engine to allow an Actor
that is animated to be created and displayed in the game. Prior to this, only static images can be used as an Actor
to be displayed in the game.
This class is taken with some modifications applied, from a comment in a StackOverflow page, where the original poster of the question is asking whether there is an animated actor in the game, to which there is None.
LibGDX is there an actor that is animated?
BuffDisplayComponent
Located in: source/core/src/main/com/deco2800/game/components/CombatItemsComponents/BuffDisplayComponent.java
Prior to this implementation, the setBuff()
method in this class takes in a filename parameter, which would be the texture path of the buff. But now, it takes in a String auraDesc
public void setBuff(String auraDesc) {
that is tied to the specified timer animations in source/core/assets/images/CombatItems/animations/BuffAnimations/buff.atlas
.
In the setBuff
method, the TextureAtlas
is loaded, and so is the animations for the buff. The animation of the specified buff is loaded by creating a new Animation
object that takes in a frame duration, 0.05ms in this case and the frames of the animation, which is searched in the loaded atlas file by atlas.findRegions(auraDesc)
.
TextureAtlas atlas = ServiceLocator.getResourceService()
.getAsset("images/CombatItems/animations/BuffAnimations/buff.atlas", TextureAtlas.class);
Animation<TextureRegion> animation1 = new Animation<>(0.05f, atlas.findRegions(auraDesc));
Other than these changes being made, everything else is left intact as per the already existing Aura Implementation's Displaying Currently Applied Aura Indicator.
Back to Combat Items Contents Page
Author
- Eugene Chong
- GitHub: @eugene2341
- Discord: gene#0005
- Slack: Eugene Chong