Guest User

Untitled

a guest
May 25th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. Texto texto;
  2. boolean keyflag;
  3. void setup()
  4. {
  5. texto = new Texto("Prueba",50,580,"Calibri-48.vlw",48);
  6. size(800, 600,P3D);
  7. stroke(255);
  8. }
  9.  
  10. void draw()
  11. {
  12. //noStroke();
  13. fill(0, 80);
  14. rect(0, 0, width, height);
  15.  
  16. if(texto.x < 0){
  17. texto.x = width;
  18. }
  19. texto.x-=2;
  20. fill(255);
  21.  
  22. texto.display();
  23.  
  24.  
  25. if(keyPressed && keyflag) {
  26. texto.texto += key;
  27. texto.x+= texto.font.width(texto.texto.charAt(0))*texto.pxsize;
  28. //println(texto.font.width(texto.texto.charAt(0)));
  29. texto.texto = texto.texto.substring(1);
  30. keyflag = false;
  31. }
  32.  
  33.  
  34. if(!keyPressed && !keyflag){
  35. keyflag = true;
  36. }
  37.  
  38.  
  39. //img.resize(10,10);
  40. //image(img,0,0);
  41. }
  42.  
  43. class Texto{
  44. String texto;
  45. int x, y , pxsize;
  46. PFont font;
  47.  
  48.  
  49. Texto(String texto ,int x ,int y,String font ,int pxsize ){
  50. this.x = x;
  51. this.y = y;
  52. this.font = loadFont(font);
  53. this.pxsize = pxsize;
  54. textFont(this.font,pxsize);
  55. this.texto=texto;
  56. textMode(SCREEN);
  57.  
  58. }
  59. void display(){
  60. text(texto, x, y);
  61. }
  62.  
  63. }
Add Comment
Please, Sign In to add comment