Random defined colored backgrounds?

justinodunnjustinodunn Member, PRO Posts: 226

How do I make it so the color of the background would change randomly amongst a list of colors? (red, purple, blue, green, yellow)

Comments

  • ArmellineArmelline Member, PRO Posts: 5,415

    Perhaps try something like this. If you unlock the actor you can hide it away and directly control the scene colour, but the end result is the same.

    You can optimise it a bit but I've gone for easiest for you to follow rather than most efficient possible method.

  • justinodunnjustinodunn Member, PRO Posts: 226

    Thanks that game me some ideas, but how can I make it so the random won't repeat the same values? So that I won't have to same overlapping colored backgrounds

  • ArmellineArmelline Member, PRO Posts: 5,415

  • justinodunnjustinodunn Member, PRO Posts: 226

    Cheers :)

  • ArmellineArmelline Member, PRO Posts: 5,415

    To be honest the linked video is a bit overkill if you just want to avoid the same colour twice in a row, but is great if you want to cycle through all colours in a random order before starting again.

    If you just want to avoid 2 of the same colour in a row, throw in a "self.Last" attribute and update it to the current colour each time. When the next random colour is generated, compare it to self.Last and if it's the same, generate again.

  • justinodunnjustinodunn Member, PRO Posts: 226

    I agree haha but sorry I'm not sure how that self last attribute works :s

Sign In or Register to comment.