paper_list.cs (547B)
1 using Godot; 2 3 public partial class paper_list : Area2D { 4 5 [Export] public 6 float offset = 300f; 7 [Export] public 8 float speed = 5f; 9 10 float init_y; 11 float target_y; 12 13 public override void _Ready() { 14 init_y = Position.Y; 15 target_y = init_y; 16 17 MouseEntered += on_enter; 18 MouseExited += on_exited; 19 } 20 21 public override void _Process(double delta) { 22 float y = Mathf.Lerp(Position.Y, target_y, speed * (float)delta); 23 Position = new Vector2(Position.X, y); 24 } 25 26 void on_enter() { 27 target_y = init_y + offset; 28 } 29 30 void on_exited() { 31 target_y = init_y; 32 } 33 34 }