Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Question about TNT particle engine — Gideros Forum

Question about TNT particle engine

newbie2018newbie2018 Member
edited March 2018 in General questions
Hi, recently I test about TNT particle engine.
In general it works if it is created at "stage", but not inside another Sprite.
For example:
I have this inside by Item Sprite class
self.emitter_1 = CEmitter.new(0,0,0, self)
which means that, each Item Sprite would start its own particle system.

Note that original tutorial is something like:
self.emitter_1 = CEmitter.new(0,0,0, stage)
And when I add the Item Sprite in my scene (3 of them, side by side), the particle engine seems not working properly.


To explain a little further, if I touch from left to right, it works at the first time. BUT, at the 4th touch (on the first button), the particle/touch event fails to emit from the original button (but it emits from the rightest button)

I am curious I miss out anything?
Tagged:

Comments

  • piepie Member
    It's been some time I'm not using it, but last time I tried it was working. Maybe the problem is somewhere else: how do you trigger the emitters? if you could post a mini project to show us how is your setup and what happens it may help to help :)
  • Gideros has it's own particle system many times faster. I might take a look at the tnt emitter though in case we can convert it to the new system. Is the source available somewhere still?
    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
  • piepie Member
    @SinisterSoft here https://github.com/piretro/TNT-Particle-Engine-for-Gideros/blob/master/tntparticlesengine.lua

    Gideros particle system is performing better, but this one has a lot of options (and a super cool editor :D )
  • will take a look at modifying it to take advantage of the new particle sprite.

    Likes: newbie2018

    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
    +1 -1 (+1 / -0 )Share on Facebook
  • SinisterSoftSinisterSoft Maintainer
    Accepted Answer
    This seems to work ok. The only issue is when the particle texture isn't square.

    https://www.dropbox.com/s/lldszhwcai9r5hq/tntparticlesengine15.zip?dl=0

    Can you test it to see if it's faster?

    Likes: newbie2018

    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
    +1 -1 (+1 / -0 )Share on Facebook
  • piepie Member
    Wow @SinisterSoft how many times I thought about doing it... :) thank you! it seems to work pretty well!
    I will do some more tests and keep you updated!
    It's a pity to lose the rectangular textures since those were useful to achieve certain effects (ie. rays), but I suppose otherwise Particles may not work so well...

    Likes: newbie2018

    +1 -1 (+1 / -0 )Share on Facebook
  • You can still use them, but load them into something like photoshop and blank out the extra bits to make them square.
    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
  • Also, if you supply nil for the texture then it will use a circular particle. I'll add more stuff like square particles after you have tested it. I'll also update the maths to use the new operators we have added.

    Likes: pie

    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
    +1 -1 (+1 / -0 )Share on Facebook
  • Hi All, it is my bad for being away. I would post a mini project as soon as possible.
    By the way, when you guys say "Gidero's own particle System", do you mean the "Particle Candy"?

    Likes: newbie2018

    +1 -1 (+1 / -0 )Share on Facebook
  • Likes: newbie2018

    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
    +1 -1 (+1 / -0 )Share on Facebook
  • There is also another particle system in LiquidFun.
    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
  • @SinisterSoft
    Really Thanks for your inputs. Sure i would go through the Gidero's Particles now :) (i didn't know about that...)

    By the way, as promised, I have uploaded my mini project.
    Basically, after touching the third item (rightest one), the subsequent touch is erroneous...

    Let me know if i miss something....
    zip
    zip
    TestParticle.zip
    420K
  • SinisterSoftSinisterSoft Maintainer
    Accepted Answer
    @newbie2018 If you are using tntparticles then try the version 15 I linked to, it uses the new particle sprite so it should be faster.

    Likes: newbie2018

    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
    +1 -1 (+1 / -0 )Share on Facebook
  • piepie Member
    Accepted Answer
    @newbie2018 There you go :)

    I made some modifications and added some comments on those lines:

    Your issue was that you were checking hitTestPoint against self (the Item Sprite) which also hosted the particle effect - item was 100x100 px at the beginning, then, after particles emission it was a lot larger.
    You got only the third one "exploding" just because it was on top of the others - being put there last - (but its size was overlapping them)
    To fix this I just checked hitTestPoint against the bitmap (not the whole sprite)

    Then you had a couple things I changed because I think it may be cleaner this way:
    in home:init you added the items on stage instead of self, maybe this was intentional, I don't know your project :)

    you were creating a new emitter and new particles each time the item was pressed, maybe this was intentional too, but if the Items are not supposed to "die" on touch I believe that this may lead to memory leaks (local particles should be removed as soon as they are no longer referenced, but since the emitter is being overwritten each time who knows? I would not do it... :) )
    I don't know how the new release of tntparticleengine will perform yet, but I learned that it's much better to create emitters before, and use them as needed instead of creating them at the last time.

    last thing I did was adding
    self:getParent():addChild(self)
    to bring the Item Sprite on top of the others, thus keeping particles over the other items


    zip
    zip
    New Project pie.zip
    420K

    Likes: antix, newbie2018

    +1 -1 (+2 / -0 )Share on Facebook
  • @SinisterSoft Thank you :) v15 fixes that
    @pie Thanks to you too~ The explanation is very useful as it helps me understand better. Sure I would create the emitters first now.
    +1 -1 (+2 / -0 )Share on Facebook
  • piepie Member
    @SinisterSoft from my tests it seems to be working very well:
    version 1.14 - without using gideros Particles: 400 particle instances returns 48-51 fps
    version 1.15 - using gideros Particles on the same effect and device returns 59-60 fps

    For the tests I used png24 textured particles with alpha translucency - I suppose that using native particle shapes it may also be better.

    looking forward for the new math operators, let's see if I we can reach 600! :p I'm sorry that the applause smiley is no longer available because you (and obviously hgy29) totally deserved it :) thanks!
    +1 -1 (+3 / -0 )Share on Facebook
  • Here is v1.16 for you to try, it uses the new math operators.
    https://www.dropbox.com/s/0cup1t70358cg5g/tntparticlesengine16.zip?dl=0

    Likes: pie, MoKaLux

    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
    +1 -1 (+2 / -0 )Share on Facebook
  • piepie Member
    watch out v.1.16 at the top of the lua file and in file name is missing

    @SinisterSoft
    On the same test effect we have a slight improvement on RAM usage (13k) and probably the framerate is better since its value looks more stable.
    We can reach 600, but at a variable fps count of 57/59 :#

    Great job, thank you! :smile:

    I will soon release an updated tntfx on google: do you like me to publish the last tnt particle engine file on github or do you want to make a pull request on the already existing one?

    Likes: newbie2018

    +1 -1 (+1 / -0 )Share on Facebook
  • You can copy that one to github if you like.

    There are still loads of improvements to speed that can be made. I'll have a look after Gideros 2018.3 has been released.
    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
    +1 -1 (+4 / -0 )Share on Facebook
  • piepie Member
    Hi,
    for those who are interested I've just published TNTFX2 - featuring TNT Particle engine 1.16 support.
    Get it here:
    https://play.google.com/store/apps/details?id=com.piretro.TNTFX2

    :)
    +1 -1 (+3 / -0 )Share on Facebook
  • antixantix Member
    @pie thanks for sharing!

    It's very hard to operate. You seem to have made the project in landscape mode but are presenting the in app GUI in portrait mode. This has the unwelcome appearance of all system requests being in l;andscape mode, not portrait.
  • piepie Member
    @antix Why do you say so? Do you have some orientation problem with the TextInputDialogs?
    The app has always been portrait because I like one hand operations on phone :)
    I was thinking to do it landscape , but on small devices the collapsable menu goes out of the screen.
  • piepie Member
    @antix I saw what you mean, that's weird: I just checked the app is set to portrait and autorotation is set to off.
    It looks fine on s7 but on tabS TextInputDialogs are landscape oriented... I don't have a clue on what could be the reason for that.. on which device did you test it?

    Thank you
  • antixantix Member
    @pie my device is a Google Pixel-C and the app is in landscape somehow because when I swish for the menu bar.. it appears from the left side of the screen. That and as I said previously.. all the dialogs open in landscape too.
  • piepie Member
    The same happens on my tablet, but android menu bar appears on the right.. :#
    however the app is (should be) portrait, as it is on my phone.. it may be the letterbox scale mode, I will change it asap

    Likes: antix

    +1 -1 (+1 / -0 )Share on Facebook
Sign In or Register to comment.