AS: Elastic mouse follower
- lan00
-
lan00
- Member since: May. 20, 2005
- Offline.
-
- Forum Stats
- Member
- Level 07
- Blank Slate
=======
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
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.
- lan00
-
lan00
- Member since: May. 20, 2005
- Offline.
-
- Forum Stats
- Member
- Level 07
- Blank Slate
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
- Toast
-
Toast
- Member since: Apr. 2, 2005
- Offline.
-
- Forum Stats
- Member
- Level 09
- Blank Slate
Your tutorials aren't:
- Long enough.
- Descriptive enough.
- Don't contain comments.
- Do not actually teach a lot.
- Are copy & paste tutorials.
- Rustygames
-
Rustygames
- Member since: May. 7, 2005
- Offline.
-
- Forum Stats
- Member
- Level 19
- Programmer
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
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.
- Rustygames
-
Rustygames
- Member since: May. 7, 2005
- Offline.
-
- Forum Stats
- Member
- Level 19
- Programmer
At 10/1/05 09:18 AM, Rantzien wrote:At 10/1/05 09:17 AM, Ninja-Chicken wrote:Me want a secks please.Now I got that off my chest who wants to make love?
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
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
- Starogre
-
Starogre
- Member since: May. 8, 2004
- Offline.
-
- Forum Stats
- Member
- Level 18
- Artist
xspeed = ((_root._xmouse-_x)*physics0)+(xspeed*phys
ics1);
yspeed = ((_root._ymouse-_y)*physics0)+(yspeed*phys
ics1);
Explain what that does, please.
- Vortex
-
Vortex
- Member since: Aug. 27, 2005
- Offline.
-
- Forum Stats
- Member
- Level 09
- Blank Slate
would be better if it actually worked
- SEXY-FETUS
-
SEXY-FETUS
- Member since: May. 2, 2005
- Offline.
-
- Forum Stats
- Member
- Level 05
- Blank Slate
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
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
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
- JeremysFilms
-
JeremysFilms
- Member since: Feb. 18, 2005
- Offline.
-
- Forum Stats
- Member
- Level 18
- Blank Slate
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
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
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
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.
- RyanPridgeon
-
RyanPridgeon
- Member since: Dec. 7, 2005
- Offline.
-
- Forum Stats
- Member
- Level 11
- Blank Slate
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
- Paradox
-
Paradox
- Member since: Jan. 28, 2006
- Offline.
-
- Forum Stats
- Member
- Level 29
- Blank Slate
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
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
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
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.
This blog I made | This game sucks | FlxGreed | Home Run Swingers: Rhythm Baseball
many typos
- GeoKureli
-
GeoKureli
- Member since: Apr. 1, 2003
- Offline.
-
- Forum Stats
- Supporter
- Level 19
- Game Developer
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.
This blog I made | This game sucks | FlxGreed | Home Run Swingers: Rhythm Baseball
many typos
- RyanPridgeon
-
RyanPridgeon
- Member since: Dec. 7, 2005
- Offline.
-
- Forum Stats
- Member
- Level 11
- Blank Slate
problem is its just a horrible code
Amen.
- joshy24
-
joshy24
- Member since: Nov. 28, 2004
- Offline.
-
- Forum Stats
- Member
- Level 06
- Musician
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
- Hoeloe
-
Hoeloe
- Member since: Apr. 29, 2004
- Offline.
-
- Forum Stats
- Member
- Level 37
- Game Developer
Song of the Firefly is on Steam Greenlight and Kickstarter. Give them a look and support the project!
------------------------------
- Scrub
-
Scrub
- Member since: May. 19, 2005
- Offline.
-
- Forum Stats
- Member
- Level 09
- Blank Slate
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
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;
}




