How to listen for JavaScript Events

Get help using Construct 2

Post » Tue Apr 04, 2017 7:10 pm

I have a few games that run on my website and they all hook into an sdk. The sdk can open/close modals, and the modal dispatches events. Is there anyway in construct to listen for those events?

In the browser I currently run this code:

Code: Select all
window.dispatchEvent(new CustomEvent('gs.modal.open'));


In construct I would like to listen for this event, is there anyway to do this? In JavaScript I would simply do this:

Code: Select all
window.addEventListener('gs.modal.open', e => { /* Execute my JavaScript here */ })
B
3
Posts: 1
Reputation: 177

Post » Tue Apr 04, 2017 8:10 pm

You can have the javascript code call a C2 function.
See javascript intergration section.
https://www.scirra.com/manual/149/function
B
92
S
32
G
109
Posts: 5,290
Reputation: 70,991


Return to How do I....?

Who is online

Users browsing this forum: dop2000, KTML5 and 37 guests