Create a custom Event

0 favourites
  • 7 posts
From the Asset Store
Very simple code without excess options (15 events for server and 11 events for client)
  • If several different things can trigger a single action (e.g. several ways a game can end- run out of life, run out of time, complete it), i would like to create my own event called say "gameEnd". Then If the time runs out, I just have to "raise" the gameEnd event etc.

    This way I only have to write the gameEnd event and actions once, and can raise it in lots of places.

    I have searched on "custom event" but cant find anything. There is nothing under events in the manual. Any ideas?

    If this is missing, its a pretty big omision. I guess the work around would be to duplicate a lot of code, or possibly to try and construct a big complex condition statement to try and catch all the places where they action is required.

    Or perhaps you can simulate this by creating a hidden sprite, then set it to say invisible in several places to simulate "raising" the event, then have your "handler" condition on the visibility attribute?

  • You can put that code into separate event sheet and then use "include event sheets" to insert it do different event sheets, groups, sub-events...

  • I guess another way is to create a polling effect, e.g. set a global variable called "gameEnd" to 1 to "raise" the event, then every tick compare the variable to 1, and if it reaches 1, do some action and set it to 0. The problem is that events could be lost because Im guessing there is no mutual exclusion on the variable.

  • Hi Shinkan, I dont see how having mutliple event sheets can simulate raising a custom event in several places a single game? My understanding from the manual: scirra.com/manual/121/event-sheets

    is that they are just like include files if you want to include your events in multyple games (I only have one game).

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • It sounds to me like what you want to do can be done with the function plugin. Link.

  • If I correctly understand your first post

    inc_ev.capx

    you can click on button or the sprite and every time when current "action" associated whit that object finish (click on button, sprite fade finish) it will trigger the same events for "game over".

    not a best example, but you'll get the point.

  • Wow, thats a very useful feature - the manual should include this in the sheets page!

    I had no idea you could create a sheet, with actions with no event conditions, then call it as an action!

    +100 credits for Shinkan.

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