Ambiera ForumDiscussions, Help and Support. |
|
|
|||||
|
Hi, I know this topic has already been discussed, but I still don't understand. I want to put a variable in a 2D Text Overlay and dynamically change. For a variable "name" for example, I put "$name$" in Text area ? ($=sharp sign) And how to change it ? name="toto" ? What is the exact syntax ? In Flash AS3, no problem, I use Flash Text Area, no Copper Text. My question is for CopperCube only, and JavaScript/CopperCube (for windows). Thanks ! Cyril |
||||
|
For changing the text, you can use the "Change 2D Overlay Text" action. If you want to show the content of a variable in it, yes, that's the right syntax. (See docs: http://www.ambiera.com/coppercub...). Changing a variable is done using the "Set or change a Variable" action. Note that in there, you must not use the $ syntax. |
||||
|
Thank you very much. OK But from a Java Script, how it works ? I want to change Text Area from a file text (for dialog for example). If I want not use the Set Variable in Copper ? |
||||
|
Hm, do you mean JavaScript in the Windows or Mac OS X target, or in WebGL? because those are two different ones. |
||||
|
JavaScript for Windows... |
||||
|
You should be able to set the text using this code:
This should even work using the 'Execute Javascript' action. For details, see the javascript docs here: http://www.ambiera.com/coppercub.... You are probably also interested in the function ccbGetCopperCubeVariable() then. hope this helps! |
||||
|
how to use the ccbSetCopperCubeVariable(varname, value) and ccbGetCopperCubeVariable(varname, value) commands I used the following command in script as follow
When using the $state$ in change 2D text it show $state$ and it give the following error in the debug console :
I noticed that when using your script above It always run directly when I launch the executable directly not when passing to execute java script Does this mean that the script always launch when exe launch ? How to launch when just calling the script ? |
||||
|
Not sure about that 'script' error. Maybe you have a .js file in the path where you saved your .ccb file, and it is named the same? Then CopperCube trys to run that one, and the error may be from there. I think it's simpler to simply build the string you want to show yourself using JavaScript, like var textToShow = "Hello " + someValue + " world!"; No need to using CopperCube variables, if you don't want to. But you can, of course, like var textToShow = ccbGetCopperCubeVariable("NameOfYourVariable"); |
||||
|
OrderedScore ="test"; var s = ccbGetSceneNodeFromName('Leaderboard'); ccbSetSceneNodeProperty(s, 'Text', OrderedScore); The above is my code Spits out an error, property does not exist:"Text" @niko |
||||
|
ok this code works var s = ccbGetSceneNodeFromName('Leaderboard'); ccbSetSceneNodeProperty(this.LastOverlayObject, 'Draw Text', true); ccbSetSceneNodeProperty(s, 'Text', OrderedScore); |
|