the floor's down_button_pressed event doesn't seem to be getting fired
MatthewFellows opened this issue · 1 comments
MatthewFellows commented
The floor's down_button_pressed event doesn't seem to be getting fired, or at least the floor.on("down_button_pressed", function(){})
doesn't seem to work...
I never see console logs for Down button pressed on floor: X
which seems a little odd to me...
Tested this on a Safari 8.0.2 browser on a Mac on Yosemite - having looked at floors.js I can not for the life of me figure out why up
would fire the event, but down
not... I'll start throwing some breakpoints in and stepping through...
{
init: function(elevators, floors) {
var elevator = elevators[0]; // Let's use the first elevator
elevator.on("idle", function() {
if (elevator.destinationQueue.length == 0) {
elevator.goToFloor(2);
} else {
elevator.goToFloor(elevator.destinationQueue[0]);
}
});
elevator.on("floor_button_pressed", function(floorNum) {
console.log("In Elevator button pressed: " + floorNum);
elevator.destinationQueue.push(floorNum);
elevator.checkDestinationQueue();
});
var floor = floors[0];
floor.on("up_button_pressed", function() {
console.log("Up button pressed on floor: " + floor.floorNum());
elevator.destinationQueue.push(floor.floorNum());
elevator.checkDestinationQueue();
});
floor.on("down_button_pressed", function() {
console.log("Down button pressed on floor: " + floor.floorNum());
elevator.destinationQueue.push(floor.floorNum());
elevator.checkDestinationQueue();
});
},
update: function(dt, elevators, floors) {
// We normally don't need to do anything here
}
}
MatthewFellows commented
Gah - never mind- floor 0 doesn't have a down button and I'm not iterating over the floors /sigh