2014-12-07 13:48:12 +01:00
|
|
|
class AnimatedItem
|
|
|
|
constructor: (options) ->
|
2014-12-07 14:02:42 +01:00
|
|
|
{@maxFrames, @image, @speed} = options
|
2014-12-07 13:48:12 +01:00
|
|
|
|
|
|
|
@frame = 0
|
2014-12-07 14:02:42 +01:00
|
|
|
window.setInterval @changeAnimation, @speed
|
2014-12-07 13:48:12 +01:00
|
|
|
|
|
|
|
sprite: ->
|
2014-12-07 14:02:42 +01:00
|
|
|
[@frame*8, 0, 8, 8]
|
2014-12-07 13:48:12 +01:00
|
|
|
|
|
|
|
changeAnimation: =>
|
|
|
|
if @frame == @maxFrames
|
|
|
|
@frame = 0
|
|
|
|
else
|
|
|
|
@frame += 1
|