Creator 2.0.2 ParticleSystem无法播放

  • Creator 版本:2.0.2

  • 目标平台: Web

  • 详细报错信息,包含调用堆栈:
    Uncaught TypeError: Cannot read property ‘material’ of null
    at RenderComponentWalker._flushIA (render-component-walker.js:165)
    at Object.renderIA (particle-system-assembler.js:59)
    at RenderComponentWalker._commitIA (render-component-walker.js:207)
    at RenderFlow.200._proto._customIARender (render-flow.js:105)
    at RenderFlow.init [as _func] (render-flow.js:233)
    at RenderFlow.200._proto._children (render-flow.js:127)
    at RenderFlow.200._proto._children (render-flow.js:127)
    at Function.render (render-flow.js:225)
    at RenderComponentWalker.visit (render-component-walker.js:214)
    at Object.render (index.js:201)

  • 重现方式:
    在scene的canvas node下添加一个empty node, 添加ParticleSystem component, 勾选custom,随意调整一下各参数,取消勾选Play On Load,在代码中调用ParticleSystem的resetSystem() 就会报错,如果勾选了Play On Load,调用resetSystem() 不会报错。

你好,我这边是正常的,能否给一下 demo 呢,十分感谢

我新建了一个空白项目又试验了一下,发现在component lifecycle callback中调用resetSystem()不报错,但是在touch callback 或 button callback中调用resetSystem()就会报错了。

新建空白项目,在scene的canvas node下添加一个empty node, 添加ParticleSystem component, 勾选custom,随意调整一下各参数,取消勾选Play On Load
新建一个Main.js,挂在scene的canvas node上,绑定properties

Main.js

cc.Class({
    extends: cc.Component,

    properties: {
        nodeCanvas: cc.Node,
        ps: cc.ParticleSystem
    },

    startListenTouch: function () {
        this.nodeCanvas.on(cc.Node.EventType.TOUCH_START, this.onTouchStart, this);
    },

    onTouchStart: function (event) {
        this.ps.resetSystem(); // error
    },

    onButtonClicked: function(){
        this.ps.resetSystem(); // error
    },
    // LIFE-CYCLE CALLBACKS:

    // onLoad () {},

    start () {
        this.startListenTouch();
        // this.ps.resetSystem(); no error
    },

    // update (dt) {},
});

同样出现. 就是最简单的自定义粒子效果, 在点击时resetSystem()就会报以上错误.

用了你的代码,但是还是正常的,能否给一下 demo 呢?这样比较清楚你做了什么,感谢

demo-ps-error.zip (493.7 KB)

附件是demo,很好奇为啥你那边复现不了,我是在空白项目上操作的。
搞定问题后请告知一下原因哈!

我用2.0.2也是粒子这里会报错,回退到2.0.1就不会报错

谢谢反馈,这个确实是个 bug ,大家可以自定义一下 engine,根据下方 pr 进行修复就行了

https://github.com/cocos-creator/engine/pull/3363

您好,mac安装目录下找到了这个js文件,改完了保存,从启还是报错 ,creator版本2.0.2

你应该自定义 engine,下面是文档:

http://docs.cocos.com/creator/manual/zh/advanced-topics/engine-customization.html?h

按照修改,git了新引擎确实不报错了。
但是新问题是button 按钮的禁用无效了:joy:

2.0.2后续的版本有修复这个bug么

有的 asd