Creator使用遇到的问题总结
tips1:js的数值格式是浮点数,对数值的操作次数过多或者使用convertToWorldSpace等方法,需要Math.ceil一下。否则会导致数据的偏差越来越大,运气好的可以正负抵消哦!祝你好运
Tips2:简单记录下跳转scene的进度条使用
cc.director.preloadScene(“scene名字”,
function (completedCount, totalCount, item) {
var pShow = (completedCount / totalCount).toFixed(2);
cc.log("onProgress completedCount = "+completedCount+",totalCount="+totalCount+",pShow="+pShow+",item="+item);
if(item){
cc.log("onProgress dothis");
//设置进度条的进度;
}
},function () {
cc.log("go scene do");
cc.director.loadScene("scene名字");
});
Tips3:js中的if语句的判断 if(0)返回的是false
Tips4:使用物理引擎需要注意,物理的刚体所在的node不会跟随父node的移动而移动。如果可以的话,直接使用碰转系统不会存在这个问题
Tips5:https://blog.csdn.net/zzx023/article/details/85318028,creator 加载优化,挺好的文章
Tips6:spine动画自定义事件的监听
this.cardSke.setEventListener((trackIndex,event)=> {
cc.log("setEventListener >>>>>>>", trackIndex, event.data.name);
if(event.data.name == "事件名"){
//操作
}
});
Tips7:按钮下图片的状态设置问题(注意这边的调用顺序)
this.btn.getComponent(cc.Button).interactable = true;//回重置按钮的图片状态
this.btn.getComponent(cc.Sprite).setState(0);//设置灰显0或者1