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