Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class animationData{
- private String name;
- private int id;
- animationData(String n, int i){
- name = n;
- id = i;
- }
- public String getName(){
- return name;
- }
- public int getId(){
- return id;
- }
- }
- public class AnimationModule extends ApplicationAdapter {
- Animation animation;
- TextureAtlas cry;
- TextureAtlas clap;
- TextureAtlas think;
- TextureAtlas atlas;
- TextureRegion[] frames;
- float speed;
- String prefix = "Dracek";
- String regionName;
- AnimationModule()
- {
- cry = new TextureAtlas(Gdx.files.internal("Spritesheets/DracekCry.atlas"));;
- clap = new TextureAtlas(Gdx.files.internal("Spritesheets/DracekClap.atlas"));;
- think = new TextureAtlas(Gdx.files.internal("Spritesheets/DracekThink.atlas"));;
- frames = new TextureRegion[20];
- }
- private void setAnimationSpeeds(float s) {
- speed = s;
- }
- private void setFrames(int s, int r) {
- for (int i = 1; i <= s; i++) {
- regionName = prefix + String.valueOf(i);
- frames[i - 1] = atlas.findRegion(regionName);
- }
- for (int i = s + 1; i <= 20; i++) {
- regionName = prefix + String.valueOf((s + 1) + (i % r));
- frames[i - 1] = atlas.findRegion(regionName);
- }
- }
- public Animation createAnimation(int n) {
- switch (n) {
- case 1:
- atlas = cry;
- setAnimationSpeeds(1f / 15f);
- setFrames(6, 2);
- break;
- case 2:
- atlas = clap;
- setAnimationSpeeds(1f / 30f);
- setFrames(6, 2);
- break;
- case 3:
- atlas = think;
- setAnimationSpeeds(1f / 10f);
- setFrames(3, 2);
- break;
- default:
- break;
- }
- animation = new Animation(speed, frames);
- return animation;
- }
- public ArrayList getAnimationList() {
- ArrayList outputData = new ArrayList<animationData>();
- outputData.add(new animationData("None", -1));
- outputData.add(new animationData("Cry", 1));
- outputData.add(new animationData("Clap", 2));
- outputData.add(new animationData("Think", 3));
- return outputData;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement