Ambiera ForumDiscussions, Help and Support. |
|
|
|||||
|
Need some javascript to seamlessly change a health bar or other meter color from green at 100% and ending in red at 0% ? here you go: just setup before first drawing variable "cond" = 100 with a 2d overlay as "overlay" // starting from 100% var cond = ccbGetCopperCubeVariable("cond"); if (cond > 0) { cond = cond - 1; ccbSetCopperCubeVariable("cond", cond); if (cond >= 50) { var G = 255; var R = (100 - cond) * 5.1; R = Math.round(R); } else if (cond >= 0) { var R = 255; var G = cond * 5.1; G = Math.round(G); } var node = ccbGetSceneNodeFromName("overlay"); ccbSetSceneNodeProperty(node, "Background Color", R,G,0); } |
||||
|
very good.... thanks Robo! |
||||
|
cheers count2rfeit - I'm using this in one of my battery meters which looks quite good - not 100% sure if better than dedicated pre-made pictures but maybe do a video and ask everyone... |
|