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.1.0";
 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 enabled, cc.Node will transform the nodes using a cached Affine matrix.<br/>
109  *   If disabled, the node will be transformed using glTranslate,glRotate,glScale.<br/>
110  *   Using the affine matrix only requires 2 GL calls.<br/>
111  *   Using the translate/rotate/scale requires 5 GL calls.<br/>
112  *   But computing the Affine matrix is relative expensive.<br/>
113  *   But according to performance tests, Affine matrix performs better.<br/>
114  *   This parameter doesn't affect cc.SpriteBatchNode nodes.<br/>
115  *   <br/>
116  *   To enable set it to a value different than 0. Enabled by default.
117  * </p>
118  * @constant
119  * @type Number
120  */
121 cc.NODE_TRANSFORM_USING_AFFINE_MATRIX = 1;
122 
123 /**
124  * <p>
125  *     If most of your imamges have pre-multiplied alpha, set it to 1 (if you are going to use .PNG/.JPG file images).<br/>
126  *     Only set to 0 if ALL your images by-pass Apple UIImage loading system (eg: if you use libpng or PVR images)<br/>
127  *     <br/>
128  *     To enable set it to a value different than 0. Enabled by default.
129  * </p>
130  * @constant
131  * @type Number
132  */
133 cc.OPTIMIZE_BLEND_FUNC_FOR_PREMULTIPLIED_ALPHA = 1;
134 
135 /**
136  * <p>
137  *   Use GL_TRIANGLE_STRIP instead of GL_TRIANGLES when rendering the texture atlas.<br/>
138  *   It seems it is the recommend way, but it is much slower, so, enable it at your own risk<br/>
139  *   <br/>
140  *   To enable set it to a value different than 0. Disabled by default.
141  * </p>
142  * @constant
143  * @type Number
144  */
145 cc.TEXTURE_ATLAS_USE_TRIANGLE_STRIP = 0;
146 
147 /**
148  * <p>
149  *    By default, cc.TextureAtlas (used by many cocos2d classes) will use VAO (Vertex Array Objects).<br/>
150  *    Apple recommends its usage but they might consume a lot of memory, specially if you use many of them.<br/>
151  *    So for certain cases, where you might need hundreds of VAO objects, it might be a good idea to disable it.<br/>
152  *    <br/>
153  *    To disable it set it to 0. Enabled by default.<br/>
154  * </p>
155  * @constant
156  * @type Number
157  */
158 cc.TEXTURE_ATLAS_USE_VAO = 1;
159 
160 /**
161  * <p>
162  *  If enabled, NPOT textures will be used where available. Only 3rd gen (and newer) devices support NPOT textures.<br/>
163  *  NPOT textures have the following limitations:<br/>
164  *     - They can't have mipmaps<br/>
165  *     - They only accept GL_CLAMP_TO_EDGE in GL_TEXTURE_WRAP_{S,T}<br/>
166  *  <br/>
167  *  To enable set it to a value different than 0. Disabled by default. <br/>
168  *  <br/>
169  *  This value governs only the PNG, GIF, BMP, images.<br/>
170  *  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.
171  * </p>
172  * @constant
173  * @type Number
174  * @deprecated This value will be removed in 1.1 and NPOT textures will be loaded by default if the device supports it.
175  */
176 cc.TEXTURE_NPOT_SUPPORT = 0;
177 
178 /**
179  * <p>
180  *    If enabled, cocos2d supports retina display.<br/>
181  *    For performance reasons, it's recommended disable it in games without retina display support, like iPad only games.<br/>
182  *    <br/>
183  *    To enable set it to 1. Use 0 to disable it. Enabled by default.<br/>
184  *    <br/>
185  *    This value governs only the PNG, GIF, BMP, images.<br/>
186  *    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.
187  * </p>
188  * @constant
189  * @type Number
190  * @deprecated This value will be removed in 1.1 and NPOT textures will be loaded by default if the device supports it.
191  */
192 cc.RETINA_DISPLAY_SUPPORT = 1;
193 
194 /**
195  * <p>
196  *    It's the suffix that will be appended to the files in order to load "retina display" images.<br/>
197  *    <br/>
198  *    On an iPhone4 with Retina Display support enabled, the file @"sprite-hd.png" will be loaded instead of @"sprite.png".<br/>
199  *    If the file doesn't exist it will use the non-retina display image.<br/>
200  *    <br/>
201  *    Platforms: Only used on Retina Display devices like iPhone 4.
202  * </p>
203  * @constant
204  * @type String
205  */
206 cc.RETINA_DISPLAY_FILENAME_SUFFIX = "-hd";
207 
208 /**
209  * <p>
210  *   If enabled, all subclasses of cc.Sprite will draw a bounding box<br/>
211  *   Useful for debugging purposes only. It is recommened to leave it disabled.<br/>
212  *   <br/>
213  *   To enable set it to a value different than 0. Disabled by default:<br/>
214  *      0 -- disabled<br/>
215  *      1 -- draw bounding box<br/>
216  *      2 -- draw texture box
217  * </p>
218  * @constant
219  * @type Number
220  */
221 cc.SPRITE_DEBUG_DRAW = 0;
222 
223 /**
224  * <p>
225  *    If enabled, all subclasses of cc.Sprite that are rendered using an cc.SpriteBatchNode draw a bounding box.<br/>
226  *    Useful for debugging purposes only. It is recommened to leave it disabled.<br/>
227  *    <br/>
228  *    To enable set it to a value different than 0. Disabled by default.
229  * </p>
230  * @constant
231  * @type Number
232  */
233 cc.SPRITEBATCHNODE_DEBUG_DRAW = 0;
234 
235 /**
236  * <p>
237  *   If enabled, all subclasses of cc.LabelBMFont will draw a bounding box <br/>
238  *   Useful for debugging purposes only. It is recommened to leave it disabled.<br/>
239  *   <br/>
240  *   To enable set it to a value different than 0. Disabled by default.<br/>
241  * </p>
242  * @constant
243  * @type Number
244  */
245 cc.LABELBMFONT_DEBUG_DRAW = 0;
246 
247 /**
248  * <p>
249  *    If enabled, all subclasses of cc.LabeltAtlas will draw a bounding box<br/>
250  *    Useful for debugging purposes only. It is recommened to leave it disabled.<br/>
251  *    <br/>
252  *    To enable set it to a value different than 0. Disabled by default.
253  * </p>
254  * @constant
255  * @type Number
256  */
257 cc.LABELATLAS_DEBUG_DRAW = 0;
258 
259 /**
260  * whether or not support retina display
261  * @constant
262  * @type Number
263  */
264 cc.IS_RETINA_DISPLAY_SUPPORTED = 1;
265 
266 /**
267  * default engine
268  * @constant
269  * @type String
270  */
271 cc.DEFAULT_ENGINE = cc.ENGINE_VERSION + "-canvas";
272 
273 
274 /**
275   Runtime information.
276   @deprecated Use "sys" instead.
277 */
278 cc.config = {
279     'platform' : sys.platform,
280 };
281 
282 /**
283  * dump config info, but only in debug mode
284  */
285 cc.dumpConfig = function()
286 {
287     for( i in sys )
288         cc.log( i + " = " + sys[i] );
289 };
290 
291