Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Help with CopperCube
Editable Text Overlay

dynamogames
Registered User
Quote
2022-06-04 19:43:05

I'm trying to create a system in CopperCube where players can name the player before the game and it saves and displays the name entered when the player starts the level. I created a scene where I added a behavior of Editable Text Overlay (JIC) and I made it that when player presses F key, player can edit the 2D overlay, then I added a behavior where when the player presses Shift key in the same scene, it saves the variable to disk. Then I added a behaviour in my level 1 scene where I have a 2d overlay, I added a behavior on the 2d overlay such that when the player for presses N key, it loads variable and I also added a behavior to change 2d overlay text to that variable. The main issue I have now Is when player presses N key in level 1 scene, it only changes the 2d overlay text to the variable name not the name the player entered in the previous scene. I want to make it that the game loads what the player entered as his/her name in the previous scene not the variable name. I really hope someone can help me solve this problem.


okeoke
Registered User
Quote
2022-06-06 08:31:27

I'm not sure if it's possible to use built-in set text action, but you can do that using 'execute javascript'.

Instead of 'change 2d overlay text' attach 'execute javascript' from special category. The action should be attached to the behavior attached to your 2d overlay node.

Put the following code:

// Gets current node
var thatNode = ccbGetCurrentNode();
// Gets name variable value
var name = ccbGetCopperCubeVariable('PUT_YOUR_VARIABLE_NAME_HERE');
// Sets 2d overlay property
ccbSetSceneNodeProperty(thatNode, 'Text', name);


Make sure 'Draw Text' checkbox is checked under your 2d overlay node Attributes.


just_in_case
Moderator
Quote
2022-06-06 10:52:40

Coppercube's variables are specific to a single scene. So when you change your scene you might need to recreate those variables in that scene too. If you want to load the variables from the previous scene in the new scene then you might need to save and load them to disk in your first scene and then load them using the same behavior in the new scene. Or you can simply assign global variables that can be used throughout your game instead of using local and scene-specific variables.

Hope that bit of information helps. Also I hope you are liking my Editable Text Overlay :)



dynamogames
Registered User
Quote
2022-06-07 16:53:49

Wow thanks @ just_in_case
But there's still a little issue, it is not displaying the players name, it is just displaying "true" on the 2d Overlay. I don't know what went wrong. Maybe I'll send a drive link for all the behaviours so u can see where I went wrong.
How do I pls create global Variables in CopperCube?


dynamogames
Registered User
Quote
2022-06-07 16:55:55

*
Yhh I'm enjoying the Editable Text Overlap behavior
Really helpful. Thanks


dynamogames
Registered User
Quote
2022-06-07 17:07:52

Thanks @ okeoke really appreciate bro.
I made a mistake earlier, the first reply was meant for you about the displaying of "true" not just_in_case. I thought it was just_in_case that replied with the JavaScript solution. Sorry for the mix up


dynamogames
Registered User
Quote
2022-06-07 17:28:15

https://drive.google.com/folderv...

This is the google drive link for the pictures of the behaviours


okeoke
Guest
Quote
2022-06-07 20:07:27

wrote:
https://drive.google.com/folderv...

This is the google drive link for the pictures of the behaviours


I can't access the folder - try to change the access rights to 'everyone who has link can access' or something similar.


dynamogames
Registered User
Quote
2022-06-08 13:10:03

Ooh I'm so sorry I forgot to change the permission to everyone can view.
I've changed it, you can view it now.


just_in_case
Moderator
Quote
2022-06-08 13:54:49

It will be much better if you can provide a test ccb file to figure out what you are doing wrong. Those are lot of images to understand what you are doing there.


okeoke
Registered User
Quote
2022-06-08 14:18:54

I believe, on the second screenshot you're setting your variable value to "true" that's why it says "true" when you set it.

Try to change Value field from "Capture 2" from "true" to something else - if the same value pops up on your 2d overlay it means you're setting the variable incorrectly.

I believe, editable overlay extension should have some option like "write value to variable" or something similar. Use it to set the value.


okeoke
Registered User
Quote
2022-06-08 14:19:35

I would also prefer to have the ccb, tbh:)


dynamogames
Registered User
Quote
2022-06-08 18:08:11

OK I'll send the drive link of the CCB file to you


dynamogames
Registered User
Quote
2022-06-08 18:17:31

But when I changed the value from "true" to something else and I publish the game, the F key to edit the name is not working in the published version, it is only when the value is "true" that The 2d overlay is editable.


just_in_case
Moderator
Quote
2022-06-09 05:25:23

Did you added the "Editable Text Overlay " behavior to the overlay in new scene as well? if not, then you need to attach the behavior to the overlay. and your overlay name should be same as the overlay name in previous scene. Otherwise, you need to add another variable with name of your new overlay. A ccb file as I said will be more helpful.


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Internati?nal" (you are not logged in)


Text:

 

  

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


   






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