can bullets have puppet strings?
This commit is contained in:
parent
5f732e1e6f
commit
6809a3733a
9 changed files with 55 additions and 8 deletions
37
systems/bullets/bullet.gd
Normal file
37
systems/bullets/bullet.gd
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
@tool
|
||||
class_name Bullet
|
||||
extends Area2D
|
||||
|
||||
|
||||
static var _hitbox_shapes: Dictionary[Vector2i, RectangleShape2D] = {}
|
||||
|
||||
|
||||
@export var texture: Texture2D:
|
||||
set(value):
|
||||
texture = value
|
||||
queue_redraw()
|
||||
|
||||
@export var hitbox_size: Vector2i:
|
||||
set(value):
|
||||
hitbox_size = value
|
||||
if not _hitbox_shapes.has(hitbox_size):
|
||||
var new_shape = RectangleShape2D.new()
|
||||
new_shape.size = hitbox_size
|
||||
_hitbox_shapes[hitbox_size] = new_shape
|
||||
_hitbox.shape = _hitbox_shapes[hitbox_size]
|
||||
|
||||
|
||||
var _hitbox: CollisionShape2D = CollisionShape2D.new()
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
_hitbox.debug_color.a = 0.0
|
||||
add_child(_hitbox)
|
||||
|
||||
|
||||
func _draw() -> void:
|
||||
draw_texture(texture, -texture.get_size() * 0.5)
|
||||
|
||||
|
||||
func _get_configuration_warnings() -> PackedStringArray:
|
||||
return []
|
||||
1
systems/bullets/bullet.gd.uid
Normal file
1
systems/bullets/bullet.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://ntpaank0h0a0
|
||||
Loading…
Add table
Add a link
Reference in a new issue