How to pass callback to custom event listener?
Thanks for opening this forum!
The JavaScript SDK documentation gives 'callback' as the second param of addCustomEventListener(). But how do I pass it a callback? raiseEvent() sends a JSON object, not a function (and that's what happens in the chat and realtime demo apps). Or can I use the JSON object to pass the callback (I'm not too familiar with JSON) (yet!).
The JavaScript SDK documentation gives 'callback' as the second param of addCustomEventListener(). But how do I pass it a callback? raiseEvent() sends a JSON object, not a function (and that's what happens in the chat and realtime demo apps). Or can I use the JSON object to pass the callback (I'm not too familiar with JSON) (yet!).
0
Comments
... or inject the function body directly, e.g. ...
[EDITED]
I see now that I misunderstood the interaction between addCustomEventListener() and raiseEvent(). I've got a clearer understanding now, and will attack Construct 2 plugin development from a different angle.
[/EDITED]
If its only a single object per player, you can use the peer of the sender itself to identify it, if its more than 1 object per player you better get a room wide UID system in place to identify them.
Thats the same it would be on any platform if you send through the informations through a single 'for all entities in game' pipeline.
Thanks for your reply, dreamora. On the receiving side, the addCustomEventListener() callback gets the the id of the player that's moving as this.myActor.photonId, so that's not a problem.
[/EDITED]
Not that I intend to use Construct2, but I might come back to ask you about your experience for usage with Game Maker HTML5
Please feel free to pick my brains (such as they are) for input with your GM HTML5 project.