Hi!
As the title says, uh how do you code for adding objects when pressing a button, specifically only the space button?
I already have a code that after a certain amount of time an you press space, the next line of text appears (makin' a choose ur own adventure)
tho my problem is that after too much time, all the lines of text appear at the same time?? so I'd like to make that the next lines of text would only
appear if you press space.
Here's the code I used:
long lastAdded = System.currentTimeMillis();
public void ShowGameTxt()
{
long curTime = System.currentTimeMillis();
if(Greenfoot.isKeyDown("space"))
{
Gametxt gmtxt = new Gametxt();
addObject(gmtxt,267,20);
if (curTime >= lastAdded + 1500 && (Greenfoot.isKeyDown("space")))//2000ms = 2s
{
Noiatxt ntxt = new Noiatxt();
addObject(ntxt,482,61);
if (curTime >= lastAdded + 2300 && (Greenfoot.isKeyDown("space")))
{
GT2 gt1 = new GT2();
addObject(gmtxt,267,93);
if (curTime >= lastAdded + 3000 && (Greenfoot.isKeyDown("space")))
{
Gtalk gtk = new Gtalk();
addObject(gtk,278, 127);
}
}
}
}
}
So uh if you could help me, that would awesome (grades are on the line,)

