Permalink
Browse files

Implement keyboard input.

  • Loading branch information...
1 parent fa9be9c commit a674e9d5139862157b7d89934dc74d706b198624 @jverkoey committed Feb 27, 2010
Showing with 12 additions and 0 deletions.
  1. +12 −0 dev/engine/class.director.js
@@ -21,6 +21,7 @@ goog.require('Breeze.Engine.Scene');
goog.require('goog.math.Vec2');
goog.require('goog.object');
+goog.require('goog.events.KeyHandler');
/**
* The director object is responsible for all scenes in the game. This responsibility includes
@@ -62,6 +63,8 @@ Breeze.Engine.Director = function(options) {
*/
this.mousePos_ = new goog.math.Vec2();
+ var keyHandler = new goog.events.KeyHandler(document);
+ goog.events.listen(keyHandler, goog.events.KeyHandler.EventType.KEY, this.keyPress.bind(this));
goog.events.listen(this.canvas_, goog.events.EventType.MOUSEMOVE, this.mouseMove.bind(this));
goog.events.listen(this.canvas_, goog.events.EventType.CLICK, this.click.bind(this));
@@ -122,6 +125,15 @@ Breeze.Engine.Director.prototype.click = function(event) {
};
/**
+ * Event callback for key presses.
+ */
+Breeze.Engine.Director.prototype.keyPress = function(event) {
+ if (this.activeSceneID_) {
+ this.scenes_[this.activeSceneID_].keyPress(event);
+ }
+};
+
+/**
* Event callback for the completion of a scene load.
*/
Breeze.Engine.Director.prototype.onLoadScene = function(sceneID) {

0 comments on commit a674e9d

Please sign in to comment.