Package com.badlogic.gdx.graphics.g2d

Examples of com.badlogic.gdx.graphics.g2d.Animation


    ResourceManager.loadResource("missile_score", new Texture("items/missile_score.png"));
   
    // Animaciones
        atlas = new TextureAtlas(Gdx.files.internal("ship/ship.pack"));
        ResourceManager.loadResource("ship", atlas);
    ResourceManager.loadResource("ship", new Animation(0.15f, atlas.findRegions("ship")));

        // Animación de nave pequeña
        atlas = new TextureAtlas(Gdx.files.internal("enemy/small.pack"));
    ResourceManager.loadResource("small_enemy", new Animation(0.15f, atlas.findRegions("small")));
        // Animación para la roca
        atlas = new TextureAtlas(Gdx.files.internal("enemy/stone.pack"));
    ResourceManager.loadResource("stone", new Animation(0.15f, atlas.findRegions("stone")));

    ResourceManager.loadResource("pursuer_enemy", ResourceManager.createAnimationFromSpriteSheet("enemy/pursuer.png", 6));
    ResourceManager.loadResource("shooter_enemy", ResourceManager.createAnimationFromSpriteSheet("enemy/shooter.png", 6));
    ResourceManager.loadResource("big_enemy", ResourceManager.createAnimationFromSpriteSheet("enemy/big.png", 6));
    ResourceManager.loadResource("missile", ResourceManager.createAnimationFromSpriteSheet("items/missile.png", 16));
        // Animación para las explosiones
        atlas = new TextureAtlas(Gdx.files.internal("explosion/explosion.pack"));
    ResourceManager.loadResource("explosion", new Animation(0.15f, atlas.findRegions("explosion")));

    //ResourceManager.loadResource("block", new SpriteSheet(new Image("res/items/blocks1.png"), 32, 32, 2, 2));

    // Sonidos
    ResourceManager.loadResource("shoot", Gdx.audio.newSound(Gdx.files.internal("sounds/disparo.mp3")));
View Full Code Here


    TextureRegion[] frames = new TextureRegion[frameCount];
    for (int i = 0; i < frameCount; i++) {
      frames[i] = sheetFrames[i][0];
    }
   
    return new Animation(0.15f, frames);
  }
View Full Code Here

                Sprite sprite = textureAtlas.createSprite(spriteName);
                sprite.setSize(Units.instance.getUnits(sprite.getWidth()), Units.instance.getUnits(sprite.getHeight()));
                sprite.setOrigin(sprite.getWidth() * .5f, sprite.getHeight() * .5f);
                sprites.add(sprite);
            }
            Animation animation = new Animation(fps, sprites);
            animations.put(name, animation);
            return animation;
        }
        return null;
    }
View Full Code Here

     * @param fps
     *         The animation fps.
     * @return The animation if it exists; otherwise, null.
     */
    public Animation getAnimation(String name, float fps) {
        Animation animation = animations.get(name);
        if(animation == null) {
            animation = createAnimation(name, fps);
        }
        return animation;
    }
View Full Code Here

      }
    }

    shipBasicBullet = new TextureRegion(shipSheet, 64, 224, 48, 16);

    shipAnimation = new Animation(.2f, shipFrames);
    shipMoveAnimation = new Animation(.2f, shipMoveFrames);

    // switch sprite sheet to enemySheet
    tmp = TextureRegion.split(enemySheet, enemySheet.getWidth() / 16, enemySheet.getHeight() / 16);

    // place enemy bulletFrames into array sprite sheet

    index = 0;
    enemyBasicBulletFrames = new TextureRegion[7];
    for (int i = 6; i < 7; i++) {
      for (int j = 8; j < 15; j++) {
        enemyBasicBulletFrames[index++] = tmp[i][j];
      }
    }
    enemyBasicBulletAnimation = new Animation(.15f, enemyBasicBulletFrames);
    animations.put("enemyBasicBulletBlue", enemyBasicBulletAnimation);
    // red enemy bullets
    index = 0;
    enemyBasicBulletFrames = new TextureRegion[7];
    for (int i = 4; i < 5; i++) {
      for (int j = 8; j < 15; j++) {
        enemyBasicBulletFrames[index++] = tmp[i][j];
      }
    }
    enemyBasicBulletAnimation = new Animation(.15f, enemyBasicBulletFrames);
    animations.put("enemyBasicBulletRed", enemyBasicBulletAnimation);

    // green enemy bullets
    index = 0;
    enemyBasicBulletFrames = new TextureRegion[7];
    for (int i = 5; i < 6; i++) {
      for (int j = 8; j < 15; j++) {
        enemyBasicBulletFrames[index++] = tmp[i][j];
      }
    }
    enemyBasicBulletAnimation = new Animation(.15f, enemyBasicBulletFrames);
    animations.put("enemyBasicBulletGreen", enemyBasicBulletAnimation);

    // place enemy frames into array from sprite sheet
    // blue shooter animations
    shooterFrames = new TextureRegion[3];
    index = 0;
    for (int i = 0; i < 1; i++) {
      for (int j = 0; j < 3; j++) {
        shooterFrames[index++] = tmp[i][j];
      }
    }
    shooterAnimation = new Animation(.2f, shooterFrames);
    animations.put("ShooterBlue", shooterAnimation);

    shooterMoveFrames = new TextureRegion[3];
    index = 0;
    for (int i = 0; i < 1; i++) {
      for (int j = 4; j < 7; j++) {
        shooterMoveFrames[index++] = tmp[i][j];
      }
    }
    shooterMoveAnimation = new Animation(.2f, shooterMoveFrames);
    animations.put("ShooterBlueMove", shooterMoveAnimation);

    shooterFrames = new TextureRegion[3];
    index = 0;
    for (int i = 1; i < 2; i++) {
      for (int j = 0; j < 3; j++) {
        shooterFrames[index++] = tmp[i][j];
      }
    }
    // red shooter animation
    shooterAnimation = new Animation(.2f, shooterFrames);
    animations.put("ShooterRed", shooterAnimation);

    shooterMoveFrames = new TextureRegion[3];
    index = 0;
    for (int i = 1; i < 2; i++) {
      for (int j = 4; j < 7; j++) {
        shooterMoveFrames[index++] = tmp[i][j];
      }
    }
    shooterMoveAnimation = new Animation(.2f, shooterMoveFrames);
    animations.put("ShooterRedMove", shooterMoveAnimation);

    // green shooter animations
    shooterFrames = new TextureRegion[3];
    index = 0;
    for (int i = 2; i < 3; i++) {
      for (int j = 0; j < 3; j++) {
        shooterFrames[index++] = tmp[i][j];
      }
    }
    shooterAnimation = new Animation(.2f, shooterFrames);
    animations.put("ShooterGreen", shooterAnimation);

    shooterMoveFrames = new TextureRegion[3];
    index = 0;
    for (int i = 2; i < 3; i++) {
      for (int j = 4; j < 7; j++) {
        shooterMoveFrames[index++] = tmp[i][j];
      }
    }
    shooterMoveAnimation = new Animation(.2f, shooterMoveFrames);
    animations.put("ShooterGreenMove", shooterMoveAnimation);

    shipSlow = new TextureRegion(projectileSheet, 288, 128, 64, 64);

    Follower = new TextureRegion(enemySheet, 1, 192, 32, 32);
    followerAnimation = new Animation(1f, Follower);
    animations.put("FollowerRed", followerAnimation);

    Follower = new TextureRegion(enemySheet, 65, 192, 32, 32);
    followerAnimation = new Animation(1f, Follower);
    animations.put("FollowerBlue", followerAnimation);

    Follower = new TextureRegion(enemySheet, 33, 192, 32, 32);
    followerAnimation = new Animation(1f, Follower);
    animations.put("FollowerGreen", followerAnimation);
    ;

    basicExplosion = new TextureRegion(enemySheet, 1, 224, 32, 32);
    textures.put("basicExplosionRed", basicExplosion);

    basicExplosion = new TextureRegion(enemySheet, 65, 224, 32, 32);
    textures.put("basicExplosionBlue", basicExplosion);

    basicExplosion = new TextureRegion(enemySheet, 33, 224, 32, 32);
    textures.put("basicExplosionGreen", basicExplosion);

    // place enemy bulletFrames into array sprite sheet
    bossWaitFrames = new TextureRegion[4];
    index = 0;
    for (int j = 0; j < 4; j++) {
      bossWaitFrames[index++] = new TextureRegion(bossSheet, j * 48, 0*64, 48, 64);
    }
    bossWaitAnimation = new Animation(.15f, bossWaitFrames);
    animations.put("BossOneWait", bossWaitAnimation);

    bossMoveFrames = new TextureRegion[3];
    index = 0;
    for (int j = 0; j < 3; j++) {
      bossMoveFrames[index++] = new TextureRegion(bossSheet, j * 48, 1*64, 48, 64);
    }
    bossMoveAnimation = new Animation(.15f, bossMoveFrames);
    animations.put("BossOneMove", bossMoveAnimation);
   
    bossAttackFrames = new TextureRegion[4];
    index = 0;
    for (int j = 0; j < 4; j++) {
      bossAttackFrames[index++] = new TextureRegion(bossSheet, j * 48, 2*64, 48, 64);
    }
    bossAttackAnimation = new Animation(.15f, bossAttackFrames);
    animations.put("BossOneAttack", bossAttackAnimation);

    bomb = new TextureRegion(projectileSheet, 695, 28, 256, 256);

    powerItem = new TextureRegion(projectileSheet, 320, 80, 16, 16);
