-
Notifications
You must be signed in to change notification settings - Fork 1
/
Util.js
23 lines (17 loc) · 800 Bytes
/
Util.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
Util = {};
Util.tweenTint = function(obj, startColor, endColor, time) {
// create an object to tween with our step value at 0
var colorBlend = {step: 0};
// create the tween on this object and tween its step property to 100
var colorTween = game.add.tween(colorBlend).to({step: 100}, time);
// run the interpolateColor function every time the tween updates, feeding it the
// updated value of our tween each time, and set the result as our tint
colorTween.onUpdateCallback(function() {
obj.tint = Phaser.Color.interpolateColor(startColor, endColor, 100, colorBlend.step);
});
// set the object to the start color straight away
obj.tint = startColor;
// start the tween
colorTween.start();
obj.colorTween = colorTween;
}