Skip to content

Commit b6c99a4

Browse files
Merge pull request #157 from SpringRoll/story/190-191-30-update-node
Update Node and Dependencies for CreateJS Seed Template
2 parents f02402f + 94b7bcf commit b6c99a4

File tree

8 files changed

+1638
-869
lines changed

8 files changed

+1638
-869
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
node_modules
22
dist
3-
deploy
3+
deploy
4+
.DS_Store

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v22.17.0
1+
v24.12.0

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [2.3.0] - Unreleased
9+
10+
- Updated Node to 24.12.0
11+
- Included Captions example w/ CSS Styling
12+
- Updated dependencies
13+
- Updated gitignore to not include .DS_Store files
14+
815
## [2.2.0] - 2025-06-27
916

1017
### Changed

package-lock.json

Lines changed: 1541 additions & 864 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "springroll-seed",
3-
"version": "2.0.1",
3+
"version": "2.3.0",
44
"description": "",
55
"main": "index.js",
66
"scripts": {
@@ -26,12 +26,12 @@
2626
"source-map-loader": "^1.0.0",
2727
"style-loader": "^3.3.1",
2828
"terser-webpack-plugin": "^5.3.10",
29-
"webpack": "^5.75.0",
29+
"webpack": "^5.105.0",
3030
"webpack-cli": "^6.0.1",
3131
"webpack-dev-server": "^5.2.2"
3232
},
3333
"dependencies": {
3434
"createjs": "^1.0.1",
35-
"springroll": "^2.8.0"
35+
"springroll": "^2.9.0"
3636
}
3737
}

src/game.js

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@ import { Property, SafeScaleManager, Application } from 'springroll';
33
import { GAMEPLAY } from './constants';
44
import createjs from 'createjs';
55

6+
let selectedLanguage;
7+
8+
const LANGUAGES = {
9+
ENGLISH: "en",
10+
SPANISH: "es",
11+
};
12+
613
export class Game
714
{
815
constructor(width, height)
@@ -50,6 +57,23 @@ export class Game
5057
{
5158
this.isPaused = value;
5259
});
60+
61+
/*
62+
PlayOptions allows developers to pass values from the container environment to the SpringRoll environment. These values can contain any key value pairs the developer requires. This is typically how language selection is passed from the container to the game.
63+
*/
64+
this.app.state.playOptions.subscribe(playOptions =>
65+
{
66+
console.log('New playOptions value set to', playOptions);
67+
68+
this.getLanguage();
69+
});
70+
71+
/*Using a default playOptions value for this demo. In a real container environment, the container would set playOptions and pass it into the game automatically. This is just for demonstration purposes to show how playOptions can be used to pass values from the container to the game.
72+
*/
73+
this.app.state.playOptions.value = {
74+
language: LANGUAGES.ENGLISH
75+
};
76+
5377
this.app.state.captionsMuted.subscribe(result =>
5478
{
5579
console.log('captionsMuted: ', result);
@@ -106,6 +130,39 @@ export class Game
106130
}
107131
}
108132

133+
getLanguage() {
134+
if (selectedLanguage) {
135+
return selectedLanguage;
136+
}
137+
138+
// Check for language param in query string first, this allows us to override the language for testing purposes without having to change the app state or reload the page with new play options. Example: ?language=es
139+
const urlParams = new URLSearchParams(window.location.search);
140+
141+
const queryLanguage = urlParams.get("language");
142+
143+
if (queryLanguage) {
144+
selectedLanguage = queryLanguage.toLowerCase();
145+
console.log(`Language set to ${selectedLanguage} from query string override!`);
146+
return selectedLanguage;
147+
}
148+
149+
const playOptions = this.app.state.playOptions;
150+
const playOptionsLanguage = playOptions.value?.language;
151+
152+
const availableLanguages = [LANGUAGES.ENGLISH, LANGUAGES.SPANISH];
153+
154+
let language;
155+
156+
if (playOptionsLanguage && playOptionsLanguage.includes(LANGUAGES.SPANISH) && availableLanguages.includes(LANGUAGES.SPANISH)) {
157+
language = LANGUAGES.SPANISH;
158+
} else {
159+
language = LANGUAGES.ENGLISH;
160+
}
161+
selectedLanguage = language;
162+
console.log(`Language set to ${selectedLanguage} from playOptions`);
163+
return selectedLanguage;
164+
}
165+
109166
update(tick)
110167
{
111168
this.stage.update();

src/styles.css

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,28 @@ body {
2525
left: 50%;
2626
-webkit-transform: translate(-50%, -50%);
2727
transform: translate(-50%, -50%);
28+
}
29+
30+
#captions {
31+
position: absolute;
32+
top: 0;
33+
left: 0;
34+
right: 0;
35+
z-index: 2;
36+
pointer-events: none;
37+
-webkit-touch-callout: none;
38+
user-select: none;
39+
cursor: default;
40+
background: rgba(0,0,0,0.4);
41+
padding: 1rem;
42+
}
43+
#captions p {
44+
font-family: Arial, Helvetica, sans-serif;
45+
text-align: center;
46+
font-size: 2rem;
47+
color: white;
48+
line-height: 1.5em;
49+
text-overflow: ellipsis;
50+
width: 40ch;
51+
margin: 0 auto;
2852
}

templates/Springroll.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
<body>
1616
<div id="frame">
1717
<canvas id="stage" width="<%= width %>" height="<%= height %>"></canvas>
18+
<div id="captions">
19+
<p>I like it garlic, rye, and brown. Banana, honey bun. Brioche, focaccia. Naan, bagel, baguette, and</p>
20+
</div>
1821
</div>
1922
</body>
2023

0 commit comments

Comments
 (0)