skillIndex=2;
}else{
skillIndex=3;
}
trace(attacker.name+"向"+defender.name+"发动了"+attacker["skill"+skillIndex]+","+defender.name+"损失了"+damage+"点HP!
");
if(defender.HP<=0){
trace(defender.name+"终于支持不住,倒下了!
\n"+attacker.name+"取得了胜利!
");
timer.removeEventListener(TimerEvent.TIMER,round);
trace("\nGameOver");
return;
}
trace(hero.name+"HP:
"+hero.HP+"\t"+monster.name+"HP:
"+monster.HP);
}
五、实验结果
注:
可用贴图的方式
1、主要使用的知识点
使用事件驱动编写AS3.0应用程序(物体移动等的动画效果)
鼠标事件:
CLICK、MOUSE_MOVE、MOUSE_OVER、MOUSE_OUT、MOUSE_WHEEL等
键盘事件:
KeyboardEvent.KEY_DOWN(UP)等
时间函数:
TimerEvent.TIMER、TimerEvent.TIMER_COMPLETE
2、作品的效果图(至少给出3个,含制作过程及结果)
六、实验总结
注:
包括制作过程中出现的问题,实验心得体会及改进意见等
大体上了解到我们平常玩的回合游戏的制作过程,很有趣,我很喜欢这个。
不过我想要是加上图片和效果的话,难度会提升很多。
上海建桥学院实验报告
课程名称:
互动媒体制作实验类型:
设计型
实验项目名称:
找茬类事件点击类小游戏
实验地点:
多媒体机房实验日期:
2013年4月15日
一、实验目的和要求
1、巩固AS3.0中核心类及显示对象的相关概念;
2、学会MovieClip类、Sprite类的创建及使用;
3、学会AS3.0中创建动画的几种方式;
4、能够熟练运用显示对象的属性;
5、能够熟练运用timer类创建动画(效果);
6、制作满足相应要求的交互动画;
二、实验内容和原理
1、确定内容健康的主题
2、相关素材的准备
3、制作交互动画的流程图(分镜头脚本)
4、运用Timer类控制显示对象的属性来制作交互动画
三、主要仪器设备或环境
PC机;Flashcs5(或以上);Photoshopcs5(或以上);移动终端5套;数码照相机1台;数码摄像机1台;数位板1个。
四、操作方法与实验步骤
1、确定主题、设计流程图
主题:
找茬游戏
设计流程图:
2、游戏整体流程拆分
游戏开始初始化:
开始按钮定义、开始界面的设置、初始化数值
游戏主题部分:
添加三个文本框,一个计分数,一个倒计时,一个统计剩余几个错找到几个错。
添加Timer时间监听,用来倒计时。
对cuowumian、cuo1、cuo2、cuo3.、cuo4.、cuo5添加鼠标事件监听,MouseEvent.CLICK。
游戏结束部分:
移除游戏主体页面上所有东西,移除监听。
根据找出的错的个数判断是否通关,并显示在名为tf的文本框里。
添加一个Restart按钮,实现重玩的功能。
3、三大游戏流程部分功能实现
游戏开始初始化、开始界面的设置;
myStartView=newStartView();
addChild(myStartView);
myStartView.x=stage.stageWidth/2;
myStartView.y=stage.stageHeight/2;
游戏正式界面设置
functiongameStart(){
scoreField=newTextField();
scoreFn();
addChild(scoreField);
myGameView=newGameView();
addChild(myGameView);
myGameView.x=stage.stageWidth/2;
myGameView.y=stage.stageHeight/2;
allTimer=10;
timer=newTimer(1000,20);
timer.addEventListener(TimerEvent.TIMER,timerFn);
timer.start();
timeField=newTextField();
timeField.autoSize="center";
timeField.text="你还有"+allTimer+"秒";
timeField.x=400;
addChild(timeField);
myGameView.cuo1.stop();
myGameView.cuo2.stop();
myGameView.cuo3.stop();
myGameView.cuo4.stop();
myGameView.cuo5.stop();
myGameView.cuowumian.addEventListener(MouseEvent.CLICK,mianFn);
myGameView.cuo1.addEventListener(MouseEvent.CLICK,cuo1Fn);
myGameView.cuo2.addEventListener(MouseEvent.CLICK,cuo2Fn);
myGameView.cuo3.addEventListener(MouseEvent.CLICK,cuo3Fn);
myGameView.cuo4.addEventListener(MouseEvent.CLICK,cuo4Fn);
myGameView.cuo5.addEventListener(MouseEvent.CLICK,cuo5Fn);
}
游戏结束
functionendGame(){
removeChild(myGameView);
removeChild(scoreField);
removeChild(timeField);
myGameView.cuowumian.removeEventListener(MouseEvent.CLICK,mianFn);
tf=newTextField();
tf.width=300;
if(score==5){tf.text="恭喜你通关了";}
else{tf.text="很遗憾,请大侠重新来过";}
varformat:
TextFormat=newTextFormat();
format.font="_sans";
format.color=0xFF0000;
format.size=50;
format.underline=true;
tf.x=(stage.stageWidth-tf.width)/2;
tf.y=(stage.stageHeight-tf.height)/2;
tf.autoSize="center";
tf.defaultTextFormat=format;
addChild(tf);
myGameView.cuowumian.removeEventListener(MouseEvent.CLICK,mianFn);
myEndBt=newButton();
addChild(myEndBt);
myEndBt.label="Restart";
myEndBt.x=(stage.stageWidth-myEndBt.width)/2;
myEndBt.y=300;
myEndBt.addEventListener(MouseEvent.CLICK,restartFn);
}
4、游戏主体部分操作步骤(含主要代码)及技巧
importfl.controls.Button;
importflash.events.MouseEvent;
importflash.utils.Timer;
importfl.motion.MotionEvent;
importflash.text.TextField;
importflash.display.Sprite;
importflash.text.TextField;
importflash.text.TextFormat;
varallScore:
int=5;
varmyStartBt:
Button;
varmyStartView:
StartView;
varmyGameView:
GameView;
varmyEndBt:
Button;
vartimer:
Timer;
varscore:
int;
varscoreField:
TextField;
vartf:
TextField;
varallTimer:
int;
vartimeField:
TextField;
init();
//游戏开始初始化
functioninit(){
//开始按钮定义
myStartBt=newButton();
addChild(myStartBt);
myStartBt.x=(stage.stageWidth-myStartBt.width)/2;
myStartBt.y=300;
myStartBt.label="Start";
myStartBt.addEventListener(MouseEvent.CLICK,myStartBtFn);
//开始界面的设置;
myStartView=newStartView();
addChild(myStartView);
myStartView.x=stage.stageWidth/2;
myStartView.y=stage.stageHeight/2;
//数值初始化
score=0;}
functionmyStartBtFn(e:
MouseEvent){
removeChild(myStartBt);
removeChild(myStartView);
myStartBt.removeEventListener(MouseEvent.CLICK,myStartBtFn);
gameStart();}
//游戏正式界面设置
functiongameStart(){
scoreField=newTextField();
scoreFn();
addChild(scoreField);
myGameView=newGameView();
addChild(myGameView);
myGameView.x=stage.stageWidth/2;
myGameView.y=stage.stageHeight/2;
allTimer=10;
timer=newTimer(1000,20);
timer.addEventListener(TimerEvent.TIMER,timerFn);
timer.start();
timeField=newTextField();
timeField.autoSize="center";
timeField.text="你还有"+allTimer+"秒";
timeField.x=400;
addChild(timeField);
myGameView.cuo1.stop();
myGameView.cuo2.stop();
myGameView.cuo3.stop();
myGameView.cuo4.stop();
myGameView.cuo5.stop();
myGameView.cuowumian.addEventListener(MouseEvent.CLICK,mianFn);
myGameView.cuo1.addEventListener(MouseEvent.CLICK,cuo1Fn);
myGameView.cuo2.addEventListener(MouseEvent.CLICK,cuo2Fn);
myGameView.cuo3.addEventListener(MouseEvent.CLICK,cuo3Fn);
myGameView.cuo4.addEventListener(MouseEvent.CLICK,cuo4Fn);
myGameView.cuo5.addEventListener(MouseEvent.CLICK,cuo5Fn);}
functiontimerFn(e:
TimerEvent){
allTimer--;
timeField.text="你还有"+allTimer+"秒";
if(allTimer<0){
timer.stop();
timer.removeEventListener(TimerEvent.TIMER,timerFn);
endGame();}}
functionmianFn(e:
MouseEvent){
allTimer--;}
functionscoreFn(){
scoreField.text="已找到"+String(score)+"错,剩余"+String(allScore-score)+"处错";
scoreField.width=300;}
functioncuo1Fn(e:
MouseEvent){
myGameView.cuo1.removeEventListener(MouseEvent.CLICK,cuo1Fn);
myGameView.cuo1.gotoAndStop
(2);
score++;
scoreFn();
allTimer+=2;
trace(score);
if(score==5){
timer.stop();
endGame();}}
functioncuo2Fn(e:
MouseEvent){
myGameView.cuo2.removeEventListener(MouseEvent.CLICK,cuo2Fn);
myGameView.cuo2.gotoAndStop
(2);
score++;
scoreFn();
allTimer+=2;
trace(score);
if(score==5){
timer.stop();
endGame();}}
functioncuo3Fn(e:
MouseEvent){
myGameView.cuo3.removeEventListener(MouseEvent.CLICK,cuo3Fn);
myGameView.cuo3.gotoAndStop
(2);
sco