70多行颜色配对游戏demo
作者:smallerbird 类型:原创 来源:闪吧
先看看游戏:
详细代码:
详细代码:
//原创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://space.flash8.net/bbs/thread-358100-1-1.html
//效果及源码下载地址 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();
责任编辑:silvia 时间:2008年7月17日
- 上一篇:
- flash中导入视频的播放暂停如何控制?
- 没有相关教材
- 最近更新
