本文整理匯總了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;
}