<script src="/js/kinetic-v4.3.3.min.js"></script>
<script>
$(document).ready(function(){
var gravity = 0.5;
var stage = new Kinetic.Stage({
container: 'stage',
width: 625,
height: 366
});
var wallLayer = new Kinetic.Layer();
var walls = [];
var wallCount = 7;
for(var i = 0; i < wallCount; i++)
{
var y = i * 61;
walls.push(new Kinetic.Rect({
x: 0,
y: y,
width: 40,
height: 60,
fill: '#FF0000'
}));
wallLayer.add(walls[i]);
}
stage.add(wallLayer);
var anim = new Kinetic.Animation(function(frame) {
//wall.vy += gravity;
// wall.setY(wall.vy);
}, wallLayer);
anim.start();
})
</script>
<div id="stage">
</div>
在这里,我只画了舞台的左侧,有很多墙,将每面墙推成一个数组,但是我怎样才能在一个循环中将相同的内容绘制到顶部、右侧和底部?或者我需要在 4 个循环中完成它?