home *** CD-ROM | disk | FTP | other *** search
/ Champak 48 / cdrom_image.iso / Games / cannonballfollier3.swf / scripts / frame_1 / DoAction_4.as < prev    next >
Encoding:
Text File  |  2007-10-01  |  3.1 KB  |  123 lines

  1. function cBall(lsClip)
  2. {
  3.    this.piGravity = 1;
  4.    _root.action_layer.attachMovie(lsClip,"ball",1);
  5.    this.pmClip = _root.action_layer.ball;
  6.    this.poVelocity = new Object();
  7.    this.mHide();
  8. }
  9. cBall.prototype.mFire = function(liAngle, liPower)
  10. {
  11.    this.pbHidden = false;
  12.    this.pmClip._x = 93 + Math.cosD(liAngle) * 35;
  13.    this.pmClip._y = 309 + Math.sinD(liAngle) * 35;
  14.    this.pmClip._y = pt.y;
  15.    this.poVelocity._x = Math.cosD(liAngle) * liPower;
  16.    this.poVelocity._y = Math.sinD(liAngle) * liPower;
  17. };
  18. cBall.prototype.mReFire = function(liAngle, liPower, lpLoc)
  19. {
  20.    this.pbHidden = false;
  21.    var liX = this.pmClip._x;
  22.    var liY = this.pmClip._y;
  23.    if(lpLoc != undefined)
  24.    {
  25.       liX = lpLoc.x - _root.action_layer._x;
  26.       liY = lpLoc.y - _root.action_layer._y;
  27.    }
  28.    this.pmClip._x = liX + Math.cosD(liAngle) * 35;
  29.    this.pmClip._y = liY + Math.sinD(liAngle) * 35;
  30.    this.pmClip._y = pt.y;
  31.    this.poVelocity._x = Math.cosD(liAngle) * liPower;
  32.    this.poVelocity._y = Math.sinD(liAngle) * liPower;
  33.    _root.goGame.mPlaySound("cannon");
  34. };
  35. cBall.prototype.mBounce = function(liAngle, liPower)
  36. {
  37.    this.pbHidden = false;
  38.    this.pmClip._x += Math.cosD(liAngle) * 35;
  39.    this.pmClip._y += Math.sinD(liAngle) * 35;
  40.    this.pmClip._y = pt.y;
  41.    this.poVelocity._x = Math.cosD(liAngle) * liPower;
  42.    this.poVelocity._y = Math.sinD(liAngle) * liPower;
  43. };
  44. cBall.prototype.mUpdate = function()
  45. {
  46.    if(!this.pbHidden)
  47.    {
  48.       this.mCollide();
  49.       this.pmClip._x += this.poVelocity._x;
  50.       this.pmClip._y += this.poVelocity._y;
  51.       this.poVelocity._y += this.piGravity;
  52.       if(_root.goGame.pbRedBallActive != true)
  53.       {
  54.          if(400 < this.pmClip._x)
  55.          {
  56.             _root.action_layer._x = - (this.pmClip._x - 400);
  57.          }
  58.          if(this.pmClip._y < 40)
  59.          {
  60.             _root.action_layer._y = - (this.pmClip._y - 40);
  61.          }
  62.       }
  63.    }
  64. };
  65. cBall.prototype.mCollide = function()
  66. {
  67.    if(!this.pbCollide)
  68.    {
  69.       if(360 < this.pmClip._y + this.poVelocity._y)
  70.       {
  71.          _root.goGame.mSplash();
  72.       }
  73.       if(this.pmClip.hitTest(_root.thing))
  74.       {
  75.          this.poVelocity._y *= -0.7;
  76.       }
  77.    }
  78. };
  79. cBall.prototype.mBreak = function()
  80. {
  81.    this.pbCollide = true;
  82.    this.poVelocity._x = 0;
  83.    this.poVelocity._y = 0;
  84.    this.pmClip.gotoAndPlay("break");
  85. };
  86. cBall.prototype.mHide = function()
  87. {
  88.    _root.action_layer.level_clip.level.pbCollide = false;
  89.    this.pbHidden = true;
  90.    this.poVelocity._x = 0;
  91.    this.poVelocity._y = 0;
  92.    this.pmClip._x = -400;
  93.    this.pmClip._y = 1000;
  94.    this.pbCollide = false;
  95. };
  96. cBall.prototype.mBounceX = function()
  97. {
  98.    _root.goGame.mPlaySound("THUNK");
  99.    this.poVelocity._x *= -0.7;
  100. };
  101. cBall.prototype.mBounceY = function()
  102. {
  103.    _root.goGame.mPlaySound("THUNK");
  104.    this.poVelocity._y *= -0.7;
  105. };
  106. cBall.prototype.mBounceYUp = function()
  107. {
  108.    _root.goGame.mPlaySound("THUNK");
  109.    if(0 < this.poVelocity._y)
  110.    {
  111.       this.poVelocity._y *= -0.7;
  112.    }
  113.    else
  114.    {
  115.       this.poVelocity._y *= 0.7;
  116.    }
  117. };
  118. cBall.prototype.mBounceXY = function()
  119. {
  120.    this.mBounceX();
  121.    this.mBounceY();
  122. };
  123.