View Full Code Here

      }
    }

    shipBasicBullet = new TextureRegion(shipSheet, 64, 224, 48, 16);

    shipAnimation = new Animation(.2f, shipFrames);
    shipMoveAnimation = new Animation(.2f, shipMoveFrames);

    // switch sprite sheet to enemySheet
    tmp = TextureRegion.split(enemySheet, enemySheet.getWidth() / 16, enemySheet.getHeight() / 16);

    // place enemy bulletFrames into array sprite sheet

    index = 0;
    enemyBasicBulletFrames = new TextureRegion[7];
    for (int i = 6; i < 7; i++) {
      for (int j = 8; j < 15; j++) {
        enemyBasicBulletFrames[index++] = tmp[i][j];
      }
    }
    enemyBasicBulletAnimation = new Animation(.15f, enemyBasicBulletFrames);
    animations.put("enemyBasicBulletBlue", enemyBasicBulletAnimation);
    // red enemy bullets
    index = 0;
    enemyBasicBulletFrames = new TextureRegion[7];
    for (int i = 4; i < 5; i++) {
      for (int j = 8; j < 15; j++) {
        enemyBasicBulletFrames[index++] = tmp[i][j];
      }
    }
    enemyBasicBulletAnimation = new Animation(.15f, enemyBasicBulletFrames);
    animations.put("enemyBasicBulletRed", enemyBasicBulletAnimation);

    // green enemy bullets
    index = 0;
    enemyBasicBulletFrames = new TextureRegion[7];
    for (int i = 5; i < 6; i++) {
      for (int j = 8; j < 15; j++) {
        enemyBasicBulletFrames[index++] = tmp[i][j];
      }
    }
    enemyBasicBulletAnimation = new Animation(.15f, enemyBasicBulletFrames);
    animations.put("enemyBasicBulletGreen", enemyBasicBulletAnimation);

    // place enemy frames into array from sprite sheet
    // blue shooter animations
    shooterFrames = new TextureRegion[3];
    index = 0;
    for (int i = 0; i < 1; i++) {
      for (int j = 0; j < 3; j++) {
        shooterFrames[index++] = tmp[i][j];
      }
    }
    shooterAnimation = new Animation(.2f, shooterFrames);
    animations.put("ShooterBlue", shooterAnimation);

    shooterMoveFrames = new TextureRegion[3];
    index = 0;
    for (int i = 0; i < 1; i++) {
      for (int j = 4; j < 7; j++) {
        shooterMoveFrames[index++] = tmp[i][j];
      }
    }
    shooterMoveAnimation = new Animation(.2f, shooterMoveFrames);
    animations.put("ShooterBlueMove", shooterMoveAnimation);

    shooterFrames = new TextureRegion[3];
    index = 0;
    for (int i = 1; i < 2; i++) {
      for (int j = 0; j < 3; j++) {
        shooterFrames[index++] = tmp[i][j];
      }
    }
    // red shooter animation
    shooterAnimation = new Animation(.2f, shooterFrames);
    animations.put("ShooterRed", shooterAnimation);

    shooterMoveFrames = new TextureRegion[3];
    index = 0;
    for (int i = 1; i < 2; i++) {
      for (int j = 4; j < 7; j++) {
        shooterMoveFrames[index++] = tmp[i][j];
      }
    }
    shooterMoveAnimation = new Animation(.2f, shooterMoveFrames);
    animations.put("ShooterRedMove", shooterMoveAnimation);

    // green shooter animations
    shooterFrames = new TextureRegion[3];
    index = 0;
    for (int i = 2; i < 3; i++) {
      for (int j = 0; j < 3; j++) {
        shooterFrames[index++] = tmp[i][j];
      }
    }
    shooterAnimation = new Animation(.2f, shooterFrames);
    animations.put("ShooterGreen", shooterAnimation);

    shooterMoveFrames = new TextureRegion[3];
    index = 0;
    for (int i = 2; i < 3; i++) {
      for (int j = 4; j < 7; j++) {
        shooterMoveFrames[index++] = tmp[i][j];
      }
    }
    shooterMoveAnimation = new Animation(.2f, shooterMoveFrames);
    animations.put("ShooterGreenMove", shooterMoveAnimation);

    shipSlow = new TextureRegion(projectileSheet, 288, 128, 64, 64);

    Follower = new TextureRegion(enemySheet, 1, 192, 32, 32);
    followerAnimation = new Animation(1f, Follower);
    animations.put("FollowerRed", followerAnimation);

    Follower = new TextureRegion(enemySheet, 65, 192, 32, 32);
    followerAnimation = new Animation(1f, Follower);
    animations.put("FollowerBlue", followerAnimation);

    Follower = new TextureRegion(enemySheet, 33, 192, 32, 32);
    followerAnimation = new Animation(1f, Follower);
    animations.put("FollowerGreen", followerAnimation);
    ;

    basicExplosion = new TextureRegion(enemySheet, 1, 224, 32, 32);
    textures.put("basicExplosionRed", basicExplosion);

    basicExplosion = new TextureRegion(enemySheet, 65, 224, 32, 32);
    textures.put("basicExplosionBlue", basicExplosion);

    basicExplosion = new TextureRegion(enemySheet, 33, 224, 32, 32);
    textures.put("basicExplosionGreen", basicExplosion);

    // place enemy bulletFrames into array sprite sheet
    bossWaitFrames = new TextureRegion[4];
    index = 0;
    for (int j = 0; j < 4; j++) {
      bossWaitFrames[index++] = new TextureRegion(bossSheet, j * 48, 0, 48, 64);
    }
    bossWaitAnimation = new Animation(.15f, bossWaitFrames);
    animations.put("BossOneWait", bossWaitAnimation);

    bossMoveFrames = new TextureRegion[3];
    index = 0;
    for (int j = 0; j < 3; j++) {
      bossMoveFrames[index++] = new TextureRegion(bossSheet, j * 48, 1 * 64, 48, 64);
    }
    bossMoveAnimation = new Animation(.15f, bossMoveFrames);
    animations.put("BossOneMove", bossMoveAnimation);

    bossAttackFrames = new TextureRegion[4];
    index = 0;
    for (int j = 0; j < 4; j++) {
      bossAttackFrames[index++] = new TextureRegion(bossSheet, j * 48, 2 * 64, 48, 64);
    }
    bossAttackAnimation = new Animation(.15f, bossAttackFrames);
    animations.put("BossOneAttack", bossAttackAnimation);

    bossHealthBar = new TextureRegion(projectileSheet, 34, 18, 14, 14);
    textures.put("healthBar", bossHealthBar);

View Full Code Here

      }
    }

    shipBasicBullet = new TextureRegion(shipSheet, 64, 224, 48, 16);

    shipAnimation = new Animation(.2f, shipFrames);
    shipMoveAnimation = new Animation(.2f, shipMoveFrames);

    // switch sprite sheet to enemySheet
    tmp = TextureRegion.split(enemySheet, enemySheet.getWidth() / 16, enemySheet.getHeight() / 16);

    // place enemy bulletFrames into array sprite sheet

    index = 0;
    enemyBasicBulletFrames = new TextureRegion[7];
    for (int i = 6; i < 7; i++) {
      for (int j = 8; j < 15; j++) {
        enemyBasicBulletFrames[index++] = tmp[i][j];
      }
    }
    enemyBasicBulletAnimation = new Animation(.15f, enemyBasicBulletFrames);
    animations.put("enemyBasicBulletBlue", enemyBasicBulletAnimation);
    // red enemy bullets
    index = 0;
    enemyBasicBulletFrames = new TextureRegion[7];
    for (int i = 4; i < 5; i++) {
      for (int j = 8; j < 15; j++) {
        enemyBasicBulletFrames[index++] = tmp[i][j];
      }
    }
    enemyBasicBulletAnimation = new Animation(.15f, enemyBasicBulletFrames);
    animations.put("enemyBasicBulletRed", enemyBasicBulletAnimation);

    // green enemy bullets
    index = 0;
    enemyBasicBulletFrames = new TextureRegion[7];
    for (int i = 5; i < 6; i++) {
      for (int j = 8; j < 15; j++) {
        enemyBasicBulletFrames[index++] = tmp[i][j];
      }
    }
    enemyBasicBulletAnimation = new Animation(.15f, enemyBasicBulletFrames);
    animations.put("enemyBasicBulletGreen", enemyBasicBulletAnimation);

    // place enemy frames into array from sprite sheet
    // blue shooter animations
    shooterFrames = new TextureRegion[3];
    index = 0;
    for (int i = 0; i < 1; i++) {
      for (int j = 0; j < 3; j++) {
        shooterFrames[index++] = tmp[i][j];
      }
    }
    shooterAnimation = new Animation(.2f, shooterFrames);
    animations.put("ShooterBlue", shooterAnimation);

    shooterMoveFrames = new TextureRegion[3];
    index = 0;
    for (int i = 0; i < 1; i++) {
      for (int j = 4; j < 7; j++) {
        shooterMoveFrames[index++] = tmp[i][j];
      }
    }
    shooterMoveAnimation = new Animation(.2f, shooterMoveFrames);
    animations.put("ShooterBlueMove", shooterMoveAnimation);

    shooterFrames = new TextureRegion[3];
    index = 0;
    for (int i = 1; i < 2; i++) {
      for (int j = 0; j < 3; j++) {
        shooterFrames[index++] = tmp[i][j];
      }
    }
    // red shooter animation
    shooterAnimation = new Animation(.2f, shooterFrames);
    animations.put("ShooterRed", shooterAnimation);

    shooterMoveFrames = new TextureRegion[3];
    index = 0;
    for (int i = 1; i < 2; i++) {
      for (int j = 4; j < 7; j++) {
        shooterMoveFrames[index++] = tmp[i][j];
      }
    }
    shooterMoveAnimation = new Animation(.2f, shooterMoveFrames);
    animations.put("ShooterRedMove", shooterMoveAnimation);

    // green shooter animations
    shooterFrames = new TextureRegion[3];
    index = 0;
    for (int i = 2; i < 3; i++) {
      for (int j = 0; j < 3; j++) {
        shooterFrames[index++] = tmp[i][j];
      }
    }
    shooterAnimation = new Animation(.2f, shooterFrames);
    animations.put("ShooterGreen", shooterAnimation);

    shooterMoveFrames = new TextureRegion[3];
    index = 0;
    for (int i = 2; i < 3; i++) {
      for (int j = 4; j < 7; j++) {
        shooterMoveFrames[index++] = tmp[i][j];
      }
    }
    shooterMoveAnimation = new Animation(.2f, shooterMoveFrames);
    animations.put("ShooterGreenMove", shooterMoveAnimation);

    shipSlow = new TextureRegion(projectileSheet, 288, 128, 64, 64);

    Follower = new TextureRegion(enemySheet, 1, 192, 32, 32);
    followerAnimation = new Animation(1f, Follower);
    animations.put("FollowerRed", followerAnimation);

    Follower = new TextureRegion(enemySheet, 65, 192, 32, 32);
    followerAnimation = new Animation(1f, Follower);
    animations.put("FollowerBlue", followerAnimation);

    Follower = new TextureRegion(enemySheet, 33, 192, 32, 32);
    followerAnimation = new Animation(1f, Follower);
    animations.put("FollowerGreen", followerAnimation);
    ;

    basicExplosion = new TextureRegion(enemySheet, 1, 224, 32, 32);
    textures.put("basicExplosionRed", basicExplosion);

    basicExplosion = new TextureRegion(enemySheet, 65, 224, 32, 32);
    textures.put("basicExplosionBlue", basicExplosion);

    basicExplosion = new TextureRegion(enemySheet, 33, 224, 32, 32);
    textures.put("basicExplosionGreen", basicExplosion);

    // place enemy bulletFrames into array sprite sheet
    bossWaitFrames = new TextureRegion[4];
    index = 0;
    for (int j = 0; j < 4; j++) {
      bossWaitFrames[index++] = new TextureRegion(bossSheet, j * 48, 0, 48, 64);
    }
    bossWaitAnimation = new Animation(.15f, bossWaitFrames);
    animations.put("BossOneWait", bossWaitAnimation);

    bossMoveFrames = new TextureRegion[3];
    index = 0;
    for (int j = 0; j < 3; j++) {
      bossMoveFrames[index++] = new TextureRegion(bossSheet, j * 48, 1 * 64, 48, 64);
    }
    bossMoveAnimation = new Animation(.15f, bossMoveFrames);
    animations.put("BossOneMove", bossMoveAnimation);

    bossAttackFrames = new TextureRegion[4];
    index = 0;
    for (int j = 0; j < 4; j++) {
      bossAttackFrames[index++] = new TextureRegion(bossSheet, j * 48, 2 * 64, 48, 64);
    }
    bossAttackAnimation = new Animation(.15f, bossAttackFrames);
    animations.put("BossOneAttack", bossAttackAnimation);

    bossHealthBar = new TextureRegion(projectileSheet, 34, 18, 14, 14);
    textures.put("healthBar", bossHealthBar);

