查看: 1801|回复: 4
|
action script 2.0 问题
[复制链接]
|
|
function makeLvl():Void{ //Places bricks onto Level
//finding the array length of the lvl code
//The index has to be currentLvl-1 because:
//array indexes start on 0 and our lvl starts at 1
//our level will always be 1 higher than the actual index of the array
var arrayLength:Number = _root.lvlArray[currentLvl-1].length;
//the current row of bricks we are creating
var brickRow:Number = 0;
//Now, creating a loop which places the bricks onto the stage
for(var i:Number = 0;i<arrayLength;i++){
//checking if it should place a brick there
if(lvlArray[currentLvl-1][i] == 1){
//creating a variable which holds the brick instance
_root.attachMovie('mcBrick', 'brick'+i,_root.getNextHighestDepth());
//setting the brick's coordinates via the i variable and brickRow
_root['brick'+i]._x = 15+(i-brickRow*7)*75;
_root['brick'+i]._y = 10+brickRow*20;
//checks if the current brick needs a new row
for(var c:Number = 1;c<=10;c++){
if(i == c*7-1){
brickRow ++;
}
}
}
}
}
请问下是什么COMMAND把LIBRARY里面的MOVIE CLIP放在SCREEN里.
上面那个CODE的来源是:
http://www.mrsunstudios.com/2009/01/tutorial-create-a-brick-breaker-game-in-as2-part-3/
_ROOT又是什么意思.
已经在这里做了点功课...
还是不明白>_< |
|
|
|
|
|
|
|
发表于 22-10-2009 05:37 AM
|
显示全部楼层
|
|
|
|
|
|
|
楼主 |
发表于 22-10-2009 01:12 PM
|
显示全部楼层
那个_ROOT读过了....
不明白>_<
我试试看attachMovie
这里看到的是酱
myMovieClip.attachMovie(idName ,newName ,depth[,initObject ])
可是我找到的TUTORIAL是_root.attachMovie(xxxx,xxx,xxx)
假设我的MOVIECLIP名字是 theone
我要放进去是不是应该用.
theone.attachMovie(theone, theone1, 2);
我用上面的CODE没有东西出来....
要怎样改变MOVIECLIP在SCREEN里出现的位置?_?
对不起.还是新手... |
|
|
|
|
|
|
|
发表于 22-10-2009 07:39 PM
|
显示全部楼层
原帖由 kjying 于 22-10-2009 01:12 PM 发表
那个_ROOT读过了....
不明白>_<
我试试看attachMovie
这里看到的是酱
myMovieClip.attachMovie(idName ,newName ,depth[,initObject ])
可是我找到的TUTORIAL是_root.attachMovie(xxxx,xxx,xx ...
_root 的解释要是看不懂英文,可以去搜索中文說明
搜索资料的时候顺便了解 _root, level, depth 与 this 的关系
注意 attachMovie 的使用說明,尤其是参数部分(parameters)
(idName:String, newName:String, depth:Number[, initObject:Object]);
遇到 String 文字類型就把文字放在 " " 之間, Number 即是数字類型
如 : theone.attachMovie("theone", "theone1", 2);
p/s: 第一参数是指 library 中的 linkage id, 所以該怎么使用你就该多話些時間到 google 搜索步驟教程 |
|
|
|
|
|
|
|
发表于 25-10-2009 11:05 PM
|
显示全部楼层
原帖由 kjying 于 22-10-2009 01:12 PM 发表
那个_ROOT读过了....
不明白>_<
我试试看attachMovie
这里看到的是酱
myMovieClip.attachMovie(idName ,newName ,depth[,initObject ])
可是我找到的TUTORIAL是_root.attachMovie(xxxx,xxx,xx ...
_root的用法通常指的都是Stage的Timeline,就是最外层的时间轴(简单来说)。在某些情况下_root的位置会改变,不过在进阶阶段应该不会遇到(我看到的例子是当你要将一个含AS的SWF档Import进另一个SWF档,就要考虑_root变位)
不过像Tomato大大说的,了解_root, this, depth等蛮重要。毕竟都是常常出现的字眼。 |
|
|
|
|
|
|
| |
本周最热论坛帖子
|