Smooth Movement?

  • Dally315
  • Born
  • Born
  • Dally315
  • Posts: 3

Post 3+ Months Ago

What I am doing is moving a movie clip around on the stage when the user presses one of the arrow keys. Since I am moving it by a number of pixels each time the user presses the key the movement looks choppy, and I was wondering if anyone could recommend a way to do this so that the movement looks more smooth. A quick example of what I'm doing (although I'm sure you've already assumed this):
Code: [ Select ]
if ((Key.isDown(Key.RIGHT))) {
this._x += 20;
}
  1. if ((Key.isDown(Key.RIGHT))) {
  2. this._x += 20;
  3. }


I realize that 20 pixels is a lot and only adds to the choppiness, but I need it to move somewhat fast, which is why it is set so high.
Any help would be greatly appreciated. Thanks so much!
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • lostinbeta
  • Guru
  • Guru
  • User avatar
  • Posts: 1402
  • Loc: Philadelphia, PA

Post 3+ Months Ago

You should check out the basic easing equation... here are two examples that implement the equation in two different ways to show how versatile it can be... very useful...

http://www.kirupa.com/developer/mx/followease.htm
http://www.kirupa.com/developer/mx/easi ... eclick.htm
  • IMMORTAL
  • Beginner
  • Beginner
  • User avatar
  • Posts: 45

Post 3+ Months Ago

The updateStage() function might also be useful to you
  • lostinbeta
  • Guru
  • Guru
  • User avatar
  • Posts: 1402
  • Loc: Philadelphia, PA

Post 3+ Months Ago

I'm guessing updateStage() is a 2k4 thing?

Is it like updateAfterEvent() in MX?
  • cmontana
  • Novice
  • Novice
  • User avatar
  • Posts: 18

Post 3+ Months Ago

The first thing to consider when smooth movement in Flash is your frame rate. What frame rate is your Flash movie using? The default is set at 12 fps, which is way too slow and makes everything very choppy.

The film industry uses 24 fps, on the Web I find it more realistic to use at least 32 fps. Make sure you don't overdo it though: not everyone has an Ultimate Gaming Beast Machine, and too high a frame rate may slow things down for some. Find a good compromise.
  • lostinbeta
  • Guru
  • Guru
  • User avatar
  • Posts: 1402
  • Loc: Philadelphia, PA

Post 3+ Months Ago

I use anywhere between 24-30 standard. 60 tops if neccessary (which is extremely rare)

Good point on the frame rate cmontana. I didn't really think to mention that because even at a higher frame rate the motion would be choppy because it is still just jumping 20px, which is going to be noticeable and not so smooth.
  • IMMORTAL
  • Beginner
  • Beginner
  • User avatar
  • Posts: 45

Post 3+ Months Ago

Quote:
Is it like updateAfterEvent() in MX?


Actually, yes, that is what I meant. Thanks for correcting my error.

Post Information

  • Total Posts in this topic: 7 posts
  • Users browsing this forum: No registered users and 6 guests
  • 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
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.