var EHDI = EHDI || Object.create(null); EHDI.components = EHDI.components || Object.create(null); EHDI.components.Grass = function() { EHDI.aka.Container.call(this); this.shadow = new EHDI.aka.Sprite(EHDI.Assets.images["star_shadow"]); this.shadow.anchor.x = 0.5; this.shadow.anchor.y = 0.5; this.addChild(this.shadow); this.sprite = new EHDI.aka.Sprite(EHDI.Assets.images["hay"]); this.sprite.anchor.x = 0.5; this.sprite.anchor.y = 0.5; this.addChild(this.sprite); this.sprite.y = -105; this.collider = EHDI.displays.FillRectangle(0x00AA00, 0, 0, 75, 50, 0); this.collider.anchor.x = 0.5; this.collider.anchor.y = 1; this.collider.visible = false; this.addChild(this.collider); this.isGrass = true; this.ignoreCollision = false; this.hoverTimeline = new TimelineMax({repeat : - 1}); this.hoverTimeline.to(this.sprite, 0.5, {y: this.sprite.y + 3, ease: Power0.easeNone}); this.hoverTimeline.to(this.sprite, 1, {y: this.sprite.y - 6, ease: Power0.easeNone}); this.hoverTimeline.to(this.sprite, 0.5, {y: this.sprite.y, ease: Power0.easeNone}); }; EHDI.components.Grass.prototype = Object.create(EHDI.aka.Container.prototype); EHDI.components.Grass.prototype.pause = function() { this.hoverTimeline.pause(); if(this.animationTimeline) this.animationTimeline.pause(); } EHDI.components.Grass.prototype.resume = function() { this.hoverTimeline.play(); if(this.animationTimeline) this.animationTimeline.play(); } EHDI.components.Grass.prototype.fadeOut = function() { this.ignoreCollision = true; this.animationTimeline = new TimelineMax({onComplete : this.makeInactive.bind(this)}); this.animationTimeline.to(this.sprite, 0.25, {alpha : 0}); this.animationTimeline.to(this.shadow, 0.25, {alpha : 0}, 0); }; EHDI.components.Grass.prototype.makeInactive = function() { this.isInactive = true; this.animationTimeline.kill(); this.hoverTimeline.kill(); };