realtime animation speed change

Discussion in 'Mac Programming' started by liptonlover, Sep 10, 2008.

  1. liptonlover macrumors 6502a

    Mar 13, 2008
    I am relieved to say that a bunch of major problems have been solved and my animation classes which I will release for public use when finished, is nearing completion. But I have a feature I want to add that while I can do without, I would rather have as an option.

    Right now I simply use a timer for the animation. So the speed at which the timer fires is a fixed rate. But I want the programmer to be able to choose an option so that it operates like a regular CA animation, where it speeds up at the beginning and slows down at the end.

    I'm thinking about doing something like having an int that increases steadily, and at each multiple of x or something like that the animation increases. But is there another way to do this? I'm always looking to learn more, I don't want to go with the noobish way to do it just because I know how.

    Thanks, Nate
  2. HiRez macrumors 603


    Jan 6, 2004
    Western US
    Why not just use NSAnimation and let it do the work for you? It already has support for ease in/out curves built in, as well as any arbitrary acceleration curve you want. You can just run it and read values using the -currentValue: method. NSAnimation doesn't actually visually animate anything, it's just a way to calculate values off a curve over time, which sounds like what you want to me. I assume you mean you want the values to be nonlinear, not the firing of the timer which draws the frames?
  3. liptonlover thread starter macrumors 6502a

    Mar 13, 2008
    my goal is to provide the simplest animation possible, but one that also gives the user the current value at any given moment so that they can use it for collision detection for instance. I haven't used NSAnimation personally, but I think mine will be simpler. All I do is animate any of the four basic variable types (int float double or NSString) from one point to another, calling a users draw method that also accepts an NSNumber containing the current value. Right now my instance methods are long, but I'm planning on making it easier.

    Also, like I said, I will animate NSStrings in various ways for visual effects. That's where I'll likely learn the most and it'll be the completely original part (aside from other 3rd party framework creators I don't know of).

    So anyways... I'll likely just do ease-in/out my way....

Share This Page