C API: add sprite->setCenter() function

,

Lua API exposes a function sprite:setCenter() which allows changing the center-point of a Sprite, which affects position / rotation and collision detection.

The C API does not have this function. Working with pixel-accurate sprite positioning is more tedious this way, as I need to constantly do things like moveTo(x - sprite_width / 2, y - sprite_height / 2).

Would love to see setCenter added to the C API so I could mark top-left corner (0,0) for everything and handle the width / position myself.

EDIT: this missing function call was also raised before in another post, but I think was still overlooked because it was buried in a different bug report :slight_smile:

EDIT2: this request would include adding the getCenter equivalents as well, obviously

I'll do this now and schedule it for 2.1 (will have to wait for a minor release instead of a patch since it's an API addition). It's like five minutes of work, tops.. And you're exactly right, since it was coupled with that other collision issue it looked like it was going to take longer.

Though I should probably fix that, too. :thinking:

1 Like

Okay, done! And it looks like that collision thing was fixed a while back. Thanks for bringing this up! We've got a huge backlog of bugs to fix, and little simple things like this can get lost. It's nice to start out the day with an easy win. :smiley:

2 Likes