互动媒体制作实验报告

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

资料范本
本资料为word版本,可以直接编辑和打印,感谢您的下载
互动媒体制作实验报告
地点:__________________
时间:__________________
说明:本资料适用于约定双方经过谈判,协商而共同承认,共同遵守的责任与义务,仅供参考,文档可直接下载或修改,不需要的部分可直接删除,使用时请详细阅读内容
上海建桥学院
本科实验报告
课程名称:互动媒体制作
学号:
姓名:
专业:数字媒体艺术
班级:
指导教师:
课内实验目录及成绩
信息技术学院
2012年12 月 1 日
上海建桥学院实验报告
课程名称:互动媒体制作实验类型:验证型
实验项目名称:交互事件动画(星星亮满天)
实验地点:多媒体机房实验日期:2013 年 3 月7 日
一、实验目的和要求
1、熟悉的运用;
2、巩固AS3.0的程序结构和基本语法;
3、能够创建和调用系统函数;
4、能够熟练运用程序基本结构;
5、制作满足相应指标要求的正确运行的小游戏;
二、实验内容和原理
1、使用显示对象、对象点击事件、三大元件等编写交互功能
2、程序的基本结构包括:顺序结构、选择结构、循环结构
3、事件函数:MouseEvent事件类
4、时间函数:Timer类
三、主要仪器设备或环境
PC机;Flash cs5.5(或以上);Photoshop cs5(或以上);移动终端5套。

四、操作方法与实验步骤
1、确定游戏的主题(名称、色彩配置、主题思想、使用方法等)
名称:星星亮满天
色彩配置:深邃的天空+颜色随机的星星
主题思想:在背景天空区域,左键单击星星出现,并且颜色随机
使用方法:鼠标左键单击
2、确定游戏的设计流程图
3、游戏素材的采集、导入或制作
导入图片bg,并转成元件导入图片星光,并制作成动画
4、关键的操作步骤(含主要代码)及技巧
星光转换成元件,并制作动画,达到星星从大到小,从小到大的变化。

然后将此元件再次转换,并再次制作动画,共5帧,每帧星星颜色不一样。

在bg上的天空上制作一个遮罩层mc ,并对mc添加一个鼠标监听。

mc.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler_2);
function fl_MouseClickHandler_2(event:MouseEvent):void
{
var mystar:star=new star();
mystar.x=mouseX;
mystar.y=mouseY;
//改大小/颜色
mystar.stop();
var randomNum:int=Math.floor(Math.random()*5+1);
mystar.width=mystar.height=Math.random()*60+30;
mystar.gotoAndStop(randomNum);
addChild(mystar);
trace("已单击鼠标");
}
五、实验结果
注:可用贴图的方式
1、主要使用的AS3.0的知识点
添加鼠标监听、实例对象显示在鼠标点击的位置(mystar.x=mouseX; mystar.y=mouseY;)、数学函数(随机数、向下取整)、gotoAndStop
2、小游戏的效果(至少给出3个,含制作过程及结果)
六、实验总结
注:包括制作过程中出现的问题,实验心得体会及改进意见等
在老师的带领下完成了此次小游戏,初次体验到Flash的神奇,特别是随机数的出现。

在这种浓烈的兴趣下,我将更认真的学习Flash。

上海建桥学院实验报告
课程名称:互动媒体制作实验类型:设计型
实验项目名称:文字回合类游戏制作(面向过程及时间函数)
实验地点:多媒体机房实验日期:2013 年 3 月21 日
一、实验目的和要求
1、巩固面向对象编程的相关概念;
2、构造函数的创建和使用;
3、事件处理机制及Event类的创建、使用(事件侦听器);
4、能够熟练运用鼠标事件;
5、制作满足要求的动画效果;
二、实验内容和原理
1、使用事件驱动编写AS3.0应用程序(物体移动等的动画效果)
2、鼠标事件:CLICK、MOUSE_MOVE、MOUSE_OVER、MOUSE_OUT、MOUSE_WHEEL等
3、键盘事件:KeyboardEvent.KEY_DOWN(UP)等
4、时间函数:TimerEvent.TIMER、TimerEvent.TIMER _COMPLETE
三、主要仪器设备或环境
PC机;Flash cs5.5(或以上);Photoshop cs5(或以上);移动终端5套。

