diff --git a/lib/scenemanager.js b/lib/scenemanager.js index 163449b..978a75e 100644 --- a/lib/scenemanager.js +++ b/lib/scenemanager.js @@ -22,7 +22,9 @@ function SceneManager(p) o.draw = function(){ me.draw(); }; o.mousePressed = function(){ me.mousePressed(); }; + o.mouseClicked = function(){ me.mouseClicked(); }; o.keyPressed = function(){ me.keyPressed(); }; + o.windowResized = function(){ me.windowResized(); }; return me; } @@ -45,7 +47,9 @@ function SceneManager(p) hasEnter : "enter" in oScene, hasDraw : "draw" in oScene, hasMousePressed : "mousePressed" in oScene, + hasMouseClicked : "mouseClicked" in oScene, hasKeyPressed : "keyPressed" in oScene, + hasWindowResized : "windowResized" in oScene, setupExecuted : false, enterExecuted : false }; @@ -162,6 +166,19 @@ function SceneManager(p) } } + // This will dispatch .mouseClicked() to the + // current scene .mouseClicked() method + this.mouseClicked = function() + { + if ( this.scene == null ) + return; + + if ( this.scene.hasMouseClicked ) + { + this.scene.oScene.mouseClicked(); + } + } + // This will dispatch .keyPressed() to the // current scene .keyPressed() method this.keyPressed = function() @@ -174,4 +191,17 @@ function SceneManager(p) this.scene.oScene.keyPressed(); } } + + // This will dispatch .windowResized() to the + // current scene .windowResized() method + this.windowResized = function() + { + if ( this.scene == null ) + return; + + if ( this.scene.hasWindowResized ) + { + this.scene.oScene.windowResized(); + } + } }