Advertisement
nezvers

Godot animation speed test SCENE

Jan 7th, 2022
392
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. [gd_scene load_steps=4 format=2]
  2.  
  3. [ext_resource path="res://icon.png" type="Texture" id=1]
  4.  
  5. [sub_resource type="GDScript" id=2]
  6. script/source = "extends Node2D
  7.  
  8. onready var anim: = $AnimationPlayer
  9.  
  10. const slow: = 1.0
  11. const fast: = 2.0
  12.  
  13. func _input(event:InputEvent)->void:
  14. if event is InputEventMouseButton:
  15. if event.button_index == 1:
  16. if event.pressed:
  17. anim.playback_speed = fast
  18. else:
  19. anim.playback_speed = slow
  20.  
  21.  
  22. "
  23.  
  24. [sub_resource type="Animation" id=1]
  25. resource_name = "Spin"
  26. loop = true
  27. tracks/0/type = "bezier"
  28. tracks/0/path = NodePath("Sprite:rotation_degrees")
  29. tracks/0/interp = 1
  30. tracks/0/loop_wrap = true
  31. tracks/0/imported = false
  32. tracks/0/enabled = true
  33. tracks/0/keys = {
  34. "points": PoolRealArray( 0, -0.25, 0, 0.25, 0, 360, -0.25, 0, 0.25, 0 ),
  35. "times": PoolRealArray( 0, 1 )
  36. }
  37.  
  38. [node name="Node2D" type="Node2D"]
  39. script = SubResource( 2 )
  40.  
  41. [node name="AnimationPlayer" type="AnimationPlayer" parent="."]
  42. autoplay = "Spin"
  43. anims/Spin = SubResource( 1 )
  44.  
  45. [node name="Sprite" type="Sprite" parent="."]
  46. position = Vector2( 169, 113 )
  47. texture = ExtResource( 1 )
  48.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement