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 
  6  http://www.cocos2d-x.org
  7 
  8  Permission is hereby granted, free of charge, to any person obtaining a copy
  9  of this software and associated documentation files (the "Software"), to deal
 10  in the Software without restriction, including without limitation the rights
 11  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 12  copies of the Software, and to permit persons to whom the Software is
 13  furnished to do so, subject to the following conditions:
 14 
 15  The above copyright notice and this permission notice shall be included in
 16  all copies or substantial portions of the Software.
 17 
 18  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 19  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 20  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 21  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 22  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 23  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 24  THE SOFTWARE.
 25  ****************************************************************************/
 26 
 27 /**
 28  * The current version of Cocos2d-JS being used.<br/>
 29  * Please DO NOT remove this String, it is an important flag for bug tracking.<br/>
 30  * If you post a bug to forum, please attach this flag.
 31  * @type {String}
 32  * @name cc.ENGINE_VERSION
 33  */
 34 window["CocosEngine"] = cc.ENGINE_VERSION = "Cocos2d-JS v3.7";
 35 
 36 /**
 37  * <p>
 38  *   If enabled, the texture coordinates will be calculated by using this formula: <br/>
 39  *      - texCoord.left = (rect.x*2+1) / (texture.wide*2);                  <br/>
 40  *      - texCoord.right = texCoord.left + (rect.width*2-2)/(texture.wide*2); <br/>
 41  *                                                                                 <br/>
 42  *  The same for bottom and top.                                                   <br/>
 43  *                                                                                 <br/>
 44  *  This formula prevents artifacts by using 99% of the texture.                   <br/>
 45  *  The "correct" way to prevent artifacts is by using the spritesheet-artifact-fixer.py or a similar tool.<br/>
 46  *                                                                                  <br/>
 47  *  Affected nodes:                                                                 <br/>
 48  *      - cc.Sprite / cc.SpriteBatchNode and subclasses: cc.LabelBMFont, cc.TMXTiledMap <br/>
 49  *      - cc.LabelAtlas                                                              <br/>
 50  *      - cc.QuadParticleSystem                                                      <br/>
 51  *      - cc.TileMap                                                                 <br/>
 52  *                                                                                  <br/>
 53  *  To enabled set it to 1. Disabled by default.<br/>
 54  *  To modify it, in Web engine please refer to CCConfig.js, in JSB please refer to CCConfig.h
 55  * </p>
 56  * @constant
 57  * @type {Number}
 58  */
 59 cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL = 0;
 60 
 61 /**
 62  * Position of the FPS (Default: 0,0 (bottom-left corner))<br/>
 63  * To modify it, in Web engine please refer to CCConfig.js, in JSB please refer to CCConfig.h
 64  * @constant
 65  * @type {cc.Point}
 66  */
 67 cc.DIRECTOR_STATS_POSITION = cc.p(0, 0);
 68 
 69 /**
 70  * <p>
 71  *   Seconds between FPS updates.<br/>
 72  *   0.5 seconds, means that the FPS number will be updated every 0.5 seconds.<br/>
 73  *   Having a bigger number means a more reliable FPS<br/>
 74  *   <br/>
 75  *   Default value: 0.1f<br/>
 76  *   To modify it, in Web engine please refer to CCConfig.js, in JSB please refer to CCConfig.h
 77  * </p>
 78  * @constant
 79  * @type {Number}
 80  */
 81 cc.DIRECTOR_FPS_INTERVAL = 0.5;
 82 
 83 /**
 84  * <p>
 85  *    If enabled, the cc.Node objects (cc.Sprite, cc.Label,etc) will be able to render in subpixels.<br/>
 86  *    If disabled, integer pixels will be used.<br/>
 87  *    <br/>
 88  *    To enable set it to 1. Enabled by default.<br/>
 89  *    To modify it, in Web engine please refer to CCConfig.js, in JSB please refer to CCConfig.h
 90  * </p>
 91  * @constant
 92  * @type {Number}
 93  */
 94 cc.COCOSNODE_RENDER_SUBPIXEL = 1;
 95 
 96 /**
 97  * <p>
 98  *   If enabled, the cc.Sprite objects rendered with cc.SpriteBatchNode will be able to render in subpixels.<br/>
 99  *   If disabled, integer pixels will be used.<br/>
100  *   <br/>
101  *   To enable set it to 1. Enabled by default.<br/>
102  *   To modify it, in Web engine please refer to CCConfig.js, in JSB please refer to CCConfig.h
103  * </p>
104  * @constant
105  * @type {Number}
106  */
107 cc.SPRITEBATCHNODE_RENDER_SUBPIXEL = 1;
108 
109 /**
110  * <p>
111  *     If most of your images have pre-multiplied alpha, set it to 1 (if you are going to use .PNG/.JPG file images).<br/>
112  *     Only set to 0 if ALL your images by-pass Apple UIImage loading system (eg: if you use libpng or PVR images)<br/>
113  *     <br/>
114  *     To enable set it to a value different than 0. Enabled by default.<br/>
115  *     To modify it, in Web engine please refer to CCConfig.js, in JSB please refer to CCConfig.h
116  * </p>
117  * @constant
118  * @type {Number}
119  */
120 cc.OPTIMIZE_BLEND_FUNC_FOR_PREMULTIPLIED_ALPHA = 1;
121 
122 /**
123  * <p>
124  *   Use GL_TRIANGLE_STRIP instead of GL_TRIANGLES when rendering the texture atlas.<br/>
125  *   It seems it is the recommend way, but it is much slower, so, enable it at your own risk<br/>
126  *   <br/>
127  *   To enable set it to a value different than 0. Disabled by default.<br/>
128  *   To modify it, in Web engine please refer to CCConfig.js, in JSB please refer to CCConfig.h
129  * </p>
130  * @constant
131  * @type {Number}
132  */
133 cc.TEXTURE_ATLAS_USE_TRIANGLE_STRIP = 0;
134 
135 /**
136  * <p>
137  *    By default, cc.TextureAtlas (used by many cocos2d classes) will use VAO (Vertex Array Objects).<br/>
138  *    Apple recommends its usage but they might consume a lot of memory, specially if you use many of them.<br/>
139  *    So for certain cases, where you might need hundreds of VAO objects, it might be a good idea to disable it.<br/>
140  *    <br/>
141  *    To disable it set it to 0. disable by default.(Not Supported on WebGL)<br/>
142  *    To modify it, in Web engine please refer to CCConfig.js, in JSB please refer to CCConfig.h
143  * </p>
144  * @constant
145  * @type {Number}
146  */
147 cc.TEXTURE_ATLAS_USE_VAO = 0;
148 
149 /**
150  * <p>
151  *  If enabled, NPOT textures will be used where available. Only 3rd gen (and newer) devices support NPOT textures.<br/>
152  *  NPOT textures have the following limitations:<br/>
153  *     - They can't have mipmaps<br/>
154  *     - They only accept GL_CLAMP_TO_EDGE in GL_TEXTURE_WRAP_{S,T}<br/>
155  *  <br/>
156  *  To enable set it to a value different than 0. Disabled by default. <br/>
157  *  <br/>
158  *  This value governs only the PNG, GIF, BMP, images.<br/>
159  *  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/>
160  *  To modify it, in Web engine please refer to CCConfig.js, in JSB please refer to CCConfig.h
161  * </p>
162  * @constant
163  * @type {Number}
164  * @deprecated This value will be removed in 1.1 and NPOT textures will be loaded by default if the device supports it.
165  */
166 cc.TEXTURE_NPOT_SUPPORT = 0;
167 
168 /**
169  * <p>
170  *    If enabled, cocos2d supports retina display.<br/>
171  *    For performance reasons, it's recommended disable it in games without retina display support, like iPad only games.<br/>
172  *    <br/>
173  *    To enable set it to 1. Use 0 to disable it. Enabled by default.<br/>
174  *    <br/>
175  *    This value governs only the PNG, GIF, BMP, images.<br/>
176  *    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/>
177  *    To modify it, in Web engine please refer to CCConfig.js, in JSB please refer to CCConfig.h
178  * </p>
179  * @constant
180  * @type {Number}
181  * @deprecated This value will be removed in 1.1 and NPOT textures will be loaded by default if the device supports it.
182  */
183 cc.RETINA_DISPLAY_SUPPORT = 1;
184 
185 /**
186  * <p>
187  *    It's the suffix that will be appended to the files in order to load "retina display" images.<br/>
188  *    <br/>
189  *    On an iPhone4 with Retina Display support enabled, the file @"sprite-hd.png" will be loaded instead of @"sprite.png".<br/>
190  *    If the file doesn't exist it will use the non-retina display image.<br/>
191  *    <br/>
192  *    Platforms: Only used on Retina Display devices like iPhone 4.
193  * </p>
194  * @constant
195  * @type {String}
196  */
197 cc.RETINA_DISPLAY_FILENAME_SUFFIX = "-hd";
198 
199 /**
200  * <p>
201  *     If enabled, it will use LA88 (Luminance Alpha 16-bit textures) for CCLabelTTF objects. <br/>
202  *     If it is disabled, it will use A8 (Alpha 8-bit textures).                              <br/>
203  *     LA88 textures are 6% faster than A8 textures, but they will consume 2x memory.         <br/>
204  *                                                                                            <br/>
205  *     This feature is enabled by default.
206  * </p>
207  * @constant
208  * @type {Number}
209  */
210 cc.USE_LA88_LABELS = 1;
211 
212 /**
213  * <p>
214  *   If enabled, all subclasses of cc.Sprite will draw a bounding box<br/>
215  *   Useful for debugging purposes only. It is recommend to leave it disabled.<br/>
216  *   <br/>
217  *   To enable set it to a value different than 0. Disabled by default:<br/>
218  *      0 -- disabled<br/>
219  *      1 -- draw bounding box<br/>
220  *      2 -- draw texture box
221  * </p>
222  * @constant
223  * @type {Number}
224  */
225 cc.SPRITE_DEBUG_DRAW = 0;
226 
227 /**
228  * <p>
229  *    If enabled, all subclasses of cc.Sprite that are rendered using an cc.SpriteBatchNode draw a bounding box.<br/>
230  *    Useful for debugging purposes only. It is recommend to leave it disabled.<br/>
231  *    <br/>
232  *    To enable set it to a value different than 0. Disabled by default.
233  * </p>
234  * @constant
235  * @type {Number}
236  */
237 cc.SPRITEBATCHNODE_DEBUG_DRAW = 0;
238 
239 /**
240  * <p>
241  *   If enabled, all subclasses of cc.LabelBMFont will draw a bounding box <br/>
242  *   Useful for debugging purposes only. It is recommend to leave it disabled.<br/>
243  *   <br/>
244  *   To enable set it to a value different than 0. Disabled by default.<br/>
245  * </p>
246  * @constant
247  * @type {Number}
248  */
249 cc.LABELBMFONT_DEBUG_DRAW = 0;
250 
251 /**
252  * <p>
253  *    If enabled, all subclasses of cc.LabelAtlas will draw a bounding box<br/>
254  *    Useful for debugging purposes only. It is recommend to leave it disabled.<br/>
255  *    <br/>
256  *    To enable set it to a value different than 0. Disabled by default.
257  * </p>
258  * @constant
259  * @type {Number}
260  */
261 cc.LABELATLAS_DEBUG_DRAW = 0;
262 
263 /**
264  * Whether or not support retina display
265  * @constant
266  * @type {Number}
267  */
268 cc.IS_RETINA_DISPLAY_SUPPORTED = 1;
269 
270 /**
271  * Default engine
272  * @constant
273  * @type {String}
274  */
275 cc.DEFAULT_ENGINE = cc.ENGINE_VERSION + "-canvas";
276 
277 /**
278  * <p>
279  *    If enabled, actions that alter the position property (eg: CCMoveBy, CCJumpBy, CCBezierBy, etc..) will be stacked.                  <br/>
280  *    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/>
281  *    If disabled, only the last run action will take effect.
282  * </p>
283  * @constant
284  * @type {number}
285  */
286 cc.ENABLE_STACKABLE_ACTIONS = 1;
287 
288 /**
289  * <p>
290  *      If enabled, cocos2d will maintain an OpenGL state cache internally to avoid unnecessary switches.                                     <br/>
291  *      In order to use them, you have to use the following functions, instead of the the GL ones:                                             <br/>
292  *          - ccGLUseProgram() instead of glUseProgram()                                                                                      <br/>
293  *          - ccGLDeleteProgram() instead of glDeleteProgram()                                                                                <br/>
294  *          - ccGLBlendFunc() instead of glBlendFunc()                                                                                        <br/>
295  *                                                                                                                                            <br/>
296  *      If this functionality is disabled, then ccGLUseProgram(), ccGLDeleteProgram(), ccGLBlendFunc() will call the GL ones, without using the cache.              <br/>
297  *      It is recommend to enable whenever possible to improve speed.                                                                        <br/>
298  *      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.
299  * </p>
300  * @constant
301  * @type {Number}
302  */
303 cc.ENABLE_GL_STATE_CACHE = 1;