libktx / ktx

Kotlin extensions for the libGDX game framework
https://libktx.github.io/
Creative Commons Zero v1.0 Universal
1.35k stars 71 forks source link

#479: add math Shape2D destructure extensions and MapRenderer use extension #480

Closed Quillraven closed 6 months ago

Quillraven commented 6 months ago

PR for #479

Unfortunately, the beginRender() and endRender() methods of the OrthogonalTiledMapRenderer are protected, which means we cannot call them directly. I never needed a custom renderer or had to override those methods. Also, they seem to never change in recent LibGDX versions. That's why I think "copy&pasting" their content is fine in this case. However, I still added a remark in the ReadMe.md that this can be a potential issue.

If you have a problem with it then feel free to remove those extensions :)

czyzby commented 6 months ago

Unfortunately, the beginRender() and endRender() methods of the OrthogonalTiledMapRenderer are protected, which means we cannot call them directly.

There's a cheesy way to get around this. Create a separate Kotlin file, set the package to match OrthogonalTiledMapRenderer (with a warning suppression that is doesn't match the folder structure :wink:), make utility functions or extension methods that call the beginRender() and endRender(), and finally use those in the use extension. This would call any overridden methods.

Quillraven commented 6 months ago

Unfortunately, the beginRender() and endRender() methods of the OrthogonalTiledMapRenderer are protected, which means we cannot call them directly.

There's a cheesy way to get around this. Create a separate Kotlin file, set the package to match OrthogonalTiledMapRenderer (with a warning suppression that is doesn't match the folder structure 😉), make utility functions or extension methods that call the beginRender() and endRender(), and finally use those in the use extension. This would call any overridden methods.

I did that trick now. Did not know about it and feels weird that this is even possible :) But a nice solution imo for this scenario.

czyzby commented 6 months ago

@Quillraven I missed that you've set the master as the target branch instead of develop. Can you set another PR to the develop branch? Sorry!