77 UseText - JcerelusDev/CanvasGameJs GitHub Wiki
useText
What is useText ? The UseText class is a DOM based text,it is used to replace the blury text version of the canvas when it is scaled, text create using that class can be any size because it's a dom text
How to use it ?
First of all the UseText class has an update version to update the text in the update function
new UseText(text,value, size, x, y, color)
text = a string value can be string or number size = amount + "px" x = left position y = top position color = color of the text
// dom text
let score = 0
let Score = new UseText("Score : ",score,20,70,120,"white")
game.update = function(delta){
Score.update(score) // this is used to update the score per frame
/*
As you can see i don't update text, but the value .
*/
}
// what if the value is not a number but a string
let test =new UseText(null,"Tested",10,70,70,"white") // i used null for text because the value is also string no need to use two string
setTimeout(function(){
test.update("Good")
},1000)
setTimeout(function(){
test.update("I am Happy to know that")
},2000)
setTimeout(function(){
test.update("The text is about to destroy")
setTimeout(function(){
test.destroy()
},500)
},3000)