ambiera logo

Ambiera Forum

Discussions, Help and Support.

folder icon Ambiera Forum > CopperCube > Programming and Scripting
forum topic indicator coding font for 2d-overlay
person icon
DouweDabbe
Guest
Quote
2022-06-25 23:49:31

How do I init in code the font properties of a 2Doverlay ?
it expects these 6 properties:
1- Point Size: 12,
2 - Face Name: "Arial",
3 - Style: "Nortmal",
4 - Weight: "Normal",
5 - Underlined: "False", <--- ? typo in Properties panel ?
6 - Family: "Swiss"

I do like this:
var oFont = {12,"Arial","Normal","Normal","False","Swiss"};
ccbSetSceneNodeProperty(nThingy, "Font", oFont );

Error :insufficient number of parameters ???

person icon
Guest
Guest
Quote
2022-06-26 01:00:23

Did you typeof the params?

person icon
just_in_case
Moderator
Quote
2022-06-26 07:15:42

Do it like this.


var s = ccbGetSceneNodeFromName("overlay");
ccbSetSceneNodeProperty(s,"Font","14; Arial; Normal; Normal; Not Underlined; Swiss");


person icon
DouweDabbe
Guest
Quote
2022-06-26 13:00:37

Thanks


just_in_case wrote:
Do it like this.


var s = ccbGetSceneNodeFromName("overlay");
ccbSetSceneNodeProperty(s,"Font","14; Arial; Normal; Normal; Not Underlined; Swiss");


Not Underlined
works with string: "False" where I expected to see logical: false

then this should be:

var oFont = {"Point Size":12, "Face Name":"Arial", "Style":"Normal",
"Weight":"Normal", "Underlined":"False", "Family":"Swiss"};
ccbSetSceneNodeProperty(nDialog, "Font", oFont );


also text color is not as expected:
vColor = new vector3d(255,255,175); // numbers
but color is distorted from selected values
vColor = {"255", "255", "175"}; // string object
ccbSetSceneNodeProperty(nDialog, "Text Color", vColor );
now correct color.

now I try to calculate the Pixel length of a given string:

var function pixlength(str, oFont) {
var pica = oFont."Point Size"; // ? <--
// ??? this may provoke a undesired string cat
// or format as: oFont.Point_Size ??? Ugly is this.
var some X = 3;
var someY = 24;
var someZ = 3.15;
return pica*someX + ( str.length*someZ/somesomeY );
};


function needed to customize the 2doverlay node for dialogs etc.
Can pad with spaces and newlines \n to outline with
underlying speechballoon image for example.


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 |