-
Notifications
You must be signed in to change notification settings - Fork 0
Player Animation Functionalities
SirAardvark edited this page Sep 13, 2021
·
1 revision
The purpose of player animation is to provide a more visual representation of the current state of the player.
Adding an animation for the player, the operation of which can consist of five parts:
- In
ForestGameArea.java
add the images of the animations that will be used in the atlas file into theforestTextures
String[].
private static final String[] forestTextures = {
"images/Walking.png",
"images/Sprint.png",
}
- In
PlayerMovementAnimations.atlas
add the atlas of the animation underneath all other animations
IdleCharacters.png
size: 1015, 462
format: RGBA8888
filter: Linear,Linear
repeat: none
normal-stationary
rotate: false
xy: 214, 1
size: 265, 431
orig: 400, 518
offset: 74, 50
index: 0
- In
PlayerFactory.java
add the animation with the same name as in the atlas file
//Defining and adding player related animation here
AnimationRenderComponent animator =
new AnimationRenderComponent(
ServiceLocator.getResourceService().getAsset("images/PlayerMovementAnimations.atlas",
TextureAtlas.class));
// Example animations added
animator.addAnimation("normal-stationary", 0.1f, Animation.PlayMode.LOOP);
animator.addAnimation("normal-walk", 0.2f, Animation.PlayMode.LOOP);
animator.addAnimation("normal-sprint", 0.1f, Animation.PlayMode.LOOP);
- In
PlayerAnimationController
if you are using an animation that is not in thePlayerStateComponent.java
add aneventListener
and a new function to callentity.startAnimation
. If the animation is in thePlayerStateComponent.java
then theupdatePlayerStatusAnimation
function will handle it for you
@Override
public void create() {
super.create();
animator = this.entity.getComponent(AnimationRenderComponent.class);
entity.getEvents().addListener("playerStatusAnimation", this::updatePlayerStatusAnimation);
}
void updatePlayerStatusAnimation() {
// Updates the health value in PlayerStateComponent
int health = this.entity.getComponent(CombatStatsComponent.class).getHealth();
if (health <= 90 && health > 50) {
this.entity.getComponent(PlayerStateComponent.class).updateHealth(Health.ROUGH);
} else if (health <= 50 && health > 10) {
this.entity.getComponent(PlayerStateComponent.class).updateHealth(Health.DAMAGED);
} else if (health == 0){
this.entity.getComponent(PlayerStateComponent.class).updateHealth(Health.DEAD);
}
// Applies the correct animation
animator.startAnimation(entity.getComponent(PlayerStateComponent.class).getStateAnimation());
}
- In the
KeyboardPlayerInputComponent
class, when the corresponding button is pressed or released, the corresponding event (i.e. animation) is triggered.
//Function to trigger the event
private void triggerMovementEvent() {
entity.getEvents().trigger("walk", walkDirection);
entity.getEvents().trigger("playerStatusAnimation");
}
//Call the animation on pressing the 'A' Key
public boolean keyDown(int keycode) {
case Keys.A:
walkDirection.add(Vector2Utils.LEFT);
triggerMovementEvent();
return true;
}
- Player UI
- Popup Menus
- Obstacles
- Boss Enemies
- Progress Tracker
- Checkpoint Design and Functionality
- Score System
- Lives System
- Game Background
- Multiple game-level
- Visual Improvements
- Tutorial Level
- Character Design and Animations
- Character Damage Animations
- Player Animation Functionalities
- Player and Serpent Portal Transition
- Pop-up Menus
- Obstacles
- Lives & Score User Testing
- Buffs & Debuffs
- Buffs & Debuffs redesign
- Obstacle Animation
- Background Design
- Level 2 Background Appearance
- Enemy Monster User Testing
- Level 1 Floor Terrain Testing
- Introduction Screens User Testing
- Character Movement Interviews & User Testing
- Sound user testing
- Level 2 Obstacles and enemy
- Story, Loading, Level 4 and Win Condition Sound Design User Testing
- Giant Bug and Purple Squid animation user testing
- General Gameplay and Tutorial Level User Testing
- Level 4 Terrain User Testing
- Game Outro User Testing