How to configure the mouse wheel (or any button!) to zoom in and out on 2D Godot games.
Code v1:
var ZoomSpeed = Vector2(0.1,0.1)
if Input.is_action_just_released("Scroll Up"):
zoom += ZoomSpeed
if Input.is_action_just_released("Scroll Down"):
zoom -= ZoomSpeed
Code v2:
var ZoomSpeed = Vector2(0.1,0.1)
var MinZoom = Vector2(0.4, 0.4)
var MaxZoom = Vector2(1,1)
if Input.is_action_just_released("Scroll Up"):
zoom = clamp(zoom, MinZoom, MaxZoom) + ZoomSpeed
if Input.is_action_just_released("Scroll Down"):
zoom = clamp(zoom, MinZoom, MaxZoom) - ZoomSpeed
Негізгі бет Godot 4 Tutorial: Configure Zoom Using the Mouse Wheel
Пікірлер: 6