lively 0.16.0 → 0.16.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/context/game-audio-tutorial.md +18 -8
- data/lib/lively/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +1 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d27407a416fa635821337fdd4e59b5e74f5116e9d30ff3026e9e4828ae7420ad
|
4
|
+
data.tar.gz: 9fc8989d73bb25d310d4094e0c4da39d7b4d05295714571f7335ae0c09c9ea28
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d7d6d282fb8788b8c8eb711c95e18f1a491138dbb91d6a8b26ec663c1b4e9f39b86c267580177838d5ea7e94464d2f6a847341b0beb71274f7aacc9a47be4b5
|
7
|
+
data.tar.gz: 7dd7b5fca6f49acd4fb53889793b53758613da379db8835e44120ce442eca18b55857e2829f72e98b79c57695fc1a03a2c58513f51db781a0301f73214629394
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
@@ -45,10 +45,12 @@ customElements.define('live-game', class GameElement extends ViewElement {
|
|
45
45
|
this.#audio = Audio.start({
|
46
46
|
window,
|
47
47
|
onOutputCreated: (controller, output) => {
|
48
|
-
|
49
|
-
this.
|
48
|
+
// Start background audio:
|
49
|
+
this.#audio.playSound('music');
|
50
50
|
}
|
51
51
|
});
|
52
|
+
|
53
|
+
this.loadSounds();
|
52
54
|
}
|
53
55
|
|
54
56
|
disconnectedCallback() {
|
@@ -60,7 +62,7 @@ customElements.define('live-game', class GameElement extends ViewElement {
|
|
60
62
|
}
|
61
63
|
|
62
64
|
loadSounds() {
|
63
|
-
// We'll add sounds here
|
65
|
+
// We'll add sounds here.
|
64
66
|
}
|
65
67
|
|
66
68
|
get audio() {
|
@@ -69,33 +71,41 @@ customElements.define('live-game', class GameElement extends ViewElement {
|
|
69
71
|
});
|
70
72
|
```
|
71
73
|
|
74
|
+
Note that playing audio can generally only be done in response to a user interaction (like a click or key press) due to browser autoplay policies. The onOutputCreated callback is a good place to start background audio after the user has interacted with the page, while other sound effects can be "best effort" if played outside of user interaction.
|
75
|
+
|
72
76
|
### 2. Adding Synthesized Sound Effects
|
73
77
|
|
74
78
|
The library includes many pre-built synthesized sounds:
|
75
79
|
|
76
80
|
```javascript
|
77
81
|
loadSounds() {
|
78
|
-
// Game action sounds
|
82
|
+
// Game action sounds:
|
79
83
|
this.#audio.addSound('jump', new Library.JumpSound());
|
80
84
|
this.#audio.addSound('coin', new Library.CoinSound());
|
81
85
|
this.#audio.addSound('powerup', new Library.PowerUpSound());
|
82
86
|
this.#audio.addSound('death', new Library.DeathSound());
|
83
87
|
|
84
|
-
// Combat sounds
|
88
|
+
// Combat sounds:
|
85
89
|
this.#audio.addSound('laser', new Library.LaserSound());
|
86
90
|
this.#audio.addSound('explosion', new Library.ExplosionSound());
|
87
91
|
|
88
|
-
// Interface sounds
|
92
|
+
// Interface sounds:
|
89
93
|
this.#audio.addSound('beep', new Library.BeepSound());
|
90
94
|
this.#audio.addSound('blip', new Library.BlipSound());
|
91
95
|
|
92
|
-
// Animal sounds
|
96
|
+
// Animal sounds:
|
93
97
|
this.#audio.addSound('meow', new Library.MeowSound());
|
94
98
|
this.#audio.addSound('bark', new Library.BarkSound());
|
95
99
|
this.#audio.addSound('duck', new Library.DuckSound());
|
96
100
|
this.#audio.addSound('roar', new Library.RoarSound());
|
97
101
|
this.#audio.addSound('howl', new Library.HowlSound());
|
98
102
|
this.#audio.addSound('chirp', new Library.ChirpSound());
|
103
|
+
|
104
|
+
// Background music (looping) with optional loop points:
|
105
|
+
this.#audio.addSound('music', new Library.BackgroundMusicSound('/_static/music.mp3', {
|
106
|
+
loopStart: 32.0 * 60.0 / 80.0,
|
107
|
+
loopEnd: 96.0 * 60.0 / 80.0,
|
108
|
+
}));
|
99
109
|
}
|
100
110
|
```
|
101
111
|
|
@@ -121,7 +131,7 @@ class GameView < Live::View
|
|
121
131
|
|
122
132
|
def player_jump
|
123
133
|
@player.jump
|
124
|
-
play_sound('jump')
|
134
|
+
play_sound('jump') # Play jump sound
|
125
135
|
end
|
126
136
|
|
127
137
|
def collect_coin
|
data/lib/lively/version.rb
CHANGED
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
metadata.gz.sig
CHANGED
Binary file
|