Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Texto texto;
- boolean keyflag;
- void setup()
- {
- texto = new Texto("Prueba",50,580,"Calibri-48.vlw",48);
- size(800, 600,P3D);
- stroke(255);
- }
- void draw()
- {
- //noStroke();
- fill(0, 80);
- rect(0, 0, width, height);
- if(texto.x < 0){
- texto.x = width;
- }
- texto.x-=2;
- fill(255);
- texto.display();
- if(keyPressed && keyflag) {
- texto.texto += key;
- texto.x+= texto.font.width(texto.texto.charAt(0))*texto.pxsize;
- //println(texto.font.width(texto.texto.charAt(0)));
- texto.texto = texto.texto.substring(1);
- keyflag = false;
- }
- if(!keyPressed && !keyflag){
- keyflag = true;
- }
- //img.resize(10,10);
- //image(img,0,0);
- }
- class Texto{
- String texto;
- int x, y , pxsize;
- PFont font;
- Texto(String texto ,int x ,int y,String font ,int pxsize ){
- this.x = x;
- this.y = y;
- this.font = loadFont(font);
- this.pxsize = pxsize;
- textFont(this.font,pxsize);
- this.texto=texto;
- textMode(SCREEN);
- }
- void display(){
- text(texto, x, y);
- }
- }
Add Comment
Please, Sign In to add comment