Skip to content

Commit

Permalink
Merge pull request #18 from romen-h/master
Browse files Browse the repository at this point in the history
Fix for animated alpha values not surviving conversion
  • Loading branch information
skairunner authored Jul 25, 2021
2 parents 6823176 + 776520d commit 5916731
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion kanimal/Reader/ScmlReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -374,9 +374,13 @@ private void PackAnim()

var element = new Element();
element.Flags = 0;
// Spriter does support setting alpha per keyframe, so we grab that value for the alpha channel of the kanim element
if (object_ref.HasAttribute("a"))
element.A = float.Parse(object_ref.Attributes["a"].Value);
else
element.A = 1.0f;
// spriter does not support changing colors of components
// through animation so this can be safely set to 0
element.A = 1.0f;
element.B = 1.0f;
element.G = 1.0f;
element.R = 1.0f;
Expand Down
1 change: 1 addition & 0 deletions kanimal/Writer/ScmlWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ protected virtual void AddTimelineInfo(XmlElement parent, int animIndex)
object_def.SetAttribute("angle", trans.Angle.ToStringInvariant());
object_def.SetAttribute("scale_x", trans.ScaleX.ToStringInvariant());
object_def.SetAttribute("scale_y", trans.ScaleY.ToStringInvariant());
object_def.SetAttribute("a", element.A.ToStringInvariant());

keyframe.AppendChild(object_def);
timelineMap[idMap[name]].AppendChild(keyframe);
Expand Down

0 comments on commit 5916731

Please sign in to comment.