四、操作方法与实验步骤
1、确定作品的主题(名称、色彩配置、主题思想、使用方法等)
名称:勇者斗恶龙
主题思想:为了描写战斗,对勇者与恶龙设置特性,如名字,攻击力,防御力以及速度,运行游戏,出现打斗文字。

使用方法:结果显示在输入框里
2、主题作品的设计
运行游戏后,勇者与恶龙轮流发动攻击,最后得出胜负。

3、素材的导入或制作
没有素材的导入
4、关键的操作步骤(含主要代码)及技巧
var hero:Object = new Object();
var monster:Object = new Object();
= "勇者";
hero.HP = 500;
hero.ATT = 90;
hero.DEF = 88;
hero.AGI = 60;
hero.skill1 = "普通攻击";
hero.skill2 = "飞刃闪";
hero.skill3 = "极光剑";
= "恶龙";
monster.HP = 1000;
monster.ATT = 120;
monster.DEF = 100;
monster.AGI = 22;
monster.skill1 = "攻击";
monster.skill2 = "龙尾击";
monster.skill3 = "毁灭光线";
var timer:Timer = new Timer(1000);
timer.addEventListener(TimerEvent.TIMER, round) timer.start();
function whoAttacks(a:Object,b:Object):Array{
return a.AGI*Math.random() > b.AGI*Math.random() ? [a,b]:[b,a];
}
function round(e:TimerEvent):void{
var damage:Number;
var skillIndex:uint;
var roundFight:Array = whoAttacks(hero,monster);
var attacker:Object = roundFight[0];
var defender:Object = roundFight[1];
damage = attacker.ATT*Math.random() - defender.DEF * Math.random();
if(damage <= 0){
damage = 0;
}else{
damage = Math.ceil(damage);
}
defender.HP -= damage;
if(damage < attacker.ATT / 3){
skillIndex = 1;
}else if(damage < attacker.ATT *2/ 3){
skillIndex = 2;
}else{
skillIndex = 3;
}
trace( + "向" + + "发动了"+attacker["skill"+skillIndex] + ","+ + "损失了" + damage + "点HP!");
if(defender.HP <= 0){
trace( + "终于支持不住,倒下了!\n"+ + "取得了胜利!");
timer.removeEventListener(TimerEvent.TIMER, round);
trace("\nGame Over");
return;
}
trace( + " HP:" + hero.HP + "\t"+ + " 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机;Flash cs5(或以上);Photoshop cs5(或以上);移动终端5套;数码照相机1台;数码摄像机1台;数位板1个。

四、操作方法与实验步骤
1、确定主题、设计流程图
主题:找茬游戏
设计流程图:
2、游戏整体流程拆分
游戏开始初始化:开始按钮定义、开始界面的设置、初始化数值
游戏主题部分:添加三个文本框,一个计分数,一个倒计时,一个统计剩余几个错找到几个错。

添加Timer时间监听,用来倒计时。

对cuowumian、cuo1、cuo2、cuo3.、cuo4.、cuo5添加鼠标事件监听,MouseEvent.CLICK。

游戏结束部分:移除游戏主体页面上所有东西,移除监听。

根据找出的错的个数判断是否通关,并显示在名为tf的文本框里。

添加一个Restart按钮,实现重玩的功能。

3、三大游戏流程部分功能实现
游戏开始初始化、开始界面的设置;
myStartView =new StartView();
addChild(myStartView);
myStartView.x = stage.stageWidth / 2;
myStartView.y = stage.stageHeight / 2;
游戏正式界面设置
function gameStart(){
scoreField=new TextField();
scoreFn();
addChild(scoreField);
myGameView=new GameView();
addChild(myGameView);
myGameView.x = stage.stageWidth / 2;
myGameView.y = stage.stageHeight / 2;
allTimer = 10;
timer = new Timer(1000,20);
timer.addEventListener(TimerEvent.TIMER,timerFn);
timer.start();
timeField=new TextField();
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);
}
游戏结束
function endGame(){
removeChild(myGameView);
removeChild(scoreField);
removeChild(timeField);
myGameView.cuowumian.removeEventListener(MouseEvent.CLICK,mianFn);
tf=new TextField();
tf.width = 300;
if (score==5) { tf.text = "恭喜你通关了"; }
else { tf.text = "很遗憾,请大侠重新来过"; }
var format:TextFormat = new TextFormat();
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=new Button();
addChild(myEndBt);
bel = "Restart";
myEndBt.x=(stage.stageWidth-myEndBt.width )/2;
myEndBt.y = 300;
myEndBt.addEventListener(MouseEvent.CLICK,restartFn);
}
4、游戏主体部分操作步骤(含主要代码)及技巧
import fl.controls.Button;
import flash.events.MouseEvent;
import flash.utils.Timer;
import fl.motion.MotionEvent;
import flash.text.TextField;
import flash.display.Sprite;
import flash.text.TextField;
import flash.text.TextFormat;
var allScore:int = 5;
var myStartBt:Button;
var myStartView:StartView;
var myGameView:GameView;
var myEndBt:Button;
var timer:Timer;
var score:int;
var scoreField:TextField;
var tf:TextField;
var allTimer:int;
var timeField:TextField;
init();
//游戏开始初始化
function init(){
//开始按钮定义
myStartBt=new Button ();
addChild(myStartBt);
myStartBt.x=(stage.stageWidth-myStartBt.width )/2;
myStartBt.y = 300;
bel = "Start";
myStartBt.addEventListener(MouseEvent.CLICK,myStartBtFn);
//开始界面的设置;
myStartView =new StartView();
addChild(myStartView);
myStartView.x = stage.stageWidth / 2;
myStartView.y = stage.stageHeight / 2;
//数值初始化
score = 0;}
function myStartBtFn(e:MouseEvent ){
removeChild(myStartBt);
removeChild(myStartView);
myStartBt.removeEventListener(MouseEvent.CLICK,myStartBtFn );
gameStart();}
//游戏正式界面设置
function gameStart(){
scoreField=new TextField();
scoreFn();
addChild(scoreField);
myGameView=new GameView();
addChild(myGameView);
myGameView.x = stage.stageWidth / 2;
myGameView.y = stage.stageHeight / 2;
allTimer = 10;
timer = new Timer(1000,20);
timer.addEventListener(TimerEvent.TIMER,timerFn);
timer.start();
timeField=new TextField();
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);} function timerFn(e:TimerEvent){
allTimer--;
timeField.text = "你还有" + allTimer + "秒";
if (allTimer<0) {
timer.stop();
timer.removeEventListener(TimerEvent.TIMER,timerFn);
endGame(); }}
function mianFn(e:MouseEvent){
allTimer--;}
function scoreFn(){
scoreField.text="已找到"+String(score)+"错,剩余"+String(allScore-score)+"处错";
scoreField.width = 300;}
function cuo1Fn(e:MouseEvent){
myGameView.cuo1.removeEventListener(MouseEvent.CLICK,cuo1Fn);
myGameView.cuo1.gotoAndStop(2);
score++;
scoreFn();
allTimer+=2;
trace(score);
if (score==5) {
timer.stop();
endGame(); }}
function cuo2Fn(e:MouseEvent){
myGameView.cuo2.removeEventListener(MouseEvent.CLICK,cuo2Fn);
myGameView.cuo2.gotoAndStop(2);
score++;
scoreFn();
allTimer+=2;
trace(score);
if (score==5) {
endGame(); }}
function cuo3Fn(e:MouseEvent){
myGameView.cuo3.removeEventListener(MouseEvent.CLICK,cuo3Fn);
myGameView.cuo3.gotoAndStop(2);
score++;
scoreFn();
allTimer+=2;
trace(score);
if (score==5) {
timer.stop();
endGame(); }}
function cuo4Fn(e:MouseEvent){
myGameView.cuo4.removeEventListener(MouseEvent.CLICK,cuo4Fn);
myGameView.cuo4.gotoAndStop(2);
score++;
scoreFn();
allTimer+=2;
trace(score);
if (score==5) {
timer.stop();
endGame(); }}
function cuo5Fn(e:MouseEvent){
myGameView.cuo5.removeEventListener(MouseEvent.CLICK,cuo5Fn);
myGameView.cuo5.gotoAndStop(2);
score++;
scoreFn();
allTimer+=2;
trace(score);
if (score==5) {
endGame();}}
//游戏结束
function endGame()
{
removeChild(myGameView);
removeChild(scoreField);
removeChild(timeField);
myGameView.cuowumian.removeEventListener(MouseEvent.CLICK,mianFn);
tf=new TextField();
tf.width = 300;
if (score==5) {
tf.text = "恭喜你通关了"; }
else {
tf.text = "很遗憾,请大侠重新来过"; }
var format:TextFormat = new TextFormat();
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=new Button();
addChild(myEndBt);
bel = "Restart";
myEndBt.x=(stage.stageWidth-myEndBt.width )/2;
myEndBt.y = 300;
myEndBt.addEventListener(MouseEvent.CLICK,restartFn);
}
function restartFn(e:MouseEvent)
{
myEndBt.removeEventListener(MouseEvent.CLICK,restartFn);
removeChild(myEndBt);
removeChild(tf);
init();
}
五、实验结果
注:可用贴图的方式
1、主要使用的知识点
运用Timer类控制显示对象的属性来制作交互动画
2、交互动画的效果(至少给出3个,含制作过程及结果)
六、实验总结
注:包括制作过程中出现的问题,实验心得体会及改进意见等
这算目前为止做的最完整的一个游戏了,很有挑战性,我多添加了两张图片,成了有3个关卡的游戏,很有趣。

上海建桥学院实验报告
课程名称:互动媒体制作实验类型:综合型
实验项目名称:碰撞类游戏制作
实验地点:多媒体机房实验日期:2013 年 6 月 6 日
一、实验目的和要求
1、巩固AS3.0外部素材的导入、处理及控制方式;
2、学会音频的设置和使用;
3、使用面向对象思路开发;
4、Flash读取XML数据素材连接技术及实现方法;
5、制作满足相应指标要求的交互媒体;
二、实验内容和原理
1、确定内容健康的主题
2、作品素材的准备
3、制作作品的流程图(分镜头脚本)
4、遵循交互媒体的设计和制作流程,完成主题作品的制作
三、主要仪器设备或环境
PC机;Flash cs5.5(或以上);Photoshop cs5(或以上);移动终端5套;数码照相机1台;数码摄像机1台。

四、操作方法与实验步骤
1、确定主题、设计流程图、色彩搭配
主题:12是男人成果30s
原理:使用键盘上下左右控制白球移动,让白球躲过蓝球,碰到蓝球游戏失败。

色彩搭配:键盘控制球----白色;随机自动出来的球-----白色;
背景----黑色;道具:七彩色
2、作品的素材处理(导入、拍摄、制作等方式)
Goal元件元件1 元件2
所属Goal类所属Qiu类所属Dao类3、游戏主体部分功能拆分(撰写)
package {
import flash.display.MovieClip;
import flash.events.*
import flash.events.KeyboardEvent
import flash.ui.Keyboard
import flash.utils.Timer;
public class Goal extends MovieClip {
var upPressed:Boolean = false;
var downPressed:Boolean = false;
var leftPressed:Boolean = false;
var rightPressed:Boolean = false;
var timer:Timer;
public function Goal()
{
this.addEventListener(Event.ADDED_TO_STAGE,ADFn);
}
public function ADFn(e:Event)
{
this.removeEventListener(Event.ADDED_TO_STAGE,ADFn);
this.addEventListener(Event.ENTER_FRAME,
fl_MoveInDirectionOfKey);
stage.addEventListener(KeyboardEvent.KEY_DOWN,
fl_SetKeyPressed);
stage.addEventListener(KeyboardEvent.KEY_UP, fl_UnsetKeyPressed);
}
public function fl_MoveInDirectionOfKey(event:Event)
{
if (upPressed)
{
this.y -= 5;
}
if (downPressed)
{
this.y += 5;
}
if (leftPressed)
{
this.x -= 5;
}
if (rightPressed)
{
this.x += 5;
}
if(this.x>stage.stageWidth
||this.x<0
||this.y>stage.stageHeight
||this.y<0){
clear() } }
public function fl_SetKeyPressed(event:KeyboardEvent):void
{
switch (event.keyCode)
{
case 38 :
{
upPressed = true;
break;
};
case Keyboard.DOWN :
{
downPressed = true;
break;
};
case Keyboard.LEFT :
{
leftPressed = true;
break;
};
case Keyboard.RIGHT :
{
rightPressed = true;
break; } } };
public function fl_UnsetKeyPressed(event:KeyboardEvent):void {
switch (event.keyCode)
{
case Keyboard.UP :
{
upPressed = false;
break;
};
case Keyboard.DOWN :
{
downPressed = false;
break;
};
case Keyboard.LEFT :
{
leftPressed = false;
break;
};
case Keyboard.RIGHT :
{
rightPressed = false;
break;
}
}
}
public function clear(){
this.removeEventListener(Event.ENTER_FRAME,
fl_MoveInDirectionOfKey);
stage.removeEventListener(KeyboardEvent.KEY_DOWN, fl_SetKeyPressed);
stage.removeEventListener(KeyboardEvent.KEY_UP,
fl_UnsetKeyPressed);
this.parent.removeChild(this)
}
public function changeBig(){
this.scaleX*=1.5;
this.scaleY*=1.5;
timer=new Timer(1000,3);
timer.addEventListener(TimerEvent.TIMER,timerFn);
timer.start();
}
public function timerFn(e:TimerEvent){
changeSmall();
}
public function changeSmall(){
this.scaleX/=1.5;
this.scaleY/=1.5;
timer.stop();
timer.removeEventListener(TimerEvent.TIMER,timerFn);
} } }
4、关键的操作步骤(含主要代码)及技巧
键盘控制球的代码:package {
import flash.display.MovieClip;
import flash.events.*
import flash.events.KeyboardEvent
import flash.ui.Keyboard
import flash.utils.Timer;
public class Goal extends MovieClip
{
var upPressed:Boolean = false;
var downPressed:Boolean = false;
var leftPressed:Boolean = false;
var rightPressed:Boolean = false;
var timer:Timer;
public function Goal()
{
this.addEventListener(Event.ADDED_TO_STAGE,ADFn);
}
public function ADFn(e:Event)
{
this.removeEventListener(Event.ADDED_TO_STAGE,ADFn);
this.addEventListener(Event.ENTER_FRAME,
fl_MoveInDirectionOfKey);
stage.addEventListener(KeyboardEvent.KEY_DOWN,
fl_SetKeyPressed);
stage.addEventListener(KeyboardEvent.KEY_UP, fl_UnsetKeyPressed);
}
public function fl_MoveInDirectionOfKey(event:Event)
{
if (upPressed)
{
this.y -= 5;
}
if (downPressed)
{
this.y += 5;
}
if (leftPressed)
{
this.x -= 5;
}
if (rightPressed)
{
this.x += 5;
}
if(this.x>stage.stageWidth
||this.x<0
||this.y>stage.stageHeight
||this.y<0){
clear()
}
}
public function fl_SetKeyPressed(event:KeyboardEvent):void {
switch (event.keyCode)
{
case 38 :
{
upPressed = true;
break;
};
case Keyboard.DOWN :
{
downPressed = true;
break;
};
case Keyboard.LEFT :
{
leftPressed = true;
break;
};
case Keyboard.RIGHT :
{
rightPressed = true;
break;
}
}
};
public function fl_UnsetKeyPressed(event:KeyboardEvent):void {
switch (event.keyCode)
{
case Keyboard.UP :
{
upPressed = false;
break;
};
case Keyboard.DOWN :
{
downPressed = false;
break;
};
case Keyboard.LEFT :
{
leftPressed = false;
break;
};
case Keyboard.RIGHT :
{
rightPressed = false;
break;
}
}
}
public function clear(){
this.removeEventListener(Event.ENTER_FRAME,
fl_MoveInDirectionOfKey);
stage.removeEventListener(KeyboardEvent.KEY_DOWN, fl_SetKeyPressed);
stage.removeEventListener(KeyboardEvent.KEY_UP,
fl_UnsetKeyPressed);
this.parent.removeChild(this)
}
public function changeBig(){
this.scaleX*=1.5;
this.scaleY*=1.5;
timer=new Timer(1000,3);
timer.addEventListener(TimerEvent.TIMER,timerFn);
timer.start();
}
public function timerFn(e:TimerEvent){
changeSmall();
}
public function changeSmall(){
this.scaleX/=1.5;
this.scaleY/=1.5;
timer.stop();
timer.removeEventListener(TimerEvent.TIMER,timerFn);
} } }
随机自动出来的篮球代码:package {
import flash.display.MovieClip;
import flash.events.Event;
public class Qiu extends MovieClip {
var QiuDirection:int =Math.floor(Math.random()*4)
var xyDirection:int=0
var speedX
var speedY
var temp:int=Math.floor(Math.random()*2)
var num:Number=1;
public function Qiu() {
this.addEventListener(Event.ADDED_TO_STAGE,ADFn)
this.addEventListener(Event.ENTER_FRAME,timeFn)
xyDirection=(temp ==0) ? 1:-1
}
public function ADFn(e:Event){
this.removeEventListener(Event.ADDED_TO_STAGE,ADFn)
switch(QiuDirection){
case 0:
this.x=Math.random()*stage.stageWidth
this.y=0
this.speedX=Math.random()*4*xyDirection
this.speedY=Math.random()*4
break
case 1:
this.x=0
this.y=Math.random()*stage.stageHeight
this.speedX=Math.random()*4
this.speedY=Math.random()*4*xyDirection break
case 2:
this.x=Math.random()*stage.stageWidth
this.y=stage.stageHeight
this.speedX=Math.random()*4*xyDirection this.speedY=Math.random()*(-4)
break
case 3:
this.x=stage.stageWidth
this.y=Math.random()*stage.stageHeight
this.speedX=Math.random()*(-4)
this.speedY=Math.random()*4*xyDirection break
}
}
public function timeFn(e:Event){
/*trace(this.parent["goal"])*/
if(this.hitTestObject(this.parent["goal"])){ myClearAll();
}
else
{
this.x+=this.speedX*num
this.y+=this.speedY*num
if(this.x<0
||this.x>stage.stageWidth
||this.y<0
||this.y>stage.stageHeight){
clear()
}
}
}
public function myClearAll(){
this.parent["clearALL"]()
}
public function clear(){
this.removeEventListener(Event.ENTER_FRAME,timeFn)
this.parent.removeChild(this)
} } }
道具的代码:
package {
import flash.display.MovieClip;
public class Dao extends Qiu {
public function Dao() {
// constructor code
}
//override表示重写父类方法
override public function myClearAll(){
this.parent["goal"].changeBig()
clear();//继承于Qiu,所以有clear()
} } }
五、实验结果
注:可用贴图的方式
1、素材外部调用的实现
2、游戏主体部分功能实现(给出关键部分功能代码,含制作过程及结果)package {
import flash.display.MovieClip;
import flash.events.*
import flash.events.KeyboardEvent
import flash.ui.Keyboard
import flash.utils.Timer;
public class Goal extends MovieClip {
var upPressed:Boolean = false;
var downPressed:Boolean = false;
var leftPressed:Boolean = false;
var rightPressed:Boolean = false;
var timer:Timer;
public function Goal()
{
this.addEventListener(Event.ADDED_TO_STAGE,ADFn);
}
public function ADFn(e:Event)
{
this.removeEventListener(Event.ADDED_TO_STAGE,ADFn);
this.addEventListener(Event.ENTER_FRAME,
fl_MoveInDirectionOfKey);
stage.addEventListener(KeyboardEvent.KEY_DOWN,
fl_SetKeyPressed);
stage.addEventListener(KeyboardEvent.KEY_UP, fl_UnsetKeyPressed);
}
public function fl_MoveInDirectionOfKey(event:Event)
{
if (upPressed)
{
this.y -= 5;
}
if (downPressed)
{
this.y += 5;
}
if (leftPressed)
{
this.x -= 5;
}
if (rightPressed)
{
this.x += 5;
}
if(this.x>stage.stageWidth
||this.x<0
||this.y>stage.stageHeight
||this.y<0){
clear() } }
public function fl_SetKeyPressed(event:KeyboardEvent):void {
switch (event.keyCode)
{
case 38 :
{
upPressed = true;
break;
};
case Keyboard.DOWN :
{
downPressed = true;
break;
};
case Keyboard.LEFT :
{
leftPressed = true;
break;
};
case Keyboard.RIGHT :
{
rightPressed = true;
break; } } };
public function fl_UnsetKeyPressed(event:KeyboardEvent):void {
switch (event.keyCode)
{
case Keyboard.UP :
{
upPressed = false;
break;
};
case Keyboard.DOWN :
{
downPressed = false;
break;
};
case Keyboard.LEFT :
{
leftPressed = false;
break;
};
case Keyboard.RIGHT :
{
rightPressed = false;
break;
}
}
}
public function clear(){
this.removeEventListener(Event.ENTER_FRAME,
fl_MoveInDirectionOfKey);
stage.removeEventListener(KeyboardEvent.KEY_DOWN, fl_SetKeyPressed);
stage.removeEventListener(KeyboardEvent.KEY_UP,
fl_UnsetKeyPressed);
this.parent.removeChild(this)
}
public function changeBig(){
this.scaleX*=1.5;
this.scaleY*=1.5;
timer=new Timer(1000,3);
timer.addEventListener(TimerEvent.TIMER,timerFn);
timer.start();
}
public function timerFn(e:TimerEvent){
changeSmall();
}
public function changeSmall(){
this.scaleX/=1.5;
this.scaleY/=1.5;
timer.stop();
timer.removeEventListener(TimerEvent.TIMER,timerFn);
} } }
4、关键的操作步骤(含主要代码)及技巧
键盘控制球的代码:package {
import flash.display.MovieClip;
import flash.events.*
import flash.events.KeyboardEvent
import flash.ui.Keyboard
import flash.utils.Timer;
public class Goal extends MovieClip
{
var upPressed:Boolean = false;
var downPressed:Boolean = false;
var leftPressed:Boolean = false;
var rightPressed:Boolean = false;
var timer:Timer;
public function Goal()
{
this.addEventListener(Event.ADDED_TO_STAGE,ADFn);
}
public function ADFn(e:Event)
{
this.removeEventListener(Event.ADDED_TO_STAGE,ADFn);
this.addEventListener(Event.ENTER_FRAME,
fl_MoveInDirectionOfKey);
stage.addEventListener(KeyboardEvent.KEY_DOWN,
fl_SetKeyPressed);
stage.addEventListener(KeyboardEvent.KEY_UP, fl_UnsetKeyPressed);
}
public function fl_MoveInDirectionOfKey(event:Event)
{
if (upPressed)
{
this.y -= 5;
}
if (downPressed)
{
this.y += 5;
}
if (leftPressed)
{
this.x -= 5;
}
if (rightPressed)
{
this.x += 5;
}
if(this.x>stage.stageWidth
||this.x<0
||this.y>stage.stageHeight
||this.y<0){
clear()
}
}
public function fl_SetKeyPressed(event:KeyboardEvent):void {
switch (event.keyCode)
{
case 38 :
{
upPressed = true;
break;
};
case Keyboard.DOWN :
{
downPressed = true;
break;
};
case Keyboard.LEFT :
{
leftPressed = true;
break;
};
case Keyboard.RIGHT :
{
rightPressed = true;
break;
}
}
};
public function fl_UnsetKeyPressed(event:KeyboardEvent):void {
switch (event.keyCode)
{
case Keyboard.UP :
{
upPressed = false;
break;
};
case Keyboard.DOWN :
{
downPressed = false;
break;
};
case Keyboard.LEFT :
{
leftPressed = false;
break;
};
case Keyboard.RIGHT :
{
rightPressed = false;
break;
}
}
}
public function clear(){
this.removeEventListener(Event.ENTER_FRAME,
fl_MoveInDirectionOfKey);
stage.removeEventListener(KeyboardEvent.KEY_DOWN, fl_SetKeyPressed);
stage.removeEventListener(KeyboardEvent.KEY_UP,
fl_UnsetKeyPressed);
this.parent.removeChild(this)
}
public function changeBig(){
this.scaleX*=1.5;
this.scaleY*=1.5;
timer=new Timer(1000,3);
timer.addEventListener(TimerEvent.TIMER,timerFn);
timer.start();
}
public function timerFn(e:TimerEvent){
changeSmall();
}
public function changeSmall(){
this.scaleX/=1.5;
this.scaleY/=1.5;
timer.stop();
timer.removeEventListener(TimerEvent.TIMER,timerFn);
} } }
随机自动出来的篮球代码:package {
import flash.display.MovieClip;
import flash.events.Event;
public class Qiu extends MovieClip {
var QiuDirection:int =Math.floor(Math.random()*4)
var xyDirection:int=0
var speedX
var speedY
var temp:int=Math.floor(Math.random()*2)
var num:Number=1;
public function Qiu() {
this.addEventListener(Event.ADDED_TO_STAGE,ADFn)
this.addEventListener(Event.ENTER_FRAME,timeFn)
xyDirection=(temp ==0) ? 1:-1
}
public function ADFn(e:Event){
this.removeEventListener(Event.ADDED_TO_STAGE,ADFn) switch(QiuDirection){
case 0:
this.x=Math.random()*stage.stageWidth
this.y=0
this.speedX=Math.random()*4*xyDirection
this.speedY=Math.random()*4
break
case 1:
this.x=0
this.y=Math.random()*stage.stageHeight
this.speedX=Math.random()*4
this.speedY=Math.random()*4*xyDirection
break
case 2:
this.x=Math.random()*stage.stageWidth
this.y=stage.stageHeight
this.speedX=Math.random()*4*xyDirection this.speedY=Math.random()*(-4)
break
case 3:
this.x=stage.stageWidth
this.y=Math.random()*stage.stageHeight
this.speedX=Math.random()*(-4)
this.speedY=Math.random()*4*xyDirection break
}
}
public function timeFn(e:Event){
/*trace(this.parent["goal"])*/
if(this.hitTestObject(this.parent["goal"])){ myClearAll();
}
else
{
this.x+=this.speedX*num
this.y+=this.speedY*num
if(this.x<0
||this.x>stage.stageWidth
||this.y<0
||this.y>stage.stageHeight){
clear()
}
}
}
public function myClearAll(){
this.parent["clearALL"]()
}
public function clear(){
this.removeEventListener(Event.ENTER_FRAME,timeFn)
this.parent.removeChild(this)
} } }
道具的代码:
package {
import flash.display.MovieClip;
public class Dao extends Qiu {
public function Dao() {
// constructor code
}
//override表示重写父类方法
override public function myClearAll(){
this.parent["goal"].changeBig()
clear();//继承于Qiu,所以有clear()
} } }
六、实验总结
注:包括制作过程中出现的问题,实验心得体会及改进意见等
通过本次实验,懂得了AS3.0编程面向对象的概念,能够编辑类实现对象实例化、完成碰撞检测等功能。

请删除以下内容后使用本资料
一、互联网的诞生
1.互联网诞生的历程
2.互联网与信息化社会
二、知识经济的发展
1.知识经济出现的时代背景
2.知识经济的内涵及发展概况
3.知识和信息对社会的影响
三、工作和生活方式的革命
四、面临的问题
重点:信息化社会的主要内容及影响
难点:知识经济的内涵
【教学方法】
由于本课的内容更加贴近于学生生活的实际,资料容易搜集,并且也很有趣味性,因此在教学前应该引导学生搜集网络发展的资料,以锻炼学生收集整理资料的能力,不断加深对历史和现实的理解。

在教学时教师在帮助学生理清课本基本线索的同时,充分利用学生课下找到的相关资料和教材中有关资料,进行交流,以充分发挥学生学习的主体性、积极性和参与性,注意把历史知识的传授和思想教育结合在一起。

这既符合新课改的精神,又符合学生的心理发展特征,也有利于培养和提高学生的学习兴趣和历史思维能力。

【导入新课】
20世纪是科学技术日新月异的世纪,是高科技层出不穷的世纪。

电子计算机是20世纪人类最伟大的发明之一。

它把人类社会引入“信息时代”。

信息网络化成为20世纪新生的事物得到迅速的发展和普及,对人类的政治、经济、文化、军事、社会生活都产了深远而重大的影响。

由此导入新课。

【讲述内容】
一、互联网的诞生。

相关文档
最新文档