How I add another javascript file that is a library to my game ?
I trying to add http://mathjs.org library putting the js file in the scripts folder and calling with:
BitsBR - I’ve been trying to figure out how Cocos creator does this all day. And in the end… it’s really easy.
In your project assets make a “scripts” folder (just for organization)
Drag the math.js file to this folder so it’s copied into the project.
Select the math.js file in the asset list.
In the property inspector (top right side), check “import as plug-in”
Click tiny check box on top of property inspector to save this setting (soooo easy to forget this one)
And…that’s it.
No need for “require” or anything else. Use your math functions in Creator based javascript as you need.
Tadah!
You are F**ked. I have not found a good way of importing libraries into cocos creator, thats why js is still play toy. Try importing as plugin and if it doesn’t work, you have to read the source code of math.js and figure out a way to copy and paste those functions into your scripts. Have fun
Thank you for all your help friends, all you are all awesome!
it’s working, but if somebody use the Production version (“math.min.js”),its also needed to add one file called “math.min.map”, I find it in the npm module.