當前位置: 首頁>>代碼示例>>Java>>正文


Java AL10.alSource方法代碼示例

本文整理匯總了Java中org.lwjgl.openal.AL10.alSource方法的典型用法代碼示例。如果您正苦於以下問題:Java AL10.alSource方法的具體用法?Java AL10.alSource怎麽用?Java AL10.alSource使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.lwjgl.openal.AL10的用法示例。


在下文中一共展示了AL10.alSource方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: playAsSoundAt

import org.lwjgl.openal.AL10; //導入方法依賴的package包/類
/**
 * Play the specified buffer as a sound effect with the specified
 * pitch and gain.
 * 
 * @param buffer The ID of the buffer to play
 * @param pitch The pitch to play at
 * @param gain The gain to play at
 * @param loop True if the sound should loop
 * @param x The x position to play the sound from
 * @param y The y position to play the sound from
 * @param z The z position to play the sound from
 * @return source The source that will be used
 */
int playAsSoundAt(int buffer,float pitch,float gain,boolean loop,float x, float y, float z) {
	gain *= soundVolume;
	if (gain == 0) {
		gain = 0.001f;
	}
	if (soundWorks) {
		if (sounds) {
			int nextSource = findFreeSource();
			if (nextSource == -1) {
				return -1;
			}
			
			AL10.alSourceStop(sources.get(nextSource));
			
			AL10.alSourcei(sources.get(nextSource), AL10.AL_BUFFER, buffer);
			AL10.alSourcef(sources.get(nextSource), AL10.AL_PITCH, pitch);
			AL10.alSourcef(sources.get(nextSource), AL10.AL_GAIN, gain); 
		    AL10.alSourcei(sources.get(nextSource), AL10.AL_LOOPING, loop ? AL10.AL_TRUE : AL10.AL_FALSE);
		    
		    sourcePos.clear();
		    sourceVel.clear();
			sourceVel.put(new float[] { 0, 0, 0 });
			sourcePos.put(new float[] { x, y, z });
		    sourcePos.flip();
		    sourceVel.flip();
		    AL10.alSource(sources.get(nextSource), AL10.AL_POSITION, sourcePos);
   			AL10.alSource(sources.get(nextSource), AL10.AL_VELOCITY, sourceVel);
		    
			AL10.alSourcePlay(sources.get(nextSource)); 
			
			return nextSource;
		}
	}
	
	return -1;
}
 
開發者ID:j-dong,項目名稱:trashjam2017,代碼行數:50,代碼來源:SoundStore.java

示例2: playAsSoundAt

import org.lwjgl.openal.AL10; //導入方法依賴的package包/類
private int playAsSoundAt(int buffer, float pitch, float gain, float x,
		float y)
{
	// gain *= soundVolume;
	if (gain == 0)
	{
		gain = 0.001f;
	}
	if (game.gameOptions.soundEnable == true)
	{
		int nextSource = findFreeSource();
		if (nextSource == -1)
		{
			return -1;
		}

		AL10.alSourceStop(sources.get(nextSource));

		AL10.alSourcei(sources.get(nextSource), AL10.AL_BUFFER, buffer);
		AL10.alSourcef(sources.get(nextSource), AL10.AL_PITCH, pitch);
		AL10.alSourcef(sources.get(nextSource), AL10.AL_GAIN, gain);

		sourcePos.clear();
		sourcePos.put(new float[]
		{ x, y, 0.0f });
		sourcePos.flip();
		AL10.alSource(sources.get(nextSource), AL10.AL_POSITION, sourcePos);

		AL10.alSourcePlay(sources.get(nextSource));

		return nextSource;
	}

	return -1;
}
 
開發者ID:TheRemote,項目名稱:Spark,代碼行數:36,代碼來源:Sounds.java

示例3: QueueSound

import org.lwjgl.openal.AL10; //導入方法依賴的package包/類
private void QueueSound(int sound)
{
	if (game.gameOptions.soundEnable == false)
		return;

	intBuffer.clear();
	intBuffer.put(sounds[sound]);
	intBuffer.flip();
	AL10.alSourceQueueBuffers(sources.get(0), intBuffer);

	int state = AL10.alGetSourcei(sources.get(0), AL10.AL_SOURCE_STATE);

	if (state != AL10.AL_PLAYING)
	{
		sourcePos.clear();
		sourcePos.put(0).put(0).put(0);
		sourcePos.flip();

		int Source = sources.get(0);

		AL10.alSourceStop(Source);

		AL10.alSourcef(Source, AL10.AL_PITCH, 1.0f);
		AL10.alSourcef(Source, AL10.AL_GAIN, 1.0f);

		AL10.alSource(Source, AL10.AL_POSITION, sourcePos);
		AL10.alSourcePlay(Source);
	}
}
 
開發者ID:TheRemote,項目名稱:Spark,代碼行數:30,代碼來源:Sounds.java


注:本文中的org.lwjgl.openal.AL10.alSource方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。