Bug 18: Separated SpriteBatch and BitmapFont
This commit is contained in:
parent
60e26c364a
commit
3c397e354f
@ -1,10 +1,6 @@
|
||||
package com.openeggbert.core.main;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.graphics.Camera;
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
|
||||
import com.badlogic.gdx.utils.ObjectMap;
|
||||
import com.badlogic.gdx.utils.viewport.Viewport;
|
||||
@ -18,6 +14,9 @@ import com.openeggbert.core.screen.InitScreen;
|
||||
import com.openeggbert.core.utils.OpenEggbertUtils;
|
||||
import com.pixelgamelibrary.api.game.GameAdapter;
|
||||
import com.pixelgamelibrary.api.Pixel;
|
||||
import com.pixelgamelibrary.api.graphics.BitmapFont;
|
||||
import com.pixelgamelibrary.api.graphics.SpriteBatch;
|
||||
import com.pixelgamelibrary.api.graphics.Texture;
|
||||
import com.pixelgamelibrary.api.storage.FileHandle;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -74,12 +73,12 @@ public class OpenEggbertGame extends GameAdapter {
|
||||
// for(FileHandle f:Gdx.files.internal(".").list()) {
|
||||
// System.out.println("assets contains also: " + f.name());
|
||||
// }
|
||||
com.pixelgamelibrary.api.storage.FileHandle embeddedModsDirectory = Pixel.files().assets().file("/embedded_mods");
|
||||
com.pixelgamelibrary.api.storage.FileHandle embeddedModsDirectory = Pixel.files().assets("/embedded_mods");
|
||||
System.out.println("embeddedModsDirectory.exists=" + embeddedModsDirectory.exists());
|
||||
System.out.println("embeddedModsDirectory.list().size()=" + embeddedModsDirectory.list().size());
|
||||
embeddedModsDirectory.list().forEach(e -> System.out.println(e.path()));
|
||||
|
||||
Pixel.files().assets().list().forEach(e -> System.out.println(e));
|
||||
Pixel.files().assetsStorage().list().forEach(e -> System.out.println(e));
|
||||
|
||||
for (FileHandle embeddedModGroup : embeddedModsDirectory.list()) {
|
||||
if (embeddedModGroup.name().equals("README.md")) {
|
||||
@ -109,13 +108,13 @@ public class OpenEggbertGame extends GameAdapter {
|
||||
|
||||
}
|
||||
////
|
||||
batch = new SpriteBatch();
|
||||
batch = Pixel.graphics().newSpriteBatch();
|
||||
//batch.setProjectionMatrix(viewport.getCamera().combined);
|
||||
image = new Texture("libgdx.png");
|
||||
image = Pixel.graphics().newTexture("libgdx.png");
|
||||
shapeRenderer = new ShapeRenderer();
|
||||
font = new BitmapFont(
|
||||
Gdx.files.internal("com/badlogic/gdx/utils/lsans-15.fnt"), Gdx.files.internal("com/badlogic/gdx/utils/lsans-15.png"),
|
||||
false, true
|
||||
font = Pixel.graphics().newBitmapFont(
|
||||
Pixel.files().assets("com/badlogic/gdx/utils/lsans-15.fnt"), Pixel.files().assets("com/badlogic/gdx/utils/lsans-15.png"),
|
||||
false
|
||||
);
|
||||
|
||||
System.out.println("Going to set screen");
|
||||
@ -134,8 +133,8 @@ public class OpenEggbertGame extends GameAdapter {
|
||||
}
|
||||
}
|
||||
|
||||
public void loadImageTexture(com.badlogic.gdx.files.FileHandle fileHandle) {
|
||||
Texture texture = new Texture(fileHandle);
|
||||
public void loadImageTexture(FileHandle fileHandle) {
|
||||
Texture texture = Pixel.graphics().newTexture(fileHandle);
|
||||
if(!fileHandle.exists()) {
|
||||
throw new OpenEggbertException("File does not exist: " + fileHandle.path());
|
||||
}
|
||||
|
@ -21,10 +21,11 @@ package com.openeggbert.core.screen;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.InputAdapter;
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
||||
import com.pixelgamelibrary.api.graphics.Color;
|
||||
|
||||
import com.badlogic.gdx.utils.ScreenUtils;
|
||||
import com.openeggbert.core.main.OpenEggbertGame;
|
||||
import com.pixelgamelibrary.api.graphics.BitmapFont;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -61,7 +62,7 @@ public class AbstractGameScreen extends OpenEggbertScreen {
|
||||
|
||||
BitmapFont font;
|
||||
font = game.getFont();
|
||||
font.getData().setScale(2.0f);
|
||||
font.setScale(2.0f);
|
||||
font.setColor(Color.RED);
|
||||
|
||||
font.draw(batch, "Sorry, game is not yet implemented", 40, 400);
|
||||
|
@ -21,10 +21,11 @@ package com.openeggbert.core.screen;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.InputAdapter;
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
||||
import com.pixelgamelibrary.api.graphics.Color;
|
||||
|
||||
import com.badlogic.gdx.utils.ScreenUtils;
|
||||
import com.openeggbert.core.main.OpenEggbertGame;
|
||||
import com.pixelgamelibrary.api.graphics.BitmapFont;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
@ -67,7 +68,7 @@ public class DemoScreen extends OpenEggbertScreen {
|
||||
|
||||
BitmapFont font;
|
||||
font = game.getFont();
|
||||
font.getData().setScale(2.0f);
|
||||
font.setScale(2.0f);
|
||||
font.setColor(Color.RED);
|
||||
|
||||
font.draw(batch, "Sorry, demo is not yet implemented", 40, 400);
|
||||
|
@ -21,10 +21,11 @@ package com.openeggbert.core.screen;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.InputAdapter;
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
||||
import com.pixelgamelibrary.api.graphics.Color;
|
||||
|
||||
import com.badlogic.gdx.utils.ScreenUtils;
|
||||
import com.openeggbert.core.main.OpenEggbertGame;
|
||||
import com.pixelgamelibrary.api.graphics.BitmapFont;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
@ -66,7 +67,7 @@ public class GameScreen extends AbstractGameScreen {
|
||||
|
||||
BitmapFont font;
|
||||
font = game.getFont();
|
||||
font.getData().setScale(2.0f);
|
||||
font.setScale(2.0f);
|
||||
font.setColor(Color.RED);
|
||||
|
||||
font.draw(batch, "Sorry, demo is not yet implemented", 40, 400);
|
||||
|
@ -24,14 +24,15 @@ import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.Input;
|
||||
import com.badlogic.gdx.InputAdapter;
|
||||
import com.badlogic.gdx.Preferences;
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
||||
import com.pixelgamelibrary.api.graphics.Color;
|
||||
|
||||
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
|
||||
import com.openeggbert.core.gamespace.GameSpace;
|
||||
import com.openeggbert.core.main.OpenEggbertGame;
|
||||
import com.openeggbert.core.mod.Mod;
|
||||
import com.openeggbert.core.mod.ModType;
|
||||
import com.pixelgamelibrary.api.Pixel;
|
||||
import com.pixelgamelibrary.api.graphics.BitmapFont;
|
||||
import com.pixelgamelibrary.api.storage.Storage;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
@ -73,7 +74,7 @@ public class GameSpaceListScreen extends AbstractBasicScreen {
|
||||
Preferences prefs = Gdx.app.getPreferences("My Preferences");
|
||||
prefs.putString("test", "abc");
|
||||
prefs.flush();
|
||||
final Storage storage = Pixel.files().local();
|
||||
final Storage storage = Pixel.files().localStorage();
|
||||
storage.createDirectory("modes");
|
||||
storage.createDirectory("gameSpaces");
|
||||
System.out.println(storage.debug());
|
||||
@ -205,7 +206,7 @@ public class GameSpaceListScreen extends AbstractBasicScreen {
|
||||
|
||||
BitmapFont font;
|
||||
font = game.getFont();
|
||||
font.getData().setScale(4.0f);
|
||||
font.setScale(4.0f);
|
||||
font.setColor(Color.BLACK);
|
||||
int x = (int) (game.getWidthInPixels() * 0.1875f);
|
||||
int y = (int) (game.getHeightInPixels() * 0.95f);
|
||||
@ -215,7 +216,7 @@ public class GameSpaceListScreen extends AbstractBasicScreen {
|
||||
float margin = 0.05f * game.getWidthInPixels();
|
||||
|
||||
y = (int) (game.getHeightInPixels() * 0.7f);
|
||||
font.getData().setScale(2.0f);
|
||||
font.setScale(2.0f);
|
||||
final float spaceBetweenLargeButtons = game.getHeightInPixels() * 0.06f;
|
||||
for (int i = 0; i < modsForPage.size(); i++) {
|
||||
buttons[i] = new Rectangle(margin, y, game.getWidthInPixels() * 0.9f, margin * 1.5f);
|
||||
@ -264,7 +265,7 @@ public class GameSpaceListScreen extends AbstractBasicScreen {
|
||||
font.draw(batch, name, margin * 1.5f, buttons[i].y + 0.8f * buttons[i].height);
|
||||
}
|
||||
|
||||
font.getData()
|
||||
font
|
||||
.setScale(1.5f);
|
||||
font.setColor(
|
||||
0f, 0f, 1f, 1f);
|
||||
|
@ -21,10 +21,11 @@ package com.openeggbert.core.screen;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.InputAdapter;
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
||||
import com.pixelgamelibrary.api.graphics.Color;
|
||||
|
||||
import com.badlogic.gdx.utils.ScreenUtils;
|
||||
import com.openeggbert.core.main.OpenEggbertGame;
|
||||
import com.pixelgamelibrary.api.graphics.BitmapFont;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
@ -66,7 +67,7 @@ public class MainHubScreen extends AbstractGameScreen {
|
||||
|
||||
BitmapFont font;
|
||||
font = game.getFont();
|
||||
font.getData().setScale(2.0f);
|
||||
font.setScale(2.0f);
|
||||
font.setColor(Color.RED);
|
||||
|
||||
font.draw(batch, "Sorry, demo is not yet implemented", 40, 400);
|
||||
|
@ -19,16 +19,16 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.openeggbert.core.screen;
|
||||
|
||||
import com.badlogic.gdx.Application;
|
||||
import static com.badlogic.gdx.Application.LOG_INFO;
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.files.FileHandle;
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||
import com.openeggbert.core.gamespace.GameFileType;
|
||||
import com.openeggbert.core.main.OpenEggbertGame;
|
||||
import com.openeggbert.core.utils.OpenEggbertUtils;
|
||||
import com.pixelgamelibrary.api.Pixel;
|
||||
import com.pixelgamelibrary.api.Platform;
|
||||
import com.pixelgamelibrary.api.app.LogLevel;
|
||||
import com.pixelgamelibrary.api.graphics.SpriteBatch;
|
||||
import com.pixelgamelibrary.api.graphics.Texture;
|
||||
import com.pixelgamelibrary.api.screen.ScreenAdapter;
|
||||
import com.pixelgamelibrary.api.storage.FileHandle;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@ -74,13 +74,13 @@ public abstract class OpenEggbertScreen extends ScreenAdapter {
|
||||
if(getScreenType().isPresent() && getScreenType().get().isBasic()) {
|
||||
if (!game.existsImageTexture("BASIC")) {
|
||||
FileHandle fileHandle;
|
||||
if (Gdx.app.getType() == Application.ApplicationType.Android || Gdx.app.getType() == Application.ApplicationType.WebGL) {
|
||||
Gdx.app.log("screen","loading from internal");
|
||||
fileHandle = Gdx.files.internal("BASIC/BASIC.PNG");
|
||||
if (Pixel.app().isOneOfPlatforms(Platform.ANDROID, Platform.WEB)) {
|
||||
Pixel.app().log("screen","loading from internal");
|
||||
fileHandle = Pixel.files().assets("BASIC/BASIC.PNG");
|
||||
} else {
|
||||
|
||||
Gdx.app.log("screen","loading from classpath");
|
||||
fileHandle = Gdx.files.classpath("BASIC/BASIC.PNG");
|
||||
Pixel.app().log("screen","loading from classpath");
|
||||
fileHandle = Pixel.files().assets("BASIC/BASIC.PNG");
|
||||
}
|
||||
game.loadImageTexture(fileHandle);
|
||||
}
|
||||
@ -91,27 +91,27 @@ public abstract class OpenEggbertScreen extends ScreenAdapter {
|
||||
if (!game.existsImageTexture(possibleFileName)) {
|
||||
String name = game.getGameSpace().getImage08Directory() + "/" + possibleFileName;
|
||||
|
||||
Gdx.app.setLogLevel(LOG_INFO);
|
||||
Gdx.app.log("screen","name=" + name);
|
||||
Pixel.app().setLogLevel(LogLevel.INFO);
|
||||
Pixel.app().log("screen","name=" + name);
|
||||
FileHandle fileHandle = null;
|
||||
if (game.getGameSpace().isEmbeddedAssets()) {
|
||||
|
||||
if (Gdx.app.getType() == Application.ApplicationType.Android || Gdx.app.getType() == Application.ApplicationType.WebGL) {
|
||||
Gdx.app.log("screen","loading from internal");
|
||||
fileHandle = Gdx.files.internal(name);
|
||||
if (Pixel.app().isOneOfPlatforms(Platform.ANDROID, Platform.WEB)) {
|
||||
Pixel.app().log("screen","loading from internal");
|
||||
fileHandle = Pixel.files().assets(name);
|
||||
} else {
|
||||
|
||||
Gdx.app.log("screen","loading from classpath");
|
||||
fileHandle = Gdx.files.classpath(name);
|
||||
Pixel.app().log("screen","loading from classpath");
|
||||
fileHandle = Pixel.files().assets(name);
|
||||
|
||||
}
|
||||
} else {
|
||||
Gdx.app.log("screen","loading from absolute");
|
||||
Pixel.app().log("screen","loading from absolute");
|
||||
|
||||
fileHandle = Gdx.files.absolute(name);
|
||||
fileHandle = Pixel.files().absolute(name);
|
||||
}
|
||||
|
||||
Gdx.app.log("screen", "fileHandleUpperCase.exists()=" + fileHandle.exists());
|
||||
Pixel.app().log("screen", "fileHandleUpperCase.exists()=" + fileHandle.exists());
|
||||
|
||||
if (fileHandle.exists()) {
|
||||
game.loadImageTexture(fileHandle);
|
||||
|
@ -21,10 +21,11 @@ package com.openeggbert.core.screen;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.InputAdapter;
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
||||
import com.pixelgamelibrary.api.graphics.Color;
|
||||
|
||||
import com.badlogic.gdx.utils.ScreenUtils;
|
||||
import com.openeggbert.core.main.OpenEggbertGame;
|
||||
import com.pixelgamelibrary.api.graphics.BitmapFont;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
@ -66,7 +67,7 @@ public class SubHubScreen extends AbstractGameScreen {
|
||||
|
||||
BitmapFont font;
|
||||
font = game.getFont();
|
||||
font.getData().setScale(2.0f);
|
||||
font.setScale(2.0f);
|
||||
font.setColor(Color.RED);
|
||||
|
||||
font.draw(batch, "Sorry, demo is not yet implemented", 40, 400);
|
||||
|
@ -19,13 +19,14 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.openeggbert.core.screen;
|
||||
|
||||
import com.badlogic.gdx.Application;
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.Input;
|
||||
import com.badlogic.gdx.InputAdapter;
|
||||
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
||||
|
||||
import com.badlogic.gdx.utils.ScreenUtils;
|
||||
import com.openeggbert.core.main.OpenEggbertGame;
|
||||
import com.pixelgamelibrary.api.Pixel;
|
||||
import com.pixelgamelibrary.api.graphics.BitmapFont;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
@ -56,7 +57,7 @@ public class TestScreen extends OpenEggbertScreen {
|
||||
ScreenUtils.clear(0.15f, 0.15f, 0.2f, 1f);
|
||||
game.getBatch().begin();
|
||||
Function<String, String> removeCurrentDir = i -> i == null ? null : i.replace(game.getAbsolutePathOfRootDirectory()+ "/", "");
|
||||
if (Gdx.app.getType() == Application.ApplicationType.Desktop && game.getGameSpace() != null) {
|
||||
if (Pixel.app().getPlatform().isDesktop() && game.getGameSpace() != null) {
|
||||
BitmapFont font;
|
||||
font = game.getFont();
|
||||
int x = 140;
|
||||
|
Reference in New Issue
Block a user