text fades in

This commit is contained in:
garrettdreyfus 2014-05-26 14:43:05 -04:00
parent f3c7752499
commit 23e6cd36f6
2 changed files with 10 additions and 17 deletions

View file

@ -1,24 +1,17 @@
var grey = '#bdc3c7';
var op=0;
function render() {
ctx.clearRect(0, 0, trueCanvas.width, trueCanvas.height);
clearGameBoard();
if (gameState == -2) {
if (Date.now() - startTime > 1300) {
var op = (Date.now() - startTime - 1300)/500;
if (op > 1) {
op = 1;
}
ctx.globalAlpha = op;
drawPolygon(trueCanvas.width / 2 , trueCanvas.height / 2 , 6, (settings.rows * settings.blockHeight) * (2/Math.sqrt(3)) + settings.hexWidth, 30, grey, false,6);
ctx.globalAlpha = 1;
if (gameState == 1) {
if (op < 1) {
op += 0.01;
}
} else {
drawPolygon(trueCanvas.width / 2 + gdx, trueCanvas.height / 2 + gdy, 6, (settings.rows * settings.blockHeight) * (2/Math.sqrt(3)) + settings.hexWidth, 30, grey, false, 6);
ctx.globalAlpha = op;
drawPolygon(trueCanvas.width / 2 , trueCanvas.height / 2 , 6, (settings.rows * settings.blockHeight) * (2/Math.sqrt(3)) + settings.hexWidth, 30, grey, false,6);
ctx.globalAlpha = 1;
}
for (var i in MainClock.blocks) {
for (var j = 0; j < MainClock.blocks[i].length; j++) {
var block = MainClock.blocks[i][j];
@ -32,7 +25,7 @@ function render() {
MainClock.draw();
if (gameState == 1) {
if ( gameState ==1 ) {
drawScoreboard();
}
for (var i in MainClock.texts) {

View file

@ -39,10 +39,10 @@ function renderText(x, y, fontSize, color, text) {
var scoreOpacity = 0;
function drawScoreboard() {
if(scoreOpacity < 1){
scoreOpacity+=(1/1-scoreOpacity)/100;
scoreOpacity+=0.01;
}
ctx.globalAlpha = scoreOpacity;
renderText(trueCanvas.width / 2 + gdx, trueCanvas.height / 2 + gdy, 50, "#fff", score);
renderText(trueCanvas.width/2+ gdx, trueCanvas.height/2+ gdy, 50, "#fff", score);
ctx.globalAlpha = 1;
}