Advertisement
irishstorm

Collision_Screen_Border.js

Dec 12th, 2012
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //  Collision_Screen_Border.js
  2. //  Date : 05/12/2012
  3. //  Time : 10:54
  4. //  Author : Christopher Cullen
  5.  
  6. //  Description :
  7. //  This Script acts as a border for the game, if the object go's passed
  8. //  the variable it will play an Aduio file to warn the user.
  9.  
  10. //  These variable declare the "Border" of the screen.
  11. public var yMax : float = 5.4;
  12. public var yMin : float = -3.5;
  13. public var xMax : float = 9.52;
  14. public var xMin : float = -9.52;
  15.  
  16. //  function Update ()
  17. //  this function is responsible for handling the "border", if an object
  18. //  goes passed the "Border".  
  19.    
  20. function Update ()
  21. {
  22.     if(transform.localPosition.y >= yMax)
  23.     {
  24.          PlayAudio();
  25.     }
  26.    
  27.     if(transform.localPosition.y <= yMin)
  28.     {
  29.          PlayAudio();
  30.     }
  31.    
  32.     if(transform.localPosition.x >= xMax)
  33.     {
  34.          PlayAudio();
  35.     }
  36.    
  37.     if(transform.localPosition.x <= xMin)
  38.     {
  39.          PlayAudio();
  40.     }
  41. }
  42. //  function PlayAudio()
  43. //  This function is responsible for playing Audio.
  44. function PlayAudio()
  45. {
  46.     audio.Play();  
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement