-
-
Notifications
You must be signed in to change notification settings - Fork 9
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
Responsive layout improvements #119
Conversation
@@ -31,6 +64,10 @@ message RiveModelDesc | |||
optional bool create_go_bones = 6 [default=false]; | |||
optional string artboard = 7; | |||
|
|||
optional CoordinateSystem coordinate_system = 8 [default = COORDINATE_SYSTEM_FULLSCREEN]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a good name for the setup? Basically what I want to achieve is to be able to position things together with defold content in the same coordinate system as well as position things according to the .riv files themselves, using the alignment options that are available in the Rive API. Not sure the naming here is good thoug, should it be something like "Game" / "GUI"? "Game" / "Rive Alignment"? 🤷
@@ -1,115 +1,240 @@ | |||
-- Copyright 2020-2024 The Defold Foundation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to use the new render script
float normalized_x = x / g_OriginalWindowWidth; | ||
float normalized_y = 1 - (y / g_OriginalWindowHeight); | ||
|
||
rive::Vec2D p_local = component->m_InverseRendererTransform * rive::Vec2D(normalized_x * window_width, normalized_y * window_height); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Save the transform used in the renderer for this artboard (will this actually be a frame late?) and use the inverse to place the x,y in the same space as the artboard.
There's some hoops here because input.x and input.y are in the projects window coordinates it seems, and we want actual screen coordinates here. If we use the x,y as is, resizing the window will break the input, so we need to normalize the coordinates first.
New:
rive.get_projection_matrix()
Fixes:
Fixes #118
Fixes #115
Fixes #113