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

TypeScript Player.getPosition函数代码示例

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

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



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

示例1: death_

  /**
   * Called when the player this sprite represents gets killed.
   */
  private death_(killee : Player, killer : Player) {
    let position = killee.getPosition();
    let velocity = killee.getVelocity();

    let resourceManager = this.game_.getResourceManager();
    let ensemble = resourceManager.getSpriteSheet('explode1');
    new Effect(this.game_, ensemble.getAnimation(0), position, velocity);

    ensemble = resourceManager.getSpriteSheet('ship' + killee.ship + '_junk');
    for (let i = 0; i < ensemble.getNumAnimations(); ++i) {
      let animation = ensemble.getAnimation(i);
      let deltaVelocity = Vector.fromPolar(Math.random() * 2, Math.random() * 2 * Math.PI);
      new Effect(this.game_, animation, position, velocity.add(deltaVelocity));
    }

    if (this.game_.getViewport().contains(position)) {
      resourceManager.playSound('explodeShip');
    }
  }
开发者ID:krslynx,项目名称:dotproduct,代码行数:22,代码来源:PlayerSprite.ts


示例2: 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


示例3: render

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

    if (!this.player_.isAlive) {
      return;
    }

    PlayerSprite.renderPlayer(this.game_, viewport, this.player_, this.player_.direction, this.player_.getPosition());
  }
开发者ID:krslynx,项目名称:dotproduct,代码行数:12,代码来源:PlayerSprite.ts


示例4: respawn_

 /** Called when the player this sprite represents respawns. */
 private respawn_(player : Player) {
   let resourceManager = this.game_.getResourceManager();
   let animation = resourceManager.getSpriteSheet('warp').getAnimation(0);
   new Effect(this.game_, animation, player.getPosition(), Vector.ZERO);
 }
开发者ID:krslynx,项目名称:dotproduct,代码行数:6,代码来源:PlayerSprite.ts


示例5: onFired

  public onFired(timeDiff : number, position : Vector, velocity : Vector, weaponData : any) {
    assert(weaponData['type'] == this.getType(), 'Cannot fire decoy with incorrect weapon type: ' + weaponData['type']);

    let lifetime = this.settings_['lifetime'];

    let projectile = this.simulation_.modelObjectFactory.newDecoy(this.owner_, this.owner_.getPosition(), this.owner_.getVelocity(), lifetime);
    this.owner_.addProjectile(projectile);

    for (let i = 0; i < timeDiff; ++i) {
      projectile.advanceTime();
    }
  }
开发者ID:krslynx,项目名称:dotproduct,代码行数:12,代码来源:DecoyWeapon.ts


示例6: fire

  public fire(position : Vector, commitFireFn : (fireEnergy : number, fireDelay : number) => boolean) : any {
    if (this.count_ <= 0 || !commitFireFn(0 /* fireEnergy */, this.settings_['fireDelay'])) {
      return null;
    }

    --this.count_;
    let lifetime = this.settings_['lifetime'];
    let projectile = this.simulation_.modelObjectFactory.newDecoy(this.owner_, this.owner_.getPosition(), this.owner_.getVelocity(), lifetime);
    this.owner_.addProjectile(projectile);

    return {
      'type': this.getType()
    };
  }
开发者ID:krslynx,项目名称:dotproduct,代码行数:14,代码来源:DecoyWeapon.ts


示例7: fire

  public fire(position : Vector, commitFireFn : (fireEnergy : number, fireDelay : number) => boolean) : any {
    if (this.count_ <= 0 || !commitFireFn(0 /* fireEnergy */, this.settings_['fireDelay'])) {
      return null;
    }

    --this.count_;
    let shrapnelCount = this.settings_['shrapnelCount'];
    let lifetime = this.settings_['lifetime'];
    let damage = this.settings_['damage'];

    for (let i = 0; i < shrapnelCount; ++i) {
      let velocity = Vector.fromPolar(this.settings_['speed'], i * 2 * Math.PI / shrapnelCount).add(this.owner_.getVelocity());
      let projectile = this.simulation_.modelObjectFactory.newBurst(this.owner_, this.owner_.getPosition(), velocity, lifetime, damage);
      this.owner_.addProjectile(projectile);
    }

    return {
      'type': this.getType()
    };
  }
开发者ID:krslynx,项目名称:dotproduct,代码行数:20,代码来源:BurstWeapon.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript types.AccessToken类代码示例发布时间:2022-05-25
下一篇:
TypeScript Player.getDimensions函数代码示例发布时间: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