Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Particular Particles v2.1.2 - Randomizer and export of particle effects

BriarfoxBriarfox Mod
edited October 2013 in Code Sharing Posts: 1,542

Particular Particle is written by @stavrogin and edited by @briarfox

Get Particular Particle Here!

Particular Particles is a particle system editor that saves and exports particle effects.

  1. Include Particular Particle in your project.

  2. Save any particle effects from within Particular Particle.

  3. Click on the SavedOutput tab and copy the generated particle class and paste into your project tab.

-Note you can change the Texture here.

--Example Saved Particle
Example = class(Particular)
    Example.settings = {}
        Example.settings.img = "SpaceCute:Planet" --Set Texture Here
        Example.settings.partPerSec = 67
        Example.settings.sizeX = 203
        Example.settings.sizeY = 199
        Example.settings.life = 70
        Example.settings.lifeVariation = 93
        Example.settings.initPartSize = 1
        Example.settings.partSizeVariation = 54
        Example.settings.finalPartSize = 36
        Example.settings.velocity = 38.8692
        Example.settings.velocityVariation = 37
        Example.settings.rotSpd = 0.0806016
        Example.settings.rotSpdVariation = 67
        Example.settings.initOpacity = 164
        Example.settings.opacityVariation = 63
        Example.settings.finalOpacity = 213
        Example.settings.windX = -48
        Example.settings.airResistance = 0.541878
        Example.settings.gravity = -3.6593
        Example.settings.useGravityVector = 0
        Example.settings.sizeWiggle = 1
        Example.settings.turbulencePosAffect = 0
function Example:init(x,y)
    Particular.init(self,x,y,Example.settings)
end
--Example


  1. To create a particle in your project:
function setup()

example = Example(WIDTH/2,HEIGHT/2)

end

function draw()
example:draw()

end

