How to setTexture to ParticleBatchNode from SpriteFrameCache's Texture?

Hi all !

Have a nice day , guys ! :grinning:

Currently , I have the ParticleBatchNode and I want to set texture for it !

auto batchNode = ParticleBatchNode::createWithTexture(nullptr, 200);
batchNode->setName(“batchNode”);
addChild(batchNode);

auto spriteFrame = SpriteFrameCache::getInstance()->getSpriteFrameByName(“money_icon.png”);

auto texture = spriteFrame->getTexture();

batchNode->setTexture(texture);

As you see , I trimmed small texture (“money_icon.png”) from large texture of SpriteSheet. I think the above code work fine !
But …OMG !.. :disappointed_relieved: the spriteFrame->getTexture() function gives me the whole texture of my sprite sheet, I want only 1 sprite’s texture from “money_icon” name. How can i do that ?

Thanks All !

You probably need to set the display sprite frame of your particle systems that you’re adding into the ParticleBatchNode.

1 Like

Hi thanks for your answer !

I solved this porblem !

In TexturePacker tool , I set Alorithm with Basic mode => the purpose is :
we don’t allow the image rotate in the SpriteSheet.

=> setTextureWithRec (or setDisplayFrame ) function will work well !

1 Like