hitbox.tscn 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. [gd_scene load_steps=7 format=2]
  2. [ext_resource path="res://hitbox.gd" type="Script" id=1]
  3. [ext_resource path="res://target4.png" type="Texture" id=2]
  4. [ext_resource path="res://expand.gd" type="Script" id=3]
  5. [sub_resource type="RectangleShape2D" id=1]
  6. extents = Vector2( 32, 32 )
  7. [sub_resource type="Shader" id=2]
  8. code = "// NOTE: Shader automatically converted from Godot Engine 3.4.4.stable's CanvasItemMaterial.
  9. shader_type canvas_item;
  10. render_mode blend_mix;
  11. uniform float speed = 5f;
  12. vec2 rotateUV(vec2 uv, float rotation)
  13. {
  14. float mid = 0.5;
  15. return vec2(
  16. cos(rotation) * (uv.x - mid) + sin(rotation) * (uv.y - mid) + mid,
  17. cos(rotation) * (uv.y - mid) - sin(rotation) * (uv.x - mid) + mid
  18. );
  19. }
  20. void vertex() {
  21. UV= rotateUV((UV*0.75)+vec2(0.125),TIME*speed );
  22. }
  23. void fragment() {
  24. vec4 albedo_tex = texture(TEXTURE,UV);
  25. COLOR.rgb = albedo_tex.rgb + vec3(sin(TIME*10.0)/10.0);
  26. COLOR.a = albedo_tex.a;
  27. }
  28. "
  29. [sub_resource type="ShaderMaterial" id=3]
  30. shader = SubResource( 2 )
  31. shader_param/speed = 5.0
  32. [node name="hitbox" type="Area2D"]
  33. script = ExtResource( 1 )
  34. [node name="CollisionShape2D" type="CollisionShape2D" parent="."]
  35. shape = SubResource( 1 )
  36. [node name="Timer" type="Timer" parent="."]
  37. autostart = true
  38. [node name="Target4" type="Sprite" parent="."]
  39. modulate = Color( 2, 2, 0, 1 )
  40. material = SubResource( 3 )
  41. texture = ExtResource( 2 )
  42. [node name="expand" type="Node" parent="."]
  43. script = ExtResource( 3 )
  44. nodepath = NodePath("../Target4")
  45. [connection signal="body_entered" from="." to="." method="_on_hitbox_body_entered"]