Comments

  • BriarfoxBriarfox Mod
    edited June 2013 Posts: 1,542

    --Reserved for revisions--

    If there is enough interest I'll keep working on this. I would like to add a pause and reset in the future.

  • Posts: 175

    Very cool, well done! I can see this being very useful. You could go a step further with the saved output and save it to a class inheriting from Particular.


    Example = class(Particular) Example.settings = {} function Example:init(x,y,strSprite) Particular.init(self,x,y,strSprite,Example.settings) end
  • BriarfoxBriarfox Mod
    Posts: 1,542

    Great idea! I'll do that tonight.

  • IgnatzIgnatz Mod
    Posts: 5,396

    @Briarfox - I think you break the record for the number of object properties ;)

    thanks!

  • BriarfoxBriarfox Mod
    Posts: 1,542

    @ignatz, I just added 3 :)

  • IgnatzIgnatz Mod
    Posts: 5,396

    you better watch out, I think Codea has a limit of 4,096

  • Posts: 140

    @Briarfox, this is awesome! You may, however, want to check the inputted particle name for illegal characters (like spaces). That's if you want to make it idiot-proof. For instance, I used "Space Debris" as the name of my first saved particle. It saved fine, but it gave me an error when I tried to run it again--it didn't like the space between the two words. I guess you could also just warn people.

  • BriarfoxBriarfox Mod
    Posts: 1,542

    @Ric_Esrey good point, I'll add in a check. Glad you like it. I found it while digging through the forums. A few tweeks really make it useable!

  • BriarfoxBriarfox Mod
    edited June 2013 Posts: 1,542

    Particular Particle has been updated. SavedOutput now outputs classes.

    example = Example(x,y)

    example:draw()

  • BriarfoxBriarfox Mod
    edited June 2013 Posts: 1,542

    Small update.

    The Texture image is now saved in output. You can change the texture in the SaveOutput tab.

    I apologize to anyone who has already implemented a previous version. The init no longer passes a texture string.

    To manually change the texture on the fly do:

    e = Example(x,y)
    e.particularMesh.texture = Your Texture

  • Posts: 140

    @Briarfox, I'm having a problem with the new version. When I load a particle parameter set and then save it again, I receive an error. It says, Error: ... 379: Attempt to concatenate field 'texture' (a userdata value). Is this a bug or user error?

  • BriarfoxBriarfox Mod
    Posts: 1,542

    @Ric_Esrey Did you try deleting all the saved particles from SavedOutput?

  • BriarfoxBriarfox Mod
    edited June 2013 Posts: 1,542

    This issue is with readImage() in SavedOutput. I added readImage() to make texture selection easier. However this converts the spritekey which breaks if you reload it. To keep any previous saves remove readImage() in SavedOutput but leave the spritekey string.

    edit: Svae/Load has been fixed.

  • Posts: 140

    @Briarfox, It works great now. Thanks for the fast fix.

  • edited June 2013 Posts: 80

    This is awesome. Thanks for sharing. I hackd in hacked in uv offsets.
    First I added in the init

    self.u = u or 0

    self.v = v or 0

    self.width = width

    self.height = height

    Right after every line:

     self.particularMesh:setRect(i,p.x,p.y,size,size,p.angle)
    

    Then I add:

     self.particularMesh:SetRectTex(1,self.u,self.v,self.width,self.height)
    

    Now I can use an atlas map for the images in the particles.

  • IgnatzIgnatz Mod
    Posts: 5,396

    @Briarfox - this looks really cool - so what am I doing wrong?

    I have it loaded and I run it, and I get all the parameters at left, nothing on the screen. If I choose Random, the screen flashes occasionally. If I set Draw_Emitters to 1, I get a blue dot on the screen, but nothing else.

    I presume I'm supposed to be seeing a preview of how it will look, but for some reason, that's not happening. Any suggestions? (It's interesting that when I flick between full screen and parameter view, I glimpse the particle effect briefly!).

    Also, it's not clear to the first timer (ie me) what happens after you output a result. I presume you need to copy that class, plus the Particular tab, to your own project, then create instances of your class (the only difference between them being x,y position) and just draw them. That process works, when I try it (and I do see the effect on screen), so I think I answered my own question.

  • BriarfoxBriarfox Mod
    edited June 2013 Posts: 1,542

    @Thwapp I'm not following you, can you post a video of the result?

    @Ignatz I have no idea why it wouldn't be working correctly. Can you try installing it again? To use the particle include Particular Particle as a library. Then copy and saved particles from SavedOutput into a tab in your project. Then create an instance of your particle and add its draw to draw()

    I just pulled the project and it's running. Not sure why you have an issue with displaying.

  • Posts: 140

    @Ignatz, the blue dot on the screen, when Draw_Emitters is set to 1, is correct behavior. I presume it's telling you where the particles are starting from. However, the fact that no particles show up is strange. Do you think there's a problem with your textures? For instance, in the Function PresetSmoke(), the texture assigned is: emitter.ParticleMesh.Texture = "Cargo Bot:Smoke Particle". If your Cargo Bot graphics are bad, you wouldn't see the preview.

  • BriarfoxBriarfox Mod
    Posts: 1,542

    @Ignatz Do any of the other presets work?

  • IgnatzIgnatz Mod
    edited June 2013 Posts: 5,396

    My Cargo-Bots are fine, and none of the presets work. I am on the latest beta, has anyone else checked it with that?

    I reinstalled the particle code, rebooted the iPad, no luck.

  • edited June 2013 Posts: 80

    @Briarfox. Well it is not exactly working as soon as I fix it I will post a video and the relavant code. My change, when done, should texture the particle rectangle with only part of the image associated to it with the setRecTex command

    I added the line:

    self.particularMesh:SetRectTex(i,self.u,self.v,self.width,self.height) after you create the rectangles. self.u and self.v are the starting cordinates in the atlas map. and self.height and self.width are the how many pixels to use from the u and v coordinates. This way you can use an image as an atlas map instead of loading in several images for each newly created particle.

    The rational behind this is if you pass in a list of vec2s you can animate the particles image by updating the index of that list. So, your fire preset could use cycle through images to create a more realistic flame. I will try to implement this to your class tomorrow.

    I am just changing the x value of the setRecTex command in the video.

    https://www.dropbox.com/s/r305sa0dtxued1c/IMG_0066.mp4

  • Jmv38Jmv38 Mod
    edited June 2013 Posts: 3,297

    @ignatz any relation with the fact that setContext + sprite is broken in the current beta? You could revert to a previuos version (testFlight allows that).

  • IgnatzIgnatz Mod
    Posts: 5,396

    I think that might be the problem, but I'll just wait for the fix

  • BriarfoxBriarfox Mod
    Posts: 1,542

    I've added a sprite picker. It's a little clunky and requires a doubletap to select a sprite. I'm unsure on any other way to distinguish between scrolling and selecting.

  • edited June 2013 Posts: 1,976

    @Briarfox My sprite picker distinguishes scrolling and selecting by how far away the touch is when it ended from when it started.

    Edit: Your sprite picker is much faster than mine...

  • BriarfoxBriarfox Mod
    Posts: 1,542

    Good idea, I'll try and handle scrolling/touch like that.

    I looked over your code, got the idea of it and started playing with it :)

  • Posts: 2,161

    If you look in my touch class you'll see that I distinguish a tap by whether or not it moved and whether or not the end came within half a second of the start.

  • Posts: 1,976

    I've been working on my sprite picker and might have a new version in a little bit.

  • BriarfoxBriarfox Mod
    Posts: 1,542

    Removed double tap!

  • IgnatzIgnatz Mod
    Posts: 5,396

    The new beta fixes the problem I was having

  • BriarfoxBriarfox Mod
    Posts: 1,542

    Awesome @ignatz so what do you think?

  • IgnatzIgnatz Mod
    edited June 2013 Posts: 5,396

    @-)
    :-O
    :D
    =D>
    boy, you make good tools! Well done!

  • BriarfoxBriarfox Mod
    Posts: 1,542

    Minor update to fix scrolling and added Loading output to show that it is indeed loading a spritepack.

  • Posts: 175

    Just updated, very nice tool! and nice use of coroutines on the sprite loader ;)

  • BriarfoxBriarfox Mod
    Posts: 1,542

    Lets just say, someones post inspired me :)

  • IgnatzIgnatz Mod
    Posts: 5,396

    but here's something interesting

    take out the coroutine.yield() inside the loops in setImages, and instead, put it after the loop, immediately before coroutine.yield(grid)

    Then the pix load 2-3 times faster.

  • BriarfoxBriarfox Mod
    Posts: 1,542

    Thanks Ignatz, I should have caught that! updated with the fix.

  • BriarfoxBriarfox Mod
    Posts: 1,542

    Added an update notification that lets you update Particular Particles if an update is detected on the gist.

  • Posts: 68

    Tanks @stavrogin and @briarfox :)

  • BriarfoxBriarfox Mod
    Posts: 1,542

    @Diablo76 Glad you found it useful! Very good looking game!

  • BriarfoxBriarfox Mod
    Posts: 1,542

    Updated to use Codea Community.

Sign In or Register to comment.