PDA

View Full Version : help with movement script:



xmattx
July 15th, 2003, 08:40 PM
im using this


onClipEvent (load) {
speed = 5;
}
onClipEvent (enterFrame) {
if (this.hitTest(_root._xmouse, _root._ymouse)) {
// /////////////
if (_root.hitbar._x>_root._xmouse) {
_root.hitbar._x = _root.hitbar._x-((_root.hitbar._x-_root._xmouse)/speed);
}
}
if (_root.hitTest(_root._xmouse, _root._ymouse)) {
if (_root.hitbar._x<_root._xmouse) {
_root.hitbar._x = _root.hitbar._x+((_root._xmouse-this.hitbar._x)/speed);
// /////////////////////////
}
}
}


however I cant get the script to work
Im placing this script on a movie clip, there is a second MC whose instance name is "hitbar" and when the mouse hits this MC it should trigger the first MC to travel along the X axis...

any help?

thanks!

comicGeek
July 16th, 2003, 01:26 AM
When you do the hitTest you have put a boolean value:



if(this.hitTest(_root._xmouse, _root._ymouse, true) == true){
trace("Mouse hit!");
}


:-\

xmattx
July 16th, 2003, 01:54 AM
i tried implementing the changes using that, i still cant get it tow work....

how are you using it in the entire script?

thanks.

comicGeek
July 16th, 2003, 02:12 AM
post your file so i can have a look at it

xmattx
July 16th, 2003, 02:34 AM
i sorta got the script to work, however its "jerky" amd has some undesirbale effects.. I would like it to operate much smoother.

comicGeek
July 16th, 2003, 03:08 AM
Do you want the pink MC follow the mouse when the mouse is over the grey MC? If yes then I think you should take a look at this!

xmattx
July 16th, 2003, 09:15 AM
very nice, is there a way( withen the same script) to restrain the pink MC to only move be able to move to a certain x position? I dont want the pink MC to be able to move further than the hitarea box.

thanks so much.

comicGeek
July 16th, 2003, 09:17 AM
You can use conditional statements again for that. You can compare the _x position and the width of the hit area MC as the borders. I'll give your file shot tomorrow. I'll have to take a rest! :)

In the meantime try to experiment with it!

xmattx
July 16th, 2003, 09:37 AM
word is bond. :beam:

comicGeek
July 16th, 2003, 10:14 PM
np