             @movesDiff.setText('+'+@level.movesDiff)
             @movesDiff.opacity(1)
 
-            tween = new Kinetic.Tween
-                node: @movesDiff
-                opacity: 0
-                duration: TWEEN_DURATION * 5
-
-            tween.play()
+            delay1s =>
+                tween = new Kinetic.Tween
+                    node: @movesDiff
+                    opacity: 0
+                    duration: TWEEN_DURATION
+                    onFinish: ->
+                        @destroy()
+
+                tween.play()
 
         @centerText(@score)
         @centerText(@scoreDiff)



class Game
    levels_params: [6, 7, 8]
    level: null
    level_id: null

    constructor: () ->
        # TODO: get active level id from local storage
        @level_id = 0
        boardSize = @levels_params[@level_id]
        @level = new Level boardSize



TWEEN_DURATION = 0.5

delay1s = (func) -> setTimeout func, 1000


randomChoice = (values) ->
    # http://rosettacode.org/wiki/Pick_random_element#CoffeeScript
    return values[Math.floor(Math.random() * values.length)]


class QueryString
    # Provide easy access to QueryString data
    # https://gist.github.com/greystate/1274961

    constructor: (@queryString) ->
        @queryString or= window.document.location.search?.substr 1
        @variables = @queryString.split '&'
        @pairs = ([key, value] = pair.split '=' for pair in @variables)

    get: (name) ->
        for [key, value] in @pairs
            return value if key is name


class FieldWidget
