On Created event not firing.

0 favourites
  • 9 posts
From the Asset Store
2D fighting template based in the game that defined the fighting games genre.
  • Is the On created event only fired when you create an object through an action? Doesn't seem to be working on objects that are already placed in the layout.

    Is there a workaround for this?

    Thanks

  • Use 'on start of layout'?

  • Use 'on start of layout'?

    Objects can be created during gameplay as well as present at the beginning. So I would rather not duplicate actions.

    Surely it makes sense for an objects Created event to be called if it 'created' when the layout starts?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Objects can be created during gameplay as well as present at the beginning. So I would rather not duplicate actions.

    I guess the objects are created before the events run, so you could either create the objects 'On start of layout' in the event sheet instead of placing them in the editor, or you could just use an OR-event:

    'On start of layout' -OR- 'On created'

  • or try:

    on start of layout
    for every Sprite
    add local variable old_x and set it to Sprite.X
    add local variable old_y and set it to Sprite.Y
    destroy Sprite
    create Sprite at x = old_x, y = old_y
  • Thanks guys, I will have a look at those solutions.

    But am I the only one that thinks the object created event should be called for each object that is already in the editor?

  • But you still need to place at least one instance of the object on the layout (outside, whatever place you want) to create it on the runtime. If you don't place the object, you'll not be able to reproduce any behavior for it (and I think your game will also bug).

  • game will do an alert if it can't find at least one instance in layout, so yes, you must have at least one instance of every sprite created NOT by events. I think a quite good solution would be to create a layout with all game sprites, and never go to that layout if you cannot bare having instances outside standard layouts and destroying them on start :)

    as for onCreated - well create object event triggers on created - that's obvious. already created objects are not created during the game, they are there from the beginning - that's why the oncreated doesnt trigger I think.

    hope that helps

  • game will do an alert if it can't find at least one instance in layout, so yes, you must have at least one instance of every sprite created NOT by events. I think a quite good solution would be to create a layout with all game sprites, and never go to that layout if you cannot bare having instances outside standard layouts and destroying them on start :)

    as for onCreated - well create object event triggers on created - that's obvious. already created objects are not created during the game, they are there from the beginning - that's why the oncreated doesnt trigger I think.

    hope that helps

    Yes, I use the same technique placing all objects in an unused layout.

    As for onCreated; technically the instance of the object must be created when that layout loads the objects you placed in the designer.

    Anyway, I've just joined the onCreated and layoutStart events with an 'or' as that seemed like the most elegant solution.

    Thanks again.

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