Be a Supporter!

AS: Elastic mouse follower

  • 7,746 Views
  • 32 Replies
New Topic Respond to this Topic
lan00
lan00
  • Member since: May. 20, 2005
  • Offline.
Forum Stats
Member
Level 07
Blank Slate
AS: Elastic mouse follower Sep. 6th, 2005 @ 05:48 AM Reply

=======
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

JackSmack
JackSmack
  • Member since: Nov. 11, 2004
  • Offline.
Forum Stats
Member
Level 22
Game Developer
Response to AS: Elastic mouse follower Sep. 6th, 2005 @ 05:52 AM Reply

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
lan00
lan00
  • Member since: May. 20, 2005
  • Offline.
Forum Stats
Member
Level 07
Blank Slate
Response to AS: Elastic mouse follower Sep. 6th, 2005 @ 05:54 AM Reply

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

brotherkipling
brotherkipling
  • Member since: Jan. 21, 2005
  • Offline.
Forum Stats
Member
Level 02
Blank Slate
Response to AS: Elastic mouse follower Oct. 1st, 2005 @ 09:11 AM Reply

Your tutorials fail.

Toast
Toast
  • Member since: Apr. 2, 2005
  • Online!
Forum Stats
Member
Level 09
Blank Slate
Response to AS: Elastic mouse follower Oct. 1st, 2005 @ 09:13 AM Reply

Your tutorials aren't:

- Long enough.

- Descriptive enough.

- Don't contain comments.

- Do not actually teach a lot.

- Are copy & paste tutorials.


BBS Signature
Rustygames
Rustygames
  • Member since: May. 7, 2005
  • Offline.
Forum Stats
Member
Level 19
Programmer
Response to AS: Elastic mouse follower Oct. 1st, 2005 @ 09:17 AM Reply

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

Rantzien
Rantzien
  • Member since: Jan. 27, 2005
  • Offline.
Forum Stats
Member
Level 15
Blank Slate
Response to AS: Elastic mouse follower Oct. 1st, 2005 @ 09:18 AM Reply

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
Rustygames
Rustygames
  • Member since: May. 7, 2005
  • Offline.
Forum Stats
Member
Level 19
Programmer
Response to AS: Elastic mouse follower Oct. 1st, 2005 @ 09:21 AM Reply

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

Rantzien
Rantzien
  • Member since: Jan. 27, 2005
  • Offline.
Forum Stats
Member
Level 15
Blank Slate
Response to AS: Elastic mouse follower Oct. 1st, 2005 @ 09:26 AM Reply

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
Starogre
Starogre
  • Member since: May. 8, 2004
  • Offline.
Forum Stats
Member
Level 18
Artist
Response to AS: Elastic mouse follower Oct. 1st, 2005 @ 09:57 AM Reply

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
Vortex
Vortex
  • Member since: Aug. 27, 2005
  • Offline.
Forum Stats
Member
Level 09
Blank Slate
Response to AS: Elastic mouse follower Oct. 11th, 2005 @ 04:39 PM Reply

would be better if it actually worked

SEXY-FETUS
SEXY-FETUS
  • Member since: May. 2, 2005
  • Offline.
Forum Stats
Member
Level 05
Blank Slate
Response to AS: Elastic mouse follower Oct. 11th, 2005 @ 04:45 PM Reply

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.

Vortex
Vortex
  • Member since: Aug. 27, 2005
  • Offline.
Forum Stats
Member
Level 09
Blank Slate
Response to AS: Elastic mouse follower Oct. 11th, 2005 @ 04:47 PM Reply

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...

SEXY-FETUS
SEXY-FETUS
  • Member since: May. 2, 2005
  • Offline.
Forum Stats
Member
Level 05
Blank Slate
Response to AS: Elastic mouse follower Oct. 11th, 2005 @ 04:47 PM Reply

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.

Vortex
Vortex
  • Member since: Aug. 27, 2005
  • Offline.
Forum Stats
Member
Level 09
Blank Slate
Response to AS: Elastic mouse follower Oct. 11th, 2005 @ 04:57 PM Reply

whatever its not working for me.

JeremysFilms
JeremysFilms
  • Member since: Feb. 18, 2005
  • Offline.
Forum Stats
Member
Level 18
Blank Slate
Response to AS: Elastic mouse follower Oct. 11th, 2005 @ 06:15 PM Reply

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

SEXY-FETUS
SEXY-FETUS
  • Member since: May. 2, 2005
  • Offline.
Forum Stats
Member
Level 05
Blank Slate
Response to AS: Elastic mouse follower Oct. 11th, 2005 @ 11:02 PM Reply

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.

Thomas
Thomas
  • Member since: Feb. 14, 2005
  • Offline.
Forum Stats
Member
Level 13
Musician
Response to AS: Elastic mouse follower Oct. 12th, 2005 @ 01:29 AM Reply

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
a compessor wil raise the volume while lowering the db - chronamut

Depredation
Depredation
  • Member since: Sep. 5, 2005
  • Offline.
Forum Stats
Member
Level 17
Game Developer
Response to AS: Elastic mouse follower Apr. 11th, 2006 @ 05:28 AM Reply

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
RyanPridgeon
RyanPridgeon
  • Member since: Dec. 7, 2005
  • Offline.
Forum Stats
Member
Level 11
Blank Slate
Response to AS: Elastic mouse follower Apr. 11th, 2006 @ 07:18 AM Reply

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


I make flashes because I can.
PM me for anything flash or web related or visit my blog!!

BBS Signature
Paradox
Paradox
  • Member since: Jan. 28, 2006
  • Offline.
Forum Stats
Member
Level 29
Blank Slate
Response to AS: Elastic mouse follower Apr. 11th, 2006 @ 08:54 AM Reply

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.

Link126
Link126
  • Member since: Mar. 23, 2006
  • Offline.
Forum Stats
Member
Level 06
Blank Slate
Response to AS: Elastic mouse follower Apr. 23rd, 2006 @ 08:18 PM Reply

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

Khao
Khao
  • Member since: Sep. 20, 2003
  • Offline.
Forum Stats
Member
Level 20
Blank Slate
Response to AS: Elastic mouse follower Apr. 23rd, 2006 @ 10:08 PM Reply

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)

fuck you?

GeoKureli
GeoKureli
  • Member since: Apr. 1, 2003
  • Offline.
Forum Stats
Supporter
Level 19
Game Developer
Response to AS: Elastic mouse follower Apr. 23rd, 2006 @ 10:17 PM Reply

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.

GeoKureli
GeoKureli
  • Member since: Apr. 1, 2003
  • Offline.
Forum Stats
Supporter
Level 19
Game Developer
Response to AS: Elastic mouse follower Apr. 23rd, 2006 @ 10:19 PM Reply

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.

RyanPridgeon
RyanPridgeon
  • Member since: Dec. 7, 2005
  • Offline.
Forum Stats
Member
Level 11
Blank Slate
Response to AS: Elastic mouse follower May. 1st, 2006 @ 03:48 PM Reply

problem is its just a horrible code

Amen.


I make flashes because I can.
PM me for anything flash or web related or visit my blog!!

BBS Signature
joshy24
joshy24
  • Member since: Nov. 28, 2004
  • Offline.
Forum Stats
Member
Level 06
Musician
Response to AS: Elastic mouse follower May. 6th, 2006 @ 07:57 PM Reply

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
Hoeloe
Hoeloe
  • Member since: Apr. 29, 2004
  • Offline.
Forum Stats
Member
Level 37
Game Developer
Response to AS: Elastic mouse follower May. 7th, 2006 @ 07:22 AM Reply

BTW, sexy_fetus, it's spelt feotus


Decima: The Last Story of Vald has a Facebook page and a development blog. Give them a look!
------------------------------

BBS Signature
Scrub
Scrub
  • Member since: May. 19, 2005
  • Offline.
Forum Stats
Member
Level 09
Blank Slate
Response to AS: Elastic mouse follower May. 25th, 2006 @ 08:33 PM Reply

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?!

menzoic
menzoic
  • Member since: Oct. 23, 2006
  • Offline.
Forum Stats
Member
Level 02
Blank Slate
Response to AS: Elastic mouse follower Dec. 10th, 2006 @ 07:16 PM Reply

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;
}