ambiera logo

Ambiera Forum

Discussions, Help and Support.

folder icon Ambiera Forum > CopperCube > Help with CopperCube
forum topic indicator Scale 2D overlay dynamically
person icon
Dieter
Guest
Quote
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)

person icon
just_in_case
Moderator
Quote
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.

person icon
Dieter
Guest
Quote
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:










 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


icon_holyicon_cryicon_devilicon_lookicon_grinicon_kissicon_monkeyicon_hmpf
icon_sadicon_happyicon_smileicon_uhicon_blink   






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