Process Event Sheet from Javascript

From the Asset Store
- This pack is suitable for shooting games, running games, platform games, and side-scrolling...
  • Sorry if this question has been answered before, but I couldn't find anything after reviewing the docs and forum posts:

    How does one go about calling an Event Sheet from within JavaScript? For example

    	
    async function OnBeforeProjectStart(runtime)
    {
    	runtime.addEventListener("tick", () => Tick(runtime));
    }
    
    function Tick(runtime)
    {
     // Call Tick on Event Sheet "my_cool_event_sheet"
    }
    

    The idea is event sheets could be really cool to prototype something before I invest the time to write up a more complex bit of logic in Javascript. Similar to the Unreal Engine where I can invoke a Blueprint from C++.

  • I don't think there's any reason to call an entire event sheet. Instead use runtime.callFunction() to call a function block in an event sheet.

  • Sorry I didn't really describe my use case very well and maybe some of this is just confusion on my part. Let me take another swing at this:

    I create a new JavaScript project because I have a back end server using WebSockets that needs to process incoming/outgoing network events, stream down server generated assets, etc.

    However when I create a new event sheet in my project it doesn't seem to be picking up things like keyboard input or basic tick handlers. Additionally I would like to process some things before the sheets tick event are processed and then other actions/operations after all the sheets have been "ticked".

    Is this possible and if so is there any examples of such a use case implemented I can review?

    Thank you so much for your help!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Make sure a layout in the project has the event sheet associated. If you have no event sheets and you add one, it won't be associated with anything so those events won't run until to attach it to a layout.

    You can call in to events from JavaScript and from JavaScript to events, so you should be able to set up everything you need using both.

  • I see and yes that was the issue. So follow up question:

    Is it possible to set the event sheet for a Layout via JavaScript? I looked in the APIs and didn't any direct calls for such an action.

    Example:

     // Does not seem to exist
    	runtime.layout.setEventSheet("My_cool_sheet")
    

    For example I might want to swap out event sheets based if a socket is still connected, etc.

    Thanks for all so much your help!

  • I don't think there's any reason to do that. You can just include all the event sheets you might need, and enable or disable groups.

  • I think it is more like if this is even an option. Is there an API to enable such functionality?

    Thanks!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)