How do I Affect All Sprites Uniformly?

  • I've tried to find information in tutorials, expressions, and general troubleshooting, but I'm coming up blank... hoping someone might have done this before, or something like it.

    I've got a level where I'm trying to set up random tile generation. The goal is to have different tile 'sets'. To do this, I've got one sprite with three animations: Jungle, Snow, and Desert. I will attach an image.

    I am able to successfully reach random tiles with the array setup. However, as you can see, it affects each tile separately. Of course I want this for assigning a random number, but NOT for assigning which of the animations to use. I want all the tiles choosing a random frame from the same, random animation.

    As you can see, I've tried 'pick all' for my tiles, but it doesn't affect all the tiles uniformly. It seems to work exactly like the 'for each' function and just has each tile choose an animation separately.

    Is there something I can call to select all these tiles and give them ALL the same random animation BEFORE their numbers are assigned? Thereby making it so random levels generate within ONE tileset, instead of all of them?

    Thank you!

  • I would create a global text variable called Biome and set it in event 4 after you initialise the array.

    then in event 5, set the new Tile_All animation to Biome, and set the frame to int(random(0,4)) and set the array value there as well.

    I am not sure what will happen when you set the frame to a decimal value... but that is probably part of your problem.

    do you have any other code that sets the animation? because I would think what you have there should work - other than not taking the int() of the random number.

  • Hope this helps!

  • Thank you so much Hayeck904, I will try your recommendation!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thank you AllanR for your help, I will try this as well!

  • Hayeck904 your example worked! Thank you so, so much!! I learned some great stuff today. :-)

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