mirror of
https://github.com/godotengine/godot.git
synced 2025-02-16 07:40:36 +00:00
Updated tutorial_canvas_transforms (markdown)
parent
4a932a0b3d
commit
e2dd4c019d
@ -42,4 +42,19 @@ Finally then, to convert a CanvasItem local coordinates to screen coordinates, j
|
||||
var screen_coord = get_viewport_transform() * ( get_global_transform() * local_pos )
|
||||
```
|
||||
|
||||
Keep in mind, however, that it is generally not desired to work with screen coordinates. The recommended approach is to simply work in Canvas coordinates (CanvasItem.get_global_transform()), to allow automatic screen resolution resizing to work properly.
|
||||
Keep in mind, however, that it is generally not desired to work with screen coordinates. The recommended approach is to simply work in Canvas coordinates (CanvasItem.get_global_transform()), to allow automatic screen resolution resizing to work properly.
|
||||
|
||||
### Feeding Custom Input Events
|
||||
|
||||
It is often desired to feed custom input events to the scene tree. With the above knowledge, to correctly do this, it must be done the following way:
|
||||
|
||||
```python
|
||||
|
||||
var local_pos = Vector2(10,20) # anything local
|
||||
var ie = InputEvent()
|
||||
ie.type=InputEvent.MOUSE_BUTTON
|
||||
ie.button_index=1 # left click
|
||||
ie.pos = get_viewport_transform() * ( get_global_transform() * local_pos )
|
||||
get_tree().input_event(ie)
|
||||
|
||||
```
|
Loading…
Reference in New Issue
Block a user