mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 18:47:35 +00:00
Updates obsolete/broken way of clearing fingerprints
When a user leaves the channel, some items need to be cleared of their fingerprints (lastTouchedBy). This feature was broken because it used the this.gameObjects pool which was no longer in use. The channel GameController now triggers an event to which all items are subscribed to and if it is triggered, all items with that users fingerprints clear themselves off those. Fixes #170
This commit is contained in:
parent
3a5af058ef
commit
dba743cd7b
5 changed files with 29 additions and 30 deletions
|
|
@ -36,7 +36,6 @@ function (Parent, PhysicsEngine, Settings, requestAnimFrame, Nc, Box2D, Player,
|
|||
console.checkpoint('starting game controller for channel (' + options.channelName + ')');
|
||||
}
|
||||
|
||||
|
||||
GameController.prototype = Object.create(Parent.prototype);
|
||||
|
||||
GameController.prototype.update = function () {
|
||||
|
|
@ -59,6 +58,16 @@ function (Parent, PhysicsEngine, Settings, requestAnimFrame, Nc, Box2D, Player,
|
|||
this.createPlayer(user);
|
||||
}
|
||||
|
||||
GameController.prototype.onUserLeft = function (userId) {
|
||||
var player = this.players[userId];
|
||||
this.clearItemsOfPlayerFingerPrints(player);
|
||||
Parent.prototype.onUserLeft.call(this, userId);
|
||||
};
|
||||
|
||||
GameController.prototype.clearItemsOfPlayerFingerPrints = function(player) {
|
||||
Nc.trigger(Nc.ns.channel.events.game.player.clearFingerPrints, player);
|
||||
};
|
||||
|
||||
GameController.prototype.createPlayer = function(user) {
|
||||
|
||||
var revealedGameController = {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
define([
|
||||
"Game/Core/GameObjects/Item"
|
||||
"Game/Core/GameObjects/Item",
|
||||
"Lib/Utilities/NotificationCenter",
|
||||
],
|
||||
|
||||
function (Parent) {
|
||||
function (Parent, Nc) {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
|
@ -10,6 +11,10 @@ function (Parent) {
|
|||
Parent.call(this, physicsEngine, uid, options);
|
||||
this.heldByPlayers = [];
|
||||
this.lastMoved = null;
|
||||
|
||||
this.ncTokens = (this.ncTokens || []).concat([
|
||||
Nc.on(Nc.ns.channel.events.game.player.clearFingerPrints, this.clearOfPlayerFingerPrints, this)
|
||||
]);
|
||||
}
|
||||
|
||||
Item.prototype = Object.create(Parent.prototype);
|
||||
|
|
@ -59,6 +64,13 @@ function (Parent) {
|
|||
}
|
||||
};
|
||||
|
||||
Item.prototype.clearOfPlayerFingerPrints = function(player) {
|
||||
if (this.getLastMovedBy() && this.getLastMovedBy().player === player) {
|
||||
console.checkpoint('Removing fingerprints from ' + this.options.image);
|
||||
this.setLastMovedBy(null);
|
||||
}
|
||||
};
|
||||
|
||||
Item.prototype.onCollisionChange = function(isColliding, fixture) {
|
||||
|
||||
if(isColliding) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue