-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
34 changed files
with
1,160 additions
and
1,164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ export_presets.cfg | |
# Mono-specific ignores | ||
.mono/ | ||
.vscode/ | ||
*.sln | ||
data_*/ | ||
mono_crash.*.json | ||
*.code-workspace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 17 additions & 17 deletions
34
GodotEngine.Utility/Extension/Camera2D_GD_CB_Extension.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,22 @@ | ||
using Cobilas.GodotEngine.Utility; | ||
|
||
namespace Godot { | ||
public static class Camera2D_GD_CB_Extension { | ||
public static Vector2 ScreenToWorldPoint(this Camera2D C, Vector2 mousePosition) { | ||
Rect2 rect; | ||
Vector2 size = Screen.CurrentResolution * C.Zoom; | ||
mousePosition *= C.Zoom; | ||
if (C.AnchorMode == Camera2D.AnchorModeEnum.DragCenter) | ||
rect = new Rect2(C.Position - size * .5f, size); | ||
else rect = new Rect2(C.Position, size); | ||
return mousePosition + Vector2.Right * rect.Left() + Vector2.Down * rect.Top(); | ||
} | ||
namespace Godot; | ||
|
||
public static Vector2 WorldToScreenPoint(this Camera2D C, Vector2 position) { | ||
Vector2 rect = C.Position; | ||
if (C.AnchorMode == Camera2D.AnchorModeEnum.DragCenter) | ||
rect = C.Position - (Screen.CurrentResolution * C.Zoom) * .5f; | ||
return position - rect; | ||
} | ||
public static class Camera2D_GD_CB_Extension { | ||
public static Vector2 ScreenToWorldPoint(this Camera2D C, Vector2 mousePosition) { | ||
Rect2 rect; | ||
Vector2 size = Screen.CurrentResolution * C.Zoom; | ||
mousePosition *= C.Zoom; | ||
if (C.AnchorMode == Camera2D.AnchorModeEnum.DragCenter) | ||
rect = new Rect2(C.Position - size * .5f, size); | ||
else rect = new Rect2(C.Position, size); | ||
return mousePosition + Vector2.Right * rect.Left() + Vector2.Down * rect.Top(); | ||
} | ||
|
||
public static Vector2 WorldToScreenPoint(this Camera2D C, Vector2 position) { | ||
Vector2 rect = C.Position; | ||
if (C.AnchorMode == Camera2D.AnchorModeEnum.DragCenter) | ||
rect = C.Position - (Screen.CurrentResolution * C.Zoom) * .5f; | ||
return position - rect; | ||
} | ||
} |
Oops, something went wrong.