Android Open Source - square-libgdx Background Animation






From Project

Back to project page square-libgdx.

License

The source code is released under:

GNU General Public License

If you think the Android project square-libgdx 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 com.denzyldick.square;
//from w w  w.ja  v  a 2 s  .co m


import java.util.Random;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.Pixmap;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.physics.box2d.Shape;
import com.badlogic.gdx.utils.Timer;
import com.badlogic.gdx.utils.Timer.Task;

public class BackgroundAnimation extends Sprite {
  
  private ShapeRenderer shapeRenderer;
  private final float square1Width = 400;
  private final float square1Height = 400;
  private final float square2Width = 300;
  private final float square2Height = 300;
  private float square1X, square1Y;
  private final float angleSpeed = 60 * 0.2f;  
  private Vector2 square1Vector = new Vector2(0,0);
  private Pixmap pixmap;
  private Sprite squareSprite;
  private Sprite squareSprite2;
  private Timer timer;
  private float delaySeconds;
  private float intervalSeconds;
  float red,green,blue;

  public BackgroundAnimation()
  {
    pixmap = new Pixmap(32, 32, Pixmap.Format.RGB565);
    pixmap.setColor(Color.CYAN);
    squareSprite = new Sprite(new Texture(pixmap));
    squareSprite2 = new Sprite(new Texture(pixmap));
    square1Vector.x = Gdx.graphics.getWidth()/2-square1Width;
    square1Vector.y = Gdx.graphics.getHeight()/3;
    squareSprite.setOrigin(square1Vector.x -(square1Width/2), square1Vector.y - (square1Height/2));
    squareSprite2.setOrigin(square1Width/2, square1Height/2);
  
  }
  @Override
  public void draw(SpriteBatch spriteBatch) {

    spriteBatch.begin();
    
    squareSprite.setBounds(square1Vector.x, square1Vector.y, square1Width, square1Height);
    squareSprite.draw(spriteBatch);
  
    squareSprite2.setBounds(square1Vector.x+square1Width+100, square1Vector.y, square1Width, square1Height);
    squareSprite2.draw(spriteBatch);
    spriteBatch.end();
  
    update();
  }
  private void update()
  {
    squareSprite.rotate(angleSpeed * Gdx.graphics.getDeltaTime());
    squareSprite2.rotate(-angleSpeed * Gdx.graphics.getDeltaTime());
  }
  
  
  

}




Java Source Code List

actors.Square.java
com.denzyldick.square.Assets.java
com.denzyldick.square.BackgroundAnimation.java
com.denzyldick.square.File.java
com.denzyldick.square.Font.java
com.denzyldick.square.Main.java
com.denzyldick.square.SoundManager.java
com.denzyldick.square.SquareMain.java
com.denzyldick.square.StarManagement.java
com.denzyldick.square.client.GwtLauncher.java
com.denzyldick.square.json.JsonArray.java
com.denzyldick.square.json.JsonLiteral.java
com.denzyldick.square.json.JsonNumber.java
com.denzyldick.square.json.JsonObject.java
com.denzyldick.square.json.JsonParser.java
com.denzyldick.square.json.JsonString.java
com.denzyldick.square.json.JsonValue.java
com.denzyldick.square.json.JsonWriter.java
com.denzyldick.square.json.ParseException.java
com.realcode.square.MainActivity.java
screens.GameMenu.java
screens.GameScreen.java
screens.LostScreen.java
screens.MenuScreen.java
screens.OptionsScreen.java
screens.SplashScreen.java
screens.TutorialScreen.java
screens.WonScreen.java