hextris/js/Text.js

37 lines
730 B
JavaScript
Raw Normal View History

2014-05-26 16:27:30 +00:00
function Text(x,y,text,font,color,incrementFunction){
this.x = x;
this.y = y;
this.font = font;
this.color = color;
this.opacity =1;
this.text = text;
2014-05-26 17:18:27 +00:00
this.alive=1;
this.draw = function(){
2014-05-26 17:18:27 +00:00
if(this.alive>0){
ctx.save();
var sf = (settings.scale - 1)/3 + 1;
ctx.scale(sf, sf);
ctx.font= this.font;
ctx.fillStyle = this.color;
ctx.globalAlpha = this.opacity;
ctx.fillText(this.text,(this.x + gdx) * (1/sf), (this.y + gdy) * (1/sf));
ctx.globalAlpha =1;
ctx.restore();
2014-05-26 16:27:30 +00:00
incrementFunction(this);
return true;
}
2014-05-31 14:55:36 +00:00
else {
2014-05-26 16:27:30 +00:00
return false;
}
}
}
2014-05-26 16:27:30 +00:00
function fadeUpAndOut(text){
2014-05-26 18:14:30 +00:00
text.opacity -= Math.pow(Math.pow((1-text.opacity), 1/3)+1,3)/100;
2014-05-26 17:18:27 +00:00
text.alive = text.opacity;
2014-05-26 16:27:30 +00:00
text.y-=3;
}
2014-05-26 16:45:52 +00:00