Very nice start!  I wasn't even planning on *thinking* about flipping through
frames of animation, yet.  I was just going to focus on moving a static image
around.  So, it looks like we're approaching it from opposite directions. : ))

On 08:49 Sun 13 Jul     , Bluebie, Jenna wrote:
> Here's what I have so far, fully functional, though not as advanced as your 
> dream, feel free to build on it! Attached is a demo app showing it working. 
> There is some buggyness when closing the window on nonmac's, I don't know 
> why.
>
> class Sprite < Widget
>   def initialize opts = {}
>     @sizes = {}
>     opts.each { |k,v| self.instance_variable_set("@#{k.to_s}", v) }
>     reanimate
>   end
>
>   attr_reader :stack, :fps, :motion
>   def motion=(value); @motion = value; reanimate; end
>   def fps=(value); @fps = value; reanimate; end
>
>   def reanimate
>     maxSize true
>     clear do
>       animate(@fps) do
>         clear do
>           path = nextFrame
>           size = @sizes[path]
>           @image = image(path)
>           @image.style(:margin_left => maxSize[:width] - size.first)
>           @image.style(:margin_top => maxSize[:height] - size.last)
>         end
>       end
>     end
>   end
>
>   def nextFrame
>     @[EMAIL PROTECTED](n = @[EMAIL PROTECTED])
>     return n
>   end
>
>   def maxSize(cache = true)
>     return @maxSize if @maxSize && cache
>     @images.values.flatten.each { |path| @sizes[path] = 
> $app.imagesize(path) }
>     x, y = @sizes.values.transpose.map { |i| i.max }
>     @maxSize = {:width => x, :height => y}
>   end
> end
>
>
>


>

-- 
[EMAIL PROTECTED]

Reply via email to