Start a new topic

Resuming animations

Resuming animations


Dear Wikituders,

Currently I am working on a project for school which involves creating an AR application for both iOS and Android. For this I am using the Image Recognition which works like a charm so far. I am working with several animations linked together by using animationGroups. This results in 1 masterAnimationGroup which contains all the animations (several animation groups).

Now when the device recognizes the image it starts the animation. After this I want to pause it when it no longer recognizes the image, and resume it when it's back in sight.

My problem now: It does start the animation, it does pause it... but it won't resume it once it is paused. I use the following code for this:

----------------------------------------------------------

 

 

var trackableOnEnterFieldOfVision = function()

    {

        if(animationRunning == true)

        {

            masterAnimationGroup.resume();

        }

        else

        {

            animationRunning = true;

            masterAnimationGroup.start(-1);

        }

    }

  

 

    var trackableOnExitFieldOfVision = function()

    {        

        if(animationRunning == true)

        {

            masterAnimationGroup.pause();

        }

}

 

    

    trackable2DObject = new AR.Trackable2DObject(logoTracker, "test4",

    { drawables:

        { cam:

           

        },

  onEnterFieldOfVision : trackableOnEnterFieldOfVision,

  onExitFieldOfVision : trackableOnExitFieldOfVision

    });

 

 

----------------------------------------------------------

 

 

I don't get why it won't resume the animation. The "animationRunning" is a global variable because the "isRunning" won't work for me when I want to pause it first and resume it after that because isRunning takes a paused animation as NOT running.

 

Any help is more than welcome!

 

With regards,

Rene, student ICT & Media Design

Hi Rene,

The first thing I see in your code is that you never reset your variable "animationRunning" back to false.
If you want to check the state of your variables you can simply do that by adding alerts or by using the AR.logger

Hope that helps,
Christian

Hello Christian,

This can't be the problem I think. I only use this variable to see if I have already started the animation. If not, the variable is False (when the image is not recognized yet). But after it has recognized it once, it sets it to true and the animation starts. After that it doesn't matter the variable stays true because it is only for making sure the animation has been running already and paused. 

The core problem is: animation.resume() just doesn't work when animation.pause() is used before. It just totally crashes the application which can't be resolved by just setting a global variable (which for the rest has no influence on the animation or what so ever) to false. This variable only serves as a first trigger for animation.start() when it is false, when it is true the animation should be resumed instead of "started()" again.

Kind regards,

René

Anyone has a solution for me? I am still stuck on this and I really need this feature to work.

Any help is more than welcome!

Kind regards,

René

Hi René,

I created a test-world and will attach the html-file to this post. The pausing and resuming works well for me. Let me know if that helps you.

Christian
Login or Signup to post a comment