How to test an export from Particle Designer 2 in the Simulator?

Hi everyone, 

I purchased Particle Designer 2 today, and I’m trying to figure out how to use it. I love the interface, but I haven’t yet been able to run a successful test and see a particle emitter running within the Simulator.

I created an effect in Particle Designer, exported it per the directions here: https://coronalabs.com/blog/2014/03/25/tutorial-using-particle-designer-in-corona/ 

But no luck yet. I’m doing something wrong.

Here’s the code snippet. 

-- testing particle designer 2 -- Require the JSON library for decoding purposes local json = require( "json" ) -- Read the exported Particle Designer file (JSON) into a string local filePath = system.pathForFile( "animations/gems1.json" ) local f = io.open( filePath, "r" ) local fileData = f:read( "\*a" ) f:close() -- Decode the string local emitterParams = json.decode( fileData ) local emitter = display.newEmitter( emitterParams ) emitter.x = display.contentCenterX emitter.y = display.contentCenterY

And here’s the error I’m receiving when I try to run it in the Simulator:

Corona Simulator Runtime error

File: main.lua

Line: 67

ERROR: invalid EmitterObject

stack traceback:

[C]: in function ‘newEmitter’

main.lua:67: in main chunk

Line 67 in the above code snippet is “local emitter = display.newEmitter( emitterParams )”. 

I’m still new at this. I don’t know what invalid EmitterObject refers to. Is that a library that hasn’t been properly loaded into the Simulator? 

Any help is greatly appreciated. 

Kind regards, 

Chad

Not sure what or why, but when I test by exporting the JSON from Particle Designer 2 directly into the project root, instead of a subdirectory, it works!

So in the code above, instead of this…

local filePath = system.pathForFile( “animations/gems1.json” )

I have this…

local filePath = system.pathForFile( “gems1.json” )

and it works!

I have literally no idea why though. Both the exported .json file and accompanying texture .png from Particle Designer 2 were in the subdirectory as well but wouldn’t work. Should I have referenced the subdir differently in the system.pathForFile function? 

Just ran into this same issue. Your code is fine. It appears that Corona is looking in the base directory for the texture, rather than the same location as the .json file (specified), which I think is the expected behavior.

Thanks, landoncope. I eventually figured it out after much hair pulling and cursing. Maybe this thread will save someone from the same fate. 

I remember to have the same issue, but the problem was that json generated file has a parameter called “textureFileName”. In my case the value was 

"textureFileName" : "fireworks.png"

When I put the json and texture file in /particle folder I need to change the parameter value to include the folder name in the filename parameter like this: 

"textureFileName" : "particle/fireworks.png"

I hope this help you, I prefer to have all particle effects in /particle folder.

Not sure what or why, but when I test by exporting the JSON from Particle Designer 2 directly into the project root, instead of a subdirectory, it works!

So in the code above, instead of this…

local filePath = system.pathForFile( “animations/gems1.json” )

I have this…

local filePath = system.pathForFile( “gems1.json” )

and it works!

I have literally no idea why though. Both the exported .json file and accompanying texture .png from Particle Designer 2 were in the subdirectory as well but wouldn’t work. Should I have referenced the subdir differently in the system.pathForFile function? 

Just ran into this same issue. Your code is fine. It appears that Corona is looking in the base directory for the texture, rather than the same location as the .json file (specified), which I think is the expected behavior.

Thanks, landoncope. I eventually figured it out after much hair pulling and cursing. Maybe this thread will save someone from the same fate. 

I remember to have the same issue, but the problem was that json generated file has a parameter called “textureFileName”. In my case the value was 

"textureFileName" : "fireworks.png"

When I put the json and texture file in /particle folder I need to change the parameter value to include the folder name in the filename parameter like this: 

"textureFileName" : "particle/fireworks.png"

I hope this help you, I prefer to have all particle effects in /particle folder.