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
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
what do you mean ‘X’ frames?
‘X’ frames is how many frames will have passed by when the move is finished. Btw, my frame rate is 25 fps.
Later,
–Elios
sorry, still don’t understand your question…
but try this… if i’m not missunderstood…
first use function for your moving action(frame action)
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:
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()
Thanks, that’s exactly what I wanted.
:: Copyright KIRUPA 2024 //--