Browse Source

Merge pull request #112 from AtomicGameEngine/JME-UI-2DVIEW

Fix for looped Spriter animations and adjustment to UISceneView root …
JoshEngebretson 10 years ago
parent
commit
537e9bb464
2 changed files with 9 additions and 6 deletions
  1. 8 5
      Source/Atomic/Atomic2D/AnimationSet2D.cpp
  2. 1 1
      Source/Atomic/UI/UISceneView.cpp

+ 8 - 5
Source/Atomic/Atomic2D/AnimationSet2D.cpp

@@ -348,7 +348,6 @@ bool AnimationSet2D::LoadSpriterAnimation(const XMLElement& animationElem)
         {
             SpriterTimelineKey2D key;
             key.time_ = keyElem.GetFloat("time") * 0.001f;
-            highestKeyTime = Max(highestKeyTime, key.time_);
             if (keyElem.HasAttribute("spin"))
                 key.spin_ = keyElem.GetInt("spin");
 
@@ -439,10 +438,6 @@ bool AnimationSet2D::LoadSpriterAnimation(const XMLElement& animationElem)
 
     // Create animation
     SharedPtr<Animation2D> animation(new Animation2D(this));
-    // Crop animation length if longer than the last keyframe, prevents sprites vanishing in clamp mode, or occasional flashes
-    // when looped
-    if (length > highestKeyTime)
-        length = highestKeyTime;
     animation->SetName(name);
     animation->SetLength(length);
     animation->SetLooped(looped);
@@ -469,6 +464,8 @@ bool AnimationSet2D::LoadSpriterAnimation(const XMLElement& animationElem)
 
             keyFrame.time_ = timelineKey.time_;
 
+            highestKeyTime = Max(highestKeyTime, keyFrame.time_);
+
             // Set disabled
             keyFrame.enabled_ = false;
             keyFrame.parent_ = timeline.parent_;
@@ -518,6 +515,12 @@ bool AnimationSet2D::LoadSpriterAnimation(const XMLElement& animationElem)
             }
         }
     }
+    else
+    {
+        // Crop non-looped animation length if longer than the last keyframe
+        if (length > highestKeyTime)
+            animation->SetLength(highestKeyTime);
+    }
 
     animations_.Push(animation);
 

+ 1 - 1
Source/Atomic/UI/UISceneView.cpp

@@ -191,8 +191,8 @@ void SceneViewWidget::OnPaint(const PaintProps &paint_props)
         return;
 
     TBRect rect = GetRect();
+    rect.x = rect.y = 0;
     ConvertToRoot(rect.x, rect.y);
-
     IntVector2 size = sceneView_->GetSize();
 
     if (size.x_ != rect.w || size.y_ != rect.h)