1.生命周期:

与unity基本一样,生命周期中的Awake变成了OnLoad,剩下的基本一样吧:

http://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
<http://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html>

 

2.component:

与unity不同的是,没有与gameObject对应的概念,transform对应节点node,显示或者隐藏为

this.node.active = true;/false;

cc.find("Canvas/GameUI").active = false;

 

3.数据本地存储(数据持久化):

unity一般用PlayerPrefs就够了,creator中用cc.sys.localStorage.getItem("key", value);

https://blog.csdn.net/maximilianliu/article/details/79368671
<https://blog.csdn.net/maximilianliu/article/details/79368671>

 

4.适配:

creator一般是用Widget组件去控制;

 

5.输入事件:

https://blog.csdn.net/qq_35131940/article/details/77584624
<https://blog.csdn.net/qq_35131940/article/details/77584624>

 

6.碰撞事件:

creator中的碰撞要先开启才能检测到:
var clidManager = cc.director.getCollisionManager();        
clidManager.enabled = true;         clidManager.enabledDebugDraw = true;

之后才能检测,参考:

https://blog.csdn.net/wzyezqxl/article/details/52126036
<https://blog.csdn.net/wzyezqxl/article/details/52126036>

 

7.脚本之间的调用:

在creator中叫做模块化脚本:

http://docs.cocos.com/creator/manual/zh/scripting/modular-script.html
<http://docs.cocos.com/creator/manual/zh/scripting/modular-script.html>

这个地方还是有很多不懂的,等下再学下下;因为调用总是会有问题(this指代不对等);

 

8.单例:

https://blog.csdn.net/leovnay/article/details/79272977
<https://blog.csdn.net/leovnay/article/details/79272977>

 

9.加载场景:

cc.director.loadScene("Main");

有时需要预加载:

http://docs.cocos.com/creator/manual/zh/scripting/scene-managing.html
<http://docs.cocos.com/creator/manual/zh/scripting/scene-managing.html>

 

10.按钮点击:

跟unity差不多,拖过去,或者addListener

 

11.计时器:

比unity好的地方,计时非常方便:

http://docs.cocos.com/creator/manual/zh/scripting/scheduler.html
<http://docs.cocos.com/creator/manual/zh/scripting/scheduler.html>
--------------------- 
原文:https://blog.csdn.net/allenwithno3/article/details/82958591 

友情链接
ioDraw流程图
API参考文档
OK工具箱
云服务器优惠
阿里云优惠券
腾讯云优惠券
华为云优惠券
站点信息
问题反馈
邮箱:ixiaoyang8@qq.com
QQ群:637538335
关注微信