Skip to content

Instantly share code, notes, and snippets.

@raresloth
Created June 9, 2015 18:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raresloth/f54a2a67b83c2b79a5b3 to your computer and use it in GitHub Desktop.
Save raresloth/f54a2a67b83c2b79a5b3 to your computer and use it in GitHub Desktop.
Spine animation script that keys the flipX key at time 0 for all animations ending in "_west"
#!/usr/bin/env ruby
require 'json'
if ARGV.count != 1
puts '[usage] ./key_flips_x.rb exported_skeleton.json'
raise RuntimeError
end
file_path = ARGV[0]
root_hash = JSON.parse(File.read(file_path))
animations = root_hash['animations']
animations.each { |name, animation_hash|
next unless name.include?('_west')
root_bone = animation_hash['bones']['root']
flipX_hash = {time: 0, x: true}
root_bone['flipX'] = [flipX_hash]
}
File.open(file_path,"w") do |f|
f.write(JSON.generate(root_hash))
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment