本文整理匯總了Java中org.newdawn.slick.util.ResourceLoader.getResource方法的典型用法代碼示例。如果您正苦於以下問題:Java ResourceLoader.getResource方法的具體用法?Java ResourceLoader.getResource怎麽用?Java ResourceLoader.getResource使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.newdawn.slick.util.ResourceLoader
的用法示例。
在下文中一共展示了ResourceLoader.getResource方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: loadClip
import org.newdawn.slick.util.ResourceLoader; //導入方法依賴的package包/類
/**
* Loads and returns a Clip from a resource.
* @param ref the resource name
* @param isMP3 true if MP3, false if WAV
* @return the loaded and opened clip
*/
private static MultiClip loadClip(String ref, boolean isMP3) {
try {
URL url = ResourceLoader.getResource(ref);
// check for 0 length files
InputStream in = url.openStream();
if (in.available() == 0) {
in.close();
return new MultiClip(ref, null);
}
in.close();
AudioInputStream audioIn = AudioSystem.getAudioInputStream(url);
return loadClip(ref, audioIn, isMP3);
} catch (Exception e) {
explode(String.format("Failed to load file '%s'.", ref), e, DEFAULT_OPTIONS);
return null;
}
}
示例2: loadClip
import org.newdawn.slick.util.ResourceLoader; //導入方法依賴的package包/類
/**
* Loads and returns a Clip from a resource.
* @param ref the resource name
* @return the loaded and opened clip
*/
private static MultiClip loadClip(String ref) {
try {
URL url = ResourceLoader.getResource(ref);
// check for 0 length files
InputStream in = url.openStream();
if (in.available() == 0) {
in.close();
return new MultiClip(ref, null);
}
in.close();
AudioInputStream audioIn = AudioSystem.getAudioInputStream(url);
return loadClip(ref, audioIn);
} catch (Exception e) {
ErrorHandler.error(String.format("Failed to load audio file '%s'.", ref), e, true);
return null;
}
}
示例3: init
import org.newdawn.slick.util.ResourceLoader; //導入方法依賴的package包/類
/**
* @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer)
*/
public void init(GameContainer container) throws SlickException {
sound = new Sound(ResourceLoader.getResource("testdata/restart.ogg"));
charlie = new Sound(ResourceLoader.getResource("testdata/cbrown01.wav"));
engine = new Sound(ResourceLoader.getResource("testdata/engine.wav"));
//music = musica = new Music("testdata/SMB-X.XM");
music = musica = new Music(ResourceLoader.getResource("testdata/restart.ogg"), false);
musicb = new Music(ResourceLoader.getResource("testdata/kirby.ogg"), false);
burp = new Sound(ResourceLoader.getResource("testdata/burp.aif"));
}