Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions lib/scenemanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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 };

Expand Down Expand Up @@ -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()
Expand All @@ -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();
}
}
}