- Home /
No idea what is going on in this post
problem with sounds game
hi , when i play the volume is not increase.pls help
Answer by rbhardwaj · Nov 23, 2012 at 07:27 AM
here unity scripts cool and enjoy
/*.............................. Scripts Name : Layer0
..............................*/
private var character : Transform;
function Start() { character = GameObject.Find("Duck").transform; }
function Update () { if((character.position.x - transform.position.x) >3) { transform.position.x += 7; } } /*.............................. Scripts Name : Layer1
..............................*/ var character : Transform;
function Start() { character = GameObject.Find("Duck").transform; }
function Update () { if((character.position.x - gameObject.transform.position.x) >5) { gameObject.transform.position.x += 8.8; } } /*.............................. Scripts Name : Layer2
..............................*/ var character : Transform;
function Start() { character = GameObject.Find("Duck").transform; }
function Update () { if((character.position.x - gameObject.transform.position.x) >3) { gameObject.transform.position.x += 7; } } /*.............................. Scripts Name : Layer3
..............................*/ var character : Transform;
function Start() { character = GameObject.Find("Duck").transform; }
function Update () { if((character.position.x - gameObject.transform.position.x) >10) { gameObject.transform.position.x += 17.5; } } /*.............................. Scripts Name : Layer4
..............................*/ var character : Transform;
function Start() { character = GameObject.Find("Duck").transform; }
function Update () { if((character.position.x - gameObject.transform.position.x) >200) { gameObject.transform.position.x += 595; } } /*.............................. Scripts Name : Layer5
..............................*/ var character : Transform;
function Start() { character = GameObject.Find("Duck").transform; }
function Update () { if((character.position.x - gameObject.transform.position.x) >20) { gameObject.transform.position.x += 35; } }
Answer by rbhardwaj · Nov 23, 2012 at 12:33 PM
here solution code try it and enjoy /*=========================================== Script Name : copter.js
=============================================*/
var count : int =0;
var dir : Vector3; private var speed1 : float = 16.0f; var speed : float = 5.0;
var bool:boolean = true; static var isGrounded : boolean;
var GUI_Manager_ref : GUIManager; var packed_sprite_ref : PackedSprite;
var isTouched : boolean; private var calibrationMatrix : Matrix4x4;
/========function Start() Start here=======/
function Start() { if(GameObject.Find("Bg_Sound") ) { Destroy(GameObject.Find("Bg_Sound")); } else if(GameObject.Find("Bg_Sound(Clone)")) { Destroy(GameObject.Find("Bg_Sound(Clone)")); } isTouched = true; bool = true; CalibrateAccelerometer(); }
/=========function Update() here==========/ function Update() { //rigidbody.AddForce(15,0,0); /--------- Accelerometer class here -------------/ if(GUI_Manager_ref.isPauseClick) { packed_sprite_ref.PauseAnim(); } else { packed_sprite_ref.UnpauseAnim(); } var accelerator : Vector3 = Input.acceleration; var fixedAcceleration : Vector3 = FixAcceleration (accelerator); dir.y = fixedAcceleration.x; if(dir.sqrMagnitude > 1) { dir.Normalize(); } dir =Time.deltaTime; if(transform.position.y > -9.5) { transform.Translate(dir speed1); } else { transform.position.y = -9.4; } if(transform.position.y < 19.7) { transform.Translate(dir speed1); var this_tranform_rotation = transform.rotation.eulerAngles.z; } else { transform.position.y = 19.6; } /--------- Touch class here -------------/ count = Input.touchCount; if (count > 0) { isTouched =true; var touch: Touch = Input.touches[0]; if(touch.phase == TouchPhase.Began ) { rigidbody.velocity.x = speed 5;
}
if (touch.phase == TouchPhase.Stationary)
{
rigidbody.velocity.x = speed * 7;
}
if(touch.phase == TouchPhase.Ended)
{
isTouched = false;
}
}
}
function CalibrateAccelerometer () { var accelerationSnapshot : Vector3 = Input.acceleration; var rotateQuaternion : Quaternion = Quaternion.FromToRotation(new Vector3(0.0, 0.0, -1.0), accelerationSnapshot); var matrix : Matrix4x4 = Matrix4x4.TRS(Vector3.zero, rotateQuaternion, new Vector3(1.0, 1.0, 1.0)); calibrationMatrix = matrix.inverse; }
function FixAcceleration (accelerator : Vector3) { var fixedAcceleration : Vector3 = calibrationMatrix.MultiplyVector(accelerator); return fixedAcceleration; }
/*=========================================== Script Name : GameManager.js
=============================================*/
var run_Time_Objects : GameObject[]; var i : int; private var instantiate_position : Vector3;
private var copter_transform : Transform;
var loaded_level : int; var random_range :int;
function Start() { AdvertisementHandler.DisableAds(); copter_transform =GameObject.Find("Copter").transform; loaded_level =Application.loadedLevel; // print("bjsg" + loaded_level); switch(loaded_level) { case 2 : random_range = 8; break; case 3 : random_range = 10; break; case 4 : random_range = 11; break; case 5 : random_range = 13; break; case 6 : random_range = 15; break; case 7 : random_range = 18; break; } }
function Update () { if((copter_transform.position.x-gameObject.transform.position.x) >1) { for(i=0 ; i< 7; i++) { var incremented_value : int; if(i==0) { incremented_value = Random.Range(35,80); } else { incremented_value = Random.Range(0,80); } if(incremented_value < 40) { incremented_value =42; } instantiate_position.x += incremented_value; instantiate_position.y = Random.Range(-10,20); instantiate_position.z = 0; Instantiate(run_Time_Objects[Random.Range(0,random_range)],instantiate_position,Quaternion.identity); } gameObject.transform.position.x = (instantiate_position.x+20); instantiate_position.x = gameObject.transform.position.x; } } /*=========================================== Script Name : GUIManager.js
=============================================*/ private var sound_manager_ref : SoundManager; private var distance_Travelled : float; private var last_Position:Vector3;
var copter_rigidbody_ref : Rigidbody; var copter_distance : Transform;
var level_selection : LevelSelection;
var buttonClick : boolean ; var isPauseClick :boolean; var isClicked :boolean; var next_levels : boolean; var time_distance :boolean;
var loose_Message : boolean ;
var my_GuiStyle :GUIStyle; var my_smallGuiStyle :GUIStyle;
var myFont : Font; var my_smallFont : Font; var my_smallFont2 : Font;
var pause_button : Texture2D; var outer_bar : Texture2D; var health_bar : Texture2D;
var distance_texture : Texture2D; var distance_texture2 : Texture2D; var box_texture : Texture2D; var Loose_texture : Texture2D; var Win_texture : Texture2D; var time_texture : Texture2D; var tryAgain_button :Texture2D; var quit_button :Texture2D; var resume_button : Texture2D; var next_button : Texture2D;
var current_health : float; var health_decrementer : float;
var sec : float ; var total_live : float;
var int_sec : int; var minutes :int ; var seconds : String; var time : String; var score : int;
var isWin :boolean; var isPausedClicked :boolean; var loose_sound : boolean; var win_sound : boolean;
var healthLife :boolean;
var level_Selected : int;
var sw :float ; var sh :float ; /========function Start() start here =========/ function Start() { win_sound= true; loose_sound =true; level_Selected = PlayerPrefs.GetInt("level_Selected"); sound_manager_ref = GameObject.Find("SoundManager").GetComponent("SoundManager"); Time.timeScale=1; last_Position = copter_distance.position; sw = Screen.width; sh= Screen.height; if(sw<=480) { my_GuiStyle.font = my_smallFont; } else if(sw<=800) { my_GuiStyle.font = my_smallFont2; } else { my_GuiStyle.font = myFont; } distance_Travelled =0; sec = 0; minutes = 0; score =0; seconds = ""; total_live = sw/4; current_health = total_live; if(level_Selected ==1) { health_decrementer = ((total_live).01)/50; if(sw <480) { health_decrementer = ((total_live).01)/40; // print(""+Screen.width); } } else { health_decrementer = ((total_live)*.01)/60; } }
function Update() { distance_Travelled = copter_distance.position.x- last_Position.x; sec = sec + Time.deltaTime; int_sec = sec;
if(int_sec < 10) { seconds = "0" + int_sec; } else { seconds = ""+int_sec; }
if(int_sec > 59) { minutes++; sec=0; } time = minutes + ":" + seconds; }
/========function OnGUI() start here =========/ function OnGUI() { if(level_Selected ==1 && (Input.GetKeyDown(KeyCode.Escape))) { Application.LoadLevel("1_LevelSelection"); } if(level_Selected ==2 && (Input.GetKeyDown(KeyCode.Escape))) { Application.LoadLevel("1_LevelSelection"); } if(level_Selected ==3 && (Input.GetKeyDown(KeyCode.Escape))) { Application.LoadLevel("1_LevelSelection"); } if(level_Selected ==4 && (Input.GetKeyDown(KeyCode.Escape))) { Application.LoadLevel("1_LevelSelection"); } if(level_Selected ==5 && (Input.GetKeyDown(KeyCode.Escape))) { Application.LoadLevel("1_LevelSelection"); } if(level_Selected ==6 && (Input.GetKeyDown(KeyCode.Escape))) { Application.LoadLevel("1_LevelSelection"); } if(!time_distance) { GUI.DrawTexture(Rect(sw/1.37,sh/15,sw/4.5,sh/15),distance_texture); GUI.Label(Rect(sw/1.14,sh/13,sw/1.1,sh/1.1), "" + Mathf.FloorToInt(distance_Travelled),my_GuiStyle); //GUI.Label(Rect(10,sh/8,sw/2.5,sh/1.5), "Score : " + score); GUI.DrawTexture(Rect(sw/8,sh/15,sw/4.5,sh/15),time_texture); GUI.Label(Rect(sw/4.63,sh/12.8,sw/2.5,sh/1.8), "" + time, my_GuiStyle); time_distance = false; } if (minutes == 2) { if(win_sound) { sound_manager_ref.Play_Respective_Sound(4); win_sound = false; } time_distance = true; Time.timeScale = 0; GUI.DrawTexture(Rect(sw/6,sh/8,sw/1.5,sh/1.3),box_texture); GUI.DrawTexture(Rect(sw/2.82,sh/4,sw/3.5,sh/10),Win_texture); isWin = true; switch(Application.loadedLevel) { case 2 : if( PlayerPrefs.GetInt("no_of_level_unlocked")<2) { PlayerPrefs.SetInt("no_of_level_unlocked",2); } break; case 3 : if( PlayerPrefs.GetInt("no_of_level_unlocked")<3) { PlayerPrefs.SetInt("no_of_level_unlocked",3); } break; case 4 : if( PlayerPrefs.GetInt("no_of_level_unlocked")<4) { PlayerPrefs.SetInt("no_of_level_unlocked",4); } break; case 5 : if( PlayerPrefs.GetInt("no_of_level_unlocked")<5) { PlayerPrefs.SetInt("no_of_level_unlocked",5); } break; case 6 : if( PlayerPrefs.GetInt("no_of_level_unlocked")<6) { PlayerPrefs.SetInt("no_of_level_unlocked",6); } break; } print("===" +Application.loadedLevel); if(!(Application.loadedLevel == 7)) { GUI.DrawTexture(Rect(sw/3.1,sh/2.4,sw/4,sh/13.5),distance_texture2); GUI.Label(Rect(sw/1.7,sh/2.3,sw/2.5,sh/1.1), "" + Mathf.FloorToInt(distance_Travelled),my_GuiStyle); GUI.DrawTexture(Rect(sw/3.4,sh/1.9,sw/6,sh/10),tryAgain_button); if(GUI.Button( Rect(sw/3.4,sh/1.9,sw/6,sh/10), "",GUIStyle.none)) { isClicked = true; Application.LoadLevel(Application.loadedLevelName); } GUI.DrawTexture(Rect(sw/1.85,sh/1.9,sw/6,sh/10),next_button); if(GUI.Button( Rect(sw/1.85,sh/1.9,sw/6,sh/10), "",GUIStyle.none)) { PlayerPrefs.SetInt("level_Selected",Application.loadedLevel);; Application.LoadLevel(Application.loadedLevel + 1); isClicked = true; } GUI.DrawTexture(Rect(sw/2.4,sh/1.5,sw/6,sh/10),quit_button); if(GUI.Button(Rect(sw/2.4,sh/1.5,sw/6,sh/10),"",GUIStyle.none)) { isClicked = true; Application.LoadLevel("0_MainMenu"); } } else { GUI.DrawTexture(Rect(sw/3.1,sh/2.4,sw/4,sh/13.5),distance_texture2); GUI.Label(Rect(sw/1.7,sh/2.3,sw/2.5,sh/1.1), "" + Mathf.FloorToInt(distance_Travelled),my_GuiStyle); GUI.DrawTexture(Rect(sw/3.25,sh/1.7,sw/6,sh/10),tryAgain_button); if(GUI.Button( Rect(sw/3.5,sh/1.7,sw/6,sh/10), "",GUIStyle.none)) { isClicked = true; Application.LoadLevel(Application.loadedLevelName); } GUI.DrawTexture(Rect(sw/1.9,sh/1.7,sw/6,sh/10),quit_button); if(GUI.Button(Rect(sw/2,sh/1.7,sw/6,sh/10),"",GUIStyle.none)) { isClicked = true; Application.LoadLevel("0_MainMenu"); } } } else if(loose_Message && minutes != 2 ) { if(loose_sound) { sound_manager_ref.Play_Respective_Sound(3); loose_sound = false; } time_distance = true; Time.timeScale = 0; GUI.DrawTexture(Rect(sw/6,sh/8,sw/1.5,sh/1.3),box_texture); GUI.DrawTexture(Rect(sw/2.82,sh/4,sw/3.5,sh/10),Loose_texture); GUI.DrawTexture(Rect(sw/3.1,sh/2.4,sw/4,sh/13.5),distance_texture2); GUI.Label(Rect(sw/1.7,sh/2.3,sw/2.5,sh/1.1), "" + Mathf.FloorToInt(distance_Travelled),my_GuiStyle); GUI.DrawTexture(Rect(sw/3.25,sh/1.7,sw/6,sh/10),tryAgain_button); if(GUI.Button( Rect(sw/3.5,sh/1.7,sw/6,sh/10), "",GUIStyle.none)) { isClicked = true; Application.LoadLevel(Application.loadedLevelName); } GUI.DrawTexture(Rect(sw/1.9,sh/1.7,sw/6,sh/10),quit_button); if(GUI.Button( Rect(sw/2,sh/1.7,sw/6,sh/10), "",GUIStyle.none)) { isClicked = true; Application.LoadLevel("0_MainMenu"); } } else if(!isPauseClick) {
GUI.DrawTexture(Rect(10,10,sw/14,sh/10),pause_button); if(GUI.Button(Rect(10,10,sw/14,sh/10),"",GUIStyle.none)) { isPausedClicked = true; isPauseClick = true; Time.timeScale=0; } } else { GUI.DrawTexture(Rect(sw/3,sh/6,sw/2.8,sh/1.5),box_texture); GUI.DrawTexture(Rect(sw/2.42,sh/2.8,sw/5,sh/10),resume_button); if(GUI.Button( Rect(sw/2.42,sh/2.8,sw/5,sh/10), "",GUIStyle.none)) { isPausedClicked = false; isPauseClick = false; Time.timeScale=1; } GUI.DrawTexture(Rect(sw/2.42,sh/1.8,sw/5,sh/10),quit_button); if(GUI.Button( Rect(sw/2.42,sh/1.8,sw/5,sh/10), "",GUIStyle.none)) { Time.timeScale=1; isPauseClick = false; Application.LoadLevel("0_MainMenu"); }
} if(current_health>1 && !isWin ) { if( !isPausedClicked) { current_health -= (health_decrementer); } } else {
loose_Message = true; copter_rigidbody_ref.constraints = RigidbodyConstraints.FreezePositionX; } GUI.DrawTexture(Rect(sw/2.6,10,current_health,sh/20),health_bar); GUI.DrawTexture(Rect(sw/2.62,10,(sw/3.9),sh/20.2),outer_bar);
} /*=========================================== Script Name : healthbar.js
=============================================*/
var copter_rigidbody_ref : Rigidbody;
private var ref_3:healthbar; private var GUI_Manager_ref : GUIManager;
var texture2:Texture2D; var texture1:Texture2D;
var texture1MaxW:float;
var currentHelath:float;
/========function Start() Start here=======/
function Start() { currentHelath = 100; texture1MaxW = texture1.width; ref_3 = GameObject.Find("HealthBar").GetComponent("healthbar"); GUI_Manager_ref = GameObject.Find("GUIManager").GetComponent("GUIManager"); } /=========function Update() here==========/
function Update () { if(currentHelath>5) currentHelath -= Time.deltaTime; else { GUI_Manager_ref.loose_Message = true; copter_rigidbody_ref.constraints = RigidbodyConstraints.FreezePositionX; } } /========function OnGUI() start here =========/
function OnGUI() { var BarWidth : float = (currentHelath/100)*texture1MaxW; var gap : int =20; GUI.BeginGroup(Rect(Screen.width/1.5 - texture2.width - gap,gap,texture2.width,texture2.height)); GUI.DrawTexture(Rect(0,0,texture2.width,texture2.height),texture2); GUI.BeginGroup(Rect(5,6,BarWidth,texture1.height)); GUI.DrawTexture(Rect(-2,-7,texture1.width-5,texture1.height),texture1); GUI.EndGroup(); GUI.EndGroup(); }
var bg_texture : Texture2D; var unlock_button : Texture2D[]; var lock_button : Texture2D[]; var back_button : Texture2D; var loading : Texture2D;
var sw : float; var sh : float;
var isLevelSelected : boolean; var back_levels : boolean;
var no_of_level_unlocked : int;
var bg_sound : GameObject;
function Start() { sw = Screen.width; sh = Screen.height; if(!PlayerPrefs.HasKey("no_of_level_unlocked")) { no_of_level_unlocked = 1; } else { no_of_level_unlocked = PlayerPrefs.GetInt("no_of_level_unlocked"); } if(!GameObject.Find("Bg_Sound") && !GameObject.Find("Bg_Sound(Clone)")) { Instantiate(bg_sound); } } function OnGUI () {
if(Input.GetKeyDown(KeyCode.Escape)) { Application.LoadLevel("0_MainMenu"); } if(!isLevelSelected) { GUI.DrawTexture(Rect(0,0,sw,sh),bg_texture); if(no_of_level_unlocked>=1) { GUI.DrawTexture(Rect(sw/4.7,sh/3,sw/8,sh/6),unlock_button[0]); if(GUI.Button(Rect(sw/4.7,sh/3,sw/8,sh/6),"",GUIStyle.none)) { isLevelSelected =true; PlayerPrefs.SetInt("level_Selected",1);; Application.LoadLevel("2_GamePlay"); back_levels =true; } } if(no_of_level_unlocked >=2) { GUI.DrawTexture(Rect(sw/2.2,sh/3,sw/8,sh/6),unlock_button[1]); if(GUI.Button(Rect(sw/2.2,sh/3,sw/8,sh/6),"",GUIStyle.none)) { isLevelSelected =true; PlayerPrefs.SetInt("level_Selected",2);; Application.LoadLevel("3_GamePlay"); } } else { GUI.DrawTexture(Rect(sw/2.2,sh/3,sw/8,sh/6),lock_button[1]); } if(no_of_level_unlocked >=3) { GUI.DrawTexture(Rect(sw/1.5,sh/3,sw/8,sh/6),unlock_button[2]); if(GUI.Button(Rect(sw/1.5,sh/3,sw/8,sh/6),"",GUIStyle.none)) { isLevelSelected =true; PlayerPrefs.SetInt("level_Selected",2);; Application.LoadLevel("4_GamePlay"); } } else { GUI.DrawTexture(Rect(sw/1.5,sh/3,sw/8,sh/6),lock_button[2]); } if(no_of_level_unlocked >=4) { GUI.DrawTexture(Rect(sw/4.7,sh/1.7,sw/8,sh/6),unlock_button[3]); if(GUI.Button(Rect(sw/4.7,sh/1.7,sw/8,sh/6),"",GUIStyle.none)) { isLevelSelected =true; PlayerPrefs.SetInt("level_Selected",4);; Application.LoadLevel("5_GamePlay"); } } else { GUI.DrawTexture(Rect(sw/4.7,sh/1.7,sw/8,sh/6),lock_button[3]); } if(no_of_level_unlocked >=5) { GUI.DrawTexture(Rect(sw/2.2,sh/1.7,sw/8,sh/6),unlock_button[4]); if(GUI.Button(Rect(sw/2.2,sh/1.7,sw/8,sh/6),"",GUIStyle.none)) { isLevelSelected =true; PlayerPrefs.SetInt("level_Selected",5);; Application.LoadLevel("6_GamePlay"); } } else { GUI.DrawTexture(Rect(sw/2.2,sh/1.7,sw/8,sh/6),lock_button[4]); } if(no_of_level_unlocked >=6) { GUI.DrawTexture(Rect(sw/1.5,sh/1.7,sw/8,sh/6),unlock_button[5]); if(GUI.Button(Rect(sw/1.5,sh/1.7,sw/8,sh/6),"",GUIStyle.none)) { isLevelSelected =true; PlayerPrefs.SetInt("level_Selected",6);; Application.LoadLevel("7_GamePlay"); } } else { GUI.DrawTexture(Rect(sw/1.5,sh/1.7,sw/8,sh/6),lock_button[5]); } GUI.DrawTexture(Rect(sw/2.4,sh/1.32,sw/6,sh/10.5),back_button); if(GUI.Button(Rect(sw/2.4,sh/1.32,sw/6,sh/11),"",GUIStyle.none)) { Application.LoadLevel("0_MainMenu"); } } else { GUI.DrawTexture(Rect(0,0,sw,sh),loading); } if (Input.deviceOrientation == DeviceOrientation.LandscapeLeft) { Screen.orientation = ScreenOrientation.LandscapeLeft; }
else if (Input.deviceOrientation == DeviceOrientation.LandscapeRight) { Screen.orientation = ScreenOrientation.LandscapeRight; } } /............................ script Name : Menuscript ............................/
var bg_texure : Texture2D; var credit_screen : Texture2D; var settings_bg : Texture2D;
var back_button : Texture2D; var play_button : Texture2D; var instruction_button : Texture2D; var instruction_bg : Texture2D; var settings_button : Texture2D; var credit_button : Texture2D;;
var plus : Texture2D; var minus : Texture2D;
var sw : float; var sh : float; var volumebar : float;
var isMain_menu : boolean; var isInstruction_screen : boolean; var isCredit_Screen : boolean; var isSetting_screen : boolean;
var mySkin : GUISkin;
var bg_sound : GameObject;
function Start() { sw = Screen.width; sh = Screen.height; isMain_menu = true; isInstruction_screen = false; isCredit_Screen = false; isSetting_screen = false; isCredit_Screen = false; volumebar = 5; if(!GameObject.Find("Bg_Sound") && !GameObject.Find("Bg_Sound(Clone)")) { Instantiate(bg_sound); } AdvertisementHandler.Instantiate("a1507fc5754b5b0", AdvertisementHandler.AdvSize.BANNER, AdvertisementHandler.AdvOrientation.HORIZONTAL, AdvertisementHandler.Position.BOTTOM, AdvertisementHandler.Position.CENTER_HORIZONTAL, false, AdvertisementHandler.AnimationInType.SLIDE_IN_LEFT, AdvertisementHandler.AnimationOutType.FADE_OUT, AdvertisementHandler.LevelOfDebug.LOW); AdvertisementHandler.EnableAds(); }
function OnGUI () { if(Input.GetKeyDown(KeyCode.Escape)) { isMain_menu = true; isInstruction_screen = false; isCredit_Screen = false; isSetting_screen = false; isCredit_Screen = false; } if(Input.GetKeyDown(KeyCode.Home)) { Application.Quit(); } if(isMain_menu) { GUI.DrawTexture(Rect(0,0,sw,sh),bg_texure); GUI.DrawTexture(Rect(sw/2.6,sh/4.8,sw/4.5,sh/9),play_button); if(GUI.Button(Rect(sw/2.6,sh/4.8,sw/4.5,sh/9),"",GUIStyle.none)) { Application.LoadLevel("1_LevelSelection"); } GUI.DrawTexture(Rect(sw/2.6,sh/2.65,sw/4.5,sh/9),settings_button); if(GUI.Button(Rect(sw/2.6,sh/2.65,sw/4.5,sh/9),"",GUIStyle.none)) { isMain_menu = false; isSetting_screen = true; } GUI.DrawTexture(Rect(sw/2.6,sh/1.85,sw/4.5,sh/9),instruction_button); if(GUI.Button(Rect(sw/2.6,sh/1.85,sw/4.5,sh/9),"",GUIStyle.none)) { isMain_menu = false; isInstruction_screen = true; } GUI.DrawTexture(Rect(sw/2.6,sh/1.41,sw/4.5,sh/9),credit_button); if(GUI.Button(Rect(sw/2.6,sh/1.41,sw/4.5,sh/9),"",GUIStyle.none)) { isMain_menu = false; isCredit_Screen = true; } } else if(isInstruction_screen) { GUI.DrawTexture(Rect(0,0,sw,sh),instruction_bg); if(GUI.Button(Rect(0,0,sw,sh),"",GUIStyle.none)) { isInstruction_screen = false; isMain_menu = true; } } else if(isSetting_screen) { GUI.skin = mySkin; GUI.DrawTexture(Rect(0,0,sw,sh),settings_bg); volumebar = GUI.HorizontalSlider (new Rect (sw/2.8,sh/2.5,sw/4,sh/4), volumebar, 1.0f, 20.0f); GUI.DrawTexture(Rect(sw/3,sh/2,sw/30,sh/34),minus); if(GUI.RepeatButton(Rect(sw/3.1,sh/2.05,sw/20,sh/20),"",GUIStyle.none)) { volumebar -= .5; } GUI.DrawTexture(Rect(sw/1.67,sh/2,sw/30,sh/34),plus); if(GUI.RepeatButton(Rect(sw/1.7,sh/2.05,sw/20,sh/20),"",GUIStyle.none)) { volumebar += .5; } if(volumebar<=1) { AudioListener.volume = 0; } else { AudioListener.volume = volumebar; } GUI.DrawTexture(Rect(sw/2.4,sh/1.5,sw/8,sh/12),back_button); if(GUI.Button(Rect(sw/2.4,sh/1.5,sw/8,sh/12),"",GUIStyle.none)) { isSetting_screen = false; isMain_menu = true; } } else if(isCredit_Screen) { GUI.DrawTexture(Rect(0,0,sw,sh),credit_screen); if(GUI.Button(Rect(0,0,sw,sh),"",GUIStyle.none)) { isCredit_Screen = false; isMain_menu = true; } } if (Input.deviceOrientation == DeviceOrientation.LandscapeLeft) { Screen.orientation = ScreenOrientation.LandscapeLeft; }
else if (Input.deviceOrientation == DeviceOrientation.LandscapeRight) { Screen.orientation = ScreenOrientation.LandscapeRight; } }
/*=========================================== Script Name : HealthDecrese.js
=============================================*/
private var copters_gameObject_transform :Transform; private var GUI_Manager_ref : GUIManager; var packed_sprite_ref : PackedSprite; private var sound_manager_ref : SoundManager; /========function Start() Start here=======/
function Start() { copters_gameObject_transform = GameObject.Find("Copter").transform; GUI_Manager_ref = GameObject.Find("GUIManager").GetComponent("GUIManager"); sound_manager_ref = GameObject.Find("SoundManager").GetComponent("SoundManager"); } /=========function Update() here==========/
function Update () { if(GUI_Manager_ref.isPauseClick) { packed_sprite_ref.PauseAnim(); } else { packed_sprite_ref.UnpauseAnim(); } if((copters_gameObject_transform.position.x-transform.position.x) >=150) { Destroy(gameObject); } } /======function OnCollisionEnter()here======/
function OnTriggerEnter (colli : Collider) { if(colli.gameObject.tag == "copter") { sound_manager_ref.Play_Respective_Sound(1); iPhoneUtils.Vibrate(); if(GUI_Manager_ref.current_health >25) { GUI_Manager_ref.current_health -= 25; } if(GUI_Manager_ref.current_health <25 && GUI_Manager_ref.current_health >11) { GUI_Manager_ref.current_health -= 10; } if(GUI_Manager_ref.current_health >1) { GUI_Manager_ref.current_health -= (GUI_Manager_ref.health_decrementer); } else { GUI_Manager_ref.loose_Message = true; } } // print("Current health : "+ GUI_Manager_ref.current_health); }
Answer by rbhardwaj · Nov 22, 2012 at 10:27 AM
hi i am use this scripts for sounds,it work.
/*.............................. Scripts Name : Sound_Manager
..............................*/
var bg_music : AudioSource; var gm_completion : AudioSource; var gm_lose : AudioSource; var coin_snd : AudioSource; var boomerrang_audio : AudioSource; var duck_slip_audio : AudioSource;
function Play_RespectiveSound(i : int) { switch(i) { case 0 : if(!bg_music.isPlaying ) bg_music.Play(); break; case 1 : if(!gm_completion.isPlaying) { gm_completion.Play(); } break; case 2 : if(!gm_lose.isPlaying) { gm_lose.Play(); } break; case 3: coin_snd.Play(); break; case 4 : boomerrang_audio.Play(); break; case 5: duck_slip_audio.Play(); break; } }
function Stop_respectiveSound(j:int) { switch(j) { case 0: if(bg_music.isPlaying) bg_music.Stop(); break; } }
Follow this Question
Related Questions
Find or make sound effects. 2 Answers
Footstep Sound Effect 0 Answers
How many sounds can play all at once? 3 Answers
Best way to play audio sound effects 1 Answer