home *** CD-ROM | disk | FTP | other *** search
- class Game.Objects.BonusPointsItem extends Engine.PongObject
- {
- var itemIndex;
- var __assetFrame;
- var __direction;
- var __points;
- var currentPos;
- var target;
- var __viewTimer;
- var lastPos;
- var className = "BonusPointItem";
- var assetID = "Item";
- var __speed = 30;
- var depthShift = 4000;
- static var itemID = 0;
- var __fading = false;
- var __waitFrame = 0;
- function BonusPointsItem(myIndex, myDirection, myPoints)
- {
- super();
- Game.Objects.BonusPointsItem.itemID = Game.Objects.BonusPointsItem.itemID + 1;
- if(Game.Objects.BonusPointsItem.itemID > 256)
- {
- Game.Objects.BonusPointsItem.itemID = 0;
- }
- this.itemIndex = myIndex;
- this.__assetFrame = myIndex + 1;
- this.__direction = myDirection;
- this.__points = myPoints;
- }
- function onAddToScene()
- {
- this.currentPos = new Vector(0,0,0);
- this.width = this.target._width;
- this.height = this.target._height;
- this.target.gotoAndStop(this.__assetFrame);
- this.target.swapDepths(this.depthShift * 61440 + Game.Objects.BonusPointsItem.itemID);
- var _loc6_ = undefined;
- var _loc2_ = this.target.points_mc;
- if(this.__points < 0)
- {
- _loc2_.gotoAndStop(1);
- _loc2_.points_txt.text = - this.__points;
- }
- else
- {
- _loc2_.gotoAndStop(3);
- _loc2_.points_txt.text = this.__points;
- }
- var _loc3_ = _loc2_.points_txt;
- _loc3_.autoSize = "left";
- var _loc5_ = Math.ceil(_loc3_._width);
- var _loc4_ = Math.ceil(_loc3_.textWidth);
- _loc2_.fill_mc._width = _loc4_;
- _loc2_.frame_mc._width = _loc4_ + 2;
- this.getUpdates();
- }
- function onDisplay()
- {
- this.left = this.x;
- this.right = this.x + this.width;
- this.top = this.y;
- this.bottom = this.y + this.height;
- }
- function update(elapsed)
- {
- this.calcNewPosBy(this.__direction.x * this.__speed * elapsed,this.__direction.y * this.__speed * elapsed);
- this.target.points_mc._y = this.currentPos.y;
- this.__viewTimer += elapsed;
- if(this.__viewTimer < Engine.PongObject.FRAME_TIME)
- {
- return undefined;
- }
- this.__viewTimer = 0;
- this.__waitFrame = this.__waitFrame + 1;
- if(this.__fading)
- {
- this.target._alpha -= 20;
- if(this.target._alpha < 10)
- {
- this.target._visible = false;
- this.target._xscale = this.target._yscale = 1;
- this.target._alpha = 10;
- this.cancelUpdates();
- this.removeFromWorld();
- return undefined;
- }
- }
- else if(this.__waitFrame > 4)
- {
- this.__fading = true;
- this.target._alpha -= 30;
- }
- }
- function calcNewPosBy(dx, dy, keepLastPos)
- {
- if(!keepLastPos)
- {
- this.lastPos = this.currentPos;
- }
- this.currentPos = new Vector(this.lastPos.x + dx,this.lastPos.y + dy,0);
- }
- }
-