var bulle;
var textKing;
var timeKing = 0;
var timeTranspaKing = 0;
var MAX_TIME_TRANSPA = 2000;

function prepareKing() {
    bulle = game.add.sprite(20,80, 'bulle');
    bulle.scale.set(0.6);
    bulle.alpha = 0;
}

function King_say(text, time, size) {
    psize = size + 'px Arial';
    var styleKing = { font: psize, fill: "#500000", boundsAlignH: "center", boundsAlignV: "middle" };
    if (textKing != null)
        textKing.destroy();
    textKing = game.add.text(250,160,text, styleKing);
    textKing.anchor.set(0.5,0.5);
    bulle.alpha = 1;
    timeKing = time;
    timeTranspaKing = MAX_TIME_TRANSPA;
}

function updateKing(diff) {
    timeKing = timeKing - diff;
    if (timeKing <= 0) {
        timeTranspaKing = timeTranspaKing - diff;
        if (timeTranspaKing >= 0) {
            bulle.alpha = timeTranspaKing/MAX_TIME_TRANSPA;
            textKing.alpha = timeTranspaKing/MAX_TIME_TRANSPA;
        }
    }
}