hextris/js/Text.js

28 lines
592 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.globalAlpha = this.opacity;
2014-07-03 21:51:13 +00:00
renderText((this.x + gdx), (this.y + gdy),36,this.color,this.text);
ctx.globalAlpha =1;
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-07-03 21:51:13 +00:00
}