The forums have permanently moved to forum.kirupa.com. This forum will be kept around in read-only mode for archival purposes. To learn how to continue using your existing account on the new forums, check out this thread.


Results 1 to 6 of 6

Thread: is there a way to change speed of animation?

  1. #1

    is there a way to change speed of animation?

    Is there anyway to change the speed of animation via actionscript? i mean, can we, err, make the animation within a particular mc, play faster or slower via actionscript? and if its not possible then what will be the possible ways of doing it, without making many animations at different speeds?
    MY BLOG

    I need a SPRITER who can do pixel arts for an arcade fighter project. If you can help out, please pm me.
    I also need someone who can write simple xml files.


  2. #2
    Jephz's Avatar
    106
    posts
    The Penguin n00b
    maybe change the fps?
    Don't you ever, ever, EVER call me a Noob. I mean it!

  3. #3
    Well blue, u can control the speed of the animation, irrespective of the FPS. Make your code run based on real-time and not on FPS.
    For eg:
    Code:
    var duration = 1000
    function animate()
    {
        char.nextFrame()
    }
    
    intervalID =setInterVal(animate,duration)
    So this way, the function animate() gets called every 1 sec or 1000ms. And if you want to increase the speed of animation,just change your duration to 500, then the function will be called every 1/2 a second or 500ms. Thus increasing the speed of the animation. This is just a simple idea on how to make your code independent from the FPS. If you are using bitMapdata or copyPixel in your game, you would probably be using a Render() and an update() function, so even here it is possible to render() at a faster rate than update().Just google on it, you will find tons of article on it.

  4. #4
    One thing you may need to do if you use setInterval or setTimeout is to account for the amount of time it takes for your code to execute.

    At the begining of the function you call in your interval, move the movie clip to it's next frame, clear the interval (or timeout) and set a variable to the value of getTimer().

    At the end of this function block, determine the elapsed time with a second call to getTimer, then subtract that amount from your desired timestep for your next setInterval or setTimeout call.

    Example:
    PHP Code:
    var duration 1000
    function animate(){
        
    clearInterval(intervalID); // clear the current interval

        
    var current getTimer(); // get the current time

        
    char.nextFrame(); // advance the movie clip to the next frame

        // all other code you want executed each timestep

        
    var newTimeStep duration - (getTimer() - current); // get the elapsed time

        
    newTimeStep = (newTimeStep 0) ? newTimeStep 1// check if function took longer than duration allows

        
    intervalID setInterVal(animatenewTimeStep); // set new interval with new time step
    }

    intervalID setInterVal(animateduration); 
    This method helps make things run smoothly, even when your code has a hiccup. It wont take care of issues with code than takes longer to process than your desired duration, but that's a different bottleneck to deal with.

  5. #5
    Wow thanks Jerryscript.... and acebuddy29 thank you too!!
    MY BLOG

    I need a SPRITER who can do pixel arts for an arcade fighter project. If you can help out, please pm me.
    I also need someone who can write simple xml files.


  6. #6
    Quote Originally Posted by Jerryscript View Post
    One thing you may need to do if you use setInterval or setTimeout is to account for the amount of time it takes for your code to execute.

    At the begining of the function you call in your interval, move the movie clip to it's next frame, clear the interval (or timeout) and set a variable to the value of getTimer().

    At the end of this function block, determine the elapsed time with a second call to getTimer, then subtract that amount from your desired timestep for your next setInterval or setTimeout call.

    Example:
    PHP Code:
    var duration 1000
    function animate(){
        
    clearInterval(intervalID); // clear the current interval

        
    var current getTimer(); // get the current time

        
    char.nextFrame(); // advance the movie clip to the next frame

        // all other code you want executed each timestep

        
    var newTimeStep duration - (getTimer() - current); // get the elapsed time

        
    newTimeStep = (newTimeStep 0) ? newTimeStep 1// check if function took longer than duration allows

        
    intervalID setInterVal(animatenewTimeStep); // set new interval with new time step
    }

    intervalID setInterVal(animateduration); 
    This method helps make things run smoothly, even when your code has a hiccup. It wont take care of issues with code than takes longer to process than your desired duration, but that's a different bottleneck to deal with.
    Sweeeeeet!!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012