//Augment Module var ITW = (function(itw){ "use strict"; //aliases var components, protot; itw.components = itw.components || Object.create(null); components = itw.components; var MAX_BUBBLES = 3; var _texMain, _sprBubbles, _player; var _startPosY, _endPosY, _dist, _currentIndex; components.PlayerBubbles = function( ){ this.super.call(this); var _this = this; var _init = function(){ _texMain = EHDI.Assets.images["bubbles"]; _sprBubbles = []; for(var i = 0; i < MAX_BUBBLES; i++){ _sprBubbles[i] = new EHDI.aka.Sprite(_texMain); _sprBubbles[i].alpha = 0; _this.addChild(_sprBubbles[i]) } _currentIndex = 0; _startPosY = _player.y - (_sprBubbles[0].height * 0.8); _this.tween = new TimelineMax(); //TweenMax.to(_this, 1, {y: _startPosY, ease: Power4.easeOut, paused: true}); } _init(); } protot = components.PlayerBubbles.prototype = Object.create(EHDI.aka.Container.prototype); protot.constructor = components.PlayerBubbles; protot.super = EHDI.aka.Container; components.PlayerBubbles.setPlayerRef = function( player ){ _player = player; } protot.play = function( callback ){ if(!this.tween.isActive()){ this.x = _player.x + (_player.width * 0.2); this.y = _player.y + (_player.height * -0.2); this.tween.clear(); for(var i = 0; i < _sprBubbles.length;i++){ _sprBubbles[i].alpha = 1; _sprBubbles[i].x = EHDI.NumberUtil.randomRange(0,10); _sprBubbles[i].y = 0; this.tween.to(_sprBubbles[i], 0.8, {y: _startPosY - this.y , alpha: 0}, i*0.1); } } } protot.pause = function( ){ if(!this.tween.paused()) this.tween.pause(); } protot.resume = function( ){ if(!!this.tween.paused()) this.tween.resume(); } protot.destroy = function(){ while(_sprBubbles.length > 0){ var bubble = _sprBubbles.pop(); bubble.destroy({children: true}); } if(this.tween) this.tween.kill(); this.super.prototype.destroy.call(this, {children: true}); } return itw; }(ITW || Object.create(null)))