The new year will come, here first to everyone to worship an early years, I wish you all in the rooster, the level of flash high. OK, now let's get to the point where we'll look at the effect.
source file Download (Zip compressed file, 6K).
In addition, you can take a look at a once very popular product game: "It's a man, 100."
This is an extension of the simple elastic effect. The main body is basically all used as to achieve. Here is a brief explanation of the production process.
1. In Flash, a new MC, on this MC, built three layers to put round, button, as well as command. As shown in the figure:
Here, the As command is:
Stop ();
2. Go back to the main scene and add the As command on the first frame.
_root.createemptymovieclip ("Ball", 69);
Create an empty MC named Ball
Ball.linestyle (0xFFFFFF, 100);
Set ball line style is 60 thick, white, alpha is 100
Ball.lineto (1, 0);
Draws a line from the current drawing position to (x, y) using the current line style
VARs = new Array ("XSpeed", "Yspeed", "Leftedge", "Rightedge", "Bottomedge", "Gravity", "friction", "bounce", "Widthball", "Heightball", "Maxaffiche", "forcedribble", 6, 0, -30, (stage.width) + (_ROOT.BALL._WIDTH/4), (Stage.height) + (_ ROOT.BALL._WIDTH/4), 2.4, 0.982, 0.7, _ROOT.BALL._WIDTH/2, _ROOT.BALL._HEIGHT/2, 10, 22);
Set up an array
for (i=0; i< (VARS.LENGTH/2); i++) {
This[vars[i]] = vars[i+ (VARS.LENGTH/2)];
}
The value of the initial array
//-----------------------------------------
Ball when clicked, change the value of the xspeed,yspeed in the array
ball.onpress = function () {
_root.xspeed-= (_root._xmouse-this._x)/2;
_root.yspeed =-_root.forcedribble;
};
//---------------------------------------
Set the ball bounce,
Ball.onenterframe = function () {
this._x = This._x+xspeed;
this._y = This._y+yspeed;
if (This._x+widthball>rightedge | | this._x-widthball
XSpeed =-xspeed*bounce;
this._x = (This._x+widthball>rightedge)? (Rightedge-widthball): (Leftedge+widthball);
}
if (This._y+heightball>bottomedge) {
Yspeed =-yspeed*bounce;
this._y = Bottomedge-heightball;
}
Yspeed = (yspeed*friction) +gravity;
XSpeed = xspeed*friction;
};
Note: This example is for study use only, please do not use for commercial use!