• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript Viewport.getDimensions函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中Viewport.getDimensions函数的典型用法代码示例。如果您正苦于以下问题:TypeScript getDimensions函数的具体用法?TypeScript getDimensions怎么用?TypeScript getDimensions使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了getDimensions函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: render

  public render(viewport : Viewport) {
    let dimensions = viewport.getDimensions();
    let x = Math.floor(this.repel_.getPosition().x - dimensions.left - this.animation_.width / 2);
    let y = Math.floor(this.repel_.getPosition().y - dimensions.top - this.animation_.height / 2);

    this.animation_.render(viewport.getContext(), x, y);
  }
开发者ID:krslynx,项目名称:dotproduct,代码行数:7,代码来源:RepelSprite.ts


示例2: render

  public render(viewport : Viewport) {
    let context = viewport.getContext();
    let dimensions = viewport.getDimensions();

    this.renderEnergyBar_(context, dimensions);
    this.renderNearShipEnergyDisplay_(context, dimensions);
  }
开发者ID:krslynx,项目名称:dotproduct,代码行数:7,代码来源:HudLayer.ts


示例3: render

  public render(viewport : Viewport) {
    if (!this.burst_.isValid()) {
      this.invalidate();
      return;
    }

    let animation = this.burst_.isActive() ? this.activeAnimation_ : this.inactiveAnimation_;
    let dimensions = viewport.getDimensions();
    let x = Math.floor(this.burst_.getPosition().x - dimensions.left - animation.width / 2);
    let y = Math.floor(this.burst_.getPosition().y - dimensions.top - animation.height / 2);

    animation.render(viewport.getContext(), x, y);
  }
开发者ID:krslynx,项目名称:dotproduct,代码行数:13,代码来源:BurstSprite.ts


示例4: render

  public render(viewport : Viewport) {
    if (!this.bomb_.isValid()) {
      this.invalidate();
      return;
    }

    let dimensions = viewport.getDimensions();
    let x = Math.floor(this.bomb_.getPosition().x - dimensions.left - this.animation_.width / 2);
    let y = Math.floor(this.bomb_.getPosition().y - dimensions.top - this.animation_.height / 2);

    if (!this.bomb_.isMine() && this.bomb_.isBouncing()) {
      this.bouncingAnimation_.render(viewport.getContext(), x, y);
    } else {
      this.animation_.render(viewport.getContext(), x, y);
    }
  }
开发者ID:krslynx,项目名称:dotproduct,代码行数:16,代码来源:BombSprite.ts


示例5: render

  public render(viewport : Viewport) {
    if (!this.bullet_.isValid()) {
      this.invalidate();
      return;
    }

    if (Labs.BULLET_TRAILS) {
      let animation = this.game_.getResourceManager().getSpriteSheet('bulletTrails').getAnimation(3 + this.bullet_.getLevel());
      new Effect(this.game_, animation, this.bullet_.getPosition(), Vector.ZERO, Layer.TRAILS);
    }

    let dimensions = viewport.getDimensions();
    let x = Math.floor(this.bullet_.getPosition().x - dimensions.left - this.animation_.width / 2);
    let y = Math.floor(this.bullet_.getPosition().y - dimensions.top - this.animation_.height / 2);
    let animation = this.bullet_.isBouncing() ? this.bouncingAnimation_ : this.animation_;

    animation.render(viewport.getContext(), x, y);
  }
开发者ID:krslynx,项目名称:dotproduct,代码行数:18,代码来源:BulletSprite.ts


示例6: render

  public render(viewport : Viewport) {
    if (!this.player_.isValid()) {
      this.game_.getPainter().unregisterDrawable(this.layer_, this);
      return;
    }

    let context = viewport.getContext();
    let dimensions = viewport.getDimensions();

    if (!this.player_.isAlive) {
      let millis = Timer.ticksToMillis(this.localPlayer_.getRespawnTimer());
      let seconds = Math.floor(millis / 1000);
      let tenths = Math.floor((millis % 1000) / 100);
      let time = seconds + '.' + tenths;
      context.save();
      context.font = Font.playerFont().toString();
      context.fillStyle = Palette.friendColor();
      context.fillText(time, dimensions.width / 2, dimensions.height / 2);
      context.restore();
      return;
    }

    this.localPlayer_.getExhaust().forEach((e : Exhaust) => {
      const image = this.resourceManager_.getImage('exhaust');
      const x = Math.floor(e.position.x - dimensions.left - image.tileWidth / 2);
      const y = Math.floor(e.position.y - dimensions.top - image.tileHeight / 2);
      image.render(context, x, y, e.frame);
    });

    super.render(viewport);

    let x = Math.floor(dimensions.width / 2);
    let y = Math.floor(dimensions.height / 2);
    if (this.localPlayer_.isSafe()) {
      context.save();
      context.font = Font.playerFont().toString();
      context.fillStyle = Palette.friendColor();
      context.textAlign = 'center';
      context.textBaseline = 'top';
      context.fillText('Safety - weapons disabled.', x, y - 50);
      context.restore();
    }
  }
