Flash 循环 - Actionscript 3 网格循环
我正在尝试为 Flash 游戏创建一个网格,以便与探路者类一起使用(完成后将构建)
我有代码
var rows:int = 4;
var cols:int = 4;
for (var py:int = 0; py <rows; py++) {
for (var px:int = 0; px <cols; px++) {
var box:Box = new Box();
box.x = 50 + box.width * px;
box.y = 50 + box.height * py;
addChild(box);
}
}
将电影剪辑添加到舞台以获取所需的列数和行数,但是,我需要网格为: 17x21,单元格大小为 20 像素,但每个其他单元格需要为 36 像素 IE。 。 。
| 36px | 20px | 36px | 20px | 36px | 20px | (all at 20px height)
| 36px | 20px | 36px | 20px | 36px | 20px | (all at 36px height)
| 36px | 20px | 36px | 20px | 36px | 20px | (all at 20px height)
| 36px | 20px | 36px | 20px | 36px | 20px | (all at 36px height)
有人有什么想法吗?
干杯
安德鲁
I am trying to create a grid for a flash game to use with a pathfinder class(will build once this is done)
I have the code
var rows:int = 4;
var cols:int = 4;
for (var py:int = 0; py <rows; py++) {
for (var px:int = 0; px <cols; px++) {
var box:Box = new Box();
box.x = 50 + box.width * px;
box.y = 50 + box.height * py;
addChild(box);
}
}
this adds a movieclip to the stage for the number of needed cols and rows, however, I need the grid to be:
17x21 with the cell sizes to be 20px however every other cell needs to be 36px
ie. . .
| 36px | 20px | 36px | 20px | 36px | 20px | (all at 20px height)
| 36px | 20px | 36px | 20px | 36px | 20px | (all at 36px height)
| 36px | 20px | 36px | 20px | 36px | 20px | (all at 20px height)
| 36px | 20px | 36px | 20px | 36px | 20px | (all at 36px height)
Anyone have any ideas?
cheers
Andrew
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果我理解正确的话,您需要检查 px 和 py 的模并根据它设置宽度和高度。类似的东西应该有效:
If I understand correctly, you need to check the modulo of px and py and set the width and height according to it. Something like that should work: