JohnSundell / ImagineEngine

A project to create a blazingly fast Swift game engine that is a joy to use 🚀
Other
1.82k stars 105 forks source link

Rotate Actor around pivot point. #164

Open fortmarek opened 6 years ago

fortmarek commented 6 years ago

I would like to rotate Actor with UIImage to rotate around a defined pivot point but I have not been able to find how to achieve this.

When I tried to find a solution, the best answer was this: https://stackoverflow.com/questions/27658454/swift-rotating-an-image-in-an-uiimageview-defined-in-the-main-storyboard

What I am trying to achieve:

demo

Alex88WH commented 6 years ago

Hey there @fortmarek I figured that out jan-31-2018 18-09-22 Check out CALayer's anchorPoint. Actor has a private layer property. Just set a new value (create a public variable 😁 ). EDIT: if you need more info just let me know

fortmarek commented 6 years ago

Thanks! Maybe it would be great if this was made available as a public property, @JohnSundell? 😄

JohnSundell commented 6 years ago

@fortmarek Yeah sounds great, feel free to implement it as a public property on Actor and send a PR👍 Just like opacity, cornerRadius etc it can just forward the value directly to the layer 🙂

JohnSundell commented 6 years ago

Just one thing to keep in mind is that this property may behave a bit differently on macOS compared to iOS+tvOS, due to coordinate system differences. Just something to test for as this is being implemented 🙂