-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Implemented the latest version of the tutorial. * Added a preload filter to prevent loading the large MP3 file at startup.
- Loading branch information
Showing
10 changed files
with
152 additions
and
59 deletions.
There are no files selected for viewing
File renamed without changes.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
a-simple-game/core/src/main/java/com/badlogic/drop/Preloader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.badlogic.drop; | ||
|
||
public interface Preloader { | ||
|
||
/**Request that the named bundle be preloaded. | ||
* | ||
* @param bundle the name of the bundle | ||
* @param callback to be called upon preload completion | ||
*/ | ||
public void preloadBundle(String bundle, Callback callback); | ||
|
||
/** Allows the Preloader to communicate back to the caller. */ | ||
public interface Callback { | ||
|
||
/**Called when the named bundle has been preloaded. | ||
* | ||
* @param bundle the name of the bundle | ||
*/ | ||
void onBundlePreloaded(String bundle); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
a-simple-game/html/src/main/java/com/badlogic/drop/gwt/DropAssetFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.badlogic.drop.gwt; | ||
|
||
import com.badlogic.gdx.backends.gwt.preloader.DefaultAssetFilter; | ||
|
||
public class DropAssetFilter extends DefaultAssetFilter { | ||
@Override | ||
public String getBundleName(String file) { | ||
file = file.replace('\\', '/'); | ||
if (file.contains("delayed-loading/")) return "delayed-loading"; | ||
return super.getBundleName(file); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
a-simple-game/html/src/main/java/com/badlogic/drop/gwt/GwtPreloader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.badlogic.drop.gwt; | ||
|
||
import com.badlogic.drop.Preloader; | ||
import com.badlogic.gdx.backends.gwt.GwtApplication; | ||
import com.badlogic.gdx.backends.gwt.preloader.Preloader.PreloaderCallback; | ||
import com.badlogic.gdx.backends.gwt.preloader.Preloader.PreloaderState; | ||
|
||
public class GwtPreloader implements Preloader { | ||
|
||
GwtApplication application; | ||
|
||
public GwtPreloader(GwtApplication application) { | ||
this.application = application; | ||
} | ||
|
||
@Override | ||
public void preloadBundle (final String bundle, final Callback callback) { | ||
application.getPreloader().preload(bundle + ".txt", new PreloaderCallback() { | ||
@Override | ||
public void update (PreloaderState state) { | ||
if (state.hasEnded()) { | ||
callback.onBundlePreloaded(bundle); | ||
} | ||
} | ||
@Override | ||
public void error (String file) { | ||
} | ||
}); | ||
} | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
a-simple-game/lwjgl3/src/main/java/com/badlogic/drop/lwjgl3/NullPreloader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.badlogic.drop.lwjgl3; | ||
|
||
import com.badlogic.drop.Preloader; | ||
|
||
public class NullPreloader implements Preloader { | ||
|
||
@Override | ||
public void preloadBundle (final String bundle, final Callback callback) { | ||
callback.onBundlePreloaded(bundle); | ||
} | ||
|
||
} |