
- 本栏最新文章
- flash as 语法编写规则的技巧经验详解 07-24
- 图片轮播效果 07-23
- FLASH打造较酷菜单效果 07-23
- 70多行颜色配对游戏Demo 07-21
- 把egoldy(王汝义)写的缓动滚动条修改成动态... 07-20
- flash中导入视频的播放暂停如何控制? 07-17
- 每隔5秒重新打字效果 07-17
- Flash中如何调整“动态文本”框的_alpha值 07-14
- 真正屏蔽FLASH右键方法 07-11
- Flash辅助利器SWFObject 07-10

- 本栏推荐文章
- Photoshop教程:水灵灵的美女调出来 12-30
- AS3与后台交互 12-21
- AS3通俗教程---AS3自身loading制作 12-19
70多行颜色配对游戏Demo
简介:先看看游戏:
详细代码:
//原创flash教程 尽在自娱自乐 www.MyGameMyLove.com //效果及源码下载地址 http://www.mygamemylove.com/t_html/607.html //停止 stop(); //获得随机数 function randRange(m ...
关键字:颜色配对游戏
先看看游戏:
详细代码:
//原创flash教程 尽在自娱自乐 www.MyGameMyLove.com
//效果及源码下载地址 http://www.mygamemylove.com/t_html/607.html
//停止
stop();
//获得随机数
function randRange(min:Number, max:Number):Number {
var randomNum:Number = Math.floor(Math.random()*(max-min+1))+min;
return randomNum;
}
//游戏的所有内容放在一个mc里。
var mcGame:MovieClip = _root.createEmptyMovieClip("mcGame", _root.getNextHighestDepth());
//游戏画面的位置
mcGame._x=100
//mcGame.isGameOver=false
//分数
mcGame.fs = 0;
//点对一个加多少分
mcGame.onefs = 100;
//行
mcGame.numhang = 5;
//列
mcGame.numlie = 5;
//单个方块宽
mcGame.numW = 50;
//单个方块高
mcGame.numH = 50;
//方块与方块之前的间隔
mcGame.numjg = 5;
//当前选择色的方块一个电影符号。用来存放,当前要点的是什么色。因为每种色的方块对应mc的一帧,所以我们判断该mc的
//当前帧 ._currentframe 就可以了.
mcGame.mcC = undefined;
//增加分数
mcGame.addFs = function() {
this.fs += this.onefs;
_root.txtTalkYou.text=("OK!! 分数:"+this.fs);
if (this.fs>=(this.numhang*this.numlie*this.onefs)) {
//this.isGameOver=true
_root.txtTalkYou.text=("gameover");
_root.mcR._visible=true
}
};
//所有当前同一色选完
mcGame.chkOverOneChk = function() {
for (var i = 1; i<=this.numlie; i++) {
for (var j = 1; j<=this.numhang; j++) {
if (this["mcE"+i+"_"+j]._currentframe == this.mcC._currentframe && this["mcE"+i+"_"+j].mc._visible) {
return false;
break;
}
}
}
return true;
};
//当前色
mcGame.mcOver = mcGame;
mcGame.ini = function() {
for (var i = 1; i<=this.numlie; i++) {
for (var j = 1; j<=this.numhang; j++) {
var mcTem:MovieClip = this.attachMovie("linke", "mcE"+i+"_"+j, this.getNextHighestDepth());
//
mcTem.onRollOver = function() {
this._parent.mcOver = this;
this._alpha = 50;
};
mcTem.onRollOut = mcTem.onDragOut=function () {
this._parent.mcOver._alpha = 100;
};
mcTem.onRelease = function() {
if (this._parent.mcC == undefined || this._parent.chkOverOneChk()) {
this._parent.mcC = this;
this.mc._visible = false;
this._parent.addFs()
} else {
if (this._currentframe == this._parent.mcC._currentframe) {
this.mc._visible = false;
this._parent.addFs();
} else {
_root.txtTalkYou.text=("NO!! 同一个色的还有");
}
}
};
//
mcTem._x = (this.numW+this.numjg)*j;
mcTem._y = (this.numH+this.numjg)*i;
mcTem.gotoAndStop(_root.randRange(1, 5));
}
}
};
//原创flash教程 尽在自娱自乐 www.MyGameMyLove.com
//下载地址:http://www.mygamemylove.com/t_html/607.html
//重新开始
mcR._visible=false
mcR.onRelease=function(){
_root.play();
}
//游戏初使化
mcGame.ini();
//效果及源码下载地址 http://www.mygamemylove.com/t_html/607.html
//停止
stop();
//获得随机数
function randRange(min:Number, max:Number):Number {
var randomNum:Number = Math.floor(Math.random()*(max-min+1))+min;
return randomNum;
}
//游戏的所有内容放在一个mc里。
var mcGame:MovieClip = _root.createEmptyMovieClip("mcGame", _root.getNextHighestDepth());
//游戏画面的位置
mcGame._x=100
//mcGame.isGameOver=false
//分数
mcGame.fs = 0;
//点对一个加多少分
mcGame.onefs = 100;
//行
mcGame.numhang = 5;
//列
mcGame.numlie = 5;
//单个方块宽
mcGame.numW = 50;
//单个方块高
mcGame.numH = 50;
//方块与方块之前的间隔
mcGame.numjg = 5;
//当前选择色的方块一个电影符号。用来存放,当前要点的是什么色。因为每种色的方块对应mc的一帧,所以我们判断该mc的
//当前帧 ._currentframe 就可以了.
mcGame.mcC = undefined;
//增加分数
mcGame.addFs = function() {
this.fs += this.onefs;
_root.txtTalkYou.text=("OK!! 分数:"+this.fs);
if (this.fs>=(this.numhang*this.numlie*this.onefs)) {
//this.isGameOver=true
_root.txtTalkYou.text=("gameover");
_root.mcR._visible=true
}
};
//所有当前同一色选完
mcGame.chkOverOneChk = function() {
for (var i = 1; i<=this.numlie; i++) {
for (var j = 1; j<=this.numhang; j++) {
if (this["mcE"+i+"_"+j]._currentframe == this.mcC._currentframe && this["mcE"+i+"_"+j].mc._visible) {
return false;
break;
}
}
}
return true;
};
//当前色
mcGame.mcOver = mcGame;
mcGame.ini = function() {
for (var i = 1; i<=this.numlie; i++) {
for (var j = 1; j<=this.numhang; j++) {
var mcTem:MovieClip = this.attachMovie("linke", "mcE"+i+"_"+j, this.getNextHighestDepth());
//
mcTem.onRollOver = function() {
this._parent.mcOver = this;
this._alpha = 50;
};
mcTem.onRollOut = mcTem.onDragOut=function () {
this._parent.mcOver._alpha = 100;
};
mcTem.onRelease = function() {
if (this._parent.mcC == undefined || this._parent.chkOverOneChk()) {
this._parent.mcC = this;
this.mc._visible = false;
this._parent.addFs()
} else {
if (this._currentframe == this._parent.mcC._currentframe) {
this.mc._visible = false;
this._parent.addFs();
} else {
_root.txtTalkYou.text=("NO!! 同一个色的还有");
}
}
};
//
mcTem._x = (this.numW+this.numjg)*j;
mcTem._y = (this.numH+this.numjg)*i;
mcTem.gotoAndStop(_root.randRange(1, 5));
}
}
};
//原创flash教程 尽在自娱自乐 www.MyGameMyLove.com
//下载地址:http://www.mygamemylove.com/t_html/607.html
//重新开始
mcR._visible=false
mcR.onRelease=function(){
_root.play();
}
//游戏初使化
mcGame.ini();


