-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
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
Conversion function for screen coords to local Canvas coords #4854
Conversation
Use as so:
func useCoord(screen_coord):
var local_coord = make_canvas_pos_local(screen_coord)
# Do whatever you want with coord that is now local to
# the CanvasItem you called this in! |
52c22f1
to
293bc93
Compare
there is but i guess this is probably a little easier to use, maybe you could rename it to make_canvas_pos_local() |
Yes I can rename however you'd like for the SDK. Yes, I think users new to On Mon, Jun 6, 2016 at 4:42 PM, Juan Linietsky notifications@github.com
|
yeah agreed, forcing them to use linear algebra may be too much |
if you manage to rename it, let me know and I will merge |
Thanks for I have to ask: What would be a way to get the WorldToScreen coords? |
- Useful if you need to Convert screen coords to the coordinate space of a CanvasItem, but don't have an associated InputEvent to use in #make_event_local. For example, if you have a particular point on the screen you'd like to project into World Space, for various reasons, you would use this function on the root of the scene. This is analogous to ray casting from screen space in 3D.
Sorry for the delay in editing this. @EdwardAngeles You'd just make, the root of your Scene, a Canvas2D node and call the inverse of this. It would be: var screen_pos = (get_canvas_transform() * get_global_transform())* world_pos @reduz Does it make sense to make a function for this? It could be |
293bc93
to
605193b
Compare
@EdwardAngeles if you'd like a convenience function |
@Razzlegames That sounds like a good idea. Thanks! |
@@ -7328,6 +7328,22 @@ | |||
</description> | |||
</method> | |||
<method name="update"> |
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.
Breaks the XML, @akien-mga (found by @vnen )
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.
Fixed by 98eec17.
Fix the addition in #4854 which added elements in the wrong place.
associated InputEvent to use in #make_event_local.
For example, if you have a particular point on the screen you'd like to project into World Space, for various reasons, you would use this function on the root of the scene. This is analogous to ray casting from screen space in 3D.