Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Programming and Scripting
js class

Guest
Guest
Quote
2023-05-11 02:20:40

as i can see cc can't use class structure by execute js, or is there some special way to create class in cc?
for example i write:

class MyClass{
constructor(nodeName, mass){
this.node = ccbGetSceneNodeFromeName(nodeName);
this.nodeMass = mass;
}
}

and can't use it, even more i always get "SyntaxError: missing ; before statement"...


Guest
Guest
Quote
2023-05-11 02:59:42



var MyClass = function(name, mass)
{
this.name = name;
this.mass = mass;
}

MyClass.prototype.getNode = function()
{
return ccbGetSceneNodeFromName(this.name);
}

var bob = new MyClass("bob", 2000);

print(bob.name);
print(bob.mass);

ccbSetSceneNodeProperty(bob.getNode(), "Visible", false);



Create reply:


Posted by: (you are not logged in)


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