/**
 * Created with JetBrains WebStorm.
 * User: ankit.goel
 * Date: 10/10/12
 * Time: 5:12 PM
 * To change this template use File | Settings | File Templates.
 */
ig.module(
    'game.entities.endanimation'
)
    .requires(
    'impact.entity'
)
    .defines(function () {
        Entityendanimation = ig.Entity.extend({
            collides:ig.Entity.COLLIDES.PASSIVE,
            type:ig.Entity.TYPE.NONE,
            pixcaltype:"ignore",
            size:{x:223,y:225},
            animSheet:new ig.AnimationSheet('media/Animation_Cangratulation_with text.png',223,225),
            bounciness:1,
            temp:0,
            init:function (x, y, settings) {
                this.parent(x, y, settings);
                //	    this.addAnim('idle',.1,[0]);
                this.addAnim('endanim',.1,[0]);
                this.maxVel.x = 500;
                this.maxVel.y = 500;
            },
            update:function (){
                this.scaleCount=this.scaleCount-2;
                if(this.scaleCount==0){
                    this.kill();
                }
                else{
                    if(!this.isScaleTrigger)
                    {   this.scaleCountFadeIn=this.scaleCountFadeIn+2;

                        this.setScale(this.scaleCountFadeIn/460,this.scaleCountFadeIn/460);
                        this.pos.x=Math.floor((ig.system.width- this.size.x)/2);
                        this.pos.y=Math.floor((ig.system.height-this.size.y)/2);
                        if( this.scaleCount==460){
                            this.isScaleTrigger=true;

                        }
                    }
                    if(this.isScaleTrigger){
                        this.scaleCountFadeOut=this.scaleCountFadeOut-2;
                        this.setScale(this.scaleCountFadeOut/460,this.scaleCountFadeOut/460);
                        this.pos.x=Math.floor((ig.system.width-this.size.x)/2);
                        this.pos.y=Math.floor((ig.system.height-this.size.y)/2);
                    }
                }
                this.parent();
            },
            scaleCountFadeOut:460,
            scaleCountFadeIn:0,
            scaleCount:920,
            isScaleTrigger:false
        });
    });