xxxxxxxxxx
29
let textValue;
let phase = 1;
function setup() {
createCanvas(400, 400);
inputBox = createInput('');
inputButton = createButton("go")
inputButton.position(20, 160)
inputBox.position(20, 100);
inputButton.mousePressed(doPressed);
// inputBox.value();
}
function doPressed(){
textValue = inputBox.value();
inputBox.remove();
inputButton.remove();
phase = 2;
}
function draw() {
background(220);
textSize(24);
if(phase == 1){
text("type your name and press go", 20, 50)
}
if(phase == 2){
text("hello " + textValue + ", prepare to die", 20, 50)
}
}