1.Cannot read property 'isTrigger' of undefined:貌似是Laya引擎的bug
解决方法:
在初次加载带有刚体的3D游戏对象组件的时候,使用代码获取刚体组件,设置刚体组件的isTrigger属性:
let rigid = this.obj.getComponent(Laya.Rigidbody3D) as Laya.Rigidbody3D;
rigid.enabled = false;
rigid.isKinematic = false;
rigid.isTrigger = false;
2.销毁3D对象的时候必须同时销毁他的子对象:否则会报各种奇怪的错误
let boy = boyTemp.getChildByName("boy");
let boyAnimRun = boyTemp.getComponent(Laya.Animator) as Laya.Animator;
boyAnimRun.enabled = false;
boyAnimRun.destroy();
boyTemp.removeChildren();
boyTemp.destroy(true);
Laya.MouseManager.multiTouchEnabled = false;
(2) 底层单例队列的bug解决:不改变源码的情况下,重写该方法
public static SingletonList_expand() {
Laya.SingletonList.prototype["_remove"] = function (index) {
// @xd added, 如果index == -1 不执行
if (index == -1) {
return;
}
this.length--;
if (index !== this.length) {
var end = this.elements[this.length];
// @xd added, 添加end是存存在判断
if (end) {
this.elements[index] = end;
end._setIndexInList(index);
}
}
}
var old_func = Laya.SimpleSingletonList.prototype.add;
Laya.SimpleSingletonList.prototype.add = function (element) {
var index = element._getIndexInList();
// add, 添加安全性判断.
if (index !== -1) {
return;
}
old_func.call(this, element);
}
}
4.iphone6? 微信版本7.0.2?游戏加载报错,问题原因,banner的onclosed函数回调报错:去掉onclosed回调后问题解决
console.log(JSON.stringify(module), JSON.stringify(err));
7.加载图片报错:Failed?to set the? 'buffer'?property on? 'AudioBufferSourceNode'
解决办法:
8.Laya.Event.CLICK事件监听,回调函数,传参示例:
9.list组件的数据datasource不能含有关键字,如果cell的类型是img的话,datasource不能含有skin字段,否则会自动复制skin字段给cell本身的skin属性:
10.laya的UI资源,设置centerX和centerY的时候,必须要有width和heigth属性值,不然的话,UI的位置容易错乱;
无论是代码创建的UI还是编辑器中直接编辑的UI资源,都要注意这一点;
11.【laya2.0编译报错捕捉】
LayaAirIDE2\resources\app\node_modules\rollup\dist\rollup.js
用图中console.log打印报错。
console.log(JSON.stringify(module), JSON.stringify(err));
12.试图调用仅当实体已添加到场景中时才可用的物理函数
Attempted to call a Physics function that is avaliable only when the Entity has been already added to the Scene.
13._getHierarchyPath? U3D导出的资源缺少骨骼