谁帮我分析一下每行代码
as3.0吧
全部回复
仅看楼主
level 2
有偿
2018年02月26日 06点02分 1
level 2
stop();
var t1:Boolean;
var t2:Boolean;
var t3:Boolean;
var t4:Boolean;
init();
function init()
{
//t1 = t2 = t3 = t4 = t5 = t6 = t7 = t8 = t9 = false;
initPosition()
for (var i=1; i<=4; i++)
{
getChildByName(("b" + i)).addEventListener(MouseEvent.MOUSE_DOWN,onDown);
getChildByName(("b" + i)).addEventListener(MouseEvent.MOUSE_UP,onUp);
}
}
function onDown(e:MouseEvent):void
{
e.currentTarget.startDrag(false);
}
function onUp(e:MouseEvent):void
{
stopDrag();
for (var i = 1; i<=4; i++)
{
for (var j = 1; j<=4; j++)
{
if (this["b"+i].p.hitTestObject(getChildByName("a"+j)))
{
getChildByName("b"+i).x = getChildByName("a"+j).x;
getChildByName("b"+i).y = getChildByName("a"+j).y;
}
}
if (this["b"+i].p.hitTestObject(getChildByName("a"+i)))
{
this["t" + i] = true;
}
else
{
this["t" + i] = false;
}
}
if (t1 && t2 && t3 && t4)
{
gotoAndStop(2);
}
}
function initPosition()
{
for (var i = 1; i<=4; i++)
{
for (var j = 1; j<=4; j++)
{
if (this["b"+i].p.hitTestObject(getChildByName("a"+j)))
{
getChildByName("b"+i).x = getChildByName("a"+j).x;
getChildByName("b"+i).y = getChildByName("a"+j).y;
}
}
if (this["b"+i].p.hitTestObject(getChildByName("a"+i)))
{
this["t" + i] = true;
}
else
{
this["t" + i] = false;
}
}
}
2018年02月26日 06点02分 2
level 1
stop(); //停止
var t1:Boolean; //定义布尔类型变量t1
var t2:Boolean;//定义布尔类型变量t2
var t3:Boolean;//定义布尔类型变量t3
var t4:Boolean;//定义布尔类型变量t4
init();//初始化
function init()
{
//t1 = t2 = t3 = t4 = t5 = t6 = t7 = t8 = t9 = false;
initPosition()//初始化位置
//给对象名为b0,b1,b2,b3注册鼠标按下和鼠标松开的事件
for (var i=1; i<=4; i++)
{
getChildByName(("b" + i)).addEventListener(MouseEvent.MOUSE_DOWN,onDown);
getChildByName(("b" + i)).addEventListener(MouseEvent.MOUSE_UP,onUp);
}
}
function onDown(e:MouseEvent):void
{
e.currentTarget.startDrag(false);//按下对象开始执行拖拽方法
}
function onUp(e:MouseEvent):void
{
stopDrag();//停止拖拽
for (var i = 1; i<=4; i++)
{
for (var j = 1; j<=4; j++)
{
if (this["b"+i].p.hitTestObject(getChildByName("a"+j)))//碰撞检测,检测b1,b2,b3,b4对象有没有和a1,a2,a3,a4对象发生碰撞
{
//碰撞到了,就让两个对象坐标位置重合
getChildByName("b"+i).x = getChildByName("a"+j).x;
getChildByName("b"+i).y = getChildByName("a"+j).y;
}
}
if (this["b"+i].p.hitTestObject(getChildByName("a"+i)))//如果i相等的对象发生碰撞了
{
this["t" + i] = true;// 对应的t1,t2,t3,t4变量为true
}
else//否则
{
this["t" + i] = false;// 对应的t1,t2,t3,t4变量为false
}
}
if (t1 && t2 && t3 && t4)//如果t1,t2,t3,t4变量都为true
{
gotoAndStop(2);//当前场景跳转到第二帧
}
}
function initPosition()
{
for (var i = 1; i<=4; i++)
{
for (var j = 1; j<=4; j++)
{
if (this["b"+i].p.hitTestObject(getChildByName("a"+j)))
{
getChildByName("b"+i).x = getChildByName("a"+j).x;
getChildByName("b"+i).y = getChildByName("a"+j).y;
}
}
if (this["b"+i].p.hitTestObject(getChildByName("a"+i)))
{
this["t" + i] = true;
}
else
{
this["t" + i] = false;
}
}
}
2019年03月21日 06点03分 4
大佬,还在吗
2022年05月19日 10点05分
level 1
加我 名字q
2019年06月05日 01点06分 5
1