A slight mistake to fix

0 favourites
  • 5 posts
From the Asset Store
Mini boss music in slight retro style, reminiscent of Metroid and Zelda
  • It appears that if we set a ept_color property for a behaviour,it returns a decimal number instead of the format rgb(r,g,b) that gets returned in the case of a plugin.

    The decimal should then be converted to hexadecimal, but the hex color is inverted in the form of bgr instead of rgb.

    Its a big hassle, so it would be great if this gets fixed.

  • You sure it's not rgba?

  • You sure it's not rgba?

    No it should be returning : rgb(r,g,b)

    Instead it returns a decimal, in my case its 6698973, which should be converted to hex, it becomes 0x6633ff.

    But its in the form of bgr, which means that 0x66 is b, 0x33 is g and 0xff is red.

    new cr.Property(ept_color, 	"Fog color",		0x222222,		"The color of the fog."),[/code:21fctseb]
    
    Here is a workaround:
    [code:21fctseb]
    var fogColor = hexToRgb(this.properties[2]);
    [/code:21fctseb]
    
    [code:21fctseb]
    function hexToRgb(hex) {
    		hex = hex.toString(16);
    		var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
    		return result ? {
    			r: parseInt(result[1], 16),
    			g: parseInt(result[2], 16),
    			b: parseInt(result[3], 16)
    		} : null;
    	}
    [/code:21fctseb]
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • OK. I know alpha uses a value of 1 to 0, so I thought that might be what you were seeing.

  • It probably isn't a mistake since it's a format used throughout C2. Here's how the rgb() function in converts it to a single number.

    Number = red & (green<<8) & (blue<<16);

    There isn't a standard color format but if I may, here's a shorter way to convert it to the format you want:

    function hex2rgb(hex)

    {

    return {

    r: hex&0xff,

    g: (hex>>8)&0xff,

    b: (hex>>16)&0xff

    };

    }

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