Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
TDT4240 Tank Wars
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Snorre Skjellestad Kristiansen
TDT4240 Tank Wars
Commits
ff419781
Commit
ff419781
authored
1 year ago
by
Magnus Segtnan Skjølberg
Browse files
Options
Downloads
Patches
Plain Diff
(
#18
): use ResourceManager for loading gameplay skin
parent
8432b1c1
No related branches found
Branches containing commit
No related tags found
3 merge requests
!51
Resolve "Adjust cannon angle from touch input"
,
!35
Draft: Resolve "Adjust cannon angle from touch input"
,
!32
Combine hud with gameplay
Pipeline
#214171
failed
1 year ago
Stage: backend test
Stage: frontend test
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
frontend/core/src/com/game/tankwars/ResourceManager.java
+17
-7
17 additions, 7 deletions
frontend/core/src/com/game/tankwars/ResourceManager.java
frontend/core/src/com/game/tankwars/view/GameHud.java
+3
-2
3 additions, 2 deletions
frontend/core/src/com/game/tankwars/view/GameHud.java
with
20 additions
and
9 deletions
frontend/core/src/com/game/tankwars/ResourceManager.java
+
17
−
7
View file @
ff419781
...
...
@@ -2,15 +2,8 @@ package com.game.tankwars;
import
com.badlogic.gdx.assets.AssetDescriptor
;
import
com.badlogic.gdx.assets.AssetManager
;
import
com.badlogic.gdx.assets.loaders.FileHandleResolver
;
import
com.badlogic.gdx.assets.loaders.resolvers.InternalFileHandleResolver
;
import
com.badlogic.gdx.graphics.g2d.BitmapFont
;
import
com.badlogic.gdx.graphics.g2d.TextureAtlas
;
import
com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator
;
import
com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGeneratorLoader
;
import
com.badlogic.gdx.graphics.g2d.freetype.FreetypeFontLoader
;
import
com.badlogic.gdx.scenes.scene2d.ui.Skin
;
import
com.badlogic.gdx.scenes.scene2d.utils.Drawable
;
import
com.badlogic.gdx.utils.GdxRuntimeException
;
import
com.github.acanthite.gdx.graphics.g2d.FreeTypeSkinLoader
;
...
...
@@ -29,6 +22,8 @@ public class ResourceManager {
new
AssetDescriptor
<>(
"menu-textures.atlas"
,
TextureAtlas
.
class
);
private
final
AssetDescriptor
<
Skin
>
MENU_SKIN
=
new
AssetDescriptor
<>(
"menu-textures.json"
,
Skin
.
class
);
private
final
AssetDescriptor
<
Skin
>
GAMEPLAY_SKIN
=
new
AssetDescriptor
<>(
"gameplay-skin.json"
,
Skin
.
class
);
public
ResourceManager
()
{
manager
=
new
AssetManager
();
...
...
@@ -66,6 +61,21 @@ public class ResourceManager {
return
null
;
}
/**
* Loads the Skin for the gameplay,
* @return loaded Skin object with JSON file, null on loading error
*/
public
Skin
loadAndGetGameplayHudAssets
()
{
if
(!
manager
.
isLoaded
(
GAMEPLAY_SKIN
))
manager
.
load
(
GAMEPLAY_SKIN
);
try
{
manager
.
finishLoading
();
return
manager
.
get
(
GAMEPLAY_SKIN
);
}
catch
(
GdxRuntimeException
error
)
{
System
.
out
.
println
(
error
.
getMessage
());
}
return
null
;
}
/**
* Block until all currently loaded assets are finished loading
*/
...
...
This diff is collapsed.
Click to expand it.
frontend/core/src/com/game/tankwars/view/GameHud.java
+
3
−
2
View file @
ff419781
...
...
@@ -13,6 +13,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.Slider;
import
com.badlogic.gdx.scenes.scene2d.ui.Table
;
import
com.badlogic.gdx.scenes.scene2d.ui.TextButton
;
import
com.badlogic.gdx.utils.viewport.Viewport
;
import
com.game.tankwars.ResourceManager
;
import
com.ray3k.stripe.FreeTypeSkin
;
public
class
GameHud
{
...
...
@@ -49,7 +50,7 @@ public class GameHud {
stage
.
addActor
(
table
);
skin
=
new
FreeTypeSkin
(
Gdx
.
files
.
internal
(
"gameplay-skin.json"
)
);
skin
=
ResourceManager
.
getInstance
().
loadAndGetGameplayHudAssets
(
);
healthProgressBarPlayer
=
new
ProgressBar
(
0
,
100
,
1
,
false
,
skin
);
healthProgressBarPlayer
.
setValue
(
100
);
...
...
@@ -69,7 +70,7 @@ public class GameHud {
fireButton
=
new
TextButton
(
"Fire!"
,
skin
);
table
.
add
(
fireButton
).
expand
().
bottom
().
left
().
padLeft
(
10
).
padBottom
(
10
);
powerLabel
=
new
Label
(
"Power"
,
skin
.
get
(
"
roboto-black
-white"
,
Label
.
LabelStyle
.
class
));
powerLabel
=
new
Label
(
"Power"
,
skin
.
get
(
"
large
-white"
,
Label
.
LabelStyle
.
class
));
powerSlider
=
new
Slider
(
0
,
100
,
1
,
false
,
skin
);
powerContainer
=
new
HorizontalGroup
().
space
(
10
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment