Why I can't pick an object?

0 favourites
  • 7 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • Hi, guys

    I use for loop to create multiple objects and set instance variable that called "ID", I want to pick two consecutive objects, so I use "pick by comparison" to pick them. But I can not pick them.

    Something was wrong?

    Here is my capx https://drive.google.com/uc?export=download&id=0B8g2b8f9ktNBLTd1T2xWam9QX1U

  • pls, help me?

  • The problem with your setup is the second pick condition.

    The first pick condition

    Pick Sprite where Sprite.ID = loopindex("a2")[/code:1rx0w2jq] works fine and selects the corresponding Sprite.
    
    The thing is that the second pick condition [code:1rx0w2jq]Pick SpriteFM (family) where SpriteFM.ID = loopindex("a2")+1[/code:1rx0w2jq] from the previously picked objects picks.
    This means that the first pick reduces the picked objects to one Sprite that has the right ID.
    The second pick condition picks the Sprite that has a different ID.
    Since there is no Sprite which has two different IDs at the same time, there isn't any Sprite picked and that's why the text doesn't change.
    
    Now to fix this, you could either just disable the second pick condition
    or
    you could add a second text object, then move the second pick condition to be checked after the first one (as sub-event to the loop) but not as a sub-event of the first pick. You would then change the second text to the second Sprite.ID.
    
    Hope I could help.
  • The problem with your setup is the second pick condition.

    The first pick condition

    Pick Sprite where Sprite.ID = loopindex("a2")[/code:2eygwdiz] works fine and selects the corresponding Sprite.
    
    The thing is that the second pick condition [code:2eygwdiz]Pick SpriteFM (family) where SpriteFM.ID = loopindex("a2")+1[/code:2eygwdiz] from the previously picked objects picks.
    This means that the first pick reduces the picked objects to one Sprite that has the right ID.
    The second pick condition picks the Sprite that has a different ID.
    Since there is no Sprite which has two different IDs at the same time, there isn't any Sprite picked and that's why the text doesn't change.
    
    Now to fix this, you could either just disable the second pick condition
    or
    you could add a second text object, then move the second pick condition to be checked after the first one (as sub-event to the loop) but not as a sub-event of the first pick. You would then change the second text to the second Sprite.ID.
    
    Hope I could help.
    

    Thank you for your reply. I think all the Sprite are created in the first for loop(10 Sprite with instance variables ID: 1 to 10, I see them in the debug mode). So, I think I can pick them in the second for loop. But nothing happened.

    What is wrong with my thinking?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • C2 doesn't let you pick newly created objects until the next top level event. Add a second On start of layout, and move your a2 loop there. It then works.

  • C2 doesn't let you pick newly created objects until the next top level event. Add a second On start of layout, and move your a2 loop there. It then works.

    Thank you for your reply, I try to call "a2" loop by a function, nothing happened. So, I want to know what is "the next top level event"

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