Android Open Source - Sneik Asset Loader






From Project

Back to project page Sneik.

License

The source code is released under:

Apache License

If you think the Android project Sneik 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 net.plastboks.sneikhelpers;
//  ww w  . j  a va  2 s  .  com
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Preferences;
import com.badlogic.gdx.audio.Sound;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.TextureRegion;

/**
 * Created by alex on 12/12/14.
 */
public class AssetLoader {
    public static Texture texture;
    public static TextureRegion bg;

    public static TextureRegion snakeHead, snakeBody;
    public static TextureRegion bird, mouse;

    public static Sound dead, coin, flap, mousefx, birdfx;
    public static BitmapFont font, shadow, fontSmall, shadowSmall;

    public static Preferences prefs;

    private static String hs = "highscore";

    public static void load() {
        texture = new Texture(Gdx.files.internal("data/sneiktexture.png"));
        texture.setFilter(Texture.TextureFilter.Nearest, Texture.TextureFilter.Nearest);

        bg = new TextureRegion(texture, 0, 0, 30, 30);
        bg.flip(false, true);

        snakeHead = new TextureRegion(texture, 32, 0, 15, 15);
        snakeHead.flip(false, true);
        snakeBody = new TextureRegion(texture, 48, 0, 15, 15);
        snakeBody.flip(false, true);

        bird = new TextureRegion(texture, 32, 16, 15, 15);
        bird.flip(false, true);
        mouse = new TextureRegion(texture, 48, 16, 15, 15);
        mouse.flip(false, true);

        dead = Gdx.audio.newSound(Gdx.files.internal("data/dead.wav"));
        coin = Gdx.audio.newSound(Gdx.files.internal("data/coin.wav"));
        flap = Gdx.audio.newSound(Gdx.files.internal("data/flap.wav"));
        birdfx = Gdx.audio.newSound(Gdx.files.internal("data/vulture.wav"));
        mousefx = Gdx.audio.newSound(Gdx.files.internal("data/mouse.wav"));

        font = new BitmapFont(Gdx.files.internal("data/text.fnt"));
        font.setScale(.25f, -.25f);
        shadow = new BitmapFont(Gdx.files.internal("data/shadow.fnt"));
        shadow.setScale(.25f, -.25f);

        fontSmall = new BitmapFont(Gdx.files.internal("data/text.fnt"));
        fontSmall.setScale(.10f, -.10f);

        prefs = Gdx.app.getPreferences("Sneik");

        if (!prefs.contains(hs)) { prefs.putInteger(hs, 0); }
    }

    public static void dispose() {
        texture.dispose();
        dead.dispose();
        coin.dispose();
        flap.dispose();
        font.dispose();
        shadow.dispose();
    }

    public static void setHighScore(int val) {
        prefs.putInteger(hs, val);
        prefs.flush();
    }

    public static int getHighScore() { return prefs.getInteger(hs); }
}




Java Source Code List

net.plastboks.gameobjects.Artificial.java
net.plastboks.gameobjects.Autonomous.java
net.plastboks.gameobjects.Bird.java
net.plastboks.gameobjects.Creature.java
net.plastboks.gameobjects.Mouse.java
net.plastboks.gameobjects.Node.java
net.plastboks.gameobjects.Snake.java
net.plastboks.gameworld.GamePlay.java
net.plastboks.gameworld.GameRenderer.java
net.plastboks.gameworld.GameWorld.java
net.plastboks.screens.GameScreen.java
net.plastboks.shared.Directions.java
net.plastboks.sneik.IOSLauncher.java
net.plastboks.sneik.SneikGame.java
net.plastboks.sneik.android.AndroidLauncher.java
net.plastboks.sneik.client.HtmlLauncher.java
net.plastboks.sneik.desktop.DesktopLauncher.java
net.plastboks.sneikhelpers.AssetLoader.java
net.plastboks.sneikhelpers.InputHandler.java