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
5
ksksks ksksks

2013/10/30

#
@Kartoffelbrot @danpost Help
danpost danpost

2013/10/30

#
Your emoticon objects are all using the default image you gave the class to assign them. You either need to assign the image and sound of each emoticon within the 'for' block or pass them to the constructor of the emoticon and have them assigned there.
ksksks ksksks

2013/10/30

#
alright, now how does the for loop do that? I mean, i have a few ideas; not many make sense.
ksksks ksksks

2013/10/30

#
Wait; how do I get these strings to work?
public class Emoticon extends Actor
{
   private String[] sound;
   private String[] image;
   private void emoticon(String image, String soundFile)
   {
      setImage( image + ".png");
    }


    /**
     * Act - do whatever the Emoticon wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    public void act() 
    {
        // When the mouse is click on this object, play the sound.
         if(Greenfoot.mouseClicked(this))
         {
             Greenfoot.playSound(sound + ".wav");
         }
            
    }    
}
ksksks ksksks

2013/10/30

#
I may have assigned the different variables in the world with arrays... can I use those here
danpost danpost

2013/10/30

#
(1) you can remove line 4 (once you set the image at line 7, you no longer need that value) (2) you need to change line 3 to the following (the 'soundFile' argument in the constructor is not an array)
private String sound;
(3) you need to assign the value of 'sound' in the constructor (add this line next to line 7)
sound = soundFile;
Finally, back in your world class, you need to pass the Strings for the image and sound to this constructor by using 'new Emoticon(image, soundfile)'.
ksksks ksksks

2013/10/30

#
THANKYOU!!!!!!!!!!!!!!!!!!!!
ksksks ksksks

2013/10/30

#
same for images?
ksksks ksksks

2013/10/30

#
 /**
     * Act - do whatever the Emoticon wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    public void act() 
    {
        // When the mouse is click on this object, play the sound.
         if(Greenfoot.mouseClicked(this))
         {
             sound = soundFile;
             Greenfoot.playSound(sound + ".wav");
         }
            
    }    
here...doesn't work.
ksksks ksksks

2013/10/30

#
wait.. i get the #ed thing
ksksks ksksks

2013/10/30

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

/**
 * Write a description of class Emoticon here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class Emoticon extends Actor
{
   private String[] sound;
   private String[] image;
   
   private void emoticon(String image, String soundFile)
   {
      setImage( image + ".png"); sound= soundFile;
    }


    /**
     * Act - do whatever the Emoticon wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    public void act() 
    {
        // When the mouse is click on this object, play the sound.
         if(Greenfoot.mouseClicked(this))
         {
             Greenfoot.playSound(sound + ".wav");
         }
            
    }    
}
I get a message, incompatible types!
danpost danpost

2013/10/30

#
What line is highlighted and what code are you now using?
ksksks ksksks

2013/10/30

#
16... and I changed my soundfile/sound relationship like you told me.
danpost danpost

2013/10/30

#
You did not follow instruction number two (2) above (or (1) for that matter).
ksksks ksksks

2013/10/30

#
What do you mean?
There are more replies on the next page.
1
2
3
4
5