void SpawnAnimation(IHTMLImage img, int x, int y, int w, int h, int from, int to, Timer t) { var div = new IHTMLDiv(); var animate = true; div.style.SetSize(w, h); div.style.backgroundRepeat = "no-repeat"; div.style.backgroundImage = "url(" + img.src + ")"; div.SetCenteredLocation(x, y); Native.Document.body.appendChild(div); div.onmouseover += delegate { animate = false; }; div.onmouseout += delegate { animate = true; }; var frame = from; t.Tick += delegate { if (!animate) return; frame++; if (frame > to) frame = from; div.style.backgroundPosition = -(frame * w) + "px 0px"; }; }