新年将到,在这里先向大家拜个早年,祝大家在鸡年里,flash的水平节节高。 好,现在进入正题,大家先看一下效果。
stop();
_root.createemptymovieclip("ball", 69);
//创建一个空的mc,命名为ball
ball.linestyle(60, 0xffffff, 100);
//设定ball的线条样式为60粗,白色,alpha为100
ball.l.neto(1, 0);
//使用当前线条样式从当前绘画位置向 (x, y) 绘制线条
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);
//建立数组
for (i=0; i<(vars.length/2); i++) {
this[vars[i]] = vars[i+(vars.length/2)];
}
//初始数组的取值
//-----------------------------------------
//ball点击时,改变数组中xspeed,yspeed的值
ball.onpress = function() {
_root.xspeed -= (_root._xmouse-this._x)/2;
_root.yspeed = -_root.forcedribble;
};
//---------------------------------------
//设置ball的反弹,
ball.onenterframe = function() {
this._x = this._x+xspeed;
this._y = this._y+yspeed;
if (this._x+widthball>rightedge this._x-widthball
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;
};
Java Asp PHP .Net XML C/C++ CGI VB Jsp J2ee J2se J2me EJB Servlet Tomcat Resin Struts Weblogic Eclipse ANT GUI JMS Web servise IDEA Webphere Hibernate Spring Jboss Applet Swing Socket Javamail Perl Ajax P2P 安全 模式 框架 测试 开源 游戏
Windows XP Windows 2000 Windows 2003 Windows Me Windows 9.x Linux UNIX 注册表 操作系统 服务器 应用服务器