16 lines
266 B
CoffeeScript
16 lines
266 B
CoffeeScript
|
class AnimatedItem
|
||
|
constructor: (options) ->
|
||
|
{@maxFrames, @image}
|
||
|
|
||
|
@frame = 0
|
||
|
window.setInterval @changeAnimation, 500
|
||
|
|
||
|
sprite: ->
|
||
|
[@frame*8, 8, 8, 8]
|
||
|
|
||
|
changeAnimation: =>
|
||
|
if @frame == @maxFrames
|
||
|
@frame = 0
|
||
|
else
|
||
|
@frame += 1
|