It appears that when you call setClip() on a Sprite, the clip coordinates are calculated from the Sprites AnchorPoint, not it's top left pixel. Is this by design?
It's kind of strange to have to make all sorts of silly offsets just to set clipping for a Sprite that is not being handled by its top left pixel (to me anyway).
Comments
Likes: antix
Likes: MoKaLux
Doesn’t that sounds correct ?
as I said though I'll just use Sprites anchored at 0, 0 for ease of use
Fragmenter - animated loop machine and IKONOMIKON - the memory game
Likes: MoKaLux
Fragmenter - animated loop machine and IKONOMIKON - the memory game
Fragmenter - animated loop machine and IKONOMIKON - the memory game
Also Bitmap behaves differently when setAnchorPoint is used (legacy specific behavior), so it may well not work as expected with setClip()
You can see by just changing the AnchorPosition, it doesn't work as I expected. But that's all good because as I already said.. I'll just not use AnchorPositions.
e.g., try to comment/uncomment the relevant lines to see the difference (i used a 120x120 bitmap):
Likes: MoKaLux
Fragmenter - animated loop machine and IKONOMIKON - the memory game
Fragmenter - animated loop machine and IKONOMIKON - the memory game
perhaps in setClip there could be a last optional variable which if set to true, then disregards the anchorpoint?
Fragmenter - animated loop machine and IKONOMIKON - the memory game
EDIT: it seems Sprite also has a setAnchorPoint function, although it is not documented.
Because of this, for @antix there is an even easier workaround, just use Pixel.new(r) instead of Bitmap.new(r) and then setAnchorPoint also works as you want.
Fragmenter - animated loop machine and IKONOMIKON - the memory game
Dislikes: theone10
Fragmenter - animated loop machine and IKONOMIKON - the memory game
With regards to Pixels and BitMaps.. I thought on a pure performance level that BitMaps were faster than Pixels overall. This is why I use them.. unless I'm mistaken (as is usually the case)
Fragmenter - animated loop machine and IKONOMIKON - the memory game
Likes: keszegh
Likes: hgy29
https://deluxepixel.com