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


TypeScript Player.getDimensions函數代碼示例

本文整理匯總了TypeScript中model/player/Player.getDimensions函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript getDimensions函數的具體用法?TypeScript getDimensions怎麽用?TypeScript getDimensions使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


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

示例1: constructor

  constructor(simulation : Simulation, owner : Player, position : Vector, velocity : Vector, lifetime : number) {
    super(simulation, owner, 0 /* level */, lifetime, 0 /* damage */, -1 /* bounceCount */);

    this.direction_ = owner.direction;
    this.position_ = position;
    this.velocity_ = velocity;
    this.radius_ = owner.getDimensions().radius;
  }
開發者ID:krslynx,項目名稱:dotproduct,代碼行數:8,代碼來源:Decoy.ts

示例2: checkPlayerCollision_

  protected checkPlayerCollision_(player : Player) : boolean {
    if (!player.isAlive || this.owner_.isFriend(player) || !this.isActive_) {
      return false;
    }

    if (player.getDimensions().boundingRect.contains(this.position_)) {
      this.explode_(player);
      return true;
    }
    return false;
  }
開發者ID:krslynx,項目名稱:dotproduct,代碼行數:11,代碼來源:Burst.ts

示例3: renderNearShipEnergyDisplay_

  private renderNearShipEnergyDisplay_(context : CanvasRenderingContext2D, dimensions : any) {
    if (!this.player_.isAlive) {
      return;
    }

    let energy = this.player_.energy;
    let playerDimensions = this.player_.getDimensions();
    let percentEnergy = energy / this.player_.maxEnergy;

    if (percentEnergy < 0.5) {
      let x = Math.floor(playerDimensions.left - dimensions.left - 10);
      let y = Math.floor(playerDimensions.top - dimensions.top);

      context.save();
      context.fillStyle = percentEnergy < 0.25 ? Palette.energyCriticalColor() : Palette.energyWarningColor();
      context.font = Font.playerFont().toString();
      context.textAlign = 'right';
      context.textBaseline = 'bottom';
      context.fillText(energy.toString(), x, y);
      context.restore();
    }
  }
開發者ID:krslynx,項目名稱:dotproduct,代碼行數:22,代碼來源:HudLayer.ts

示例4: checkPlayerCollision_

  protected checkPlayerCollision_(player : Player) : boolean {
    if (!player.isAlive || this.owner_.isFriend(player)) {
      return false;
    }

    let distance = this.position_.subtract(player.getPosition()).magnitude();
    if (player.getDimensions().boundingRect.contains(this.position_)) {
      this.explode_(player);
      return true;
    } else if (!this.proxActivator_) {
      if (distance <= this.proxRadius_) {
        this.proxActivator_ = player;
        this.lastDistanceToProxActivator_ = distance;
      }
    } else if (player == this.proxActivator_) {
      if (distance > this.lastDistanceToProxActivator_) {
        this.explode_(null);
        return true;
      }
      this.lastDistanceToProxActivator_ = distance;
    }
    return false;
  }
開發者ID:krslynx,項目名稱:dotproduct,代碼行數:23,代碼來源:Bomb.ts


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