Home > other >  Cocos creator with a script tunes custom function in another script
Cocos creator with a script tunes custom function in another script

Time:09-28

My Java poisoning too deep, js didn't learn, teach

CodePudding user response:

This. Hang NewScript sheep2 this node has. Js this script?

If you have try this. Sheep2. GetComponent (" NewScript). Setj (2);

CodePudding user response:

GetComponent (' NewScript) don't add. Js suffix

CodePudding user response:

Look at my blog at https://blog.csdn.net/S_clifftop/article/details/94456992

CodePudding user response:

NewScripts. The use of the module in the js. Exports or ccclass writing, and then in the need to use the module or class (documents) in var=the require XXX ('/NewScripts');
For example, in NewScripts. Js code:
The module. Exports={
Name: 'qq_45330885'
}
So in the use of places:
Var SomeOne=the require ("../NewScripts');
Cc. The log (SomeOne. Name);

//the hope can help you
  • Related