Pick Object by IID / manipulate previous object instance?

0 favourites
  • 5 posts
From the Asset Store
Pick Up Items Sound effects for your game, Take them for a ride right now and you will worry no more.
  • Is there any possible way how I can reference a previous sprite if there are a multiple number of them?

    Like picking the sprite by it's IID: icon(icon.count-1)?

    I make a calendar. At every day in the calendar events can happen. If there is an event at a given day I will spawn an icon/sprite inside that calendar cell.

    Now I want to modify the size and position of the previous icon, if there is already an event at the same day. Instead of centering a single big icon I want to make both icons smaller and have one left and one right.

    Here is a screenshot from the event:

    And here is the result:

    As you can see the first icon is bigger and centered. That's how it should look like if there is only one event on that day. But because there are two events on that day both should be small and on the sides like the smaller, right one.

    But I do not know how I can edit the properties of the previous sprite from within the second subevent.

    I know some Javascript, but with runtime.Objects.RaidIcons(runtime.Objects.RaidIcons.count-1).destroy() I wasnt able to destroy the Icon with the previous Index.

    Any ideas? Thanks in advance! :D

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You can use a family to pick another instance of the same object in one event. Add icon sprite to a family and you can do this:

    Pick Icon
     Pick IconFamily where IconFamily.IID=(Icon.IID-1)
    	Set Icon scale to 1.2
    	Set IconFamily scale to 0.8

    Picking by IID will only work correctly if you created icons in the correct order. It may be easier to use an instance variable, e.g. "Pick IconFamily where IconFamily.Day=(Icon.Day-1)"

  • Oh thank you for the fast response!

    I did not fully understand how I can "Pick" the Icon and the IconFamily.

    But with your hints I found the Pick last created condition and it works perfect. Because it will always have the same instance order.

    But just in case, can you tell me how I can use your solution? :)

  • Many events in Construct pick instances.

    For example, "Icon is visible" event will pick all instances that are visible.

    Or "On clicked icon" will pick one clicked icon instance. Everywhere inside this event "icon" will refer to that one picked instance.

    If you want to pick another instance or instances in the same event, and work with both picked scopes independently, use the trick with a family:

    Pick Icon
     Pick IconFamily 
    	.... do something with icon instances
    	.... do something with IconFamily instances
  • Ahhhh. I see now. Very clever. Thank you that will surely come in handy.

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