It looks like you're new here. If you want to get involved, click one of these buttons!
When using spawners with the "UseRelativeSpeed" flag along with scaling of parent objects, rotation is applied before scaling. This can cause problem when using scaling to flip objects. Taking "The Beginner's Guide to Orx" as an example where we use scaling to flip the hero and set the "UseRelativeSpeed" flag to "spawner" in the "BulletSpawner" section. If a non-zero rotation is applied to the hero, the bullets won't fly in the right direction when the hero is flipped. Just as shown below,
This is because the parent object's scale is applied piror to the its rotation, which can be seen from the code in "orxSpawner.c:823",
orxVector_Mul(&vSpeed, orxVector_2DRotate(&vSpeed, &(pstSpawner->vSpeed), pstSpawner->fPendingRotation), pstSpawner->pvPendingScale);
This problem can be solved by modifying the line to
orxVector_2DRotate(&vSpeed, orxVector_Mul(&vSpeed, &(pstSpawner->vSpeed), pstSpawner->pvPendingScale), pstSpawner->fPendingRotation);
All three similar lines in the switch statement should be modified accordingly. Then the direction of bullets will correctly follow the direction of hero.
Comments
Hi @Tang and welcome here.
Thank you for reporting this issue in much details, including the screenshots, it's much appreciated.
I'll update the code before the end of the week.
I've been doing some testing tonight, and I think the current behavior is indeed incorrect but it's still incorrect, in a different way, with the proposed fix.
I'll post an example later over the weekend after further testing.
After more reflection, I think your proposal is the correct one as it'll mimic the order of transformations as they happen in frames: scale then rotation.
I'll submit the changes shortly. Thanks again for the report.
And it's been pushed!
Thanks for the quick update!