evgeniyfill82,
Object.keys возможно опять нет -- тогда for in
<!DOCTYPE html>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
</head>
<body>
<div id="pole"></div>
<script>
var glb = {};
glb.obs = [];
glb.sss = 0;
function getTr(prm){
var img = new Image();
img.src = 'http://paar.com.au/images/star95x72.png'
img.className = 'obj';
img.style.position ='absolute'
pole.appendChild(img);
var tr = {
obj: img,
x: prm.x,
y: prm.y,
u: prm.u,
vid: 'none',
liv: 20,
css : function(data) {
Object.keys(data).forEach(function (key) {
img.style[key] = data[key]
});
}
}
return tr;
}
var vrm = setInterval(function(){ gmm(); }, 100);
function gmm(){
if (glb.sss == 5) glb.sss = 0;
if (glb.sss == 0)
glb.obs.push(getTr({x:100, y:200, u:1}));
for(i=0;glb.obs.length>i;i++) if (glb.obs[i]) {
glb.obs[i].x += 10;
glb.obs[i].y += 10;
glb.obs[i].u += 10;
glb.obs[i].liv--;
glb.obs[i].vid = 'block';
glb.obs[i].css({
'transform': 'rotate('+ glb.obs[i].u +'deg)',
'top': glb.obs[i].x +'px',
'left': glb.obs[i].y +'px',
'display': glb.obs[i].vid
});
if (glb.obs[i].liv == 0) {
glb.obs[i].obj.remove();
delete glb.obs[i];
}
}
glb.sss++;
}
</script>
</body>
</html>