Any way to get the color ?

0 favourites
  • 5 posts
From the Asset Store
HSV RGB Color Picker and Converter for Construct 3
  • Hey Constructors,

    Just a little question. Is there any way (third party or not) to get a sprite's color ? I was thinking of a good way to improve some stuff in the little game I'm currently working on, and until now, I was dealing with several families. One family stands for one color. If I need to know if the player stands on a purple, red, or orange platform, all I have to do is to check if the said platform belongs to the red, purple or orange family. Done. It works, but hell, as soon as my level begins to be a little more complex it takes some times to put every sprites in every matching families. Thus, if I could detect the color itself directly, that'd be great. I'm picturing this as something like this, for example :

    If the character is standing on a sprite with a color between #HexDeciValue and #HexDeciValue then apply this bonus/malus

    Do you know any way to achieve something like this ?

    If you have any idea to improve my mechanic, don't be shy, I'll take it too ! Please know that I don't ask this in the How do I section because I don't think there is a native feature to deal with that in C2 for the moment. I may be wrong of course, and if I am, sorry, wrong post, wrong place. Thanks !

  • There is this:

    Thers is de canvas plugin that has this rgbaAt expression.

    Personaly i think that you take this 'problem' as to strict. 'colour' can be presented as an instance variable (or family variable). Either as a string or as a number. Use the variable to pick.

    If you choose to present the colors with a number, you can (to make it yourself easy) create a event sheet without an assigned layout, and include that in your main sheet. Create global variables there like:

    Global variable 'cPurple' ... value 1

    Global variable 'cBlue' ... value 2

    Now if you gonna compare, it is easier to wrap your mind around it.

    if instance variable = cBlue ... then

    You can also set the animation speed to zero. (if you dont have animations). Now you make frames that match with the numbers. Frame 1 = Purple. Frame 2 is Blue.

    Now you only deal with instances of the same Sprite. And do things like:

    Mouse > object clicked > sprite

    Sprite > compare frame > =? > Cblue

    ............. actions

  • Hello, thanks for replying, I'm gonna try that as soon as I can !

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I was in need of a similar logic in my project and I solved that by creating different animations for each color. In my code I get the color simply by referring to the object's animation name.

  • Personally...I would create one platform family. all platforms of all colors would go into it.

    Each platform object would have a instance variable "Color"

    that way my code would read something like this:

    player collision with platform

    if(platform.color==1) Do this

    else if(platform.color==2) Do something else.

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