11 2018 档案
摘要:使用sleep和wake方法的好处:
1.可以彻底让scene场景彻底休眠
2.update function不会再运行
3.同时会暂停场景内的Timer事件
阅读全文
摘要:
// 三角函数 得出鱼要旋转的角度
this.fish.rotation = Math.atan2(pointer.y - this.fish.y, pointer.x - this.fish.x);
// 判断鱼是否需要反转:点击的位置和鱼头相同=>不反转
if ((pointer.x > this.fish.x)) {
console.log("点击的位置和鱼头相同=>不反转");
this.fish.flipY = false;
}
// 判断鱼是否需要反转:点击的位置和鱼头相反=>反转
阅读全文

摘要:使用对象池 Object Pool产生炸弹,首先创建一个对象组 this.exploadGroup = this.add.group();
然后用对象组的.get重复应用对象池而不是用.create,this.exploadGroup.get(x,y,'explode');
最后销毁的时候不是用.destory(),而是用 this.exploadGroup.killAndHide(singleExplode);
阅读全文
摘要:1)通过事件this.events.emit('event key',{objKey:objValue});
从sceneA通过 ths.events.emit时传值到sceneB时有个需要特别注的事项就是,得把sceneB的 active设为 ture,否则因为 sceneB还未激活,是监听不到 events.on事件的!!!
2)通过场景启动this.scene.start('gameB key',{objKey:objValue});
阅读全文
摘要:坑:
在config内不要把 width 设为 window.innnerWidth
在config内不要把 width 设为 window.innnerWidth
在config内不要把 width 设为 window.innnerWidth
重要的事情得说三遍...
阅读全文