Problem with "for each" for sprites under a condition

0 favourites
  • 3 posts
From the Asset Store
A set of 10 pixel art animated magic effects with icons. 2 Fire, 2 Earth, 2 Wind, 2 Water, Portal, Explosion.
  • Hi.

    I have a problem with understanding "for each" loop. Generally I though I have an idea how it works, but under specific condition it doesn't:

    My code:

    - Mouse | Cursor is over [SPRITE-AAA]
    -- System | varibale1 > variable2
    --- For each | [SPITE-BBB] : Set opacity to 100
    -- System | varibale1 < variable2
    --- For each | [SPITE-BBB] : Set opacity to 0
    

    Please note: SPRITE-AAA and SPRITE-BBB is in the same family (I don't think it matters though).

    When mouse is over SPRITE-AAA, test varibable1 and variable2 and then do the "for each" loop for each of SPRITE-BBB sprites on the layout.

    What am I doing wrong?

    Thanks for any help in advanced!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You don't actually need For Each loop in this event, because you are setting the same opacity to all instances, but there is nothing wrong with using For Each here.

    Your code is correct, it should be working.

    .

    If you are interested, there is a much shorter way to do the same:

    Mouse | Cursor is over [SPRITE-AAA]
     --> [SPITE-BBB] Set opacity to ((varibale1 > variable2)*100)
    
  • Yes! It works they way you sugested :-)

    Thank you.

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