Skip to content

Arrow and fire projectile dispose animation

MTbir edited this page Oct 4, 2021 · 1 revision

Overview

The weapon breakage animation is trigger while the weapon dispose task is called so that the weapon is wait before dispose

Code

    public void waitForDeathAnimation() {
        if (this.declareEnd) {
            this.start = System.currentTimeMillis();
            owner.getEntity().getComponent(HitboxComponent.class).dispose();
            this.declareEnd = false;
        } else {
            owner.getEntity().getComponent(PhysicsMovementComponent.class).setMoving(false);
            if ((System.currentTimeMillis() - start) / 1000 >= duration) {
                stop();
                owner.getEntity().prepareDispose();
                status = Status.FINISHED;
            }
        }
    }

This code is called so that the weapon (arrow) is wait for the animation is finished running

The animation is trigger if the weapon have contact with any object

    public void broken() {
        if (!entity.getEntityType().equals("fireBall")) {
            animator.startAnimation("brokenArrow");
        } else {
            animator.startAnimation("hit");
        }
    }

The broken method is called to start the animation if the weapon is on collision

Table of Contents

Home

Design Document

Design Document

Design Document

Game Engine

Getting Started

Entities and Components

Item Drops from Entities

Service Locator

Loading Resources

Logging

Unit Testing

Debug Terminal

Input Handling

UI

Animations

Audio

AI

Physics

Game Screens and Areas

Terrain

Map Generation

Concurrency & Threading

Settings

Troubleshooting

MacOS Setup Guide

Clone this wiki locally