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

2017/8/24

Music and Gifs

SwarmDark SwarmDark

2017/8/24

#
Hello, I have been having problems with adding background music to my game. For some reason I can not import the music into the game from the sound folder an error comes up: Caused by: java.io.FileNotFoundException: Could not find file: Disconnect_Music.mp3 at greenfoot.util.GreenfootUtil.getURL(GreenfootUtil.java:554) at greenfoot.sound.SoundFactory.createSound(SoundFactory.java:99) ... 12 more This is my code:
public void music(){
     Greenfoot.playSound("energy.wav");
     if (musicTimer == 100000){
     Greenfoot.playSound("Disconnect_Music.mp3");
    }
    if (musicTimer == 20000){
    Greenfoot.playSound("Fade_Music.mp3");
    
    
    }
    if( musicTimer == 30000){
    Greenfoot.playSound("Titans_Music.mp3");
    
    
    
    
    
    
}*/
In addition, I trying to work with gifs to animate my character, however I am having trouble finding the greenfoot commands, is there somewhere I can look to give me a broader understanding of gif manipulation and integration
danpost danpost

2017/8/24

#
Copy the music files into the 'sounds' folder within the project folder manually. Check out my GifImage vs Animation scenario. You can download it and open it in greenfoot to see how the two classes work for animation and then you can decide which might suit your needs better.
SwarmDark SwarmDark

2017/9/1

#
Hello, I have looked through your tutorial on gif Images. However, when using the setImage() method im my act() it creates the error of: java.lang.NullPointerException at Dragon.act(Dragon.java:30) at greenfoot.core.Simulation.actActor(Simulation.java:604) at greenfoot.core.Simulation.runOneLoop(Simulation.java:562) at greenfoot.core.Simulation.runContent(Simulation.java:221) at greenfoot.core.Simulation.run(Simulation.java:211) Edit: well only the at Dragon.act(Dragon.java:30) comes up red
 private GifImage Dragon_Animation;

public void act() 
    {
     
      
       animation();
       
       setImage(Dragon_Animation.getCurrentImage());
    }    

 public void animation(){
      GifImage Dragon_Animation = new GifImage("images/Dragon.gif");
      setImage(Dragon_Animation.getCurrentImage());  
    }
danpost danpost

2017/9/1

#
SwarmDark wrote...
Hello, I have looked through your tutorial on gif Images. However, when using the setImage() method im my act() it creates the error of: java.lang.NullPointerException at Dragon.act(Dragon.java:30)
Replace line 1 with line 13 and remove line 7 and lines 12 through 15..
You need to login to post a reply.