如果是 5MB 的资产,我说只需将它们加载到启动屏幕上即可。这样,屏幕切换之间几乎没有“加载”时间。方法1是最好的。
创建一个名为Assets
. 在这有一个名为“load”的静态方法,就像这样
公共类资产{
private static Texture tex;
public static TextureRegion tree,cloud1,cloud2,cloud3,rock,platform,playerStanding,
rocket, rocketShadow, moon, star;
public static SpriteAnimation playerMoving;
public static void load(){
tex = new Texture(Gdx.files.internal("data/Graphics.png"));
tex.setFilter(TextureFilter.Linear, TextureFilter.Linear);
tree = new TextureRegion(tex, 0,0,246,226);
cloud1 = new TextureRegion(tex, 246,0,225,92);
cloud2 = new TextureRegion(tex, 358,197,88,84);
cloud3 = new TextureRegion(tex, 0,226,105,64);
rock = new TextureRegion(tex, 246,197,112,90);
platform = new TextureRegion(tex, 246,92,193,105);
tex = new Texture(Gdx.files.internal("data/Graphics2.png"));
tex.setFilter(TextureFilter.Linear, TextureFilter.Linear);
playerMoving = new SpriteAnimation(new TextureRegion(tex,0,0,458,555), 4, 5, 0.01f);
playerStanding = new TextureRegion(tex,0,0,112,110);
tex = new Texture(Gdx.files.internal("data/Graphics3.png"));
tex.setFilter(TextureFilter.Linear, TextureFilter.Linear);
rocket = new TextureRegion(tex,0,218,119,201);
rocketShadow = new TextureRegion(tex,0,0,138,218);
tex = new Texture(Gdx.files.internal("data/Graphics4.png"));
tex.setFilter(TextureFilter.Linear, TextureFilter.Linear);
moon = new TextureRegion(tex,0,0,410,382);
star = new TextureRegion(tex,0,382,123,123);
}
public static void dispose(){
tex.dispose();
}
}
(这只是我游戏中的一个例子。名字并不重要,重要的是方法)
在您的初始屏幕上,您只需调用即可Assets.load();
加载您的所有资产!
然后你想使用一个资产,你可以通过它调用它Assets.whatever
(静态的很好)
希望这可以帮助!