arcade icon indicating copy to clipboard operation
arcade copied to clipboard

Requested Functionality - Sprite Mirroring

Open BrettskiPy opened this issue 4 years ago • 4 comments

Request: Sprites should be able to mirror itself.

Workarounds: PIL and textured pairs offer this functionality, but it can be misunderstood or overlooked by newer programmers.

Solution: Add something like Sprite.mirror()

BrettskiPy avatar Sep 13 '21 02:09 BrettskiPy

This was discussed on discord as well. It could be an idea to support all the flip functions Sprite currently support. The Texutre class could implement most of these functions. A big part of this is also making sure the texture atlas re-use the same texture instead of repeating it in the atlas itself.

There's definitely some cleanup that can be done around this. Still, this is kind of supported already by passing the texture parameter to Sprite, but I'm not sure how that works with hit boxes etc.

einarf avatar Sep 13 '21 02:09 einarf

Might look into this when we do the texture texture cache in 2.7. The main problem is that we need proper control of the cached images. When that is done it should be much easier to clone(), .mirror() and other things.

einarf avatar Apr 03 '22 01:04 einarf

Unless I misunderstood something, this can now be done in the dev branch by multiplying a channel of scale_xy by -1.

pushfoo avatar Jun 29 '22 04:06 pushfoo

Unless I misunderstood something, this can now be done in the dev branch by multiplying a channel of scale_xy by -1.

This is 100% correct

einarf avatar Jun 29 '22 08:06 einarf

You can just flip the texture on the sprite now and it's fast, self.texture = self.texture.flip_horizontally()

einarf avatar Feb 20 '23 04:02 einarf