Implement getScreenWidth/Height for Cocos2d renderering

This commit is contained in:
Florian Rival
2016-03-01 21:27:13 +01:00
parent 3a2f6a2ac7
commit d54eadf39d
2 changed files with 20 additions and 1 deletions

View File

@@ -67,9 +67,14 @@ gdjs.RuntimeGameCocosRenderer.prototype.getDirectorManager = function() {
return this._directorManager;
}
/**
* As Cocos2d is managing the game loop, the Cocos scenes need to call this
* function to step the game engine. See RuntimeSceneCocosRenderer.
* @method onSceneUpdated
*/
gdjs.RuntimeGameCocosRenderer.prototype.onSceneUpdated = function() {
if (!this._gameLoopFn()) {
this._directorManager.end()
this._directorManager.end();
}
}
@@ -77,3 +82,11 @@ gdjs.RuntimeGameCocosRenderer.prototype.convertYPosition = function(y) {
//Cocos2D Y axis is inverted, with origin at the bottom of the window.
return this._currentHeight - y;
}
gdjs.RuntimeGameCocosRenderer.getScreenWidth = function() {
return cc.view.getFrameSize().width;
}
gdjs.RuntimeGameCocosRenderer.getScreenHeight = function() {
return cc.view.getFrameSize().height;
}

View File

@@ -39,10 +39,16 @@ gdjs.evtTools.window.getWindowTitle = function(runtimeScene) {
};
gdjs.evtTools.window.getWindowWidth = function() {
if (gdjs.RuntimeGameRenderer && gdjs.RuntimeGameRenderer.getScreenWidth)
return gdjs.RuntimeGameRenderer.getScreenWidth();
return (typeof window !== "undefined") ? window.innerWidth : 800;
};
gdjs.evtTools.window.getWindowHeight = function() {
if (gdjs.RuntimeGameRenderer && gdjs.RuntimeGameRenderer.getScreenHeight)
return gdjs.RuntimeGameRenderer.getScreenHeight();
return (typeof window !== "undefined") ? window.innerHeight : 800;
};