mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
better feedback on killing. fixes #109
This commit is contained in:
parent
81f5990e0c
commit
5007ab5b02
8 changed files with 95 additions and 22 deletions
63
app/Game/Client/View/Pixi/Layers/Messages.js
Normal file
63
app/Game/Client/View/Pixi/Layers/Messages.js
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
define([
|
||||
"Game/Client/View/Pixi/Layer",
|
||||
"Lib/Vendor/Pixi",
|
||||
"Lib/Utilities/NotificationCenter",
|
||||
"Game/Config/Settings"
|
||||
],
|
||||
|
||||
function (Parent, PIXI, Nc, Settings) {
|
||||
|
||||
"use strict";
|
||||
|
||||
function Messages() {
|
||||
Parent.call(this, "messages", -1);
|
||||
|
||||
this.ncTokens = [
|
||||
Nc.on(Nc.ns.client.view.gameStats.kill, this.onKill, this)
|
||||
];
|
||||
|
||||
this.mainTextOptions = {
|
||||
font: "normal 22px 'Joystix'",
|
||||
fill: "#cc0000",
|
||||
stroke: "rgba(0,0,0,0.8)",
|
||||
strokeThickness: 6
|
||||
};
|
||||
|
||||
this.mainText = new PIXI.Text("", this.mainTextOptions);
|
||||
this.container.addChild(this.mainText);
|
||||
this.mainText.visible = false;
|
||||
}
|
||||
|
||||
Messages.prototype = Object.create(Parent.prototype);
|
||||
|
||||
Messages.prototype.onKill = function(options) {
|
||||
|
||||
var killer = options.killer.isMe ? "You" : options.killer.name;
|
||||
|
||||
var victim = options.victim.isMe
|
||||
? options.killer.isMe
|
||||
? "Yourself"
|
||||
: "You"
|
||||
: options.victim.name;
|
||||
|
||||
var text = killer + " killed " + victim + " with " + options.item;
|
||||
|
||||
this.mainText.setText(text);
|
||||
this.mainText.setStyle(this.mainTextOptions);
|
||||
this.mainText.position = new PIXI.Point(-this.mainText.width / 2, (Settings.STAGE_HEIGHT / 4) -this.mainText.height / 2);
|
||||
this.mainText.visible = true;
|
||||
|
||||
var self = this;
|
||||
setTimeout(function(){
|
||||
self.mainText.visible = false;
|
||||
}, 2000);
|
||||
|
||||
}
|
||||
|
||||
Messages.prototype.render = function(centerPosition, zoom) {
|
||||
Parent.prototype.render.call(this, centerPosition, 1);
|
||||
}
|
||||
|
||||
return Messages;
|
||||
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue