Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Feature requests and bug reports
Draw text

2021-12-31 23:53:34

Please, add functionality to Draw Text via scripting
With CopperCube current scripting we can only draw texture or colored rectangle without any text.

There is a need to draw text either inside the rectangle or independent Text.
Please add this feature in the next update so that one can draw Text through script.

ccbDrawText("Text", pos_X, pos_Y);

Something like this will be super usefull.


2022-01-01 06:28:49

read the manual !

2d oveLay can displaY TEXT

with a bit of scripting dynamically

search the forum / the manual


best wishes etc

2022-01-01 06:47:16

Maybe you didn't read my post correctly, I don't want 2D overlays. I want to draw text with scripting. Just like the ccbDrawColoredRecatngle and coloredRectangle with Alpha. I know 2D overlays can draw colored rectangle and colored rectangle with alpha as well. Does that mean the developer should remove the scripting API of drawing colored rectangle and rectnagle with Alpha texture.
Because one can use 2D overlays for that.

I have read the manual carefully and there is no way to draw text using javascript. I don't want to use inbuilt editor's 2D textoverlay. I want to create text items during runtime without adding them all in my project as 2D overlays.

So yeah, there is need for drawing text as a javascript command.
I think others will also need this at one or another point of game developing. Specially those who prefer to script things, instead of using default prefabs.


2022-01-01 15:52:53

Not 100% sure what you mean - can you explain a little more of what you;re trying to achieve please?

As mentioned, "draw text" does already exist as part of the SetSceneNodeProperty API.

If you create a single 2D overlay, set it to "do not draw background", then you can use Java script or commands to display any text you like on the same overlay (any size/font/colour/position etc) - ie: dynamically re-use the same overlay for all your text, rather than creating separate overlays for each of your different texts.

You can even read a text file and dump that to the 2D overlay or display changeable "variable" values by enclosing them in dollar-signs: $text$

For example, the following scene node parameters are adjustable:

'Pos X (percent)', 'Pos Y (percent)', 'Width (percent)', 'Height (percent)', 'Pos X (pixels)', 'Pos Y (pixels)', 'Width (pixels)', 'Height (pixels)', 'Alpha', 'Image', 'Background Color', 'Draw Text', 'TextColor', 'Text'.

You can update the overlay at specific intervals (every few miliseconds) or trigger the update as a triggered event.

Depending what you want to achieve, there are a few different methods of applying text. With a little thought and creativity, it's possible to make a scrolling effect or a typewriter effect with just a basic 2D overlay and text strings.

Of course, you're not limited to using just 2D overlays for text. For more creativity, you can, for example, create 3D modelled alphabet and type in 3D if you wanted to (with individually spinning/scaling/bouncing letters/dynamic lighting or normal mapping) - or use a sprite sheet for bitmap-fonts which could then be mapped to a billboard or a texture etc with colour ripples, pixel morphs, and flash effects.

Personally, I use billlboards with bitmap fonts to scale the text in and out of the screen and can apply fancy warps/transitions/fades and wobbles etc. and I use 2D overlays for Head-up displays and variable information. Haven't used a 3D text font yet but may incorporate it at some point.

2022-01-01 17:18:34

Well, sometimes I also need to draw text with scripting. Few months ago I created an app, and I can't really use the 2D overlays for text, so I used a bitmap font an instead of actual text I used that bitmap font to draw text on screen.

I will also like to see it as a javascript individual command.

If you want you can also use the method i used to draw text by using a bitmap font. Or go with 2D overlays as suggested by others until @Niko push this as a javascript command.

Registered User
2022-01-01 18:02:19

If the game is for Windows system (I don't know if it works for other OS) you can use the commands, "print("text")" or "alert("text") or system(). To get a text output.

2022-01-01 19:21:29

@pmax, sorry from my experience
- alert doesn't work with CopperCube scripting
- print only gives you a console output testing from the editor - not in the published built

Registered User
2022-01-01 20:23:11

You are right I did not specify
the alert() command works only in the editor not in game, and the print() command uses the debug console for output.

2022-01-02 06:03:18

Here is a video demonstration of my experimental project in CopperCube that draws text using bitmap fonts. All the GUI elements have been created with pure javascript, not a single CC's default node has been used in the scene. however, there is
.cca files loading mechanism.CCA files are nothing but actual coppercube prefabs files renamed from .ccp to .cca.

My main motive is to show you the draw mechanism that draws Text, I can specify the text, their size, space between them, and all.
I was working on this project when I got attacked by hackers because of ransomware, and since then it has been dropped but I will pick it up this project in the future and will see if I can expand it more to have some real use.
Right now it is a great project for creating GUI, real easy.

Watch the unlisted video here on my YouTube channel.

2022-01-06 06:24:21

Thanks for your help, I think my request doesn't worth it.

2022-01-09 16:40:01

alert() works when exported for WebGL target. That's really the question, whether you want this to work on all platforms.
I'm pretty sure it's easy to write a function based on a 2D overlay, that emulates independent text commands. Maybe you can explain why 2D overlay didn't work for you.

The idea would be to use a function like
function myText(x,y,text){
and then update the 2D overlay with all the text in these arrays, once every frame or so.

Create reply:

Posted by: (you are not logged in)

Enter the missing letter in: "Internatio?al" (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© 2020 Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact