main.js 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /****************************************************************************
  2. Copyright (c) 2010-2012 cocos2d-x.org
  3. Copyright (c) 2008-2010 Ricardo Quesada
  4. Copyright (c) 2011 Zynga Inc.
  5. http://www.cocos2d-x.org
  6. Permission is hereby granted, free of charge, to any person obtaining a copy
  7. of this software and associated documentation files (the "Software"), to deal
  8. in the Software without restriction, including without limitation the rights
  9. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10. copies of the Software, and to permit persons to whom the Software is
  11. furnished to do so, subject to the following conditions:
  12. The above copyright notice and this permission notice shall be included in
  13. all copies or substantial portions of the Software.
  14. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. THE SOFTWARE.
  21. ****************************************************************************/
  22. var cocos2dApp = cc.Application.extend({
  23. config:document['ccConfig'],
  24. ctor:function (scene) {
  25. this._super();
  26. this.startScene = scene;
  27. cc.COCOS2D_DEBUG = this.config['COCOS2D_DEBUG'];
  28. cc.initDebugSetting();
  29. cc.setup(this.config['tag']);
  30. cc.AppController.shareAppController().didFinishLaunchingWithOptions();
  31. },
  32. applicationDidFinishLaunching:function () {
  33. if(cc.RenderDoesnotSupport()){
  34. //show Information to user
  35. alert("Browser doesn't support WebGL");
  36. return false;
  37. }
  38. cc.EGLView.getInstance().resizeWithBrowserSize(true);
  39. cc.EGLView.getInstance().setDesignResolutionSize(640, 960, cc.RESOLUTION_POLICY.SHOW_ALL);
  40. // initialize director
  41. var director = cc.Director.getInstance();
  42. // turn on display FPS
  43. director.setDisplayStats(this.config['showFPS']);
  44. // set FPS. the default value is 1.0/60 if you don't call this
  45. director.setAnimationInterval(1.0 / this.config['frameRate']);
  46. //load resources
  47. cc.LoaderScene.preload(g_resources, function () {
  48. director.replaceScene(new this.startScene());
  49. }, this);
  50. return true;
  51. }
  52. });
  53. var myApp = new cocos2dApp(GameLoginScene);