Working with emitters I would like the ‘User’ to be able to load their own particle image.
The ‘Parameters’ for an emitter have an "emitter.textureFileName=“file.jpg” property which loads the image from the system.ResourceDirectory. Unfortunately we are not supposed to use that location.
So my plan was to load an image using media.selectPhoto then save it out to an app directory as “tmp.jpg”
where I would supply the path and file to the emitter parameter.
Below is the Listener from the media.select.
for testing i have put a “tmp.jpg” into system.ResourceDirectory and then I defined a variable “filename” to be “tmp.jpg” Then I can update the emitter.textureFileName and destroy/create a new emitter… Works fine…
What I don’t seem to be able to do is add a path to the system.DocumentsDirectory where the file will actually exist… Is it possible to do that?
Also, I thought that emitter.textureImageData= may have accepted a pre loaded image but it doesn’t seem to, cant really find anything about that one.
local function gotParticleListener( event ) local image = event.target --print("image.\_properties: " .. json.prettify( image.\_properties ) ) local particleImageGroup = display.newGroup() particleImageGroup:insert(image) if image then --Have Loaded new image, so save it out as "tmp.jpg" to a local device location display.save( particleImageGroup , { filename = "tmp.jpg" , baseDir = system.DocumentsDirectory}) --The file I would like to access with activeSampleCopy.textureFileName local filename = "tmp.jpg" --This "activeSampleCopy" below is a working copy of the current emitters options. --The parameters are changed throughout the app and applied on the fly or dispose/createnew emitter where neccesary activeSampleCopy.textureFileName = filename or activeSampleCopy.textureFileName -- This works fine where "filename" is defined above. -- tidy up particleImageGroup:removeSelf() particleImageGroup = nil -- create a new emitter with the modified options createEmitter() else haveNewParticle = false end return true end