Slick Forums

Discuss the Slick 2D Library
It is currently Wed Oct 16, 2019 11:44 am

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Fri Dec 03, 2010 11:45 pm 
Offline
Oldbie
User avatar

Joined: Fri Jul 20, 2007 9:25 am
Posts: 410
Location: Croatia
If we have animation which has ping pong set to true, isStopped() will return true if animation reached last frame even if animation needs to pong back.

Code:
         if ((currentFrame == frames.size() - 1) && (!loop)) {
               stopped = true;
            break;
         }


expected results: isStopped() returns true only when animation stops it's cycle forth and back.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 28, 2010 9:48 pm 
Offline
Site Admin
User avatar

Joined: Thu Jan 01, 1970 12:00 am
Posts: 3143
Fixed in SVN.

Kev


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 23, 2011 9:57 pm 
Offline
Oldbie
User avatar

Joined: Fri Jul 20, 2007 9:25 am
Posts: 410
Location: Croatia
sry for the late reply...

the fix is not what I had in mind.. now isStopped() is returning false always if animation is set to ping pong

normally animation is considered stopped when it has reached it's target frame, from 0 to n where n is last frame. If set to pingpong, target frame becomes 0 but only when in negative direction (going backwards)

EDIT:
remove last fix:
Code:
   public boolean isStopped() {
      return stopped;
   }


and add new one:
Animation:558,
Code:
private void nextFrame(long delta) {...
      while (nextChange < 0 && (!stopped)) {
         if (currentFrame == stopAt) {
            stopped = true;
            break;
         }
         if (!loop && (!pingPong && currentFrame == frames.size() - 1)) {            // THIS CHANGED
               stopped = true;
            break;
         }
         currentFrame = (currentFrame + direction) % frames.size();
         
         if (pingPong) {
            if (currentFrame <= 0) {
               currentFrame = 0;
               direction = 1;
               if (!loop) {            // THIS CHANGED
                        stopped = true;            // THIS CHANGED
                        break;            // THIS CHANGED
                    }            // THIS CHANGED
            }
            else if (currentFrame >= frames.size()-1) {
               currentFrame = frames.size()-1;
               direction = -1;
            }
         }
         int realDuration = (int) (((Frame) frames.get(currentFrame)).duration / speed);
         nextChange = nextChange + realDuration;
      }


it's a bit ugly.. but I couldn't do it without major refactoring in mind...


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 10, 2011 4:18 pm 
Offline
Site Admin
User avatar

Joined: Thu Jan 01, 1970 12:00 am
Posts: 3143
Updated with respect to your suggestion in SVN.

Kev


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group