(see this page for an overview of shared globals)
The event system we are currently working on is a simple way of broadcasting something happened in your game/iframe so that other games/iframes can react to it if they want to.
There are 2 things you can do with events:
I (mut) used in sequential-games.html used a pattern I think Darwin suggested in the chat of calling the events with some sort of namespace, like
alidator.tea
orsalada.bucket
. Hopefully we might keep some nice pattern like this.
Here is a list of currently-in-use events. If you make a new event, add it there!
THERE IS NOW A WAY TO LISTEN TO EVENTS NICELY.
If your current window has events enabled, or if it’s embedded in a page that does. The only code you need to add to listen to events is the following:
// Event listening
// ctrl+f "#listen" to get here on file 'gatherings/sequential-games.html'
// copy the template below to add your own! (you can add anywhere!)
window.top.d.Events.listen('event.name', () => {
// Write the code that should happen in response for the event
})
to see how some events currently work. You can also look at ./games/free-tanooki.js
in the end of the file there are some events specific for that game.
The current way to raise events is to call d.Events.raise("event.name")
from the game (that is embedded in the current page). Therefore the challenge is to make being able to execute javascript code in whatever tool we are using for our games to be able to call the events.
So far, we have instructions for the following:
If you have a bitsy game and want it to be able to have events, add the javascript dialog
hack. borksy is pretty good for this.
With that you now have the power to write any arbitrary javascript in your bitsy dialogues. And so you have access to our work in progress event system! Where you can do either of the following:
(jsNow "window.top.d.Events.raise('event.name')")
(js "window.top.d.Events.raise('event.name')")
– work in progress –
Following whatever is described in this link should work: https://docs.unity3d.com/Manual/webgl-interactingwithbrowserscripting.html