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.
Comments
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 ?
www.tntengine.com
wait a little so i can confirm...
www.tntengine.com
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.
www.tntengine.com
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?
www.tntengine.com