0 Favourites

How to generate random color and change sprite color runtime

  • Hello

    is there anyway to generate random color and change a sprite color in run-time ?

    after some researches I found a way to put effect and change it (and this supported in webGL only)

    any alternative way to change it ?

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • How about you make multiple frames for the sprite?

    Set the Default animation speed to 0 and randomize the current frame of the sprite using Set animation frame action with floor(random(Self.AnimationFrameCount)))

  • How about you make multiple frames for the sprite?

    Set the Default animation speed to 0 and randomize the current frame of the sprite using Set animation frame action with floor(random(Self.AnimationFrameCount)))

    I'll try it

  • Hey frodoe7,

    Another similar method is to use multiple sprites stacked together.

    Suppose you have a tank in your game, and you want to be able to change the color of the body, the treads, and the turret separately.

    One way to do this is to create a sprite for the body, a sprite for the treads, and a sprite for the turret, and for each one include color variations. The variations can either be in frames as Tetriser suggested, or in their own separate animations within the sprite.

    You can then use the "Pin" behavior to keep all the sprites together.

    This approach can be especially handy if you want to allow for a lot of variations, as the number of color combinations is the product (multiplicative total) of the number of color variations in each sprite.

    So if the tank has 8 colors for each sprite (body, treads, and turret), then the total number of color arrangements is 8 * 8 * 8, which is 512 combinations. It adds (multiplies) up fast.

  • but we still here

    I need for example to generate a totally random color (don't know it previously) and assign it to my sprite

    I can write C2 plugin for that with JS , bu how to access the sprite image ?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic
0 Favourites
Sprite Font Generator - v3
368 112,397
RetroDaddy's avatar
RetroDaddy
Unread hot topic
187 45,150
Yann's avatar
Yann
Unread hot topic Locked topic
195 16,205
Ashley's avatar
Ashley Construct Team Founder