How do I set a random number to an instance

0 favourites
  • 6 posts
From the Asset Store
10 Beautiful Pokemon-like Building Pixel Art Sprite Sets
  • What I'm trying to do here is more than the title suggests. I want to, at the start of the layout, give 16 instances of an object different integers ranging between 0 and 15 so I can change their colour accordingly (This means every instance of the object will have a different colour). What I have so far is this (capx):

    However, when I run my game, the layout which this is for will not load. If I remove the flooring of the random it will, but then the colours generated can be too similar. How can this be achieved?

  • You are probably misusing the loop but I don't know where the problem is.

    The random color by it self is easy however. You could also use the random values with an instance variable to store the color for each instance.

  • This isn't what I'm looking for though. Your example shows just picking random colours. The colours I'm needing cannot be the same and they must have the correct hue values (Hue's can be 0/15, 100/15, 200/15, 300/15 etc).

  • I see. Then yes, you need some kind of a loop that checks if one color is the same with an other and if yes to change it. I'll be damned if I knew how it's done 8\

    Sorry for not being able to help, I am sure that others can though

  • My graphics card locks up with that effect so I can't open the capx, but an event like this should work well to make each ColorBox have a different color.

    For each ColorBox ordered by random(1)

    ---Set effect "AdjustHSL" parameter 0 to loopindex*100/15

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks

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