Back to project page crash-landing.
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.
package com.balitechy.crashlanding.models; /*from ww w . j a va 2s .c o m*/ import com.badlogic.gdx.Gdx; import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.Texture.TextureFilter; import com.badlogic.gdx.graphics.g2d.Batch; import com.badlogic.gdx.math.Vector2; public class FuelMeter extends BaseObject { private Texture textureBar, textureSafe, textureCritical; private float level; //percentage of fuel level public FuelMeter(Vector2 position, float width, float height) { super(position, width, height); textureBar = new Texture(Gdx.files.internal("data/white.png")); textureBar.setFilter(TextureFilter.Linear, TextureFilter.Linear); textureSafe = new Texture(Gdx.files.internal("data/green.png")); textureSafe.setFilter(TextureFilter.Linear, TextureFilter.Linear); textureCritical = new Texture(Gdx.files.internal("data/red.png")); textureCritical.setFilter(TextureFilter.Linear, TextureFilter.Linear); } public void setLevel(float level) { this.level = level; } @Override public void draw(Batch batch, float parentAlpha) { batch.draw(textureBar, position.x, position.y, width, height); if(level > 0.5f) batch.draw(textureSafe, position.x, position.y, width*level, height); else batch.draw(textureCritical, position.x, position.y, width*level, height); } @Override public void dispose() { textureBar.dispose(); textureSafe.dispose(); textureCritical.dispose(); } }