Created
June 9, 2015 18:52
-
-
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"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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