View Full Code Here

   
    // Set the sprite width and height.
    setWidth(tileWidth);
    setHeight(tileHeight);
   
    animation = new Animation(frameDuration, frames);
    stateTime = 0f;
  }
View Full Code Here

    idleRight = atlas.findRegion("mario_idle_right");
    walkLeft = atlas.findRegion("mario_walk_left", 1);
    walkRight = atlas.findRegion("mario_walk_right", 1);
   
    // Crea la animación para correr hacia la derecha
    rightAnimation = new Animation(0.15f, atlas.findRegions("mario_walk_right"));
   
    // Crea la animación para correr hacia la izquierda
    leftAnimation = new Animation(0.15f, atlas.findRegions("mario_walk_left"));
  }
View Full Code Here

    TextureRegion[][] frames = TextureRegion.split(spriteSheet, spriteSheet.getWidth() / FRAMES, spriteSheet.getHeight());
    TextureRegion[] rightFrames = new TextureRegion[FRAMES];
    for (int i = 0; i < FRAMES; i++) {
      rightFrames[i] = frames[0][i];
    }
    animation = new Animation(0.15f, rightFrames);
    stateTime = 0;
   
    explosions = new Array<Explosion>();
    dead = false;
  }
View Full Code Here

TOP

Related Classes of com.badlogic.gdx.graphics.g2d.Animation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.