Limit number of objects

0 favourites
  • 8 posts
From the Asset Store
Jump on numbers in the proper order and reach the sun!
  • Hello everyone,

    I'm new to Construct2, and I'm trying to create the following behavior:

    • Create a new object each 0.5 seconds
    • If I've reached 10 objects on screen, remove the first one.

    what I have:

    • System.Every 0.5:               Create object Obj

          System.Obj.Count >= 10

          System.Pick-nth-instance Obj(0)     Obj.Destroy

    I hope I wrote it in an understandable way.

    What I'm trying to do is get the first Obj instance and simply destroy it.

    Thanks!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I don't get it, is it not working?

    2 increments the UID every time an instance of any object is spawned. C2 increments IID every time an instance of a specific object is spawned.

    Pick the object with the lowest IID and destroy it?

  • Lowest IID is always 0.

  • Hello everyone,

    I'm new to Construct2, and I'm trying to create the following behavior:

    - Create a new object each 0.5 seconds

    - If I've reached 10 objects on screen, remove the first one.

    what I have:

    - System.Every 0.5:               Create object Obj

          System.Obj.Count >= 10

          System.Pick-nth-instance Obj(0)     Obj.Destroy

    I hope I wrote it in an understandable way.

    What I'm trying to do is get the first Obj instance and simply destroy it.

    Thanks!

    Also, it may help you: scirra.com/tutorials/361/understanding-uid-iid-health-of-enemies-and-rocket-smoke-trail

  • Thanks guys!

    What I ended up doing is:

    Event: Obj.Count >= 10

    -Sub Event: Pick All Obj

    --Sub Event: Pick nth 0

    Because this is done in the same timing event used to create the objects, if I did the "pick nth(0)" directly it returned the Object I just created. Does that make sense?

    Is what I did OK, or did I over complicate it?

  • Could some one tell me what nth stands for?

  • http://www.thefreedictionary.com/nth

    th [?n?]

    adj

    1. (Mathematics) Maths of or representing an unspecified ordinal number, usually the greatest in a series of values the nth power

    2. Informal being the last, most recent, or most extreme of a long series for the nth time, eat your lunch!

    to the nth degree Informal to the utmost extreme; as much as possible

    I mean it's like to say, the last "number", the higher, the most recent.

  • the "N" in "nth" is a number variable.

    to say "nth element" is to say "any element that's in the index N".

    N also means the number of items in a set. So if I have 10 instances of Object, N=10.

    like TELLES0808 reply, it could mean the last item (since N literally is the number of items), but it could also mean "any number between 0 and N" (like in our case).

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