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

2013/10/28

Emoticon Project- Gruver- so hard!!!

1
2
3
4
ksksks ksksks

2013/10/28

#
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class HomeworkWorld here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class HomeworkWorld extends World
{
    private String[] image = {"smiley1", "smiley2","smiley3","smiley4","smiley5"};;
    private String[] soundfile = {"hello","happy","crying","ohno","raspberry"};

    /**
     * Constructor for objects of class HomeworkWorld.
     * 
     */
    public HomeworkWorld()
    {   

        // Create a new world with 400x100 cells with a cell size of 1x1 pixels.
        super(400, 100, 1); 

        for(int i = 0; i<6; i++)
        {
            while(i<5)
            {
                addObject(Emoticon.class(("smiley"+ i + ".png",soundfile + ".wav"));
            }
        }

    }
}
  • Make the images appear(strings)
  • Make each one have it's own sound
  • Can't make multiple classes; just one: emoticon
ksksks ksksks

2013/10/28

#
How the heck do I do this?!!!
danpost danpost

2013/10/28

#
There are two problems I see with the code you have given. The first is that the 'addObject' method call in line 28 is missing the two int arguments for the location at which to add the object. The other is that the 'while' loop inside the 'for' loop will never be exited because 'i' is never changed within that loop (I believe you do want one of the two loops ... just not both). Beyond that, you will need to create a subclass of Actor for the Emoticon objects and code it to set the sound and image for each one created; and to play that sound when some trigger is detected.
ksksks ksksks

2013/10/28

#
How do I change i? Which would you use(why?)?
danpost danpost

2013/10/28

#
Add the location arguments to the 'addObject' statement in line 28 and remove either the 'for' loop or the 'while' loop.
ksksks ksksks

2013/10/28

#
  /**
     * Constructor for objects of class HomeworkWorld.
     * 
     */
    public HomeworkWorld()
    {   

        // Create a new world with 400x100 cells with a cell size of 1x1 pixels.
        super(400, 100, 1); 

        for(int i = 0; i<6; i++)
        {
            
            
                Emoticon emoticon = Emoticon;
                addObject(emoticon,10*(i+60),50);
            }
        
    }
What do you think of this??
ksksks ksksks

2013/10/28

#
Wait, It gives me this error "cannot find symbol: variable 'Emoticon'"; what did i do?
daksouku daksouku

2013/10/28

#
idk how to do this? WHY???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????.
ksksks ksksks

2013/10/28

#
You're way more helpful than my programming 1 teacher! He hardly says anything! Thanks alot danpost. I followed you, if that's alright, #111!
ksksks ksksks

2013/10/28

#
Yo; you in this class?
ksksks ksksks

2013/10/28

#
that was to daksouku, What seat are you?? _Kara
danpost danpost

2013/10/28

#
To create a new object, you need the following: (1) the 'new' keyword; (2) the class name followed by a set of parenthesis; and (3) values for any arguments within the parenthesis:
ClassName classObject = new ClassName(args[]);
The above code creates a new object of the class 'ClassName' using the values given in 'args' and assigns that object to the field 'classObject' declared to hold an object of the class 'ClassName'. The change in the looping looks good, as well as line 16, which adds the object (or tries to). What happened to the String arrays and the arguments needed to assign to each of the emoticons?
ksksks ksksks

2013/10/28

#
YOU ARE RIGHT NEXT TO ME DWEEB!!!!!!!!!
daksouku daksouku

2013/10/28

#
DWWWWWWWEEEEEEEEEEEBBBBBBBBBBB!!!!!!!!!!!!!!!!!!!!!
ksksks ksksks

2013/10/28

#
Thanks danpost
There are more replies on the next page.
1
2
3
4