class SceneIcon extends Phaser.Scene
{
    create (data)
    {
        this.parent = data.scene;

        this.frameTime = 250;
        this.frameTimer = -1;
        this.defaultFrame = 0;
        this.frame = 0;

        this.icon = new Icon({
            'scene': this,
            'key': data.key,
            'gameid': data.gameid,
            'url': data.url,
            'up': 0,
            'over':1,
            'down':2,
            'x': data.x,
            'y': data.y,
            'horizontalOffset': data.horizontalOffset,
            'vDelta': data.vDelta,
            'onClick': data.onClick,
            'handlerScene': this.parent
        });

        this.scene.sleep();
    }
    
    setPosition(x, y)
    {
        this.icon.setPosition_(x, y);
    }
    
    setScale(v)
    {
        this.icon.setScale(v);
    }

    setFrame(frame)
    {
        this.frame = this.icon.getFrame();

        switch(frame)
        {
            case 'DOWN':this.frameTimer = this.frameTime;this.icon.setFrame_(0);break;
            case 'OVER':this.frameTimer = this.frameTime;this.icon.setFrame_(1);break;
            case 'UP':this.frameTimer = this.frameTime;this.icon.setFrame_(2);break;
            default:break;
        }
    }

    update(time, delta)
    {
        this.icon.update(time, delta);
        
        if(this.frameTimer >= 0)
        {
            this.frameTimer -= delta;
            if(this.frameTimer < 0)
            {
                this.icon.setFrame_(this.frame);
            }
        }
    }
}
