CCConfig.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. /****************************************************************************
  2. Copyright (c) 2008-2010 Ricardo Quesada
  3. Copyright (c) 2011-2012 cocos2d-x.org
  4. Copyright (c) 2013-2014 Chukong Technologies 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. /**
  23. * The current version of Cocos2d-JS being used.<br/>
  24. * Please DO NOT remove this String, it is an important flag for bug tracking.<br/>
  25. * If you post a bug to forum, please attach this flag.
  26. * @type {String}
  27. * @name cc.ENGINE_VERSION
  28. */
  29. window["CocosEngine"] = cc.ENGINE_VERSION = "Cocos2d-JS v3.0 RC3";
  30. /**
  31. * <p>
  32. * If enabled, the texture coordinates will be calculated by using this formula: <br/>
  33. * - texCoord.left = (rect.x*2+1) / (texture.wide*2); <br/>
  34. * - texCoord.right = texCoord.left + (rect.width*2-2)/(texture.wide*2); <br/>
  35. * <br/>
  36. * The same for bottom and top. <br/>
  37. * <br/>
  38. * This formula prevents artifacts by using 99% of the texture. <br/>
  39. * The "correct" way to prevent artifacts is by using the spritesheet-artifact-fixer.py or a similar tool.<br/>
  40. * <br/>
  41. * Affected nodes: <br/>
  42. * - cc.Sprite / cc.SpriteBatchNode and subclasses: cc.LabelBMFont, cc.TMXTiledMap <br/>
  43. * - cc.LabelAtlas <br/>
  44. * - cc.QuadParticleSystem <br/>
  45. * - cc.TileMap <br/>
  46. * <br/>
  47. * To enabled set it to 1. Disabled by default.<br/>
  48. * To modify it, in Web engine please refer to CCConfig.js, in JSB please refer to CCConfig.h
  49. * </p>
  50. * @constant
  51. * @type {Number}
  52. */
  53. cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL = 0;
  54. /**
  55. * Position of the FPS (Default: 0,0 (bottom-left corner))<br/>
  56. * To modify it, in Web engine please refer to CCConfig.js, in JSB please refer to CCConfig.h
  57. * @constant
  58. * @type {cc.Point}
  59. */
  60. cc.DIRECTOR_STATS_POSITION = cc.p(0, 0);
  61. /**
  62. * <p>
  63. * Seconds between FPS updates.<br/>
  64. * 0.5 seconds, means that the FPS number will be updated every 0.5 seconds.<br/>
  65. * Having a bigger number means a more reliable FPS<br/>
  66. * <br/>
  67. * Default value: 0.1f<br/>
  68. * To modify it, in Web engine please refer to CCConfig.js, in JSB please refer to CCConfig.h
  69. * </p>
  70. * @constant
  71. * @type {Number}
  72. */
  73. cc.DIRECTOR_FPS_INTERVAL = 0.5;
  74. /**
  75. * <p>
  76. * If enabled, the cc.Node objects (cc.Sprite, cc.Label,etc) will be able to render in subpixels.<br/>
  77. * If disabled, integer pixels will be used.<br/>
  78. * <br/>
  79. * To enable set it to 1. Enabled by default.<br/>
  80. * To modify it, in Web engine please refer to CCConfig.js, in JSB please refer to CCConfig.h
  81. * </p>
  82. * @constant
  83. * @type {Number}
  84. */
  85. cc.COCOSNODE_RENDER_SUBPIXEL = 1;
  86. /**
  87. * <p>
  88. * If enabled, the cc.Sprite objects rendered with cc.SpriteBatchNode will be able to render in subpixels.<br/>
  89. * If disabled, integer pixels will be used.<br/>
  90. * <br/>
  91. * To enable set it to 1. Enabled by default.<br/>
  92. * To modify it, in Web engine please refer to CCConfig.js, in JSB please refer to CCConfig.h
  93. * </p>
  94. * @constant
  95. * @type {Number}
  96. */
  97. cc.SPRITEBATCHNODE_RENDER_SUBPIXEL = 1;
  98. /**
  99. * <p>
  100. * If most of your images have pre-multiplied alpha, set it to 1 (if you are going to use .PNG/.JPG file images).<br/>
  101. * Only set to 0 if ALL your images by-pass Apple UIImage loading system (eg: if you use libpng or PVR images)<br/>
  102. * <br/>
  103. * To enable set it to a value different than 0. Enabled by default.<br/>
  104. * To modify it, in Web engine please refer to CCConfig.js, in JSB please refer to CCConfig.h
  105. * </p>
  106. * @constant
  107. * @type {Number}
  108. */
  109. cc.OPTIMIZE_BLEND_FUNC_FOR_PREMULTIPLIED_ALPHA = 0;
  110. /**
  111. * <p>
  112. * Use GL_TRIANGLE_STRIP instead of GL_TRIANGLES when rendering the texture atlas.<br/>
  113. * It seems it is the recommend way, but it is much slower, so, enable it at your own risk<br/>
  114. * <br/>
  115. * To enable set it to a value different than 0. Disabled by default.<br/>
  116. * To modify it, in Web engine please refer to CCConfig.js, in JSB please refer to CCConfig.h
  117. * </p>
  118. * @constant
  119. * @type {Number}
  120. */
  121. cc.TEXTURE_ATLAS_USE_TRIANGLE_STRIP = 0;
  122. /**
  123. * <p>
  124. * By default, cc.TextureAtlas (used by many cocos2d classes) will use VAO (Vertex Array Objects).<br/>
  125. * Apple recommends its usage but they might consume a lot of memory, specially if you use many of them.<br/>
  126. * So for certain cases, where you might need hundreds of VAO objects, it might be a good idea to disable it.<br/>
  127. * <br/>
  128. * To disable it set it to 0. disable by default.(Not Supported on WebGL)<br/>
  129. * To modify it, in Web engine please refer to CCConfig.js, in JSB please refer to CCConfig.h
  130. * </p>
  131. * @constant
  132. * @type {Number}
  133. */
  134. cc.TEXTURE_ATLAS_USE_VAO = 0;
  135. /**
  136. * <p>
  137. * If enabled, NPOT textures will be used where available. Only 3rd gen (and newer) devices support NPOT textures.<br/>
  138. * NPOT textures have the following limitations:<br/>
  139. * - They can't have mipmaps<br/>
  140. * - They only accept GL_CLAMP_TO_EDGE in GL_TEXTURE_WRAP_{S,T}<br/>
  141. * <br/>
  142. * To enable set it to a value different than 0. Disabled by default. <br/>
  143. * <br/>
  144. * This value governs only the PNG, GIF, BMP, images.<br/>
  145. * This value DOES NOT govern the PVR (PVR.GZ, PVR.CCZ) files. If NPOT PVR is loaded, then it will create an NPOT texture ignoring this value.<br/>
  146. * To modify it, in Web engine please refer to CCConfig.js, in JSB please refer to CCConfig.h
  147. * </p>
  148. * @constant
  149. * @type {Number}
  150. * @deprecated This value will be removed in 1.1 and NPOT textures will be loaded by default if the device supports it.
  151. */
  152. cc.TEXTURE_NPOT_SUPPORT = 0;
  153. /**
  154. * <p>
  155. * If enabled, cocos2d supports retina display.<br/>
  156. * For performance reasons, it's recommended disable it in games without retina display support, like iPad only games.<br/>
  157. * <br/>
  158. * To enable set it to 1. Use 0 to disable it. Enabled by default.<br/>
  159. * <br/>
  160. * This value governs only the PNG, GIF, BMP, images.<br/>
  161. * This value DOES NOT govern the PVR (PVR.GZ, PVR.CCZ) files. If NPOT PVR is loaded, then it will create an NPOT texture ignoring this value.<br/>
  162. * To modify it, in Web engine please refer to CCConfig.js, in JSB please refer to CCConfig.h
  163. * </p>
  164. * @constant
  165. * @type {Number}
  166. * @deprecated This value will be removed in 1.1 and NPOT textures will be loaded by default if the device supports it.
  167. */
  168. cc.RETINA_DISPLAY_SUPPORT = 1;
  169. /**
  170. * <p>
  171. * It's the suffix that will be appended to the files in order to load "retina display" images.<br/>
  172. * <br/>
  173. * On an iPhone4 with Retina Display support enabled, the file @"sprite-hd.png" will be loaded instead of @"sprite.png".<br/>
  174. * If the file doesn't exist it will use the non-retina display image.<br/>
  175. * <br/>
  176. * Platforms: Only used on Retina Display devices like iPhone 4.
  177. * </p>
  178. * @constant
  179. * @type {String}
  180. */
  181. cc.RETINA_DISPLAY_FILENAME_SUFFIX = "-hd";
  182. /**
  183. * <p>
  184. * If enabled, it will use LA88 (Luminance Alpha 16-bit textures) for CCLabelTTF objects. <br/>
  185. * If it is disabled, it will use A8 (Alpha 8-bit textures). <br/>
  186. * LA88 textures are 6% faster than A8 textures, but they will consume 2x memory. <br/>
  187. * <br/>
  188. * This feature is enabled by default.
  189. * </p>
  190. * @constant
  191. * @type {Number}
  192. */
  193. cc.USE_LA88_LABELS = 1;
  194. /**
  195. * <p>
  196. * If enabled, all subclasses of cc.Sprite will draw a bounding box<br/>
  197. * Useful for debugging purposes only. It is recommend to leave it disabled.<br/>
  198. * <br/>
  199. * To enable set it to a value different than 0. Disabled by default:<br/>
  200. * 0 -- disabled<br/>
  201. * 1 -- draw bounding box<br/>
  202. * 2 -- draw texture box
  203. * </p>
  204. * @constant
  205. * @type {Number}
  206. */
  207. cc.SPRITE_DEBUG_DRAW = 0;
  208. /**
  209. * <p>
  210. * If enabled, all subclasses of cc.Sprite that are rendered using an cc.SpriteBatchNode draw a bounding box.<br/>
  211. * Useful for debugging purposes only. It is recommend to leave it disabled.<br/>
  212. * <br/>
  213. * To enable set it to a value different than 0. Disabled by default.
  214. * </p>
  215. * @constant
  216. * @type {Number}
  217. */
  218. cc.SPRITEBATCHNODE_DEBUG_DRAW = 0;
  219. /**
  220. * <p>
  221. * If enabled, all subclasses of cc.LabelBMFont will draw a bounding box <br/>
  222. * Useful for debugging purposes only. It is recommend to leave it disabled.<br/>
  223. * <br/>
  224. * To enable set it to a value different than 0. Disabled by default.<br/>
  225. * </p>
  226. * @constant
  227. * @type {Number}
  228. */
  229. cc.LABELBMFONT_DEBUG_DRAW = 0;
  230. /**
  231. * <p>
  232. * If enabled, all subclasses of cc.LabelAtlas will draw a bounding box<br/>
  233. * Useful for debugging purposes only. It is recommend to leave it disabled.<br/>
  234. * <br/>
  235. * To enable set it to a value different than 0. Disabled by default.
  236. * </p>
  237. * @constant
  238. * @type {Number}
  239. */
  240. cc.LABELATLAS_DEBUG_DRAW = 0;
  241. /**
  242. * Whether or not support retina display
  243. * @constant
  244. * @type {Number}
  245. */
  246. cc.IS_RETINA_DISPLAY_SUPPORTED = 1;
  247. /**
  248. * Default engine
  249. * @constant
  250. * @type {String}
  251. */
  252. cc.DEFAULT_ENGINE = cc.ENGINE_VERSION + "-canvas";
  253. /**
  254. * <p>
  255. * If enabled, actions that alter the position property (eg: CCMoveBy, CCJumpBy, CCBezierBy, etc..) will be stacked. <br/>
  256. * If you run 2 or more 'position' actions at the same time on a node, then end position will be the sum of all the positions. <br/>
  257. * If disabled, only the last run action will take effect.
  258. * </p>
  259. * @constant
  260. * @type {number}
  261. */
  262. cc.ENABLE_STACKABLE_ACTIONS = 1;
  263. /**
  264. * <p>
  265. * If enabled, cocos2d will maintain an OpenGL state cache internally to avoid unnecessary switches. <br/>
  266. * In order to use them, you have to use the following functions, instead of the the GL ones: <br/>
  267. * - ccGLUseProgram() instead of glUseProgram() <br/>
  268. * - ccGLDeleteProgram() instead of glDeleteProgram() <br/>
  269. * - ccGLBlendFunc() instead of glBlendFunc() <br/>
  270. * <br/>
  271. * If this functionality is disabled, then ccGLUseProgram(), ccGLDeleteProgram(), ccGLBlendFunc() will call the GL ones, without using the cache. <br/>
  272. * It is recommend to enable whenever possible to improve speed. <br/>
  273. * If you are migrating your code from GL ES 1.1, then keep it disabled. Once all your code works as expected, turn it on.
  274. * </p>
  275. * @constant
  276. * @type {Number}
  277. */
  278. cc.ENABLE_GL_STATE_CACHE = 1;