fix: runtime-load actor sprites (was preload) — stale import cache no longer breaks scripts
A stale/incomplete Godot import cache made preload() of the sprite textures fail at COMPILE time, killing the actor scripts entirely — no movement, no draw, near-black screen (reported on the Mac editor after pull). Switching preload -> runtime load() degrades a missing texture to an invisible sprite instead of a dead script; movement and logic always survive. Committed state was verified sound via fresh clone (imports + main scene + smoke all clean); this hardens against the cross-machine cache-lag failure mode. Smoke 3/3 green.
This commit is contained in:
@@ -9,16 +9,15 @@ extends Area2D
|
|||||||
@export var knockback := 220.0
|
@export var knockback := 220.0
|
||||||
@export var lifetime := 0.8
|
@export var lifetime := 0.8
|
||||||
|
|
||||||
const SPRITE := preload("res://assets/sprites_ph/slug_ph.png")
|
|
||||||
|
|
||||||
var direction := Vector2.RIGHT
|
var direction := Vector2.RIGHT
|
||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
add_to_group("projectiles")
|
add_to_group("projectiles")
|
||||||
rotation = direction.angle()
|
rotation = direction.angle()
|
||||||
|
# Runtime load, not preload — resilient to a stale import cache.
|
||||||
var spr := Sprite2D.new()
|
var spr := Sprite2D.new()
|
||||||
spr.texture = SPRITE
|
spr.texture = load("res://assets/sprites_ph/slug_ph.png")
|
||||||
add_child(spr)
|
add_child(spr)
|
||||||
body_entered.connect(_on_body_entered)
|
body_entered.connect(_on_body_entered)
|
||||||
|
|
||||||
|
|||||||
+4
-4
@@ -16,14 +16,14 @@ var hull: float
|
|||||||
var _dash := Vector2.ZERO
|
var _dash := Vector2.ZERO
|
||||||
|
|
||||||
|
|
||||||
const SPRITE := preload("res://assets/sprites_ph/m03_ph.png")
|
|
||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
add_to_group("mech")
|
add_to_group("mech")
|
||||||
hull = hull_max
|
hull = hull_max
|
||||||
|
# Runtime load (not preload): a stale/incomplete import cache must
|
||||||
|
# degrade to an invisible sprite, never a script-compile failure
|
||||||
|
# that would kill movement too.
|
||||||
var spr := Sprite2D.new()
|
var spr := Sprite2D.new()
|
||||||
spr.texture = SPRITE
|
spr.texture = load("res://assets/sprites_ph/m03_ph.png")
|
||||||
add_child(spr)
|
add_child(spr)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+2
-3
@@ -4,8 +4,6 @@ extends Area2D
|
|||||||
## levels). Drifts to the mech inside the magnet radius, collected on
|
## levels). Drifts to the mech inside the magnet radius, collected on
|
||||||
## contact, fades out if ignored. Constructed in code, no scene.
|
## contact, fades out if ignored. Constructed in code, no scene.
|
||||||
|
|
||||||
const SPRITE := preload("res://assets/sprites_ph/scrap_ph.png")
|
|
||||||
|
|
||||||
var value := 1
|
var value := 1
|
||||||
var magnet_radius := 70.0
|
var magnet_radius := 70.0
|
||||||
var drift_speed := 150.0
|
var drift_speed := 150.0
|
||||||
@@ -25,8 +23,9 @@ func _ready() -> void:
|
|||||||
sh.radius = 6.0
|
sh.radius = 6.0
|
||||||
cs.shape = sh
|
cs.shape = sh
|
||||||
add_child(cs)
|
add_child(cs)
|
||||||
|
# Runtime load, not preload — resilient to a stale import cache.
|
||||||
_sprite = Sprite2D.new()
|
_sprite = Sprite2D.new()
|
||||||
_sprite.texture = SPRITE
|
_sprite.texture = load("res://assets/sprites_ph/scrap_ph.png")
|
||||||
add_child(_sprite)
|
add_child(_sprite)
|
||||||
body_entered.connect(_on_body_entered)
|
body_entered.connect(_on_body_entered)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user