playdate.graphics.sprite:setPositionFilter( function )

One feature that might be useful is a "position filter" for a sprite. The difference between this and filtering the coordinates and then calling moveTo() is that the sprite knows the "real" coordinates, which means it would be able to play nicely with animators and such, and that it would know where it is "supposed" to be.

One possible way to implement it is to have a setPositionFilter( function ) or have a sprite.PositionFilter() function which could be overridden in a derived class. This could be a lot more flexible since the coder could then have logarithmic grid snapping or snapping along a sine curve or always lock the x or y value of the sprite, but still know where it is.

Nevermind. This can easily be accomplished in a child class. eg:

function MySpriteClass:MoveTo( xx, yy )
    MySpriteClass.super.moveTo( self, xx*3, yy*3 )
end
1 Like