Slick Forums

Discuss the Slick 2D Library
It is currently Wed May 22, 2013 8:13 pm

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Wed Jul 04, 2012 7:07 pm 
Offline

Joined: Thu Jun 21, 2012 3:27 pm
Posts: 27
Alright so I've been trying to make music stop when you enter another state. Here's what I tried first:
Code:
      if(input.isKeyDown(Input.KEY_ENTER)){
         mus.stop();
            sbg.enterState(1);
         }

But when I hit enter the game crashed. No errors it just closed down. Then I used google to find another way to stop music with Slick and here's what I found:
Code:
public void stop()
So I tried this:
Code:
      if(input.isKeyDown(Input.KEY_ENTER)){
         public void stop(mus);
            sbg.enterState(1);
         }
But Eclipse gave me an error saying "void is an invalid type for the variable stop"
What do I do? Is it possible to stop music from another .java file/game state? If so, how?

_________________
http://ReinventGaming.com/


Top
 Profile  
 
PostPosted: Wed Jul 04, 2012 7:30 pm 
Offline
Game Developer
User avatar

Joined: Thu Mar 03, 2011 6:22 pm
Posts: 534
It probalty because you are trynt to stop it all the time. You check "isKeyDown", replace this with "isKeyPressed" so you just stop the music if you pressed the once and not hold it down.

Also "public void stop()" refers to the name of the method in the music class. Of course you stop call a method by saying music.stop (or whatever the name of your object is).

_________________
Current Projects:
Image Mr. Hat I
Image Vegan Vs. Zombies
Projects:
RadicalFish Engine - Build on top of Slick2D, Ideas, Bugs? Open an Issue ticket!


Top
 Profile  
 
PostPosted: Wed Jul 04, 2012 11:18 pm 
Offline
Slick Zombie

Joined: Sat Jan 27, 2007 7:10 pm
Posts: 1469
leosiden wrote:
Alright so I've been trying to make music stop when you enter another state. Here's what I tried first:
Code:
      if(input.isKeyDown(Input.KEY_ENTER)){
         mus.stop();
            sbg.enterState(1);
         }

But when I hit enter the game crashed. No errors it just closed down. Then I used google to find another way to stop music with Slick and here's what I found:
Code:
public void stop()
So I tried this:
Code:
      if(input.isKeyDown(Input.KEY_ENTER)){
         public void stop(mus);
            sbg.enterState(1);
         }
But Eclipse gave me an error saying "void is an invalid type for the variable stop"
What do I do? Is it possible to stop music from another .java file/game state? If so, how?

No errors... That's a little fishy. Are you sure you aren't exiting the JVM somewhere else? And are you sure the console is empty? Slick will report any errors if there was a problem.

I think you need to start smaller -- your second bit of code leads me to believe you have no idea what you're doing. :) You need to know how to use Java in order to use Slick. I'd suggest you read some books and take a course before you attempt rendering graphics or making a game.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group