CCConfig.js 12 KB

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