# Game programming: easing?

**URL:** <https://forum.kirupa.com/t/game-programming-easing/17394>\
**Category:** Uncategorized\
**Created:** [April 4, 2003, 5:18pm UTC](https://forum.kirupa.com/t/game-programming-easing/17394 "2003-04-04T17:18:30Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Elios](https://avatars.discourse-cdn.com/v4/letter/e/2acd7d/32.png) [@Elios](https://forum.kirupa.com/u/Elios)\
**Post date:** [April 4, 2003, 5:18pm UTC](https://forum.kirupa.com/t/game-programming-easing/17394/1 "2003-04-04T17:18:30Z")

</div>

Alright, I’m coding an rpg, but I’ve hit a problem. How do I make the map (let’s just say it’s called \_root.btmMC) move 16 pixels up/down/left/right over ‘X’ frames?

Thanks in advance,  
–Elios

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [April 4, 2003, 5:24pm UTC](https://forum.kirupa.com/t/game-programming-easing/17394/2 "2003-04-04T17:24:08Z")

</div>

what do you mean ‘X’ frames?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [April 4, 2003, 5:36pm UTC](https://forum.kirupa.com/t/game-programming-easing/17394/3 "2003-04-04T17:36:00Z")

</div>

‘X’ frames is how many frames will have passed by when the move is finished. Btw, my frame rate is 25 fps.

Later,  
–Elios

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [April 4, 2003, 6:38pm UTC](https://forum.kirupa.com/t/game-programming-easing/17394/4 "2003-04-04T18:38:55Z")

</div>

sorry, still don’t understand your question…

1. what will be the trigger of the moving MC? is it buttons or keyboard?
2. what is the use of frames in this situation?only need one frame stopped i guess…

but try this… if i’m not missunderstood…

first use function for your moving action(frame action)

```php
MovieClip.prototype.slideX = function(endPosx) {
	this.onEnterFrame = function() {
		if (this._x<=endPosx) {
			currentPosx = this._x;
			diffPosx = endPosx-currentPosx;
			movex = diffPosx/3;
			this._x = this._x+movex;
			if (this._x>=endPosx) {
				this._x = endPosx;
				this.onEnterFrame = null;
			}
		}
		if (this._x>=endPosx) {
			currentPosx = this._x;
			diffPosx = endPosx-currentPosx;
			movex = diffPosx/3;
			this._x = this._x+movex;
			if (this._x<=endPosx) {
				this._x = endPosx;
				this.onEnterFrame = null;
			}
		}
	};
};

```

\*\*this function only for x axis, for y axis build another function(just change the x to y), for diagonal move u should make another function (slideXY)

test this with a button,  
on the button action:

```php
 on(press){
_root.btmMC.slideX(16);
}

```

i assume your btmMC is(0,0), 16 will have your btmMC move 16 pixel right, but if it’s not, you’ll have to change the number…  
or another way change the (endPosx) to (this.\_x+16) if u only want to move it by 16 pixels

if your trigger is keyboard, use Key.isDown()

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [April 5, 2003, 2:03pm UTC](https://forum.kirupa.com/t/game-programming-easing/17394/5 "2003-04-05T14:03:45Z")

</div>

Thanks, that’s exactly what I wanted.
