This site requires JavaScript, please enable it in your browser!
Greenfoot back
Ethan243
Ethan243 wrote ...

2013/1/5

Help please - worked but now have compiling error :(

Ethan243 Ethan243

2013/1/5

#
Hi. I'm hoping someone could help me. I'm trying to create a Scribblenauts-type game where users can input text into a box and then the item would appear. I had started by setting up a box to accept text input, which was actually working but now I'm getting the following compiling error and can't figure out why. "no suitable constructor found for World() - constructor greenfoot.World.World(int,int.int.boolean) is not applicable (actual and formal argument lists differ in length) - construtor greenfoot.World.World(int,int.int) is not applicable (actual and formal argument lists differ in length) Any advice would be most appreciated! Here's the code for world(): public class world extends World { boolean gettingNumber = false; boolean gettingLetter = false; /** * Constructor for objects of class world. * */ public world() { String text = ""; super(600, 400, 1); act(); prepare(); addObject(new TextInputBox(), 300, 50); gettingNumber = true; } public void act() { if (gettingNumber && getObjects(TextInputBox.class).isEmpty()) { gettingNumber = false; System.out.println("" + TextInputBox.value); } } /** * Prepare the world for the start of the program. That is: create the initial * objects and add them to the world. */ private void prepare() { Terrain terrain = new Terrain(); addObject(terrain, 133, 392); terrain.setLocation(126, 384); Terrain terrain2 = new Terrain(); addObject(terrain2, 385, 392); terrain2.setLocation(379, 385); terrain.setLocation(125, 385); terrain2.setLocation(374, 385); Terrain terrain3 = new Terrain(); addObject(terrain3, 482, 392); terrain3.setLocation(482, 385); Maxwell maxwell = new Maxwell(); addObject(maxwell, 270, 254); removeObject(maxwell); Maxwell maxwell2 = new Maxwell(); addObject(maxwell2, 251, 332); maxwell2.setLocation(250, 324); } } -- Thanks so much for any help!!
Gevater_Tod4711 Gevater_Tod4711

2013/1/5

#
The line "super(600, 400, 1);" has to be the first in your constructor. If you change the position of this line and the line "String text = "";" it'll work.
danpost danpost

2013/1/5

#
First, your first statement (line 1) in the world class needs to be
import greenfoot.*;
Then, the first statement in your 'world' constructor (public world()) MUST be
super(600, 400, 1);
danpost danpost

2013/1/5

#
The line 'String text="";' that was in the world constructor needs to be placed above the constructor with the boolean field declarations.
Ethan243 Ethan243

2013/1/5

#
Thanks so much for the quick and helpful replies - really appreciate it! It's working great now. :)
You need to login to post a reply.