- public class TerrereCo extends ApplicationAdapter {
- public static final int VIRTUAL_WIDTH = 1000;
- public static final int VIRTUAL_HEIGHT = 750;
- public static Content res;
- public static AInput input;
- public GSM gsm;
- @Override
- public void create() {
- Gdx.gl.glClearColor(0.6f, 0.6f, 0.7f, 1);
- res = new Content();
- gsm = new GSM();
- gsm.pushState(new SplashState(gsm));
- res.loadTexture("badlogic.jpg", "logo");
- input = new AInput();
- }
- @Override
- public void render() {
- gsm.update();
- gsm.render();
- input.update();
- }
- }
- ================================================================================
- public class SplashState extends State {
- private Texture tex;
- private Sprite logo;
- private TweenManager tm;
- public SplashState(GSM gsm) {
- super(gsm);
- tex = TerrereCo.res.getTexture("logo");
- logo = new Sprite(tex);
- Tween.registerAccessor(Sprite.class, new SpriteAccessor());
- tm = new TweenManager();
- Tween.set(logo, SpriteAccessor.ALPHA).target(0).start(tm);
- Tween.to(logo, SpriteAccessor.ALPHA, 1).target(2).repeatYoyo(1, 2).start(tm);
- }
- @Override
- protected void render() {
- sb.setProjectionMatrix(cam.combined);
- sb.begin();
- logo.draw(sb);
- sb.end();
- }
- @Override
- protected void update() {
- tm.update(1 / 60f);
- handleInput();
- cam.update();
- }
- @Override
- protected void handleInput() {
- }
- }
- ================================================================================
- public class Content {
- private HashMap<String, Texture> textures;
- private HashMap<String, Sound> sfx;
- private HashMap<String, Music> music;
- private HashMap<String, TextureAtlas> atlases;
- public Content() {
- textures = new HashMap<String, Texture>();
- sfx = new HashMap<String, Sound>();
- music = new HashMap<String, Music>();
- atlases = new HashMap<String, TextureAtlas>();
- }
- public void loadTexture(String path, String key) {
- Texture t = new Texture(Gdx.files.internal(path));
- textures.put(key, t);
- }
- public Texture getTexture(String key) {
- return textures.get(key);
- }
- public void disposeTexture(String key) {
- Texture t = textures.get(key);
- if(t != null) t.dispose();
- }
- public void loadSFX(String path, String key) {
- Sound s = Gdx.audio.newSound(Gdx.files.internal(path));
- sfx.put(key, s);
- }
- public Sound getSFX(String key) {
- return sfx.get(key);
- }
- public void disposeSFX(String key) {
- Sound s = sfx.get(key);
- if(s != null) s.dispose();
- }
- public void loadMusic(String path, String key) {
- Music m = Gdx.audio.newMusic(Gdx.files.internal(path));
- music.put(key, m);
- }
- public Music getMusic(String key) {
- return music.get(key);
- }
- public void disposeMusic(String key) {
- Music m = music.get(key);
- if(m != null) m.dispose();
- }
- public void loadAtlas(String path, String key) {
- TextureAtlas ta = new TextureAtlas(Gdx.files.internal(path));
- atlases.put(key, ta);
- }
- public TextureAtlas getAtlas(String key) {
- return atlases.get(key);
- }
- public void disposeAtlas(String key) {
- TextureAtlas ta = atlases.get(key);
- if(ta != null) ta.dispose();
- }
- }
- ================================================================================
- Exception in thread "LWJGL Application" java.lang.NullPointerException
- at com.badlogic.gdx.graphics.g2d.Sprite.<init>(Sprite.java:56)
- at com.terrerec.game.states.SplashState.<init>(SplashState.java:20)
- at com.terrerec.game.TerrereCo.create(TerrereCo.java:25)
- at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:136)
- at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:114)
- ================================================================================
SHARE
TWEET
Untitled
a guest
Sep 20th, 2014
181
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.
