Android Open Source - GravityShip Landing Zone






From Project

Back to project page GravityShip.

License

The source code is released under:

GNU General Public License

If you think the Android project GravityShip 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.hajnar.GravityShip.GameObjects;
//from  w  ww  .  j a  va 2s .  c o m
import com.badlogic.gdx.graphics.g2d.Animation;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.physics.box2d.BodyDef.BodyType;
import com.badlogic.gdx.physics.box2d.FixtureDef;
import com.badlogic.gdx.physics.box2d.World;
import com.hajnar.GravityShip.Assets;

public class LandingZone extends GameObject {
    public static final int ZONETYPE_START = 1;
    public static final int ZONETYPE_FINISH = 2;
    public static final int ZONETYPE_REFUEL = 3;
    private Sprite sprite;
    private int zoneType;
    private TextureRegion[] animRegions;
    private Animation blinkAnimation;
    private float animTime;

    public LandingZone(int zoneType, World world, float x, float y, float rotDegrees) {
        super(world, BodyType.StaticBody, 2, x, y, (float) Math.toRadians(rotDegrees));

        this.zoneType = zoneType;
        this.animRegions = new TextureRegion[2];
        this.animRegions[0] = Assets.landzoneCommonRegion;
        this.sprite = new Sprite(this.animRegions[0]);

        if (zoneType == 1)
            this.animRegions[1] = Assets.landzoneStartRegion;
        else if (zoneType == 2)
            this.animRegions[1] = Assets.landzoneFinishRegion;
        else {
            this.animRegions[1] = Assets.landzoneRefuelRegion;
        }
        this.blinkAnimation = new Animation(0.5F, this.animRegions);

        this.sprite.setPosition(this.objectBody.getPosition().x * 100.0F - this.sprite.getWidth() / 2.0F,
                this.objectBody.getPosition().y * 100.0F - this.sprite.getHeight() / 2.0F);
        this.sprite.setRotation((float) Math.toDegrees(this.objectBody.getAngle()));

        FixtureDef fixtureDef = new FixtureDef();

        Assets.objectBodiesLoader.attachFixture(this.objectBody, "landingZone", fixtureDef, 2.56F);

        this.objectBody.setUserData(this);
        this.animTime = 0.0F;
    }

    public void update(float delta) {
        this.animTime += delta;
        this.sprite.setRegion(this.blinkAnimation.getKeyFrame(this.animTime, true));
    }

    public Sprite getSprite() {
        return this.sprite;
    }

    public int getSubType() {
        return this.zoneType;
    }
}




Java Source Code List

com.hajnar.GravityShip.Assets.java
com.hajnar.GravityShip.CollisionProcessor.java
com.hajnar.GravityShip.GameSettings.java
com.hajnar.GravityShip.GameWorldRenderGL2.java
com.hajnar.GravityShip.GameWorld.java
com.hajnar.GravityShip.GravityShip.java
com.hajnar.GravityShip.Helper.java
com.hajnar.GravityShip.MainActivity.java
com.hajnar.GravityShip.Main.java
com.hajnar.GravityShip.ScrollingBackground.java
com.hajnar.GravityShip.GameObjects.BlackHole.java
com.hajnar.GravityShip.GameObjects.Bullet.java
com.hajnar.GravityShip.GameObjects.Canon.java
com.hajnar.GravityShip.GameObjects.GameCamera.java
com.hajnar.GravityShip.GameObjects.GameObject.java
com.hajnar.GravityShip.GameObjects.LandingZone.java
com.hajnar.GravityShip.GameObjects.Player.java
com.hajnar.GravityShip.GameObjects.Star.java
com.hajnar.GravityShip.GameObjects.Terrain.java
com.hajnar.GravityShip.Screens.GameScreen.java
com.hajnar.GravityShip.Screens.MenuScreen.java
com.hajnar.GravityShip.Screens.SettingsScreen.java
com.hajnar.GravityShip.Screens.SplashScreen.java