feat: Optimizes animation commands (#446)
Co-authored-by: Dennis Ploeger <develop@dieploegers.de>
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
# without blocking. The next command in the event will be executed immediately
|
||||
# after. Optional parameters:
|
||||
#
|
||||
# * reverse: plays the animation in reverse when true
|
||||
# * `reverse`: plays the animation in reverse when true
|
||||
#
|
||||
# @ESC
|
||||
extends ESCBaseCommand
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
# `cut_scene object name [reverse]`
|
||||
# `anim_block object name [reverse]`
|
||||
#
|
||||
# Executes the animation specificed with the "name" parameter on the object,
|
||||
# blocking. The next command in the event will be executed when the animation
|
||||
# is finished playing. Optional parameters:
|
||||
#
|
||||
# * reverse plays the animation in reverse when true
|
||||
# * `reverse`: plays the animation in reverse when true
|
||||
#
|
||||
# @ESC
|
||||
extends ESCBaseCommand
|
||||
class_name CutSceneCommand
|
||||
class_name AnimBlockCommand
|
||||
|
||||
|
||||
# Return the descriptor of the arguments of this command
|
||||
@@ -24,7 +24,7 @@ func configure() -> ESCCommandArgumentDescriptor:
|
||||
func validate(arguments: Array):
|
||||
if not escoria.object_manager.objects.has(arguments[0]):
|
||||
escoria.logger.report_errors(
|
||||
"anim: invalid object",
|
||||
"anim_block.gd:validate",
|
||||
[
|
||||
"Object with global id %s not found." % arguments[0]
|
||||
]
|
||||
@@ -1,9 +1,15 @@
|
||||
# `set_state object state [immediate]`
|
||||
#
|
||||
# Changes the state of an object, and executes the state animation if present.
|
||||
# Changes the state of an object to the given state.
|
||||
#
|
||||
# If the associated animation player has an animation with the same name,
|
||||
# it also plays that animation.
|
||||
#
|
||||
# The command can be used to change the appearance of an item or a player
|
||||
# character.
|
||||
# If `immediate` is set to true, the animation is run directly
|
||||
# character. See https://docs.escoria-framework.org/states for details.
|
||||
#
|
||||
# If `immediate` is set to true, the animation is directly skipped to the last
|
||||
# frame
|
||||
#
|
||||
# @ESC
|
||||
extends ESCBaseCommand
|
||||
|
||||
@@ -136,6 +136,12 @@ func seek_end(name: String):
|
||||
#
|
||||
# - name: Name of the animation played
|
||||
func _on_animation_finished(name: String):
|
||||
if _is_animation_player:
|
||||
_animation_player.stop()
|
||||
_animation_player.seek(0)
|
||||
else:
|
||||
_animated_sprite.stop()
|
||||
_animated_sprite.frame = 0
|
||||
emit_signal("animation_finished", name)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user