Skip to content

Instantly share code, notes, and snippets.

@zkendall
Created April 9, 2016 07:13
Show Gist options
  • Save zkendall/79f80db2882d2e23b5862f2091c3212e to your computer and use it in GitHub Desktop.
Save zkendall/79f80db2882d2e23b5862f2091c3212e to your computer and use it in GitHub Desktop.
{
init: function(elevators, floors) {
log = function() { return console.log.apply(console, arguments); };
for(i = 0; i < floors.length; i++) {
var floor = floors[i];
log("Iterate Floor Num:" + floor.floorNum()) // I iterate as expected 1,2,3,4
floor.on("up_button_pressed", function() {
log("floor[" + floor.floorNum() + "].up_button_pressed()") // I am always 4, what gives?
});
}
},
update: function(dt, elevators, floors) {
// We normally don't need to do anything here
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment