00:00
00:00
Newgrounds Background Image Theme

mae6NG just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

AS: Elastic mouse follower

9,982 Views | 31 Replies
New Topic Respond to this Topic

AS: Elastic mouse follower 2005-09-06 05:48:56


=======
INTRO
=======

ok in this tutorial you will learn how to make a object follow the mouse BUT when it gets to the mouse it is elastic
(kid of like this TUT but follows the mouse)

ok heres what to do.
=====
Let's Make This Thing
=====

1.Create a circle and convert it to a MC (F8)

2. in that MC on frame 1 put these actions in it

physics0 = .50;
//speed at which the ball move towards the cursor
physics1 = .50;
//the stop at the cursor rate

xspeed = ((_root._xmouse-_x)*physics0)+(xspeed*phys
ics1);
yspeed = ((_root._ymouse-_y)*physics0)+(yspeed*phys
ics1);

// add the speed to the current position of the ball
_x += xspeed;
_y += yspeed;

3. add a Keyframe onto frame 2 (F6)

4.Push CTRL and ENTER together and CONGRATULATIONS it is finished

Hope this Tutorial has helped you
Please reply any questions
Thanks

Response to AS: Elastic mouse follower 2005-09-06 05:52:02


That is already covered I think...

http://www.newground../topic.php?id=299438

it's easy to change the code in the other post.. just change the target to _xmouse and _ymouse and drop the modes.


Visit JackSmack.com and submit your Flash Games!

BBS Signature

Response to AS: Elastic mouse follower 2005-09-06 05:54:59


yeah

i saw the elastic ball in the bbs and i made a whole new one but it follows the mouse

oh well it is a new AS tutorial

Response to AS: Elastic mouse follower 2005-10-01 09:11:48


Your tutorials fail.

Response to AS: Elastic mouse follower 2005-10-01 09:13:29


Your tutorials aren't:

- Long enough.

- Descriptive enough.

- Don't contain comments.

- Do not actually teach a lot.

- Are copy & paste tutorials.


BBS Signature

Response to AS: Elastic mouse follower 2005-10-01 09:17:16


lan00 YOU ARE A FUCKING N00B and you know NOTHING about AS so stop making shag tutorials dick lover

Now I got that off my chest who wants to make love?

- Matt, Rustyarcade.com

Response to AS: Elastic mouse follower 2005-10-01 09:18:04


At 10/1/05 09:17 AM, Ninja-Chicken wrote:
Now I got that off my chest who wants to make love?

Me want a secks please.


BBS Signature

Response to AS: Elastic mouse follower 2005-10-01 09:21:27


At 10/1/05 09:18 AM, Rantzien wrote:
At 10/1/05 09:17 AM, Ninja-Chicken wrote:
Now I got that off my chest who wants to make love?
Me want a secks please.

lets do it suger

Actualy do I have you on msn? I think you should add me so I can put you in my AS section (only inglor and delta were good enough to go in there so consider yourself pro)


- Matt, Rustyarcade.com

Response to AS: Elastic mouse follower 2005-10-01 09:26:53


At 10/1/05 09:21 AM, Ninja-Chicken wrote: lets do it suger

Actualy do I have you on msn? I think you should add me so I can put you in my AS section (only inglor and delta were good enough to go in there so consider yourself pro)

Oh em gee =)
Sure, I'll add you


BBS Signature

Response to AS: Elastic mouse follower 2005-10-01 09:57:36


xspeed = ((_root._xmouse-_x)*physics0)+(xspeed*phys
ics1);
yspeed = ((_root._ymouse-_y)*physics0)+(yspeed*phys
ics1);

Explain what that does, please.


the events are merely fictional, written, directed, and acted out by all who create them

BBS Signature

Response to AS: Elastic mouse follower 2005-10-11 16:39:45


would be better if it actually worked

Response to AS: Elastic mouse follower 2005-10-11 16:45:05


make it easier on yourself
onClipEvent(load){
physics0 = .50;
physics1 = .50;
}
onClipEvent(enterFrame){
xspeed = ((_root._xmouse-_x)*physics0)+(xspeed*phys
ics1);
yspeed = ((_root._ymouse-_y)*physics0)+(yspeed*phys
ics1);
_x += xspeed;
_y += yspeed;
}
Alot cleaner and doesn't give you that bumpy effect


Our growing dependence on laws only shows how uncivilized we are.

Response to AS: Elastic mouse follower 2005-10-11 16:47:04


At 10/11/05 04:45 PM, SEXY_FETUS wrote: make it easier on yourself
onClipEvent(load){
physics0 = .50;
physics1 = .50;
}
onClipEvent(enterFrame){
xspeed = ((_root._xmouse-_x)*physics0)+(xspeed*phys
ics1);
yspeed = ((_root._ymouse-_y)*physics0)+(yspeed*phys
ics1);
_x += xspeed;
_y += yspeed;
}
Alot cleaner and doesn't give you that bumpy effect

..doesent work either...

Response to AS: Elastic mouse follower 2005-10-11 16:47:55


At 10/1/05 09:57 AM, Starogre wrote: xspeed = ((_root._xmouse-_x)*physics0)+(xspeed*phys
ics1);
yspeed = ((_root._ymouse-_y)*physics0)+(yspeed*phys
ics1);

Explain what that does, please.

that's just the bbs cutting stuff short it should be
(yspeed*physics1); so adjust that in your code

oh and sorry for the double post.


Our growing dependence on laws only shows how uncivilized we are.

Response to AS: Elastic mouse follower 2005-10-11 16:57:32


whatever its not working for me.

Response to AS: Elastic mouse follower 2005-10-11 18:15:11


You didn't explain eahc part of the script or anything. This is not a tutorial, this is a copy/paste thread!

Response to AS: Elastic mouse follower 2005-10-11 23:02:45


I think this is kinda a nice one to teach simple math functions and how they can be used. So what the hell I'll break it apart and it might help someone.
onClipEvent(load){//proprties in this tag are loaded once
physics0 = .5;//simple name with value in this case ".5" could be anything
physics1 = .5;//ditto
}//closes the "onclipevent" handler
onClipEvent(enterFrame){//properties in this will be updated every frame
//even if every timeline is stopped frames are updated at the ratio you set
xspeed = ((_root._xmouse-_x)*physics0)+(xspeed*phys
ics1);
//the x position of the mouse subtracted by the x position of the MC this code is place on
//multiplied by the first value set on the load plus itself multiplied by the second value
//breaks apart exactly the same as high school algebra
yspeed = ((_root._ymouse-_y)*physics0)+(yspeed*phys
ics1);
//same as above with y position instead of x
_x += xspeed;
//adds the sum of the xspeed equasion(speeling) to the mc's x position
//if that's confusing look for a tutorial on simple character movement
_y += yspeed;
//same as above except with y position
}//closes onclipevent again

Play with this a bit change values see what happens when you take away the y position handling and the x position handling


Our growing dependence on laws only shows how uncivilized we are.

Response to AS: Elastic mouse follower 2005-10-12 01:29:04


At 10/11/05 04:57 PM, Vortex wrote: whatever its not working for me.

Stop posting that.

Anyways,your code isn't achieving Syntax.It's error-ful.

Ixfay ouryay odecay.
Now shutup and learn pig latin.

wat

Response to AS: Elastic mouse follower 2006-04-11 05:28:53


This is more of a FOSS than a AS. Btw, tom you need to change your name. Retarded animal Babies 15 is out now, lol.


BBS Signature

Response to AS: Elastic mouse follower 2006-04-11 07:18:52


hold up guys, i know why it doesnt work.

onClipEvent(load){
physics0 = 0.50;
physics1 = 0.50;
xspeed=0;
yspeed=0;
}
onClipEvent(enterFrame){
xspeed = ((_root._xmouse-_x)*physics0)+(xspeed*phys
ics1);
yspeed = ((_root._ymouse-_y)*physics0)+(yspeed*phys
ics1);
_x += xspeed;
_y += yspeed;
}

notice you have to give all variables SOMETHING to start out with. at the start it cant do xspeed*physics1 if xspeed is "undefined".

:D

Response to AS: Elastic mouse follower 2006-04-11 08:54:24


At 4/11/06 07:18 AM, ryanpridgeon wrote: notice you have to give all variables SOMETHING to start out with. at the start it cant do xspeed*physics1 if xspeed is "undefined".

D

Originally there was only one error, now there is four.

Response to AS: Elastic mouse follower 2006-04-23 20:18:35


I can't get anything to work. T_T Somebody help me. I'm a baffled noob

Response to AS: Elastic mouse follower 2006-04-23 22:17:06


at first i was gonna say that every eeryone should calm down.but when i looked at the code - in fact not even the code, the first instruction- i barfed. you do not even understand clip events. i understoon clip events literally the first day i tried flash. i looked at a sample, tried it out, understood it. you are so horrible its not even funny. then i looked at your code, half of it it not needed, why have 2 variables with the same value? why even have 2 varibles with something this simple?! because of that im sure you copy and pasted. although i dont know where you would find such a crappy tutorial.

Response to AS: Elastic mouse follower 2006-04-23 22:19:59


At 4/11/06 07:18 AM, ryanpridgeon wrote: hold up guys, i know why it doesnt work.

onClipEvent(load){
physics0 = 0.50;
physics1 = 0.50;
xspeed=0;
yspeed=0;
}
onClipEvent(enterFrame){
xspeed = ((_root._xmouse-_x)*physics0)+(xspeed*phys
ics1);
yspeed = ((_root._ymouse-_y)*physics0)+(yspeed*phys
ics1);
_x += xspeed;
_y += yspeed;
}

notice you have to give all variables SOMETHING to start out with. at the start it cant do xspeed*physics1 if xspeed is "undefined".

D

thats only if your using += or -=. you dont need to predefine things when your just using =, buts its a good idea. the problem is its just a horrible code.

Response to AS: Elastic mouse follower 2006-05-01 15:48:33


problem is its just a horrible code

Amen.

Response to AS: Elastic mouse follower 2006-05-06 19:57:23


ok, guys, after months, i figured it out. And i feel like an idiot.

well it was a long time

after you copy and paste it, you need to fix the
phy
sics
or something like that. The point is, is that part of the code is entered
so the code would be
onClipEvent(load){
physics0 = 0.50;
physics1 = 0.50;
xspeed=0;
yspeed=0;
}
onClipEvent(enterFrame){
xspeed = ((_root._xmouse-_x)*physics0)+(xspeed*phys
ics1);
yspeed = ((_root._ymouse-_y)*physics0)+(yspeed*phys
ics1);
_x += xspeed;
_y += yspeed;
}

ok now check the xspeed*physics and the yspeed*physics, see?


Steam: imuffin101

BBS Signature

Response to AS: Elastic mouse follower 2006-05-07 07:22:41


BTW, sexy_fetus, it's spelt feotus


BBS Signature

Response to AS: Elastic mouse follower 2006-05-25 20:33:56


Ok guys I'm not lying to you when I say I have tinkered with this for hours and can't get it to work. I'm no asking to copy/paste but will someone give me somewhere to START?!

Response to AS: Elastic mouse follower 2006-12-10 19:16:36


I don't know if anyone reads this tut anymore but the code is messed up, this is how it should look:
//put this on the movieclip and not inside it
onClipEvent(load){
physics0 = .50;
physics1 = .50;
}
onClipEvent(enterFrame){
xspeed = ((_root._xmouse - this._x)*physics0);
yspeed = ((_root._ymouse - this._y)*physics0);
xspeed += (xspeed*physics1);
yspeed += (yspeed*physics1);
this._x += xspeed;
this._y += yspeed;
trace(yspeed);
trace(xspeed);
}

The original with comments explaining the errors:

onClipEvent(enterFrame){
physics0 = .50;
//speed at which the ball move towards the cursor
physics1 = .50;
//the stop at the cursor rate

//----------------You can't assign a variable with a variable that is undefined------------
//xpeed is given the value of ((_root._xmouse-this._x)*physics0)+(XSPEED*ph ysics1);
//the capitalized XSPEED is undeined so xspeed gets nothing.
//The same goes for yspeed

xspeed = ((_root._xmouse-this._x)*physics0)+(xspeed*ph ysics1);
yspeed = ((_root._ymouse-this._y)*physics0)+(yspeed*ph ysics1);

// add the speed to the current position of the ball
this._x += xspeed;
this._y += yspeed;
}

Response to AS: Elastic mouse follower 2006-12-10 19:18:25


undeined == undefined*