本文整理汇总了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;
}
示例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;
}
示例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();
}
}
示例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;
}