How to create a ParticleSystem by script?

Hi…,

I have loaded my particle file with cc.loader.loadRes() and try to set my new node like this:

cc.loader.loadRes( 'particle_file', function (error, particle)
{
  this.particleSystem = new cc.Node( 'PS' );
  this.particleSystem.addComponent( cc.ParticleSystem ).file = particle;  // <- gets an error
  ...
}

Setting the file property gets me an error. Has anybody a tip for me?

Thanks

Mike

How can I Create Topic to ask question?
When I create a Topic, I will got a tips which say “You are not permitted to view the requested resource.”

Hi…,

I’ve tried also to set a file name directly, like this:

this.particleSystem.addComponent( cc.ParticleSystem ).file = 'particle_file'

I didn’t get it set up without loading errors, now I have used a prefab.

Cheers

Mike

P.S. Hi @stan, I have seen you have found the “New Topic” button. Welcome to this forum, Mike

@MikeFromMars looks like the file path has to be resolved through the loader -

res/raw-assets/resources/path/in/your/resources/particle.plist

1 Like