All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.uwsoft.editor.renderer.data.SpriteAnimationVO Maven / Gradle / Ivy

Go to download

overlap2d-runtime-libgdx provides functionality to load, manipulate and render scenes generated by Overlap2D.

The newest version!
package com.uwsoft.editor.renderer.data;

import com.badlogic.ashley.core.Entity;
import com.badlogic.gdx.graphics.g2d.Animation;
import com.uwsoft.editor.renderer.components.sprite.SpriteAnimationComponent;

import java.util.ArrayList;

public class SpriteAnimationVO extends MainItemVO {

    public String animationName = "";
    public int fps = 24;
    public String currentAnimation;
    public ArrayList frameRangeMap = new ArrayList();
    public int playMode = 0;

    public SpriteAnimationVO() {

    }

    public SpriteAnimationVO(SpriteAnimationVO vo) {
        super(vo);
        animationName = vo.animationName;
        fps = vo.fps;
        frameRangeMap = vo.frameRangeMap;
    }

    @Override
    public void loadFromEntity(Entity entity) {
        super.loadFromEntity(entity);

        SpriteAnimationComponent spriteAnimationComponent = entity.getComponent(SpriteAnimationComponent.class);
        animationName = spriteAnimationComponent.animationName;
        fps = spriteAnimationComponent.fps;
        frameRangeMap = new ArrayList();
        for(FrameRange fr: spriteAnimationComponent.frameRangeMap.values()) {
            frameRangeMap.add(fr);
        }
        currentAnimation = spriteAnimationComponent.currentAnimation;
        if(spriteAnimationComponent.playMode == Animation.PlayMode.NORMAL) playMode = 0;
        if(spriteAnimationComponent.playMode == Animation.PlayMode.REVERSED) playMode = 1;
        if(spriteAnimationComponent.playMode == Animation.PlayMode.LOOP) playMode = 2;
        if(spriteAnimationComponent.playMode == Animation.PlayMode.LOOP_REVERSED) playMode = 3;
        if(spriteAnimationComponent.playMode == Animation.PlayMode.LOOP_PINGPONG) playMode = 4;
        if(spriteAnimationComponent.playMode == Animation.PlayMode.LOOP_RANDOM) playMode = 5;
        if(spriteAnimationComponent.playMode == Animation.PlayMode.NORMAL) playMode = 6;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy