We are about to switch to a new forum software. Until then we have removed the registration on this forum.
String name = " " ;
void setup(){
size(500,500);
background(0);
}
void draw(){
fill(255);
strokeWeight(20);
text(name,200,200);
if (keyPressed == true) {
delay(220);
name = name + key;
}
}
i'd like to stop the name for 10 letters, is it possible ?
Answers
if(name.length()<10) {
omg thank you ^^
;-)
Using delay is usually a bad idea. You are using it here to slow down the key repeat.
Look at keyPressed (), the method, instead
should i change the frameRate ?
Better ?
No, don't use framerate either
Instead: use the function
keyPressed
instead of the variable of the same nameWhat does this mean? Do you mean that, after 10 key-presses, you wish to stop accepting more keys?
@Chrisir gave you the solution -- you can combine it with your keypress:
Or, outside draw():
omg i am so dumb xD thanks Chrisir it's much better
Jeremy yes thanks I have already change it on my sketch ;)
this
is the same as
This (although you don't use it anymore) :
same as
okay i'll change it later !
but i did this to erase my name
well done!
keyPressed
must be with small letter at beginning (otherwise it's not called automatically):p :D
;-)