├── .gitignore
├── Android
├── AndroidManifest.xml
├── ant.properties
├── assets
│ └── data
│ │ ├── libgdx.png
│ │ ├── loading.pack
│ │ └── loading.png
├── build.xml
├── proguard-project.txt
├── project.properties
├── res
│ ├── drawable-hdpi
│ │ └── ic_launcher.png
│ ├── drawable-ldpi
│ │ └── ic_launcher.png
│ ├── drawable-mdpi
│ │ └── ic_launcher.png
│ ├── drawable-xhdpi
│ │ └── ic_launcher.png
│ ├── layout
│ │ └── main.xml
│ └── values
│ │ └── strings.xml
└── src
│ └── com
│ └── matsemann
│ └── libgdxloadingscreen
│ └── AndroidStarter.java
├── Desktop
└── src
│ └── com
│ └── matsemann
│ └── libgdxloadingscreen
│ ├── DesktopStarter.java
│ └── PackSkins.java
├── Main
├── src
│ └── com
│ │ └── matsemann
│ │ └── libgdxloadingscreen
│ │ ├── LoadingBar.java
│ │ ├── SomeCoolGame.java
│ │ └── screen
│ │ ├── AbstractScreen.java
│ │ ├── LoadingScreen.java
│ │ └── MainMenuScreen.java
└── workfiles
│ ├── 800x480.png
│ └── finished
│ ├── libgdx-logo.png
│ ├── loading-bar-anim_1.png
│ ├── loading-bar-anim_2.png
│ ├── loading-bar-anim_3.png
│ ├── loading-bar-anim_4.png
│ ├── loading-bar-anim_5.png
│ ├── loading-bar-hidden.png
│ ├── loading-bar1.png
│ ├── loading-bar2.png
│ ├── loading-frame-bg.png
│ ├── loading-frame.png
│ └── screen-bg.png
├── README.md
└── UNLICENSE.txt
/.gitignore:
--------------------------------------------------------------------------------
1 | # LIBS
2 | libs/
3 |
4 | # INTELLIJ
5 | *.iml
6 | .idea/
7 |
8 | # ANDROID
9 | *.class
10 | bin/
11 | gen/
12 | local.properties
--------------------------------------------------------------------------------
/Android/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/Android/ant.properties:
--------------------------------------------------------------------------------
1 | # This file is used to override default values used by the Ant build system.
2 | #
3 | # This file must be checked into Version Control Systems, as it is
4 | # integral to the build system of your project.
5 |
6 | # This file is only used by the Ant script.
7 |
8 | # You can use this to override default values such as
9 | # 'source.dir' for the location of your java source folder and
10 | # 'out.dir' for the location of your output folder.
11 |
12 | # You can also use it define how the release builds are signed by declaring
13 | # the following properties:
14 | # 'key.store' for the location of your keystore and
15 | # 'key.alias' for the name of the key to use.
16 | # The password will be asked during the build when you use the 'release' target.
17 |
18 |
--------------------------------------------------------------------------------
/Android/assets/data/libgdx.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Matsemann/libgdx-loading-screen/6e1e3d56215fc700f070b5fccf1599fdb939199b/Android/assets/data/libgdx.png
--------------------------------------------------------------------------------
/Android/assets/data/loading.pack:
--------------------------------------------------------------------------------
1 |
2 | loading.png
3 | format: RGBA8888
4 | filter: Nearest,Nearest
5 | repeat: none
6 | loading-frame
7 | rotate: false
8 | xy: 1, 435
9 | size: 540, 60
10 | orig: 540, 60
11 | offset: 0, 0
12 | index: -1
13 | loading-bar-anim
14 | rotate: false
15 | xy: 1, 384
16 | size: 501, 49
17 | orig: 501, 49
18 | offset: 0, 0
19 | index: 1
20 | loading-bar-anim
21 | rotate: false
22 | xy: 1, 333
23 | size: 501, 49
24 | orig: 501, 49
25 | offset: 0, 0
26 | index: 2
27 | loading-bar-anim
28 | rotate: false
29 | xy: 1, 282
30 | size: 501, 49
31 | orig: 501, 49
32 | offset: 0, 0
33 | index: 3
34 | loading-bar-anim
35 | rotate: false
36 | xy: 1, 231
37 | size: 501, 49
38 | orig: 501, 49
39 | offset: 0, 0
40 | index: 4
41 | loading-bar-anim
42 | rotate: false
43 | xy: 1, 180
44 | size: 501, 49
45 | orig: 501, 49
46 | offset: 0, 0
47 | index: 5
48 | loading-bar1
49 | rotate: false
50 | xy: 1, 129
51 | size: 501, 49
52 | orig: 501, 49
53 | offset: 0, 0
54 | index: -1
55 | loading-bar2
56 | rotate: false
57 | xy: 1, 78
58 | size: 501, 49
59 | orig: 501, 49
60 | offset: 0, 0
61 | index: -1
62 | libgdx-logo
63 | rotate: false
64 | xy: 1, 8
65 | size: 408, 68
66 | orig: 408, 68
67 | offset: 0, 0
68 | index: -1
69 | loading-bar-hidden
70 | rotate: false
71 | xy: 543, 441
72 | size: 33, 54
73 | orig: 33, 54
74 | offset: 0, 0
75 | index: -1
76 | loading-frame-bg
77 | rotate: false
78 | xy: 504, 428
79 | size: 5, 5
80 | orig: 5, 5
81 | offset: 0, 0
82 | index: -1
83 | screen-bg
84 | rotate: false
85 | xy: 1, 1
86 | size: 5, 5
87 | orig: 5, 5
88 | offset: 0, 0
89 | index: -1
90 |
--------------------------------------------------------------------------------
/Android/assets/data/loading.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Matsemann/libgdx-loading-screen/6e1e3d56215fc700f070b5fccf1599fdb939199b/Android/assets/data/loading.png
--------------------------------------------------------------------------------
/Android/build.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
29 |
30 |
31 |
35 |
36 |
37 |
38 |
39 |
40 |
49 |
50 |
51 |
52 |
56 |
57 |
69 |
70 |
71 |
89 |
90 |
91 |
92 |
93 |
--------------------------------------------------------------------------------
/Android/proguard-project.txt:
--------------------------------------------------------------------------------
1 | # To enable ProGuard in your project, edit project.properties
2 | # to define the proguard.config property as described in that file.
3 | #
4 | # Add project specific ProGuard rules here.
5 | # By default, the flags in this file are appended to flags specified
6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt
7 | # You can edit the include path and order by changing the ProGuard
8 | # include property in project.properties.
9 | #
10 | # For more details, see
11 | # http://developer.android.com/guide/developing/tools/proguard.html
12 |
13 | # Add any project specific keep options here:
14 |
15 | # If your project uses WebView with JS, uncomment the following
16 | # and specify the fully qualified class name to the JavaScript interface
17 | # class:
18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
19 | # public *;
20 | #}
21 |
--------------------------------------------------------------------------------
/Android/project.properties:
--------------------------------------------------------------------------------
1 | # This file is automatically generated by Android Tools.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must be checked in Version Control Systems.
5 | #
6 | # To customize properties used by the Ant build system edit
7 | # "ant.properties", and override values to adapt the script to your
8 | # project structure.
9 | #
10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
12 |
13 | # Project target.
14 | target=android-16
15 |
--------------------------------------------------------------------------------
/Android/res/drawable-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Matsemann/libgdx-loading-screen/6e1e3d56215fc700f070b5fccf1599fdb939199b/Android/res/drawable-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Android/res/drawable-ldpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Matsemann/libgdx-loading-screen/6e1e3d56215fc700f070b5fccf1599fdb939199b/Android/res/drawable-ldpi/ic_launcher.png
--------------------------------------------------------------------------------
/Android/res/drawable-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Matsemann/libgdx-loading-screen/6e1e3d56215fc700f070b5fccf1599fdb939199b/Android/res/drawable-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Android/res/drawable-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Matsemann/libgdx-loading-screen/6e1e3d56215fc700f070b5fccf1599fdb939199b/Android/res/drawable-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Android/res/layout/main.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/Android/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Android
4 |
5 |
--------------------------------------------------------------------------------
/Android/src/com/matsemann/libgdxloadingscreen/AndroidStarter.java:
--------------------------------------------------------------------------------
1 | package com.matsemann.libgdxloadingscreen;
2 |
3 | import android.os.Bundle;
4 |
5 | import com.badlogic.gdx.backends.android.AndroidApplication;
6 | import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration;
7 |
8 | /**
9 | * @author Mats Svensson
10 | */
11 | public class AndroidStarter extends AndroidApplication {
12 | @Override
13 | public void onCreate(Bundle savedInstanceState) {
14 | super.onCreate(savedInstanceState);
15 |
16 | AndroidApplicationConfiguration cfg = new AndroidApplicationConfiguration();
17 | cfg.useGL20 = false;
18 |
19 | initialize(new SomeCoolGame(), cfg);
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/Desktop/src/com/matsemann/libgdxloadingscreen/DesktopStarter.java:
--------------------------------------------------------------------------------
1 | package com.matsemann.libgdxloadingscreen;
2 |
3 | import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
4 | import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
5 |
6 | /**
7 | * @author Mats Svensson
8 | */
9 | public class DesktopStarter {
10 | public static void main(String[] args) {
11 | LwjglApplicationConfiguration cfg = new LwjglApplicationConfiguration();
12 | cfg.title = "libgdx-loading-screen";
13 | cfg.useGL20 = false;
14 | cfg.width = 800;
15 | cfg.height = 480;
16 |
17 | new LwjglApplication(new SomeCoolGame(), cfg);
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/Desktop/src/com/matsemann/libgdxloadingscreen/PackSkins.java:
--------------------------------------------------------------------------------
1 | package com.matsemann.libgdxloadingscreen;
2 |
3 | import com.badlogic.gdx.tools.imagepacker.TexturePacker2;
4 |
5 | /**
6 | * @author Mats Svensson
7 | */
8 | public class PackSkins {
9 |
10 | public static void main(String[] args) {
11 | TexturePacker2.Settings s = new TexturePacker2.Settings();
12 | TexturePacker2.process(s, "Main/workfiles/finished", "Android/assets/data", "loading.pack");
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/Main/src/com/matsemann/libgdxloadingscreen/LoadingBar.java:
--------------------------------------------------------------------------------
1 | package com.matsemann.libgdxloadingscreen;
2 |
3 | import com.badlogic.gdx.graphics.g2d.Animation;
4 | import com.badlogic.gdx.graphics.g2d.SpriteBatch;
5 | import com.badlogic.gdx.graphics.g2d.TextureRegion;
6 | import com.badlogic.gdx.scenes.scene2d.Actor;
7 |
8 | /**
9 | * @author Mats Svensson
10 | */
11 | public class LoadingBar extends Actor {
12 |
13 | Animation animation;
14 | TextureRegion reg;
15 | float stateTime;
16 |
17 | public LoadingBar(Animation animation) {
18 | this.animation = animation;
19 | reg = animation.getKeyFrame(0);
20 | }
21 |
22 | @Override
23 | public void act(float delta) {
24 | stateTime += delta;
25 | reg = animation.getKeyFrame(stateTime);
26 | }
27 |
28 | @Override
29 | public void draw(SpriteBatch batch, float parentAlpha) {
30 | batch.draw(reg, getX(), getY());
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/Main/src/com/matsemann/libgdxloadingscreen/SomeCoolGame.java:
--------------------------------------------------------------------------------
1 | package com.matsemann.libgdxloadingscreen;
2 |
3 | import com.badlogic.gdx.Game;
4 | import com.badlogic.gdx.assets.AssetManager;
5 | import com.matsemann.libgdxloadingscreen.screen.LoadingScreen;
6 |
7 | /**
8 | * @author Mats Svensson
9 | */
10 | public class SomeCoolGame extends Game {
11 |
12 | /**
13 | * Holds all our assets
14 | */
15 | public AssetManager manager = new AssetManager();
16 |
17 | @Override
18 | public void create() {
19 | setScreen(new LoadingScreen(this));
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/Main/src/com/matsemann/libgdxloadingscreen/screen/AbstractScreen.java:
--------------------------------------------------------------------------------
1 | package com.matsemann.libgdxloadingscreen.screen;
2 |
3 | import com.badlogic.gdx.Screen;
4 | import com.matsemann.libgdxloadingscreen.SomeCoolGame;
5 |
6 | /**
7 | * @author Mats Svensson
8 | */
9 | public abstract class AbstractScreen implements Screen {
10 |
11 | protected SomeCoolGame game;
12 |
13 | public AbstractScreen(SomeCoolGame game) {
14 | this.game = game;
15 | }
16 |
17 | @Override
18 | public void pause() {
19 | }
20 |
21 | @Override
22 | public void resume() {
23 | }
24 |
25 | @Override
26 | public void dispose() {
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/Main/src/com/matsemann/libgdxloadingscreen/screen/LoadingScreen.java:
--------------------------------------------------------------------------------
1 | package com.matsemann.libgdxloadingscreen.screen;
2 |
3 | import com.badlogic.gdx.Gdx;
4 | import com.badlogic.gdx.graphics.GL10;
5 | import com.badlogic.gdx.graphics.g2d.Animation;
6 | import com.badlogic.gdx.graphics.g2d.TextureAtlas;
7 | import com.badlogic.gdx.math.Interpolation;
8 | import com.badlogic.gdx.scenes.scene2d.Actor;
9 | import com.badlogic.gdx.scenes.scene2d.Stage;
10 | import com.badlogic.gdx.scenes.scene2d.ui.Image;
11 | import com.matsemann.libgdxloadingscreen.LoadingBar;
12 | import com.matsemann.libgdxloadingscreen.SomeCoolGame;
13 |
14 | /**
15 | * @author Mats Svensson
16 | */
17 | public class LoadingScreen extends AbstractScreen {
18 |
19 | private Stage stage;
20 |
21 | private Image logo;
22 | private Image loadingFrame;
23 | private Image loadingBarHidden;
24 | private Image screenBg;
25 | private Image loadingBg;
26 |
27 | private float startX, endX;
28 | private float percent;
29 |
30 | private Actor loadingBar;
31 |
32 | public LoadingScreen(SomeCoolGame game) {
33 | super(game);
34 | }
35 |
36 | @Override
37 | public void show() {
38 | // Tell the manager to load assets for the loading screen
39 | game.manager.load("data/loading.pack", TextureAtlas.class);
40 | // Wait until they are finished loading
41 | game.manager.finishLoading();
42 |
43 | // Initialize the stage where we will place everything
44 | stage = new Stage();
45 |
46 | // Get our textureatlas from the manager
47 | TextureAtlas atlas = game.manager.get("data/loading.pack", TextureAtlas.class);
48 |
49 | // Grab the regions from the atlas and create some images
50 | logo = new Image(atlas.findRegion("libgdx-logo"));
51 | loadingFrame = new Image(atlas.findRegion("loading-frame"));
52 | loadingBarHidden = new Image(atlas.findRegion("loading-bar-hidden"));
53 | screenBg = new Image(atlas.findRegion("screen-bg"));
54 | loadingBg = new Image(atlas.findRegion("loading-frame-bg"));
55 |
56 | // Add the loading bar animation
57 | Animation anim = new Animation(0.05f, atlas.findRegions("loading-bar-anim") );
58 | anim.setPlayMode(Animation.LOOP_REVERSED);
59 | loadingBar = new LoadingBar(anim);
60 |
61 | // Or if you only need a static bar, you can do
62 | // loadingBar = new Image(atlas.findRegion("loading-bar1"));
63 |
64 | // Add all the actors to the stage
65 | stage.addActor(screenBg);
66 | stage.addActor(loadingBar);
67 | stage.addActor(loadingBg);
68 | stage.addActor(loadingBarHidden);
69 | stage.addActor(loadingFrame);
70 | stage.addActor(logo);
71 |
72 | // Add everything to be loaded, for instance:
73 | // game.manager.load("data/assets1.pack", TextureAtlas.class);
74 | // game.manager.load("data/assets2.pack", TextureAtlas.class);
75 | // game.manager.load("data/assets3.pack", TextureAtlas.class);
76 | }
77 |
78 | @Override
79 | public void resize(int width, int height) {
80 | // Set our screen to always be XXX x 480 in size
81 | width = 480 * width / height;
82 | height = 480;
83 | stage.setViewport(width , height, false);
84 |
85 | // Make the background fill the screen
86 | screenBg.setSize(width, height);
87 |
88 | // Place the logo in the middle of the screen and 100 px up
89 | logo.setX((width - logo.getWidth()) / 2);
90 | logo.setY((height - logo.getHeight()) / 2 + 100);
91 |
92 | // Place the loading frame in the middle of the screen
93 | loadingFrame.setX((stage.getWidth() - loadingFrame.getWidth()) / 2);
94 | loadingFrame.setY((stage.getHeight() - loadingFrame.getHeight()) / 2);
95 |
96 | // Place the loading bar at the same spot as the frame, adjusted a few px
97 | loadingBar.setX(loadingFrame.getX() + 15);
98 | loadingBar.setY(loadingFrame.getY() + 5);
99 |
100 | // Place the image that will hide the bar on top of the bar, adjusted a few px
101 | loadingBarHidden.setX(loadingBar.getX() + 35);
102 | loadingBarHidden.setY(loadingBar.getY() - 3);
103 | // The start position and how far to move the hidden loading bar
104 | startX = loadingBarHidden.getX();
105 | endX = 440;
106 |
107 | // The rest of the hidden bar
108 | loadingBg.setSize(450, 50);
109 | loadingBg.setX(loadingBarHidden.getX() + 30);
110 | loadingBg.setY(loadingBarHidden.getY() + 3);
111 | }
112 |
113 | @Override
114 | public void render(float delta) {
115 | // Clear the screen
116 | Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
117 |
118 | if (game.manager.update()) { // Load some, will return true if done loading
119 | if (Gdx.input.isTouched()) { // If the screen is touched after the game is done loading, go to the main menu screen
120 | game.setScreen(new MainMenuScreen(game));
121 | }
122 | }
123 |
124 | // Interpolate the percentage to make it more smooth
125 | percent = Interpolation.linear.apply(percent, game.manager.getProgress(), 0.1f);
126 |
127 | // Update positions (and size) to match the percentage
128 | loadingBarHidden.setX(startX + endX * percent);
129 | loadingBg.setX(loadingBarHidden.getX() + 30);
130 | loadingBg.setWidth(450 - 450 * percent);
131 | loadingBg.invalidate();
132 |
133 | // Show the loading screen
134 | stage.act();
135 | stage.draw();
136 | }
137 |
138 | @Override
139 | public void hide() {
140 | // Dispose the loading assets as we no longer need them
141 | game.manager.unload("data/loading.pack");
142 | }
143 | }
144 |
--------------------------------------------------------------------------------
/Main/src/com/matsemann/libgdxloadingscreen/screen/MainMenuScreen.java:
--------------------------------------------------------------------------------
1 | package com.matsemann.libgdxloadingscreen.screen;
2 |
3 | import com.badlogic.gdx.Gdx;
4 | import com.badlogic.gdx.graphics.GL10;
5 | import com.matsemann.libgdxloadingscreen.SomeCoolGame;
6 |
7 | /**
8 | * @author Mats Svensson
9 | */
10 | public class MainMenuScreen extends AbstractScreen {
11 |
12 | public MainMenuScreen(SomeCoolGame game) {
13 | super(game);
14 | }
15 |
16 | @Override
17 | public void render(float delta) {
18 | // Draws a red background
19 | Gdx.gl.glClearColor(0.5f, 0.1f, 0.1f, 1);
20 | Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
21 | }
22 |
23 | @Override
24 | public void resize(int width, int height) {
25 | }
26 |
27 | @Override
28 | public void show() {
29 | }
30 |
31 | @Override
32 | public void hide() {
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/Main/workfiles/800x480.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Matsemann/libgdx-loading-screen/6e1e3d56215fc700f070b5fccf1599fdb939199b/Main/workfiles/800x480.png
--------------------------------------------------------------------------------
/Main/workfiles/finished/libgdx-logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Matsemann/libgdx-loading-screen/6e1e3d56215fc700f070b5fccf1599fdb939199b/Main/workfiles/finished/libgdx-logo.png
--------------------------------------------------------------------------------
/Main/workfiles/finished/loading-bar-anim_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Matsemann/libgdx-loading-screen/6e1e3d56215fc700f070b5fccf1599fdb939199b/Main/workfiles/finished/loading-bar-anim_1.png
--------------------------------------------------------------------------------
/Main/workfiles/finished/loading-bar-anim_2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Matsemann/libgdx-loading-screen/6e1e3d56215fc700f070b5fccf1599fdb939199b/Main/workfiles/finished/loading-bar-anim_2.png
--------------------------------------------------------------------------------
/Main/workfiles/finished/loading-bar-anim_3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Matsemann/libgdx-loading-screen/6e1e3d56215fc700f070b5fccf1599fdb939199b/Main/workfiles/finished/loading-bar-anim_3.png
--------------------------------------------------------------------------------
/Main/workfiles/finished/loading-bar-anim_4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Matsemann/libgdx-loading-screen/6e1e3d56215fc700f070b5fccf1599fdb939199b/Main/workfiles/finished/loading-bar-anim_4.png
--------------------------------------------------------------------------------
/Main/workfiles/finished/loading-bar-anim_5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Matsemann/libgdx-loading-screen/6e1e3d56215fc700f070b5fccf1599fdb939199b/Main/workfiles/finished/loading-bar-anim_5.png
--------------------------------------------------------------------------------
/Main/workfiles/finished/loading-bar-hidden.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Matsemann/libgdx-loading-screen/6e1e3d56215fc700f070b5fccf1599fdb939199b/Main/workfiles/finished/loading-bar-hidden.png
--------------------------------------------------------------------------------
/Main/workfiles/finished/loading-bar1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Matsemann/libgdx-loading-screen/6e1e3d56215fc700f070b5fccf1599fdb939199b/Main/workfiles/finished/loading-bar1.png
--------------------------------------------------------------------------------
/Main/workfiles/finished/loading-bar2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Matsemann/libgdx-loading-screen/6e1e3d56215fc700f070b5fccf1599fdb939199b/Main/workfiles/finished/loading-bar2.png
--------------------------------------------------------------------------------
/Main/workfiles/finished/loading-frame-bg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Matsemann/libgdx-loading-screen/6e1e3d56215fc700f070b5fccf1599fdb939199b/Main/workfiles/finished/loading-frame-bg.png
--------------------------------------------------------------------------------
/Main/workfiles/finished/loading-frame.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Matsemann/libgdx-loading-screen/6e1e3d56215fc700f070b5fccf1599fdb939199b/Main/workfiles/finished/loading-frame.png
--------------------------------------------------------------------------------
/Main/workfiles/finished/screen-bg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Matsemann/libgdx-loading-screen/6e1e3d56215fc700f070b5fccf1599fdb939199b/Main/workfiles/finished/screen-bg.png
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | libgdx loading screen
2 | =====================
3 |
4 | **OBS**: This code uses an older version of Libgdx. You may want to take a look at:
5 | * [Libgdx 1.2.0][7]-branch contributed by [EyeOfMidas][10].
6 | * [Libgdx 1.4.1][8]-branch contributed by [Deathsbreed][9].
7 | * [Libgdx 1.9.9][12]-branch contributed by [LaurenceWarne][13].
8 |
9 | What is this?
10 | -------------
11 |
12 | 
13 | This is an example of how to make a loading screen in libgdx. It loads the game resources asynchronously in the background, e.g. non-blocking, which makes it possible to have an animated loading bar showing the progress and other responsive features.
14 | The bar is interpolated to make the progress less 'jerky'.
15 | [Video example] [1]
16 |
17 | Featured in book
18 | ----------------
19 |
20 | This repository's code is used in the book [LibGDX Game Development Essentials][11] by Juwal Bose for Packt Publishing.
21 |
22 | How does it work?
23 | -----------------
24 |
25 | Check out the [LoadingScreen.java] [4] file, which is commented.
26 | It relies on the [AssetManager] [6] to load the assets in another thread. This gives it the opportunity to show a responsive
27 | screen instead of having the game freeze while assets are being loaded.
28 |
29 | First it loads the assets needed to show the loading screen. For this, it is calling AssetManager's finishLoading();
30 | This will make the screen wait until all the loading assets are loaded before moving on.
31 | Then it should tell the AssetManager what to load next.
32 |
33 | In the resize() method we are placing all the components.
34 | **NOTE:** If you check the code you will see that the loadingBar is actually never resized or moved. Instead it is hidden
35 | from the beginning, and then showing more and more as the assets are being loaded.
36 |
37 | In the render() method AssetManager.update() is being constantly called to make it load the assets. This method will return *TRUE*
38 | when everything is loaded, so then it would be a good time to move on to some other screen. In this example, it moves on to MainMenuScreen
39 | after a touch.
40 | The percentage value given by the manager is interpolated to give a more smooth bar. Try changing the value from 0.1f to 1f to see the difference.
41 | Or check this [video with no interpolation] [5]
42 |
43 |
44 |
45 | Links
46 | -----
47 |
48 | [Libgdx] [2]
49 | [Vector logo] [3]
50 |
51 |
52 | License
53 | -------
54 |
55 | **UNLICENSE**
56 |
57 |
58 | This is free and unencumbered software released into the public domain.
59 |
60 | Anyone is free to copy, modify, publish, use, compile, sell, or
61 | distribute this software, either in source code form or as a compiled
62 | binary, for any purpose, commercial or non-commercial, and by any
63 | means.
64 |
65 | In jurisdictions that recognize copyright laws, the author or authors
66 | of this software dedicate any and all copyright interest in the
67 | software to the public domain. We make this dedication for the benefit
68 | of the public at large and to the detriment of our heirs and
69 | successors. We intend this dedication to be an overt act of
70 | relinquishment in perpetuity of all present and future rights to this
71 | software under copyright law.
72 |
73 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
74 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
75 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
76 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
77 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
78 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
79 | OTHER DEALINGS IN THE SOFTWARE.
80 |
81 | For more information, please refer to
82 |
83 |
84 |
85 |
86 | [1]: http://www.youtube.com/watch?v=gpI2U_9jDak "YouTube"
87 | [2]: http://libgdx.badlogicgames.com/ "Libgdx home"
88 | [3]: http://bioboblog.blogspot.no/2012/08/vector-libgdx-logo.html
89 | [4]: https://github.com/Matsemann/libgdx-loading-screen/blob/master/Main/src/com/matsemann/libgdxloadingscreen/screen/LoadingScreen.java
90 | [5]: http://www.youtube.com/watch?v=pyZwkYVHEyI
91 | [6]: http://code.google.com/p/libgdx/wiki/AssetManager
92 | [7]: https://github.com/Matsemann/libgdx-loading-screen/tree/libgdx1.2.0-EyeOfMidas
93 | [8]: https://github.com/Matsemann/libgdx-loading-screen/tree/libgdx-1.4.1-Deathsbreed
94 | [9]: https://github.com/Matsemann/libgdx-loading-screen/pull/4
95 | [10]: https://github.com/Matsemann/libgdx-loading-screen/pull/3
96 | [11]: https://www.packtpub.com/game-development/libgdx-game-development-essentials
97 | [12]: https://github.com/Matsemann/libgdx-loading-screen/tree/libgdx-1.9.9-LaurenceWarne
98 | [13]: https://github.com/Matsemann/libgdx-loading-screen/pull/5
99 |
--------------------------------------------------------------------------------
/UNLICENSE.txt:
--------------------------------------------------------------------------------
1 | This is free and unencumbered software released into the public domain.
2 |
3 | Anyone is free to copy, modify, publish, use, compile, sell, or
4 | distribute this software, either in source code form or as a compiled
5 | binary, for any purpose, commercial or non-commercial, and by any
6 | means.
7 |
8 | In jurisdictions that recognize copyright laws, the author or authors
9 | of this software dedicate any and all copyright interest in the
10 | software to the public domain. We make this dedication for the benefit
11 | of the public at large and to the detriment of our heirs and
12 | successors. We intend this dedication to be an overt act of
13 | relinquishment in perpetuity of all present and future rights to this
14 | software under copyright law.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 | OTHER DEALINGS IN THE SOFTWARE.
23 |
24 | For more information, please refer to
25 |
--------------------------------------------------------------------------------