Android Open Source - crash-landing Base Object






From Project

Back to project page crash-landing.

License

The source code is released under:

MIT License

If you think the Android project crash-landing 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.balitechy.crashlanding.models;
/*from w ww  .  j ava  2 s  .  c o  m*/
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.scenes.scene2d.Actor;

public abstract class BaseObject extends Actor{
  protected float width;
  protected float height;
  protected Vector2 position;
  protected Texture texture;
  protected Rectangle bounds = new Rectangle();
  
  public BaseObject(Vector2 position, float width, float height){
    this.position = position;
    this.width = width;
    this.height = height;
  
    setBounds(position.x, position.y, width, height);
  }

  public Rectangle getBounds() {
    return bounds;
  }

  public Vector2 getPosition() {
    return position;
  }

  public float getWidth() {
    return width;
  }
  
  public void setWidth(float width) {
    this.width = width;
  }
  
  public float getHeight() {
    return height;
  }
  
  public void setHeight(float height) {
    this.height = height;
  }
  
  public Texture getTexture() {
    return texture;
  }
  
  @Override
  public void setBounds(float x, float y, float width, float height) {
    super.setBounds(x, y, width, height);
    bounds.x = position.x;
    bounds.y = position.y;
    bounds.width = width;
    bounds.height = height;
  }

  @Override
  public void act(float delta){
    setBounds(position.x, position.y, width, height);
  }
  
  // If subclass have texture, texture must disposed from this function.  
  public abstract void dispose();
}




Java Source Code List

com.balitechy.crashlanding.CrashLanding.java
com.balitechy.crashlanding.GameAudio.java
com.balitechy.crashlanding.GameUtils.java
com.balitechy.crashlanding.MainActivity.java
com.balitechy.crashlanding.Main.java
com.balitechy.crashlanding.models.Accelerator.java
com.balitechy.crashlanding.models.BaseObject.java
com.balitechy.crashlanding.models.FuelMeter.java
com.balitechy.crashlanding.models.LandingPad.java
com.balitechy.crashlanding.models.MovableObject.java
com.balitechy.crashlanding.models.SpaceShip.java
com.balitechy.crashlanding.screens.GameResult.java
com.balitechy.crashlanding.screens.GameScreen.java
com.balitechy.crashlanding.screens.HomeScreen.java