Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
ProgArkProject
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
Releases
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
Sixten Müller
ProgArkProject
Commits
c5e3de9d
Commit
c5e3de9d
authored
1 year ago
by
Rebekka Aashaug Stangvik
Browse files
Options
Downloads
Plain Diff
Merge branch '34-make-statemanager-a-singleton-class' into 'main'
added singleton pattern to state manager Closes
#34
See merge request
!25
parents
34bf64c5
68418c3b
No related branches found
No related tags found
1 merge request
!25
added singleton pattern to state manager
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
core/src/com/wordbattle/game/WordBattle.java
+1
-1
1 addition, 1 deletion
core/src/com/wordbattle/game/WordBattle.java
core/src/com/wordbattle/game/states/StateManager.java
+9
-1
9 additions, 1 deletion
core/src/com/wordbattle/game/states/StateManager.java
with
10 additions
and
2 deletions
core/src/com/wordbattle/game/WordBattle.java
+
1
−
1
View file @
c5e3de9d
...
@@ -28,7 +28,7 @@ public class WordBattle extends ApplicationAdapter {
...
@@ -28,7 +28,7 @@ public class WordBattle extends ApplicationAdapter {
public
void
create
()
{
public
void
create
()
{
_FBIC
.
SomeFunction
();
_FBIC
.
SomeFunction
();
batch
=
new
SpriteBatch
();
batch
=
new
SpriteBatch
();
stateManager
=
new
StateManager
();
stateManager
=
StateManager
.
getInstance
();
// Make changes in assets/words.txt, and uncomment the two lines beneath to update database
// Make changes in assets/words.txt, and uncomment the two lines beneath to update database
// CreateWords createWords = new CreateWords(_FBIC);
// CreateWords createWords = new CreateWords(_FBIC);
// createWords.updateDB();
// createWords.updateDB();
...
...
This diff is collapsed.
Click to expand it.
core/src/com/wordbattle/game/states/StateManager.java
+
9
−
1
View file @
c5e3de9d
...
@@ -2,9 +2,11 @@ package com.wordbattle.game.states;
...
@@ -2,9 +2,11 @@ package com.wordbattle.game.states;
import
com.badlogic.gdx.graphics.g2d.SpriteBatch
;
import
com.badlogic.gdx.graphics.g2d.SpriteBatch
;
public
class
StateManager
{
import
java.security.SecureRandom
;
public
class
StateManager
{
private
static
StateManager
instance
;
private
GameState
currentState
;
private
GameState
currentState
;
private
GameState
previousState
;
private
GameState
previousState
;
...
@@ -12,6 +14,12 @@ public class StateManager {
...
@@ -12,6 +14,12 @@ public class StateManager {
}
}
public
static
StateManager
getInstance
()
{
if
(
instance
==
null
){
instance
=
new
StateManager
();
}
return
instance
;
}
public
void
setState
(
GameState
newState
)
{
public
void
setState
(
GameState
newState
)
{
if
(
currentState
!=
null
)
{
if
(
currentState
!=
null
)
{
...
...
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