Closed nighca closed 1 month ago
Based on the comment here
In Scratch and SPX, the initial instance of a sprite is the prototype (somewhat similar to JavaScript). The prototype instance cannot be destroyed, so the 'die' function behaves differently for prototype instances and cloned instances.
@xushiwei To address compatibility concerns, I suggest:
destroy
to deleteThisClone
for compatibility with Scratch's Delete This Clone
destroy
, which always destroys the current instance, regardless of whether it's the initial or a cloned instancedie
based on destroy
, so it always destroys the current instance as wellclosed by #329
In SPX, there are different implementations of the
Die
method for initial and cloned sprites:https://github.com/goplus/spx/blob/3df776b555a0532999520609e172f45c1816de49/sprite.go#L483-L494
Ideally, there should be no noticeable differences for game developers, but this is not the case. For example, consider this sprite code:
After calling
die
, the loop continues, so"im alive"
keeps being printed.In contrast, for a cloned sprite:
After calling
die
, the loop stops, and"im alive"
is no longer printed.Game developers may perform more complex actions than just
println "im alive"
, potentially affecting overall game behavior. Therefore, it is crucial to unify the behavior ofdie
for both sprite types.Please check this out, @xushiwei @JiepengTan.