animsaver.gd 947 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. extends Sprite
  2. var frame1 = 0
  3. export(NodePath) var node
  4. export var anim = 'run'
  5. export var fps = 15
  6. func _ready():
  7. set_physics_process(false)
  8. func _physics_process(delta):
  9. get_node(node).set_active(false)
  10. var frametext = str(frame1)
  11. if frame1 < 10 :
  12. frametext = "0" + frametext
  13. var filename2 = "res://anim/texture-image-saved"+str(frametext)+".png"
  14. print("Saving PNG for Frame: " + str(frame1))
  15. var img = texture.get_data()
  16. img.clear_mipmaps()
  17. var x = img.save_png(filename2)
  18. print("Saved.")
  19. frame1 += 1
  20. get_node(node).set_active(true)
  21. func _on_AnimationPlayer_animation_finished(anim_name):
  22. set_physics_process(false)
  23. pass # Replace with function body.
  24. func _on_AnimationPlayer_animation_started(anim_name):
  25. set_physics_process(true)
  26. pass # Replace with function body.
  27. func _on_Timer_timeout():
  28. Engine.iterations_per_second = fps
  29. get_node(node).play(anim)
  30. set_physics_process(true)
  31. pass # Replace with function body.