如何在gdx中播放声音?

编程入门 行业动态 更新时间:2024-10-21 09:10:46
本文介绍了如何在gdx中播放声音?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

嗨每一个 我有背景音乐,我想在游戏开始时播放音乐,但音乐没有播放我没有知道为什么任何人都可以帮我解决这个问题 看到代码

Hi every one I have background music, and I want to play the music when the game start, but the music didn't play I don't know why can any one help me to solve this problem see the code

public void create() { . . . . backgroundMusic = Gdx.audio.newSound(Gdx.files.internal("musicBG.mp3")); backgroundMusic.play(0.5f); }

我的尝试: 我试过这个流媒体音乐·libgdx / libgdx Wiki·GitHub [ ^ ]

推荐答案

根据我对LibGDX的理解,如果您使用的音乐文件太大,音乐将无法使用Sound类播放。 Sound类的含义正是它所说的,声音和简短的。 我的解决方案: 当我编码时使用LibGDX的游戏我总是使用音乐类: 私人音乐背景音乐; backgroundMusic = Gdx.audio.newMusic(Gdx.files。内部(musicBG.mp3)); 希望这会有所帮助! 如果没有,我建议在不同的音乐文件类型之间进行试验,例如.wav From what I understand of LibGDX, music will not play using the Sound class if the music file you are using is too large. The Sound class was meant for exactly what it says, sounds, and short ones at that. My Solution: When I am coding games using LibGDX I always use the Music class: private Music backgroundMusic; backgroundMusic = Gdx.audio.newMusic(Gdx.files.internal("musicBG.mp3")); Hope this helps! If it does not, I would suggest experimenting between different music file types such as .wav

更多推荐

如何在gdx中播放声音?

本文发布于:2023-11-14 15:13:22,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1587743.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:声音   如何在   gdx

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!