for loop and button bug

0 favourites
  • 8 posts
From the Asset Store
SynthWave Loop Pack includes 68 seamless loops, founded on 11 original melodies.
  • I have a for loop that works this way, I want to make it so that when I press the button, it deletes the first 5 objects, but when I press the button, it deletes only 1 object and the others remain.

  • "lvl"&4 is the character string "lvl4". You are doing a size <= type comparison with a character string. While this might work for some character strings it isn't standard practice.

    Since I don't understand this part of your code, I don't feel qualified to answer, but I simply point it out as questionable.

    yours

    winkr7

  • "lvl"&4 is the character string "lvl4". You are doing a size <= type comparison with a character string. While this might work for some character strings it isn't standard practice.

    Since I don't understand this part of your code, I don't feel qualified to answer, but I simply point it out as questionable.

    yours

    winkr7

    actually what I am asking is that when I press a button, the for loop does not work, it works 1 time, I just want it to work until the for ends when I press the button.

  • Is this loop nested under some parent event? You need to explain the task.

    The code you posted will destroy only one SpritesA instance at a time. Even if there are 100 sprite instances on the layout, the loop will repeat 101 times, but every time it will be picking the same single instance - closest to (0,0).

    Then after 0.07s delay it will destroy this one instance 101 times :)

  • Is this loop nested under some parent event? You need to explain the task.

    The code you posted will destroy only one SpritesA instance at a time. Even if there are 100 sprite instances on the layout, the loop will repeat 101 times, but every time it will be picking the same single instance - closest to (0,0).

    Then after 0.07s delay it will destroy this one instance 101 times :)

    all the code is like this, when I want to make the code to work when a button is pressed, it doesn't happen, but it happens whenever I take the code out.

    so it works smoothly as it is, what I want is to delete the top 5 objects when the button is pressed.

  • If you want to delete 5 sprites in the order from nearest to furthest with a small delay between them, try changing the code like this:

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • If you want to delete 5 sprites in the order from nearest to furthest with a small delay between them, try changing the code like this:

    In fact, this is not what I want, it works smoothly in the code I send before message, what I want is to delete these 5 objects in order when I press the button, but when I make it work when I press the button, only 1 object is deleted.

  • That's because you are using the "Wait" action wrong and picking the same one instance! See my screenshot.

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