Created
March 16, 2015 17:13
-
-
Save bgadrian/e910da1fb527dd50077e to your computer and use it in GitHub Desktop.
tweenJS modify a JS object
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Each time score is added, tween the value. | |
function addScore(score) { | |
// Save the new score | |
this.newScore = score; | |
// Create a tween that will update the "displayScore", which | |
// we use to display the changing number. | |
var tween = createjs.Tween.get(this).to({displayScore:score}, 800); | |
// For this example, set a local "scope" so the onChange | |
// callback has something to refer to. | |
var scope = this; | |
// As the tween runs, it will call "onChange" | |
tween.onChange = function(tween) { | |
// Update the text instance with "displayScore". | |
scope.text.text = scope.displayScore; | |
} | |
} | |
// The "ScoreManager" abstracts the score formatting and tweening. | |
function killEnemy(points) { | |
this.scoreManager.addScore(points); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment