Revision | efe8ac8299dd8bb67b64b27eed2a57a4e31d0c86 (tree) |
---|---|
Zeit | 2022-01-10 06:21:20 |
Autor | sebastian_bugiu |
Commiter | sebastian_bugiu |
Added new font ttfs.
@@ -1,5 +1,5 @@ | ||
1 | 1 | { |
2 | -BitmapFont: { default-font: { file: default.fnt } }, | |
2 | + | |
3 | 3 | Color: { |
4 | 4 | green: { a: 1, b: 0, g: 1, r: 0 }, |
5 | 5 | white: { a: 1, b: 1, g: 1, r: 1 }, |
@@ -12,7 +12,7 @@ | ||
12 | 12 | classpath 'com.android.tools.build:gradle:4.1.3' |
13 | 13 | classpath 'com.mobidevelop.robovm:robovm-gradle-plugin:2.3.12' |
14 | 14 | classpath "com.badlogicgames.gdx:gdx-tools:1.10.0" |
15 | - | |
15 | + classpath "com.badlogicgames.gdx:gdx-freetype:1.10.0" | |
16 | 16 | } |
17 | 17 | } |
18 | 18 |
@@ -49,7 +49,7 @@ | ||
49 | 49 | api "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion" |
50 | 50 | api "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop" |
51 | 51 | api "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-desktop" |
52 | - | |
52 | + api "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop" | |
53 | 53 | } |
54 | 54 | } |
55 | 55 |
@@ -70,6 +70,11 @@ | ||
70 | 70 | natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-arm64-v8a" |
71 | 71 | natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86" |
72 | 72 | natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86_64" |
73 | + api "com.badlogicgames.gdx:gdx-freetype:$gdxVersion" | |
74 | + natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi-v7a" | |
75 | + natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-arm64-v8a" | |
76 | + natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86" | |
77 | + natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86_64" | |
73 | 78 | |
74 | 79 | } |
75 | 80 | } |
@@ -86,7 +91,7 @@ | ||
86 | 91 | api "com.badlogicgames.gdx:gdx-backend-robovm:$gdxVersion" |
87 | 92 | api "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-ios" |
88 | 93 | api "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-ios" |
89 | - | |
94 | + api "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-ios" | |
90 | 95 | } |
91 | 96 | } |
92 | 97 |
@@ -97,7 +102,7 @@ | ||
97 | 102 | dependencies { |
98 | 103 | api "com.badlogicgames.gdx:gdx:$gdxVersion" |
99 | 104 | api "com.badlogicgames.gdx:gdx-box2d:$gdxVersion" |
100 | - | |
105 | + api "com.badlogicgames.gdx:gdx-freetype:$gdxVersion" | |
101 | 106 | } |
102 | 107 | } |
103 | 108 |
@@ -34,7 +34,7 @@ | ||
34 | 34 | |
35 | 35 | Gdx.input.setInputProcessor(stage); |
36 | 36 | |
37 | - Skin skin = new Skin(Gdx.files.internal("uiskin.json")); | |
37 | + Skin skin = SpaceRocket.getGame().getSkin(); | |
38 | 38 | |
39 | 39 | titleLabel = new Label("Options", skin); |
40 | 40 | creditsLabel = new Label("Sound enabled", skin); |
@@ -37,7 +37,7 @@ | ||
37 | 37 | Gdx.input.setInputProcessor(stage); |
38 | 38 | |
39 | 39 | // temporary until we have asset manager in |
40 | - Skin skin = new Skin(Gdx.files.internal("uiskin.json")); | |
40 | + Skin skin = SpaceRocket.getGame().getSkin(); | |
41 | 41 | |
42 | 42 | String helpString = "CONTROLS \n\n For movement use direction keys or the\n" + |
43 | 43 | "arrows on the screen or the accelerometer.\n" + |
@@ -87,7 +87,7 @@ | ||
87 | 87 | //table.setDebug(true); |
88 | 88 | stage.addActor(table); |
89 | 89 | |
90 | - Skin skin = new Skin(Gdx.files.internal("uiskin.json")); | |
90 | + Skin skin = SpaceRocket.getGame().getSkin(); | |
91 | 91 | |
92 | 92 | Label titleLabel = new Label("High Score", skin); |
93 | 93 |
@@ -36,7 +36,7 @@ | ||
36 | 36 | Gdx.input.setInputProcessor(stage); |
37 | 37 | |
38 | 38 | // temporary until we have asset manager in |
39 | - Skin skin = new Skin(Gdx.files.internal("uiskin.json")); | |
39 | + Skin skin = SpaceRocket.getGame().getSkin(); | |
40 | 40 | |
41 | 41 | //create buttons |
42 | 42 | Label title = new Label("Hotshot", skin); |
@@ -42,7 +42,7 @@ | ||
42 | 42 | |
43 | 43 | Gdx.input.setInputProcessor(stage); |
44 | 44 | |
45 | - Skin skin = new Skin(Gdx.files.internal("uiskin.json")); | |
45 | + Skin skin = SpaceRocket.getGame().getSkin(); | |
46 | 46 | |
47 | 47 | titleLabel = new Label("Options", skin); |
48 | 48 | soundLabel = new Label("Sound enabled", skin); |
@@ -97,16 +97,16 @@ | ||
97 | 97 | }); |
98 | 98 | |
99 | 99 | table.add(titleLabel).colspan(2); |
100 | - table.row().pad(10, 10, 10, 10); | |
100 | + table.row().pad(10, 0, 10, 0); | |
101 | 101 | table.add(soundLabel).left(); |
102 | 102 | table.add(soundCheckbox); |
103 | - table.row().pad(10, 10, 10, 10); | |
103 | + table.row().pad(10, 0, 10, 0); | |
104 | 104 | table.add(vibrationLabel).left(); |
105 | 105 | table.add(vibrationCheckbox); |
106 | - table.row().pad(10, 10, 10, 10); | |
106 | + table.row().pad(10, 0, 10, 0); | |
107 | 107 | table.add(shipMovementLabel).left(); |
108 | 108 | table.add(shipMovementSelectBox); |
109 | - table.row().pad(10, 10, 10, 10); | |
109 | + table.row().pad(10, 0, 10, 0); | |
110 | 110 | table.add(backButton).colspan(2).fillX().uniformX(); |
111 | 111 | |
112 | 112 |
@@ -2,12 +2,18 @@ | ||
2 | 2 | |
3 | 3 | import com.badlogic.gdx.Game; |
4 | 4 | import com.badlogic.gdx.Gdx; |
5 | +import com.badlogic.gdx.assets.AssetManager; | |
6 | +import com.badlogic.gdx.assets.loaders.SkinLoader; | |
5 | 7 | import com.badlogic.gdx.files.FileHandle; |
8 | +import com.badlogic.gdx.graphics.Color; | |
6 | 9 | import com.badlogic.gdx.graphics.g2d.BitmapFont; |
7 | 10 | import com.badlogic.gdx.graphics.g2d.SpriteBatch; |
8 | 11 | import com.badlogic.gdx.graphics.g2d.TextureAtlas; |
9 | 12 | import com.badlogic.gdx.graphics.g2d.TextureRegion; |
13 | +import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator; | |
14 | +import com.badlogic.gdx.scenes.scene2d.ui.Skin; | |
10 | 15 | import com.badlogic.gdx.utils.Array; |
16 | +import com.badlogic.gdx.utils.ObjectMap; | |
11 | 17 | import com.badlogic.gdx.utils.ScreenUtils; |
12 | 18 | import com.headwayent.spacerocket.old.BossSprite; |
13 | 19 | import com.headwayent.spacerocket.old.DifficultySelection; |
@@ -40,6 +46,8 @@ | ||
40 | 46 | private MultiplayerJoinGameActivity multiplayerJoinGameActivity; |
41 | 47 | private MultiplayerLobbyActivity multiplayerLobbyActivity; |
42 | 48 | private FinalResultsActivity finalResultsActivity; |
49 | + private Skin skin; | |
50 | + private AssetManager assetManager; | |
43 | 51 | |
44 | 52 | public enum Mode { |
45 | 53 | CLIENT, SERVER |
@@ -73,7 +81,33 @@ | ||
73 | 81 | TextureRegion t = tr.get(i); |
74 | 82 | t.flip(false, true); |
75 | 83 | } |
76 | - font = new BitmapFont(true); | |
84 | + FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal("Republica Minor Regular.ttf")); | |
85 | + FreeTypeFontGenerator.FreeTypeFontParameter parameter = new FreeTypeFontGenerator.FreeTypeFontParameter(); | |
86 | + parameter.size = 13; | |
87 | + parameter.borderWidth = 1; | |
88 | + parameter.color = Color.GREEN; | |
89 | +// parameter.shadowOffsetX = 3; | |
90 | +// parameter.shadowOffsetY = 3; | |
91 | +// parameter.shadowColor = new Color(0, 0.5f, 0, 0.75f); | |
92 | +// parameter.flip = true; | |
93 | + font = generator.generateFont(parameter); // For the menu ttf. | |
94 | +// ObjectMap<String, Object> fontMap = new ObjectMap<>(); | |
95 | +// fontMap.put("default-font", font); | |
96 | +// | |
97 | +// SkinLoader.SkinParameter skinParameter = new SkinLoader.SkinParameter(fontMap); | |
98 | +// assetManager = new AssetManager(); | |
99 | +// assetManager.load("uiskin.json", Skin.class, skinParameter); | |
100 | +// assetManager.finishLoading(); | |
101 | +// skin = assetManager.get("uiskin.json", Skin.class); | |
102 | + skin = new Skin(); | |
103 | + skin.addRegions(new TextureAtlas(Gdx.files.internal("uiskin.atlas"))); | |
104 | +// skin.remove("default-font", BitmapFont.class); | |
105 | + skin.add("default-font", font, BitmapFont.class); | |
106 | + skin.load(Gdx.files.internal("uiskin.json")); | |
107 | +// font = new BitmapFont(true); | |
108 | + parameter.flip = true; | |
109 | + font = generator.generateFont(parameter); // For the in game flipped ttf. | |
110 | + generator.dispose(); | |
77 | 111 | canvas = new ExtendedCanvas(); |
78 | 112 | setScreen(new MainMenuActivity(this)); |
79 | 113 | } |
@@ -317,6 +351,14 @@ | ||
317 | 351 | return canvas; |
318 | 352 | } |
319 | 353 | |
354 | + public Skin getSkin() { | |
355 | + return skin; | |
356 | + } | |
357 | + | |
358 | + public AssetManager getAssetManager() { | |
359 | + return assetManager; | |
360 | + } | |
361 | + | |
320 | 362 | public VersionStats getVersionStats() { |
321 | 363 | return versionStats; |
322 | 364 | } |
@@ -64,7 +64,7 @@ | ||
64 | 64 | Gdx.input.setInputProcessor(stage); |
65 | 65 | |
66 | 66 | // temporary until we have asset manager in |
67 | - Skin skin = new Skin(Gdx.files.internal("uiskin.json")); | |
67 | + Skin skin = SpaceRocket.getGame().getSkin(); | |
68 | 68 | |
69 | 69 | Label title = new Label("Select difficulty", skin); |
70 | 70 | title.setAlignment(Align.center); |