开发者ID:krslynx,项目名称:dotproduct,代码行数:43,代码来源:LocalPlayerSprite.ts


示例7: renderPlayer

  /**
   * This function renders the given |player| with an override for |direction| and
   * |position|. It's used to share player rendering code between PlayerSprite
   * and DecoySprite.
   */
  public static renderPlayer(game : Game, viewport : Viewport, player : Player, direction : number, position : Vector) {
    let resourceManager = game.getResourceManager();
    let shipImage = resourceManager.getImage('ship' + player.ship);

    let dimensions = viewport.getDimensions();
    let context = viewport.getContext();

    let x = Math.floor(position.x - dimensions.left - shipImage.tileWidth / 2);
    let y = Math.floor(position.y - dimensions.top - shipImage.tileHeight / 2);

    shipImage.render(context, x, y, direction);

    // Draw a label for the player's name.
    let name = player.name;
    let bounty = player.bounty;
    let isFriend = player.isFriend(game.simulation.playerList.localPlayer);
    context.save();
    context.font = Font.playerFont().toString();
    context.fillStyle = isFriend ? Palette.friendColor() : Palette.foeColor();
    context.textAlign = 'center';
    context.textBaseline = 'top';
    context.fillText(name + '(' + bounty + ')', x + shipImage.tileWidth / 2, y + shipImage.tileHeight);
    context.restore();

    // Draw a presence indicator for the player if applicable.
    let presenceImage : Image | null = null;
    if (player.hasPresence(Player.Presence.AWAY)) {
      presenceImage = resourceManager.getImage('presenceAway');
    } else if (player.hasPresence(Player.Presence.TYPING)) {
      presenceImage = resourceManager.getImage('presenceTyping');
    }

    if (presenceImage) {
      let speechX = x + shipImage.tileWidth - Math.floor(presenceImage.tileWidth / 2);
      let speechY = y - Math.floor(presenceImage.tileHeight / 2);
      presenceImage.render(context, speechX, speechY);
    }
  }
开发者ID:krslynx,项目名称:dotproduct,代码行数:43,代码来源:PlayerSprite.ts


示例8: render

  public render(viewport : Viewport) {
    let map = this.map_;
    let dimensions = viewport.getDimensions();
    let context = viewport.getContext();

    let tileWidth = this.tileset_.tileWidth;
    let tileHeight = this.tileset_.tileHeight;

    context.save();
    let halfWidth = Math.floor(dimensions.width / 2);
    let halfHeight = Math.floor(dimensions.height / 2);

    // Render one extra tile around the top and left in case we have a large
    // rock that's only partially protruding into the viewport.
    let leftTile = Math.floor((dimensions.x - halfWidth) / tileWidth) - 1;
    let topTile = Math.floor((dimensions.y - halfHeight) / tileHeight) - 1;
    let numHorizTiles = Math.ceil(dimensions.width / tileWidth) + 1;
    let numVertTiles = Math.ceil(dimensions.height / tileHeight) + 1;

    // Don't render tiles before 0th index.
    topTile = Math.max(topTile, 0);
    leftTile = Math.max(leftTile, 0);

    // Don't draw tiles past the map width/height.
    if (topTile + numVertTiles >= map.getHeight()) {
      numVertTiles = map.getHeight() - topTile - 1;
    }

    if (leftTile + numHorizTiles >= map.getWidth()) {
      numHorizTiles = map.getWidth() - leftTile - 1;
    }

    for (let y = topTile; y <= topTile + numVertTiles; ++y) {
      for (let x = leftTile; x <= leftTile + numHorizTiles; ++x) {
        let tileNum = map.getTile(x, y);
        if (tileNum == TileType.NONE) {
          continue;
        }

        let tileProperties = map.getTileProperties(tileNum);
        let index = tileProperties['index'];
        if (!tileProperties['animated']) {
          this.tileset_.render(context,
            x * tileWidth - dimensions.x + halfWidth,
            y * tileHeight - dimensions.y + halfHeight,
            index);
        } else {
          // Animated tile.
          if (!this.animations_[index]) {
            this.animations_[index] = this.resourceManager_.getSpriteSheet('anim' + index).getAnimation(0);
            this.animations_[index].setRepeatCount(-1);
          }
          this.animations_[index].render(context,
            x * tileWidth - dimensions.x + halfWidth,
            y * tileHeight - dimensions.y + halfHeight);
        }
      }
    }

    context.restore();
  }
开发者ID:krslynx,项目名称:dotproduct,代码行数:61,代码来源:MapLayer.ts



注:本文中的Viewport.getDimensions函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript encrypted_value.EncryptedValue类代码示例发布时间:2022-05-25
下一篇:
TypeScript Viewport.getContext函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap