Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Augmentile
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Auglement
Augmentile
Commits
b6bef85a
Verified
Commit
b6bef85a
authored
4 years ago
by
Nik | Klampfradler
Browse files
Options
Downloads
Patches
Plain Diff
Document game class
parent
080456f0
No related branches found
No related tags found
No related merge requests found
Pipeline
#7397
passed
4 years ago
Stage: test
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/frontend/game.js
+22
-1
22 additions, 1 deletion
src/frontend/game.js
with
22 additions
and
1 deletion
src/frontend/game.js
+
22
−
1
View file @
b6bef85a
...
...
@@ -18,8 +18,15 @@ import SplashScene from './scenes/splash';
import
LoginScene
from
'
./scenes/login
'
;
import
'
./game.css
'
;
/** Main game class serving as frontend. */
class
Game
extends
Phaser
.
Game
{
/**
* Construct a game instance linked to an already initialised backend.
*
* @param {object} backend - Reference to the backend instance
*/
constructor
(
backend
)
{
// Phaser configuration
const
config
=
{
title
:
'
Aug[m]entile
'
,
url
:
'
https://edugit.org/auglement/augmentile
'
,
...
...
@@ -29,7 +36,7 @@ class Game extends Phaser.Game {
height
:
window
.
innerHeight
,
parent
:
'
phaser-container
'
,
dom
:
{
createContainer
:
true
,
createContainer
:
true
,
// Needed for Rex UI
},
scale
:
{
mode
:
Phaser
.
Scale
.
FIT
,
...
...
@@ -38,18 +45,32 @@ class Game extends Phaser.Game {
scene
:
[
SplashScene
,
LoginScene
],
};
// Pass config to parent class (Phaser itself)
super
(
config
);
// Establish dual-link between game and backend
this
.
backend
=
backend
;
this
.
backend
.
game
=
this
;
}
/**
* Called by backend after successful login.
*
* @todo Use events or similar instead
*/
loggedIn
()
{
this
.
scene
.
start
(
'
splash
'
,
{
'
message
'
:
'
Loading game state...
'
,
});
}
/**
* Called by backend on login error.
*
* @param {string} error message from login
*
* @todo Use events or similar instead
*/
loginError
(
error
)
{
this
.
scene
.
start
(
'
login
'
,
{
'
message
'
:
error
,
...
...
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