本文整理汇总了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"));
}