|
|
Search Tutorials
Movement along the Y-axisTo make movement along the y axis possible we basically just have to copy the script we just wrote, insert it just behind and change all x to y. mx has to be changed to my, _root._xmouse to _root._ymouse, _x to _y and so on. The script remains the same because there is not really a difference between up-down movement and left-right movement. The complete script should now look something like this:
onClipEvent (enterFrame) {
//x movement
mx=_root._xmouse;
if (mx<_x) {
dx=_x-mx;
}
else {
dx=mx-_x;
}
moveSpeedx=dx/10;
if (mx<_x) {
_x=_x-moveSpeedx;
}
else {
_x=_x+moveSpeedx;
}
//y movement
my=_root._ymouse;
if (my<_y) {
dy=_y-my;
}
else {
dy=my-_y;
}
moveSpeedy=dy/10;
if (my<_y) {
_y=_y-moveSpeedy;
}
else {
_y=_y+moveSpeedy;
}
}
|
||||||||||||||||||||||||||||||||||||||||||||||||
![]() |
|||||||||||||||||||||||||||||||||||||||||||||||||
|