Object created event

0 favourites
  • 6 posts
From the Asset Store
14 amazing sound files of game events like Level Ups, Level Completes, object spawn, object taking etc.
  • I was wondering if there was an event for when objects are created during run time, like when I spawn a monster for example, if not could one be created or is there a specific way I'm supposed to get this info.

    What I'm trying to do is but a health bar and unit info (name/lvl/etc) above the units sprite, so I need a way to get dynamically created content and create/attach specific objects to them.

  • when you create something it's automatically picked, so just do those actions immediately after it's created

    if this won't work for some reason

    make a function called CreateObject with the function object

    and make the function both create the object, and do whatever it needs to do to them

  • Unfortunately there isn't a function object yet in C2 Lucid.

    Nevertheless the first part of your answer is correct, creating an object gives it focus.

    So CrAzD, when creating your "monster", you can modify its instance variables. Those will act as the unit info. Create a variable name, level, etc...

    You can then access those as monster.name, monster.health, etc...

    Your level bar will be another sprite I guess. Then after having created your monster sprite, you'll create your bar sprite.

    Ashley said that C2 tries to pair objects by default. So the bar Sprite will depend of the monster sprite. (unless I'm still missing the point on this feature)

    Creating the monster and the bar are actions done during the same event (whatever the event is: startup of layout, mouse click, ...)

    Once you use the action system.create (object) said object has the focus, and you can set it as you like.

  • There's no function object in C2 yet, lucid :) The other way you said works, though. Any actions following a create or spawn action apply to the object that was created or spawned only. So there's no need for a "on created" event, really.

    (Edit: ninja'd!)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • oh. oops <img src="smileys/smiley9.gif" border="0" align="middle" />

    I just clicked through the new posts thing, didn't bother to double check the forum

  • Ahh that makes sense and makes things a lot easier. I'll get to work and see how it works out, thanks for the info(s) lucid, Kyatric and Ashley xD!

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