Ver Mensaje Individual
  #7 (permalink)  
Antiguo 31/01/2010, 00:39
Avatar de ClubIce
ClubIce
 
Fecha de Ingreso: diciembre-2008
Mensajes: 216
Antigüedad: 15 años, 4 meses
Puntos: 2
Respuesta: no detecta ID

Código Javascript:
Ver original
  1. Animation=function(spr,spd) {
  2.  this.initialize({
  3.   sprite:spr,
  4.   speed:spd,
  5.   frames:[],
  6.   timer:null,
  7.   count:0,
  8.   id:null
  9.  });
  10. }
  11. Animation.prototype={
  12.  addFrame: function (id) {
  13.   spr=this
  14.   this.frames[frames.length]={
  15.    id:id,
  16.    sprite:"url('"+spr.sprite.image.src+"') "+spr.sprite.frames[id].x+"px "+spr.sprite.frames[id].y+"px;"
  17.   }
  18.  },
  19.  drawAnimation:function (con, id) {
  20.   image=document.createElement('img')
  21.   image.setAttribute('src','sprites/empy.gif')
  22.   image.setAttribute('style',"background:"+this.frames[0].sprite)
  23.   image.setAttribute('class','animation')
  24.   image.setAttribute('width',this.sprite.width)
  25.   image.setAttribute('height',this.sprite.height)
  26.   image.setAttribute('id',id)
  27.   this.id=image
  28.   con.appendChild(image)
  29.   this.timer=setInterval(this.play,this.speed);
  30.  },
  31.  play:function() {
  32.   if (this.count=this.frames.length) {
  33.    this.count=0
  34.   } else {
  35.    this.count++
  36.   }
  37.   this.id.style.background=this.frames[this.count]
  38.  }
  39. }