Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
TNT particle engine emitter adds 10x10 to parent sprite. Unexpected behavior? — Gideros Forum

TNT particle engine emitter adds 10x10 to parent sprite. Unexpected behavior?

detourdetour Member
edited March 2013 in General questions
I guess this question is mainly for @GregBUG but anyone who can offer insight would be greatly appreciated.

I recently started playing around with TNT Particle Engine and its very fun and cool to play around with. However I noticed some unexpected behavior; adding an emitter alters the parent sprite's dimensions by 10x10. This seemed pretty odd since generally, adding a child sprite to a parent places it "within" the parent. For example, let's say I have TestSprite1. I add a 100x100 square. Then I add a second, 10x10 square. TestSprite1's dimensions are 100x100. Now I create TestSprite2 and add a 100x100 square and an emitter, TestSprite2 dimensions are 110x110. See attached file for example code demonstrating this.

I've tried setting the initial xPos, yPos settings for the emitter, as well as moving it using setPosition(). Where particles are emitted from is correctly changed but the extra 10x10 space is still there. Could someone please show me how I can avoid this? I want to add an emitter to a parent sprite without changing its dimensions.

zip
zip
tnt_test.zip
13K

Comments

  • hi @detour thanks for play with tnt particles!

    really i don't know about this problem...
    in tnt engine i only add particles and emitter as child of parent... (as you can see from sources)

    the strange things is that if you resize emitter sprite (i tried to resize emitter to 60x60px)
    parent sprite became 130x130px (not graphically resized anyway only getWidth() and getHeight() return wrong size) so half size of particle is added to parent sprite....


    i dont know if is related to Gideros SDK on tnt particles...

    investigating ...

    @atilim what do you think ?
    TNT ENGiNE for Gideors Studio - Particle Engine, Virtual Pad, Animator Studio, Collision Engine - DOWNLOAD NOW !!! IT'S FREE!!! -
    www.tntengine.com
  • oh... i think to find the problem...

    wait a little so i can confirm...
    TNT ENGiNE for Gideors Studio - Particle Engine, Virtual Pad, Animator Studio, Collision Engine - DOWNLOAD NOW !!! IT'S FREE!!! -
    www.tntengine.com
  • GregBUGGregBUG Guru
    Accepted Answer
    Ok. It's how i added particles to parent sprite...
    all particles are added to a new transparent sprite layer.. (that in your example is "over" your black box)
    and the particles are mid handled (setAnchorPoint(.5, .5))
    so particles child layer can not be perfect aligned with you box and getWidth and getHeigh return the new graphics bounds.

    for example try now your modded example and see that also in red box the is the same behavior of tnt particles engine.

    hope it helps.

    zip
    zip
    test.zip
    23K
    TNT ENGiNE for Gideors Studio - Particle Engine, Virtual Pad, Animator Studio, Collision Engine - DOWNLOAD NOW !!! IT'S FREE!!! -
    www.tntengine.com
  • atilimatilim Maintainer
    @GregBUG do you think I need to look at this issue? (getWidth()/getHeight())
  • GregBUGGregBUG Guru
    edited March 2013
    mmm.. for me getWidth/getHeight work fine...

    i mean if a i add a child to a parent and this child go outside the parent the new parent bounding box are parent+child.

    an example...


    if gideros will add a "clipping" for child that are outside the parent (so the "outside" part of child is not visible) i think is better that getWidth/height return original parent size (100,100)

    @all @atilim what do you think?
    example.png
    530 x 224 - 7K
    example2.png
    505 x 218 - 10K
    TNT ENGiNE for Gideors Studio - Particle Engine, Virtual Pad, Animator Studio, Collision Engine - DOWNLOAD NOW !!! IT'S FREE!!! -
    www.tntengine.com
  • Thank you @GregBUG this answers why its happening. I suppose I'll keep working on it to figure out how to position my sprites with this in mind.
Sign In or Register to comment.