1.你好。flash as3.0小游戏,要源代码,类似于连连看,打砖块之类的。能发我吗?
2.flashas3.0制作电梯效果谁会或者谁有源代码告诉我一下我着急用!磁悬浮源码!!!!!!!电脑代码源码!
你好。flash as3.0小游戏,要源代码,类似于连连看,打砖块之类的。能发我吗?
的面试框架源码源码!!
package
{
import flash.display.Sprite;
import flash.events.*;
import flash.text.*;
import flash.geom.Point;
public class GameMain extends Sprite
{
private var i:int = 0;
private var j:int = 0;
private var k:int = 0;
private var tf:TextFormat = new TextFormat();
private var ContainTxt:Sprite = new Sprite();
private var arrTxt:Array = new Array();
private var arrTxtColor:Array = new Array();
private var arrTxtValue:Array = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]];
private var arrTemp:Array = new Array(5);
private var arrValue:Array = [0, 2, 4, 8, , , , , , , , GameMain, ];
private var arrColor:Array = [0xffffff, 0x, 0xff, 0xffcc, 0xff, 0xff, 0xff, 0xff, 0xffff, 0xff, 0xff, 0xffff];
private var B_change:Boolean = false;
private var dotest:int = 0;
private var score:int = 0;
public function GameMain():void
{
Depth(); //深度管理
new_Game(); //初始化
TF1();
}
private function new_Game():void
{
stage.addEventListener(Event.ENTER_FRAME, ValueToTxt);
Create_one();
Create_one();
stage.addEventListener(KeyboardEvent.KEY_DOWN, KEYDOWN);
}
private function KEYDOWN(ekey:KeyboardEvent):void
{
switch (ekey.keyCode)
{
case :
for (j = 0; j <= 3; j++)
{
for (i = 0; i <= 3; i++)
{
arrTemp[i] = arrTxtValue[i][j];
}
arrTemp[4] = 0;
doMove();
for (i = 0; i <= 3; i++)
{
arrTxtValue[i][j] = arrTemp[i];
}
}
break;
case :
for (k = 0; k <= 3; k++)
{
for (j = 0; j <= 3; j++)
{
arrTemp[j] = arrTxtValue[k][j];
}
arrTemp[4] = 0;
doMove();
for (j = 0; j <= 3; j++)
{
arrTxtValue[k][j] = arrTemp[j];
}
}
break;
case :
for (j = 0; j <= 3; j++)
{
for (i = 0; i <= 3; i++)
{
arrTemp[i] = arrTxtValue[3 - i][j];
}
arrTemp[4] = 0;
doMove();
for (i = 0; i <= 3; i++)
{
arrTxtValue[3 - i][j] = arrTemp[i];
}
}
break;
case :
for (k = 0; k <= 3; k++)
{
for (j = 0; j <= 3; j++)
{
arrTemp[j] = arrTxtValue[k][3 - j];
}
arrTemp[4] = 0;
doMove();
for (j = 0; j <= 3; j++)
{
arrTxtValue[k][3 - j] = arrTemp[j];
}
}
break;
default:
break;
}
}
private function doMove():void
{
var temp:int = 0;
score++;
//
do
{
for (i = 0; i <= 3; i++)
{
if (arrTemp[i] == 0)
{
if (arrTemp[i] != arrTemp[i + 1])
{
arrTemp[i] = arrTemp[i + 1];
arrTemp[i + 1] = 0;
B_change = true;
}
}
}
temp++;
} while (temp <= 3);
//
do
{
for (i = 1; i < 4; i++)
{
if (arrTemp[i] == arrTemp[i - 1])
{
if (arrTemp[i] != 0)
{
arrTemp[i - 1] = arrTemp[i] * 2;
arrTemp[i] = 0;
B_change = true;
}
}
}
temp++;
} while (temp <= 3);
//
do
{
for (i = 0; i < 4; i++)
{
if (arrTemp[i] == 0)
{
arrTemp[i] = arrTemp[i + 1];
arrTemp[i + 1] = 0;
}
}
temp++;
} while (temp <= 3);
// donothing
}
private function Create_one():void
{
do
{
i = Math.floor(Math.random() * 4);
j = Math.floor(Math.random() * 4);
} while (arrTxtValue[i][j] != 0);
if (Math.random() < 0.)
{
arrTxtValue[i][j] = arrValue[1];
}
else
{
arrTxtValue[i][j] = arrValue[2];
}
}
private function ValueToTxt(e:Event):void
{
for (i = 0; i < 4; i++)
{
for (j = 0; j < 4; j++)
{
var n:int = arrValue.indexOf(arrTxtValue[i][j]);
arrTxtColor[i][j].backgroundColor = arrColor[n];
arrTxt[i][j].text = arrTxtValue[i][j];
arrTxt[i][j].setTextFormat(tf);
}
}
//
if (B_change)
{
Create_one();
B_change = false;
}
}
private function GameOver():void
{
stage.removeEventListener(Event.ENTER_FRAME, ValueToTxt);
stage.removeEventListener(KeyboardEvent.KEY_DOWN, KEYDOWN);
}
private function TF1():void
{
tf.align = "center";
tf.bold = true;
tf.size = ;
tf.font = "Arial";
tf.color = 0xFFFFFF;
}
private function Depth():void
{
addChild(ContainTxt); //文本框容器
var Frame:Sprite = FRAME();
addChild(Frame); //结构
FrameTxt(); //文本框
}
private function FrameTxt():void
{
for (i = 0; i < 4; i++)
{
arrTxt[i] = new Array();
arrTxtColor[i] = new Array();
for (j = 0; j < 4; j++)
{
var temptxt:TextField = new TextField();
var temptxtColor:TextField = new TextField();
temptxt.selectable = temptxtColor.selectable = false;
temptxt.x = i * ;
temptxtColor.x = i * ;
temptxt.y = j * + ;
temptxtColor.y = j * ;
temptxtColor.width = temptxtColor.height = ;
temptxtColor.background = true;
ContainTxt.addChild(temptxtColor);
ContainTxt.addChild(temptxt);
arrTxt[i][j] = temptxt;
arrTxtColor[i][j] = temptxtColor;
}
}
}
private function FRAME():Sprite
{
var tempframe:Sprite = new Sprite();
for (i = 0; i <= 4; i++)
{
tempframe.graphics.moveTo(i * , 0);
tempframe.graphics.lineStyle(8, 0xCCCCCC);
tempframe.graphics.lineTo(i * , );
}
for (j = 0; j <= 4; j++)
{
tempframe.graphics.moveTo(0, j * );
tempframe.graphics.lineStyle(8, 0xCCCCCC);
tempframe.graphics.lineTo(, j * );
}
return tempframe;
}
}
}
flashas3.0制作电梯效果谁会或者谁有源代码告诉我一下我着急用!!!!制cpu源码!!!!!知道视频源码
实际的电梯效果较为复杂,例如能同时记住多个楼层,电梯会首先判断当前是上升还是下降,然后在上行或下降过程中按照楼层顺序停靠(而非按按钮顺序),每次停靠后会先开门,等待关闭门按钮按下或一定时间后自动关门,继续上升或下降等。本人能力有限,制作这样的效果需要花费大量时间。在此先提供一个简单的电梯效果代码:
```as3
// 假设有层楼,需要创建个按钮,放在舞台上后分别命名为:bnt1,bnt2,bnt3,...,bnt
// 再创建一个名为myMc的电梯MC,设置其注册点为上边中点,高度为,每楼层高度也为
// 在舞台上放置一个名为myText的动态文本框
// 声明一个数组var myBntArray:Array = new Array(bnt1, bnt2, bnt3, bnt4, bnt5, bnt6, bnt7, bnt8, bnt9, bnt);
// 准备一个变量,存储电梯目前所在的楼层数var n:int = ;
// 声明一个变量,存储要到达的楼层数var nn:int = ;
// 声明一个变量,控制电梯是否在移动var moving:Boolean = false;
myMc.y = 0;
// 为每个按钮添加事件监听器
for (var i:int = 0; i < myBntArray.length; i++) {
myBntArray[i].addEventListener(MouseEvent.CLICK, goFloor);
}
function goFloor(e:MouseEvent):void {
nn = myBntArray.indexOf(e.target) + 1;
moving = true;
// trace(nn);
}
addEventListener(Event.ENTER_FRAME, onEnterFrame);
function onEnterFrame(e:Event):void {
if (myMc.y != * Math.abs( - nn) && moving) {
myMc.y = myMc.y + (n - nn) / Math.abs(n - nn);
myText.text = String( - Math.round(myMc.y / ));
// trace(myMc.y);
} else {
n = nn;
moving = false;
}
}
```
这是一个简单的电梯效果。请根据实际需求进行调整和扩展。