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

2012/4/29

LearningGame help

chris4800 chris4800

2012/4/29

#
I'm having trouble understanding why my code won't compile. I'm trying to create letters of the alphabet 1 row at a time. I'm using an array to story the images for the letters but when I try to call the array to create the objects with the desired image an error message ensues stating that "constructor Letter in class Letter cannot be applied to given types..." Clearly I'm missing something so I'm hoping someone can help me out. My TA tried helping me, but his accent can be tough to understand and he ended up just confusing me haha. Any help would be awesome. I'll post my code below: this is the code for the LearningGame class: import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class LearningGame here. * * @author (your name) * @version (a version number or a date) */ public class LearningGame extends World { private Letter recorder; private String lettersFirstRow = {"A.png", "B.png", "C.png", "D.png", "E.png", "F.png", "G.png"}; /** * Constructor for objects of class LearningGame. * */ public LearningGame() { super(600, 455, 1); //Create a recorder object to be used by the other elements in the scenario. Recorder recorder = new Recorder(); //Insert your code for creating the letters here. addObject(new Message(recorder), 300, 403); for (int i=0; i < 7; i++) { getWorld().addObject(new Letter(recorder, lettersFirstRow, lettersFirstRow.charAt(0)), 39 + i*77, 25); } for (int i = 0; i < 7; i++) { addObject(new Letter(recorder),39 + i*77, 102); } for (int i = 0; i < 7; i++) { addObject(new Letter(recorder), 39 + i*77, 174); } for (int i = 0; i < 5; i++) { addObject(new Letter(recorder), 39 + i*77,244); } } } and this is the code for the Letter class: import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * The letters to display on the screen. * * @author (your name) * @version (a version number or a date) */ public class Letter extends Actor { private Recorder _recorder; private String lettersFirstRow = {"A.png", "B.png", "C.png", "D.png", "E.png", "F.png", "G.png"}; public Letter(Recorder recorder) { _recorder = recorder; //setImage(lettersFirstRow, lettersFirstRow.charAt(0)); } /** * Act - do whatever the Letter wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { } }
danpost danpost

2012/4/30

#
Is it giving you an error message? and, if so, what does it say? Best to copy/paste the message in its entirety. Also, when posting code, use the 'code' link below the 'Post a reply' box and copy/paste your code into the pop-up window.
yanks101 yanks101

2012/4/30

#
chris any interest in helping me out with the 2 labs due tonight, ill pay you.
rkzkIMP rkzkIMP

2012/5/1

#
yanks101 wrote...
chris any interest in helping me out with the 2 labs due tonight, ill pay you.
come to you-know-where-the-linux is. ill help you out with practice 4
You need to login to post a reply.