[英]What's wrong with “no suitable method found for load”?
在android中运行我的应用程序时声音无法播放,因此建议的解决方法包括AssetManager来预加载文件:我想在类初始化时预加载所有文件,稍后再在子函数中播放。
该管理器应在该类中全局使用,但似乎定义不是问题(尝试本地实现,相同错误)。
这是代码:
public AssetManager manager=new AssetManager();
public InterpreterAudioPlugin() {
//Preload all sounds
FileHandle sounds=Gdx.files.internal("Sound");
for (FileHandle file: sounds.list()){
manager.load(Gdx.files.internal(file.toString()),Music.class);
manager.finishLoading();
}
它在加载时弹出错误,提示“找不到适合的加载方法”。 不确定“没有合适的方法”在这里是什么意思,因为对其进行谷歌搜索后发现它是非常特定于该函数的,在我的情况下是“加载”。 有什么帮助吗?
它不存在带有参数的方法load()
:FileHandle和Class。 可能的加载方法是:
load(AssetDescriptor)
load(String, Class)
load(String, Class, AssetLoaderParameters)
您的第一个参数必须是字符串,而不是FileHandle。
尝试这个:
FileHandle sounds=Gdx.files.internal("Sound");
for (FileHandle file: sounds.list()){
manager.load("Sound/" + file.name(), Music.class);
}
manager.finishLoading();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.