DEADSOFTWARE

Fix weird behavior on android
[cavedroid.git] / core / src / ru / deadsoftware / cavedroid / misc / Assets.java
index d86d3f8a17942e2a1d0301e0c7f2ec8399aee166..0dd1cf7673063a33a8f89af113f6f460c9a48fb4 100644 (file)
@@ -10,6 +10,7 @@ import com.badlogic.gdx.math.Rectangle;
 import com.badlogic.gdx.utils.ArrayMap;
 import com.badlogic.gdx.utils.JsonReader;
 import com.badlogic.gdx.utils.JsonValue;
+import ru.deadsoftware.cavedroid.game.objects.TouchButton;
 
 import java.util.HashMap;
 
@@ -18,15 +19,14 @@ public class Assets {
     public static final JsonReader jsonReader = new JsonReader();
 
     private static final GlyphLayout glyphLayout = new GlyphLayout();
-
     static BitmapFont minecraftFont;
 
     public static final Sprite[][] playerSprite = new Sprite[2][4];
     public static final Sprite[][] pigSprite = new Sprite[2][2];
-    public static Sprite fallingSandSprite;
-    public static Sprite fallingGravelSprite;
     public static final HashMap<String, TextureRegion> textureRegions = new HashMap<>();
-    public static final ArrayMap<String, Rectangle> guiMap = new ArrayMap<>();
+    public static final ArrayMap<String, TouchButton> guiMap = new ArrayMap<>();
+    public static Sprite sandSprite;
+    public static Sprite gravelSprite;
 
     private static TextureRegion flippedRegion(Texture texture, int x, int y, int width, int height) {
         return new TextureRegion(texture, x, y + height, width, -height);
@@ -74,11 +74,6 @@ public class Assets {
         pigSprite[1][1] = flippedSprite(new TextureRegion(pigTex, 16, 26, 12, 12));
     }
 
-    private static void loadFallingBlocks() {
-        fallingSandSprite = flippedSprite(new Texture((Gdx.files.internal("textures/blocks/sand.png"))));
-        fallingGravelSprite = flippedSprite(new Texture((Gdx.files.internal("textures/blocks/gravel.png"))));
-    }
-
     /**
      * Loads texture names and sizes from <b>json/texture_regions.json</b>, cuts them to TextureRegions
      * and puts to {@link #textureRegions} HashMap
@@ -102,12 +97,13 @@ public class Assets {
     }
 
     public static void load() {
-        minecraftFont = new BitmapFont(Gdx.files.internal("font.fnt"), true);
-        minecraftFont.getData().setScale(.375f);
         loadPlayer();
         loadPig();
-        loadFallingBlocks();
         loadJSON();
+        minecraftFont = new BitmapFont(Gdx.files.internal("font.fnt"), true);
+        minecraftFont.getData().setScale(.375f);
+        sandSprite = flippedSprite(new Texture((Gdx.files.internal("textures/blocks/sand.png"))));
+        gravelSprite = flippedSprite(new Texture((Gdx.files.internal("textures/blocks/gravel.png"))));
     }
 
     /**