Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Help with CopperCube
Scale 2D overlay dynamically

2023-08-24 22:17:20

I'm trying to use 2D overlays for a kind of health bar, and to scale it dynamically. However,
ccbSetSceneNodeProperty(node, "Height (percent)", percentage); 

does nothing. Am I doing something wrong? (webgl target)

2023-08-25 06:30:43

yeah, the webGL target somehow doesn't support the relative (Percent) based scale and position method for overlays.

You can still use the Pixel based scaling and height adjusting. It won't be hard to create your own percentage based scaling with canvas height and width by calculating it with the pixels based values.

so if you use something like this

var node = ccbGetSceneNodeFromName("overlay");
ccbSetSceneNodeProperty(node, "Height (pixels)", value here);

then it should just work fine and will scale your 2D overlay.

2023-08-25 13:18:07

Thanks, just_in_case!

I just figured that out too. "Height (pixels)" works, "Height (percent)" doesn't. Despite the latter appearing in copperlicht.js.

But yes, initial position and scale is by percent, based on node attributes in the editor. Then I can simply read the pixels to see how much that'd be for eg. 50% of the screen height. It won't support resolution changes while playing, but that's acceptable.

Create reply:

Posted by: (you are not logged in)

Enter the missing letter in: "Inter?ational" (you are not logged in)




Possible Codes

Feature Code
Link [url] [/url]
Bold [b]bold text[/b]
Image [img][/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]



Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact