I've been working on some stuff in EaselJS. Recently I typed up a little object to handle managing different Scene type things in a stage. Each scene inherits off a collection, but the superglobal inputs were bugging me, so I wrote this up to default out the input handlers and not have to worry about the game's scale.
In the game's resize I set the self's (just the this of the object) inverseScale to be equal to 1 / the original Canvas scale for each dimension.
It's been working well so far!
if (self.currentScene) {
createjs.Ticker.removeListener(self.currentScene);
if (!retain) {
self.currentScene.removeAllChildren();
delete self.currentScene;
}
this.stage.removeAllChildren();
}
self.currentScene = newscene;
//reset input handlers
(function (target) {
['onMouseDown', 'onMouseMove', 'onMouseUp', 'onPress', 'onClick'].map(
function (inputType) {
if (newscene.hasOwnProperty(inputType)) {
target.stage[inputType] = function (event) {
event.stageX *= self.inverseScale.x;
event.stageY *= self.inverseScale.y;
return newscene[inputType](event);
};
} else {
target.stage[inputType] = undefined;
}
}
);
})(self);
self.stage.addChild(newscene);
self.stage.update();
};