Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add world-space FlxCamera rotation #3245

Closed
wants to merge 1 commit into from

Conversation

cyn0x8
Copy link

@cyn0x8 cyn0x8 commented Aug 25, 2024

implementation of world-space FlxCamera rotation via a new rotation:Float property (rotates about the center)

uses a new _rotationCanvas:Sprite to not interfere with current canvas behavior or whatever people might be doing with it

test.mp4

Note

this is my first pr here!! criticism and suggestions and changes are appreciated...
(especially on the margin calculation since the math was kinda figured out by trial & error)

@richTrash21
Copy link
Contributor

is there a reason why Sprite.__transform is used for rotation instead of Sprite.rotation? it also seems to break the flash target

@DetectiveBaldi
Copy link
Contributor

DetectiveBaldi commented Aug 26, 2024

i think there was an attempt to do this in #2679, but from what i could tell there was an issue where objects that would have been visible at a certain rotation, weren't
does this pr address this?

@cyn0x8
Copy link
Author

cyn0x8 commented Aug 26, 2024

i think there was an attempt to do this in #2679, but from what i could tell there was an issue where objects that would have been visible at a certain rotation, weren't does this pr address this?

yes, with the margin changes

@cyn0x8
Copy link
Author

cyn0x8 commented Aug 26, 2024

is there a reason why Sprite.__transform is used for rotation instead of Sprite.rotation? it also seems to break the flash target

Sprite.rotation seemed to be rotating it about the top left corner rather than the center when i was changing it? unsure if that was just a quirk in my test or not... but regardless im guessing itd be more performant than the matrix math so tomorrow ill try using that + translating the sprite if necessary to center the rotation

also i saw (before the workflow disappeared??) that Sprite.__transform doesnt seem to be present on flash target! changing to Sprite.rotation would fix that as well

@cyn0x8 cyn0x8 marked this pull request as draft August 26, 2024 03:39
@richTrash21
Copy link
Contributor

Sprite.rotation seemed to be rotating it about the top left corner rather than the center when i was changing it?

tested this myself and this problem was present. in that case it might be useful to look into Sprite.transform. using it's matrix variable i successfully recreated the rotation effect. this variable is also present in the flash target so theoretically it might also fix the flash target (can't say for sure because i didn't test it on flash).

one more thing: while testing i encountered a bug with resizing the window (affects fullscreen too). it seems to misplace the camera if rotation set to any value except 0

@Geokureli
Copy link
Member

FYI, we have a proposed way to introduce world-rotation, already, here: #2715
the idea is that we will be able to nest objects within objects that when rotated, rotate all the objects nested inside, as a bonus, this will allow us to easily apply the same transformations to the camera as well. Note in the section labelled "Advantages":

We could also give camera's a DrawContext, or its own orientation and color rendering information, that is applied to all sprites rendered to it, allowing cameras to have rotation (related to #2679)

It'll take longer to implement, but I'd rather go this route than make some adhoc field, like this.

I have to assume this is kind of a cheat that doesn't honor properties like sprite.isOnScreen and therefore wouldn't work with things like FlxBackdrop

@cyn0x8
Copy link
Author

cyn0x8 commented Aug 26, 2024

FYI, we have a proposed way to introduce world-rotation, already, here: #2715 the idea is that we will be able to nest objects within objects that when rotated, rotate all the objects nested inside, as a bonus, this will allow us to easily apply the same transformations to the camera as well. Note in the section labelled "Advantages":

We could also give camera's a DrawContext, or its own orientation and color rendering information, that is applied to all sprites rendered to it, allowing cameras to have rotation (related to #2679)

It'll take longer to implement, but I'd rather go this route than make some adhoc field, like this.

I have to assume this is kind of a cheat that doesn't honor properties like sprite.isOnScreen and therefore wouldn't work with things like FlxBackdrop

awesome! ill close the pr then

@cyn0x8 cyn0x8 closed this Aug 26, 2024
@cyn0x8 cyn0x8 deleted the flxcamera_rotation branch August 26, 2024 16:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants