有一个可以作为模块导入的纸JS文件
我正在制作游戏,我想将我的代码分为两个文件。一个是游戏玩法的普通JavaScript文件,另一个用于所有图形的论文文件。我想从主文件从paperscript文件调用函数,但据我所知,它需要加载type =“ module”
让我能够调用函数,但是它还需要加载type =“ text/paperscript”
才能用作论文。 如果有一个请求的方法可以从其他文件调用函数,我想听到有关它的信息PaperScript“ 在同一脚本元素中。
如果不可能,我知道我可以使用JavaScript而不是Paperscript
I am making a game and I would like to have my code split into two files. One, an ordinary javascript file for the gameplay, the other a paperscript file for all the graphics. I want to call functions from the paperscript file from the main file, but as far as I can see it needs to be loaded with type="module"
for me to be able to call functions, but it also needs to be loaded with type="text/paperscript"
for it to work as paperscript.
If there is annother way to call functions from a different file I would like to hear about it, or if there is a way to include both type="module"
and type="text/paperscript"
in the same script element.
If this is not possible I know I could use javascript not paperscript but I would rather not because all the examples I have seen are using paperscript
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我已经弄清楚了如何做我想做的事,现在我感到非常愚蠢。我学到了Python,并且是JavaScript的新手,并且没有意识到您只能从其他文件中调用函数,在Python中,您只能使用模块来执行此操作。
在这里,我可以将一个变量声明为
窗口。
I've figured out how to do what I want and I feel very stupid now. I learned python and am new to javascript and didn't realise that you could just call functions from other files, in python you can only do this by using modules.
Here I can declare a variable as
window.<myVariableName>
in paperscript to be able to access it from raw javascript.