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

View file

@ -39,10 +39,10 @@ function renderText(x, y, fontSize, color, text) {
var scoreOpacity = 0; var scoreOpacity = 0;
function drawScoreboard() { function drawScoreboard() {
if(scoreOpacity < 1){ if(scoreOpacity < 1){
scoreOpacity+=(1/1-scoreOpacity)/100; scoreOpacity+=0.01;
} }
ctx.globalAlpha = scoreOpacity; 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; ctx.globalAlpha = 1;
} }