I just publish a senario called type box where u could make as manny thype boxes as you want by just creating an object of the class I descoverd that if you had multiples it was quid of random I witch u type . I tried a fix for it but it didn't work : this is the current ( falling ) code :
pretti mutch the only thing I changed was
instead of
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class Text here. * * @author (your name) * @version (a version number or a date) */ public class Text extends Actor { int nKeysStoreable = 100; String[] key = new String[nKeysStoreable]; String keys; int cKey = 0; public String toString() { keys = "0"; for(int i = 0; i < nKeysStoreable; i++) { if(key[i] != null) { keys = keys+ key[i]; } } return keys; } public int toInt() { return Integer.parseInt(this.toString()); } public void act() { if(Greenfoot.getMouseInfo().getActor() == this) { run(); } } public void run() { getWorld().showText(this.toString(),getX(),getY()); String keyIn = Greenfoot.getKey(); if(keyIn != null & keyIn != "backspace" & keyIn != "enter" & keyIn != "space" & keyIn != "shift" & keyIn != "control" & cKey < nKeysStoreable) { key[cKey] = keyIn; cKey++; //Greenfoot.delay(30); } if(keyIn == "backspace" && cKey > 0) { cKey--; key[cKey] = null; //Greenfoot.delay(30); } if(keyIn == "space") { key[cKey] = " "; cKey++; //Greenfoot.delay(10); } } }
public void act() { if(Greenfoot.getMouseInfo().getActor() == this) { run(); } }
public void act() { run(); }