1
\$\begingroup\$

I was wondering how one would go about duplicating the same sprite in SFML, instead of having to create new sprites every time I would want have another sprite of the same image. Just some basic thought process or pseudo-code is what I'm looking for.

Thanks.

\$\endgroup\$
3
\$\begingroup\$

Well,

The whole idea of SFML sprites is to share a heavyweight object (texture) between all lightweight(sprite) that requires it. That is already the arguably best way.

Of course, there is one alternative, you can reuse the same sprite by just sharing it across your entities, and each one sets a new tranform before re-rendering the sprite. Im not even sure if that is anyway better than the first method, but seems to be what you want.

| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.