HaxeFlixel / flixel

Free, cross-platform 2D game engine powered by Haxe and OpenFL
https://haxeflixel.com/
MIT License
1.92k stars 427 forks source link

Fix for brocken hitboxes, when scale < 0 #3163

Closed PurSnake closed 3 weeks ago

PurSnake commented 4 weeks ago

Makes _scaledOrigin values always positive

Geokureli commented 4 weeks ago

can you provide an small example of when the old code fails and the new code behaves as expected?

PurSnake commented 3 weeks ago

The fastest and most obvious example that I have without a debug interface (Yes, fnf) Before: https://github.com/HaxeFlixel/flixel/assets/56314743/64beda2d-5255-4773-be88-048eced8b44f

After: https://github.com/HaxeFlixel/flixel/assets/56314743/ca58045d-2bbd-4fa7-9399-0c8622ac43f8

Well, I think it’s already clear how it breaks down with a negative scale _scaledOrigin gets incorrect positions

Geokureli commented 3 weeks ago

I just need a small example code that I can take and run locally. The videos you shared look identical to me without context

PurSnake commented 3 weeks ago

boyfriend.scale.x *= -1; or

image Without: https://cdn.discordapp.com/attachments/1219255780172107814/1248303330577354792/1tc1eZ9.gif?ex=66632c92&is=6661db12&hm=c576c0ad323426f534b9b216c7c2edd2f3452f0a0b3d3588d7ad3b702c6b65e8&

With: https://cdn.discordapp.com/attachments/1219255780172107814/1248303359044227123/Ahy2amJ.gif?ex=66632c99&is=6661db19&hm=2f6c057d69725abd41d8b46d792a894f38133ea3fb767217b9a3dd5510ac01b7&

Geokureli commented 3 weeks ago

I understand now, in the future just use words to describe the unexpected behavior and provide simple code that reproduces it and things will move a lot faster

Geokureli commented 3 weeks ago

Also FYI, you should be using sprite.flipX and flipY instead of scaling it to -1. even with this fix, you still get issues where the hitbox isn't right