Skip to content

Commit e7af5ba

Browse files
authored
Merge pull request #13 from SpringRoll/documentation/play-options
Play Options documentation
2 parents c52f309 + c548c0a commit e7af5ba

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,35 @@ The Container supports custom interface elements for managing things like toggle
5353
| **musicButton** | Toggles only music mute |
5454
| **pauseButton** | Plays and pause the game |
5555

56+
### Play Options
57+
The `openPath` method of the Container provides a mechanism for providing options directly to the game, called
58+
`playOptions`:
59+
60+
```javascript
61+
var container = new springroll.Container('#game');
62+
container.openPath('game.html', {
63+
playOptions: {
64+
difficulty: 7,
65+
theme: 'blue'
66+
}
67+
});
68+
```
69+
70+
In a SpringRoll Application, the Container Client Plugin [mirrors this data directly onto the object](https://github.com/SpringRoll/SpringRoll/blob/master/src/container-client/ContainerClientPlugin.js#L316).
71+
Once the application finishes its `init` process, this data will be available directly on the application instance:
72+
73+
```javascript
74+
var app = new springroll.Application({
75+
// various options here
76+
});
77+
78+
app.on('init', function() {
79+
springroll.Debug.log('Play Options are', app.playOptions); // { difficulty: 7, theme: 'blue' }
80+
});
81+
```
82+
83+
Any JSON-serializable object can be set as a `playOption`.
84+
5685
##Documentation
5786

5887
[API Documentation](http://springroll.github.io/SpringRollContainer/) has full documentation for the Container.

0 commit comments

Comments
 (0)