Android Open Source - libgdx-demo-pax-britannica Countdown






From Project

Back to project page libgdx-demo-pax-britannica.

License

The source code is released under:

Copyright (c) 2010 Ben Abraham, Renaud B?dard, Henk Boom, Daniel Burton, Matthew Gallant Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated ...

If you think the Android project libgdx-demo-pax-britannica listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package de.swagner.paxbritannica.mainmenu;
/*from www. java2 s.c  o  m*/
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.math.Vector2;

import de.swagner.paxbritannica.Resources;

public class Countdown extends Sprite {

  public boolean finished = false;

  private boolean showed = true;

  private float fade = 0.0f;

  private int cnt = 5;
  
  float delta;

  private Vector2 position = new Vector2();

  public Countdown(Vector2 position) {
    this.position = position;

    changeTexture(5);
  }
  
  public void reset() {
    changeTexture(5);
    finished = false;
    showed = true;
    fade = 0.0f;
    cnt = 5;
    this.setRotation(0);
    this.setScale(1f);
    this.setPosition(position.x, position.y);
    this.setColor(0, 0, 0, 0);
  }

  private void changeTexture(int id) {

    switch (id) {
    case 5:
      this.set(Resources.getInstance().cnt5);
      break;
    case 2:
      this.set(Resources.getInstance().cnt2);
      break;
    case 3:
      this.set(Resources.getInstance().cnt3);
      break;
    case 4:
      this.set(Resources.getInstance().cnt4);
      break;
    default:
      this.set(Resources.getInstance().cnt1);
      break;
    }
    this.setRotation(0);
    this.setScale(1f);
    this.setPosition(position.x, position.y);
    this.setColor(0, 0, 0, 1);
  }

  @Override
  public void draw(Batch batch) {
    delta = Math.min(0.06f, Gdx.graphics.getDeltaTime());
    
    super.draw(batch);

    if (cnt < 1) {
      finished = true;
      this.setColor(1, 1, 1, 0);
      return;
    }

    if (showed) {
      fade = Math.min(fade + delta * 2.f, 1);
    } else {
      fade = Math.max(fade - delta * 2.f, 0);
    }
    this.setColor(1, 1, 1, fade);

    if (fade == 1) {
      showed = !showed;
    }
    if (fade == 0) {
      showed = !showed;
      --cnt;
      changeTexture(cnt);
    }
  }
}




Java Source Code List

de.swagner.paxbritannica.Bullet.java
de.swagner.paxbritannica.Collision.java
de.swagner.paxbritannica.Constants.java
de.swagner.paxbritannica.DefaultScreen.java
de.swagner.paxbritannica.GameInstance.java
de.swagner.paxbritannica.GameScreen.java
de.swagner.paxbritannica.IOSLauncher.java
de.swagner.paxbritannica.PaxBritannica.java
de.swagner.paxbritannica.Resources.java
de.swagner.paxbritannica.Ship.java
de.swagner.paxbritannica.Targeting.java
de.swagner.paxbritannica.android.AndroidLauncher.java
de.swagner.paxbritannica.background.BackgroundFXRenderer.java
de.swagner.paxbritannica.background.Debris.java
de.swagner.paxbritannica.background.Fish.java
de.swagner.paxbritannica.bomber.Bomb.java
de.swagner.paxbritannica.bomber.BomberAI.java
de.swagner.paxbritannica.bomber.Bomber.java
de.swagner.paxbritannica.client.HtmlLauncher.java
de.swagner.paxbritannica.desktop.DesktopLauncher.java
de.swagner.paxbritannica.factory.EasyEnemyProduction.java
de.swagner.paxbritannica.factory.FactoryProduction.java
de.swagner.paxbritannica.factory.HardEnemyProduction.java
de.swagner.paxbritannica.factory.MediumEnemyProduction.java
de.swagner.paxbritannica.factory.PlayerProduction.java
de.swagner.paxbritannica.factory.Production.java
de.swagner.paxbritannica.fighter.FighterAI.java
de.swagner.paxbritannica.fighter.Fighter.java
de.swagner.paxbritannica.fighter.Laser.java
de.swagner.paxbritannica.frigate.FrigateAI.java
de.swagner.paxbritannica.frigate.Frigate.java
de.swagner.paxbritannica.frigate.MissileAI.java
de.swagner.paxbritannica.frigate.Missile.java
de.swagner.paxbritannica.help.Help.java
de.swagner.paxbritannica.mainmenu.Countdown.java
de.swagner.paxbritannica.mainmenu.FactorySelector.java
de.swagner.paxbritannica.mainmenu.MainMenu.java
de.swagner.paxbritannica.particlesystem.BigBubbleParticleEmitter.java
de.swagner.paxbritannica.particlesystem.BubbleParticleEmitter.java
de.swagner.paxbritannica.particlesystem.ExplosionParticleEmitter.java
de.swagner.paxbritannica.particlesystem.ParticleEmitter.java
de.swagner.paxbritannica.particlesystem.Particle.java
de.swagner.paxbritannica.particlesystem.SparkParticleEmitter.java
de.swagner.paxbritannica.settings.Settings.java