Objects with random colors

0 favourites
  • 10 posts
From the Asset Store
Creepy Sprite Font suitable font for your Dark/Horror/Halloween games.
  • Hi there. I would like to spawn objects with random colors, how do I do that?

  • If the object is a sprite, and random colors are all in different frames, you can do this:

    Create Sprite
    Sprite set Animation Frame to: random(self.AnimationFrameCount)
    
  • You could use the Set Color in Appearance, Set your Sprite to initially to white, create a new object, and in the Set Color box put rgbEx255(int(random(255)),int(random(255)),int(random(255)))

  • Will go with sizcoz which is easier to implement, thanks!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Will go with sizcoz which is easier to implement, thanks!

    rgbEx(r, g, b)

    rgbEx255(r, g, b)

    rgba(r, g, b, a)

    rgba255(r, g, b, a)

    Generate a single number containing a color with the given red, green, blue and optionally alpha components. rgbEx and rgba use components in the range 0-100, whereas rgbEx255 and rgba255 use components in the range 0-255. When an alpha is not provided, the resulting color is opaque. These are useful for conditions or actions taking a color parameter.

  • Truly random colors can often be unpleasant. A trick I have used in the past is to blend the random color with another one, so that colors you create have a common base.

    rgbEx(
    	lerp(50, random(100), 0.4),
    	lerp(50, random(100), 0.4),
    	lerp(50, random(100), 0.4)
    )
    

    That blends a random color with the fixed color rgb(50%, 50%, 50%), with a blend ratio of 40%.

  • I tried the lerp solution suggested by Nepeo but it's still pretty hard to discern the differences.

    For reference, here is the original which is not so unpleasant.

  • Looks like something isn't quite right, the concept is pretty sound. Here's an example

    dropbox.com/s/gqd4ipsh8f3ifjs/Random%20Colors.c3p

  • I think we need something like a palette plug.

  • Looks like something isn't quite right, the concept is pretty sound. Here's an example

    https://www.dropbox.com/s/gqd4ipsh8f3ifjs/Random%20Colors.c3p?dl=0

    Nice example, thanks!

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