Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Help with CopperCube
popup text???

evils_phoenix
Registered User
Quote
2023-07-13 10:17:00

hello, please tell me how to implement a description or pop-up text on the screen when you hover over the desired object.
for example, when hovering over a closed door, a text pops up that a key is needed.
Perhaps there is a plugin that makes this task easier. I tried to make pop-up windows, as a result, it does not work correctly.


SamGrady
Guest
Quote
2023-07-13 13:05:11

i create this easy action and for example upload *ccb file

/*
<action jsname="action_SetTextRelative" description="Set text relative to node">
<property name="Overlay2dNode" type="scenenode" />
<property name="ParentNode" type="scenenode" />
<property name="isVisible" type="bool" default="true" />
</action>
*/

// Define the action_SetTextRelative function
action_SetTextRelative = function(){

};

// Add the execute method to the action_SetTextRelative prototype
action_SetTextRelative.prototype.execute = function(currentNode){
// Get the absolute position of the parent node in 3D space
this.pos3d = ccbGetSceneNodeProperty(this.ParentNode, "PositionAbs");
// Convert the 3D position to 2D screen position
this.pos2d = ccbGet2DPosFrom3DPos(this.pos3d.x,this.pos3d.y,this.pos3d.z);
// Check the position mode of the overlay 2D node
if(ccbGetSceneNodeProperty(this.Overlay2dNode,"Position Mode") == "absolute (pixels)"){
// If the position mode is absolute (pixels), calculate the new position based on the parent node's position and size
this.w = ccbGetSceneNodeProperty(this.Overlay2dNode,"Width (pixels)");
this.h = ccbGetSceneNodeProperty(this.Overlay2dNode,"Height (pixels)");
this.x = this.pos2d.x - (this.w/2);
this.y = this.pos2d.y - (this.h/2);
// Set the new position of the overlay 2D node in pixels
ccbSetSceneNodeProperty(this.Overlay2dNode, "Pos X (pixels)", this.x);
ccbSetSceneNodeProperty(this.Overlay2dNode, "Pos Y (pixels)", this.y);
} else if(ccbGetSceneNodeProperty(this.Overlay2dNode,"Position Mode") == "relative (percent)"){
// If the position mode is relative (percent), calculate the new position based on the parent node's position and size as a percentage of the screen dimensions
this.w = ccbGetSceneNodeProperty(this.Overlay2dNode,"Width (percent)");
this.h = ccbGetSceneNodeProperty(this.Overlay2dNode,"Height (percent)");
this.x = (this.pos2d.x/(ccbGetScreenWidth()/100)) - (this.w/2);
this.y = (this.pos2d.y/(ccbGetScreenHeight()/100)) - (this.h/2);
// Set the new position of the overlay 2D node as a percentage
ccbSetSceneNodeProperty(this.Overlay2dNode, "Pos X (percent)", this.x);
ccbSetSceneNodeProperty(this.Overlay2dNode, "Pos Y (percent)", this.y);
}
// Set the visibility of the overlay 2D node
ccbSetSceneNodeProperty(this.Overlay2dNode, "Visible", this.isVisible);
}



https://drive.google.com/file/d/...
hope i right understand you and write what you need


evils_phoenix
Registered User
Quote
2023-07-14 10:17:38

yes thank you it is. It remains to understand where to insert this script.


SamGrady
Guest
Quote
2023-07-14 13:46:25

i can make some more example for better understanding


evils_phoenix
Registered User
Quote
2023-07-14 20:20:50

It would be nice to post a small guide with screenshots. please


evils_phoenix
Registered User
Quote
2023-07-14 22:23:15

thanks, I figured it out, it's a little different, the text is shown regardless of the distance, but it needs to be when the character is in the area of the object


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Intern?tional" (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