我有一个包含 27 个元素的精灵表(png 文件),每个元素之间的空格相等
+----------------+
| 1 2 3
| 4 5 6
|
|
|
|
|
|
|
| 24 25 26
我想将所有元素插入到数组中我想出了一种方法来做到这一点它工作正常
var ElemObjects = [];
ElemObjects.push(new Elem(0,0));
ElemObjects.push(new Elem(380,0));
ElemObjects.push(new Elem(760,0));
ElemObjects.push(new Elem(0,340));
ElemObjects.push(new Elem(380,340));
ElemObjects.push(new Elem(760,340));
ElemObjects.push(new Elem(0,680))
ElemObjects.push(new Elem(380,680))
ElemObjects.push(new Elem(760,680))
等等
我想使用 for 循环做同样的事情我的问题是我不知道必须更改 for 循环内的 x 和 y 坐标的逻辑
for(var i =0; i < 26; i++){
ElemObjects[ElemObjects.length] = new Elem(Xsr,Ysr);
Xsr=Xsr+380;
}
有什么建议么