选择显示字体大小

flash游戏制作:点击可弹动的小球

  新年将到,在这里先向大家拜个早年,祝大家在鸡年里,flash的水平节节高。 好,现在进入正题,大家先看一下效果。

flash/0502/flash/06flashclick01.swf" width="400" height="300">


  源文件下载(zip压缩文件,6k)。

  另外大家可以看一看一个曾经很流行的成品游戏:《是男人就点一百下》

  这个是简单的弹性效果的延伸。主体基本全是用as来实现的。下面讲解一下制作过程。

  1. 在flash中新一个mc,在此mc上分别建三层来放圆,按钮,还有as命令。如图所示:

  在此,as命令为:

stop();


  2. 回到主场景,在第一帧上加入as命令。

_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-widthballxspeed = -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;
};



  注:此例仅供学习使用,请勿用于商业用途!


 


关键字 本文所属关键字

相关 与本文相关文章

分类 所有文章关键字导航

源码编程相关

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   安全   模式   框架   测试   开源   游戏

SQL数据库相关

My-SQL   Ms-SQL   Access   DB2   Oracle   Sybase   SQLserver   索引   存储过程   加密   数据库   分页   视图  

手机无线相关

3G   Wap   CDMA   GRPS   GSM   IVR   彩信   短信   无线   增值业务

网页设计制作相关

HTML   CSS   网页配色   网页特效   Javascript   VBscript   Dreamweaver   Frontpage   JS   Web   网站设计

网站建设推广相关

建站经验   网站优化   网站排名   推广   Alexa

操作系统/服务器相关

Windows XP   Windows 2000   Windows 2003   Windows Me   Windows 9.x   Linux   UNIX   注册表   操作系统   服务器   应用服务器

图形图像多媒体相关

Photoshop   Fireworks   Flash   Coreldraw   Illustrator   Freehand   Photoimpact   多媒体   图形图像

标准 网站致力的规范

Valid CSS!

无不良内容,无不良广告,无恶意代码

Valid XHTML 1.0 Transitional

creativecommons