-
-
Notifications
You must be signed in to change notification settings - Fork 97
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 a project setting to automatically scale custom mouse cursors according to the viewport scale factor #11296
Comments
An easier workaround is to use var scale_factor: float = min(
(float(get_viewport().size.x) / get_viewport().get_visible_rect().size.x),
(float(get_viewport().size.y) / get_viewport().get_visible_rect().size.y)
) (The above snippet can be replaced by godotengine/godot#80965 in 4.4 onwards.) To avoid blurriness at high scale factors, you could start from an image that is tailored for the highest scale factor your game is designed to reasonably support (e.g. the scale factor used when playing on a 4K display), then scale down from that. |
This is a good workaround! Thanks. |
The warning is still accurate - you want to make sure your final cursor image size doesn't exceed 256×256 (128×128 on the web platform). For example, this means that on a hiDPI display at 200% scale, the physical size of the cursor image must not exceed 128×128 DPI-independent pixels (64×64 on the web platform). This is because the image data is internally 256×256 (128×128 on the web platform), and that's what the limitation affects. |
It will be good to clarify this (about physical size) in the documentation. |
The engine currently doesn't scale cursor images for you, so mentioning a notion of physical size would be misleading right now. |
Describe the project you are working on
A 2D twin-stick shooter.
Describe the problem or limitation you are having in your project
Currently, custom mouse cursors only work at a specific size, and do not scale according to the resolution of the game. This is great if it's being used for it's intended purpose. Unfortunately, you cannot use this to create a twin stick shooter crosshair for the mouse, as you cannot scale the mouse cursor dynamically with the resolution.
Describe the feature / enhancement and how it helps to overcome the problem or limitation
Currently, accomplishing this is extremely difficult, as using a sprite instead as a software cursor introduces input lag. Extending the custom mouse settings would make the process of creating a 2D crosshair much simpler, such as those in games like Noita and Nuclear Throne currently have.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
If this enhancement will not be used often, can it be worked around with a few lines of script?
This can be worked around by generating different cursors at all resolutions and then picking a proper one based on the resolution. This is extremely cumbersome to do, and is not future proof.
Is there a reason why this should be core and not an add-on in the asset library?
Not possible without lag using GDScript. Extends existing cursor logic rather than adding a new feature.
The text was updated successfully, but these errors were encountered: