How to use propertyName method in wpt

Best JavaScript code snippet using wpt

CCSpriteLoader.js

Source:CCSpriteLoader.js Github

copy

Full Screen

1/****************************************************************************2 Copyright (c) 2008-2010 Ricardo Quesada3 Copyright (c) 2011-2012 cocos2d-x.org4 Copyright (c) 2013-2014 Chukong Technologies Inc.5 http://www.cocos2d-x.org6 Permission is hereby granted, free of charge, to any person obtaining a copy7 of this software and associated documentation files (the "Software"), to deal8 in the Software without restriction, including without limitation the rights9 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell10 copies of the Software, and to permit persons to whom the Software is11 furnished to do so, subject to the following conditions:12 The above copyright notice and this permission notice shall be included in13 all copies or substantial portions of the Software.14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE17 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER18 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 IN20 THE SOFTWARE.21 ****************************************************************************/22var PROPERTY_FLIP = "flip";23var PROPERTY_DISPLAYFRAME = "displayFrame";24var PROPERTY_COLOR = "color";25var PROPERTY_OPACITY = "opacity";26var PROPERTY_BLENDFUNC = "blendFunc";27cc.SpriteLoader = cc.NodeLoader.extend({28 _createCCNode:function (parent, ccbReader) {29 return new cc.Sprite();30 },31 onHandlePropTypeColor3:function (node, parent, propertyName, ccColor3B, ccbReader) {32 if (propertyName === PROPERTY_COLOR) {33 if(ccColor3B.r !== 255 || ccColor3B.g !== 255 || ccColor3B.b !== 255){34 node.setColor(ccColor3B);35 }36 } else {37 cc.NodeLoader.prototype.onHandlePropTypeColor3.call(this, node, parent, propertyName, ccColor3B, ccbReader);38 }39 },40 onHandlePropTypeByte:function (node, parent, propertyName, byteValue, ccbReader) {41 if (propertyName === PROPERTY_OPACITY) {42 node.setOpacity(byteValue);43 } else {44 cc.NodeLoader.prototype.onHandlePropTypeByte.call(this, node, parent, propertyName, byteValue, ccbReader);45 }46 },47 onHandlePropTypeBlendFunc:function (node, parent, propertyName, ccbBlendFunc, ccbReader) {48 if (propertyName === PROPERTY_BLENDFUNC) {49 node.setBlendFunc(ccbBlendFunc);50 } else {51 cc.NodeLoader.prototype.onHandlePropTypeBlendFunc.call(this, node, parent, propertyName, ccbBlendFunc, ccbReader);52 }53 },54 onHandlePropTypeSpriteFrame:function (node, parent, propertyName, ccSpriteFrame, ccbReader) {55 if (propertyName === PROPERTY_DISPLAYFRAME) {56 if(ccSpriteFrame)57 node.setSpriteFrame(ccSpriteFrame);58 else59 cc.log("ERROR: SpriteFrame is null");60 } else {61 cc.NodeLoader.prototype.onHandlePropTypeSpriteFrame.call(this, node, parent, propertyName, ccSpriteFrame, ccbReader);62 }63 },64 onHandlePropTypeFlip:function (node, parent, propertyName, flip, ccbReader) {65 if (propertyName === PROPERTY_FLIP) {66 node.setFlippedX(flip[0]);67 node.setFlippedY(flip[1]);68 } else {69 cc.NodeLoader.prototype.onHandlePropTypeFlip.call(this, node, parent, propertyName, flip, ccbReader);70 }71 }72});73cc.SpriteLoader.loader = function () {74 return new cc.SpriteLoader();75};76var PROPERTY_TOUCH_ENABLED = "touchEnabled";77var PROPERTY_IS_TOUCH_ENABLED = "isTouchEnabled";78var PROPERTY_ACCELEROMETER_ENABLED = "accelerometerEnabled";79var PROPERTY_IS_ACCELEROMETER_ENABLED = "isAccelerometerEnabled";80var PROPERTY_IS_MOUSE_ENABLED = "isMouseEnabled";81var PROPERTY_MOUSE_ENABLED = "mouseEnabled";82var PROPERTY_KEYBOARD_ENABLED = "keyboardEnabled";83var PROPERTY_IS_KEYBOARD_ENABLED = "isKeyboardEnabled";84cc.LayerLoader = cc.NodeLoader.extend({85 _createCCNode:function (parent, ccbReader) {86 var layer = new cc.Layer();87 layer.setContentSize(0,0);88 return layer;89 },90 onHandlePropTypeCheck:function (node, parent, propertyName, check, ccbReader) {91 if (propertyName === PROPERTY_TOUCH_ENABLED || propertyName === PROPERTY_IS_TOUCH_ENABLED) {92 //node.setTouchEnabled(check);93 } else if (propertyName === PROPERTY_ACCELEROMETER_ENABLED || propertyName === PROPERTY_IS_ACCELEROMETER_ENABLED) {94 //node.setAccelerometerEnabled(check);95 } else if (propertyName === PROPERTY_MOUSE_ENABLED || propertyName === PROPERTY_IS_MOUSE_ENABLED ) {96 //node.setMouseEnabled(check);97 } else if (propertyName === PROPERTY_KEYBOARD_ENABLED || propertyName === PROPERTY_IS_KEYBOARD_ENABLED) {98 // TODO XXX99 if(node.setKeyboardEnabled && !cc.sys.isNative) {100 node.setKeyboardEnabled(check);101 } else {102 cc.log("The property '" + PROPERTY_IS_KEYBOARD_ENABLED + "' is not supported!");103 // This comes closest: ((CCLayer *)pNode).setKeypadEnabled(pCheck);104 }105 } else {106 cc.NodeLoader.prototype.onHandlePropTypeCheck.call(this, node, parent, propertyName, check, ccbReader);107 }108 }109});110cc.LayerLoader.loader = function () {111 return new cc.LayerLoader();112};113cc.LayerColorLoader = cc.LayerLoader.extend({114 _createCCNode:function (parent, ccbReader) {115 return new cc.LayerColor();116 },117 onHandlePropTypeColor3:function (node, parent, propertyName, ccColor3B, ccbReader) {118 if (propertyName === PROPERTY_COLOR) {119 node.setColor(ccColor3B);120 } else {121 cc.LayerLoader.prototype.onHandlePropTypeColor3.call(this, node, parent, propertyName, ccColor3B, ccbReader);122 }123 },124 onHandlePropTypeByte:function (node, parent, propertyName, byteValue, ccbReader) {125 if (propertyName === PROPERTY_OPACITY) {126 node.setOpacity(byteValue);127 } else {128 cc.LayerLoader.prototype.onHandlePropTypeByte.call(this, node, parent, propertyName, byteValue, ccbReader);129 }130 },131 onHandlePropTypeBlendFunc:function (node, parent, propertyName, ccBlendFunc, ccbReader) {132 if (propertyName === PROPERTY_BLENDFUNC) {133 node.setBlendFunc(ccBlendFunc);134 } else {135 cc.LayerLoader.prototype.onHandlePropTypeBlendFunc.call(this, node, parent, propertyName, ccBlendFunc, ccbReader);136 }137 }138});139cc.LayerColorLoader.loader = function () {140 return new cc.LayerColorLoader();141};142var PROPERTY_STARTCOLOR = "startColor";143var PROPERTY_ENDCOLOR = "endColor";144var PROPERTY_STARTOPACITY = "startOpacity";145var PROPERTY_ENDOPACITY = "endOpacity";146var PROPERTY_VECTOR = "vector";147cc.LayerGradientLoader = cc.LayerLoader.extend({148 _createCCNode:function (parent, ccbReader) {149 return new cc.LayerGradient();150 },151 onHandlePropTypeColor3:function (node, parent, propertyName, ccColor3B, ccbReader) {152 if (propertyName === PROPERTY_STARTCOLOR) {153 node.setStartColor(ccColor3B);154 } else if (propertyName == PROPERTY_ENDCOLOR) {155 node.setEndColor(ccColor3B);156 } else {157 cc.LayerLoader.prototype.onHandlePropTypeColor3.call(this, node, parent, propertyName, ccColor3B, ccbReader);158 }159 },160 onHandlePropTypeByte:function (node, parent, propertyName, byteValue, ccbReader) {161 if (propertyName === PROPERTY_STARTOPACITY) {162 node.setStartOpacity(byteValue);163 } else if (propertyName === PROPERTY_ENDOPACITY) {164 node.setEndOpacity(byteValue);165 } else {166 cc.LayerLoader.prototype.onHandlePropTypeByte.call(this, node, parent, propertyName, byteValue, ccbReader);167 }168 },169 onHandlePropTypePoint:function (node, parent, propertyName, point, ccbReader) {170 if (propertyName === PROPERTY_VECTOR) {171 node.setVector(point);172 // TODO Not passed along the ccbi file.173 // node.setCompressedInterpolation(true);174 } else {175 cc.LayerLoader.prototype.onHandlePropTypePoint.call(this, node, parent, propertyName, point, ccbReader);176 }177 },178 onHandlePropTypeBlendFunc:function (node, parent, propertyName, ccBlendFunc, ccbReader) {179 if (propertyName === PROPERTY_BLENDFUNC) {180 node.setBlendFunc(ccBlendFunc);181 } else {182 cc.LayerLoader.prototype.onHandlePropTypeBlendFunc.call(this, node, parent, propertyName, ccBlendFunc, ccbReader);183 }184 }185});186cc.LayerGradientLoader.loader = function () {187 return new cc.LayerGradientLoader();188};189cc.MenuLoader = cc.LayerLoader.extend({190 _createCCNode:function (parent, ccbReader) {191 var menu = new cc.Menu();192 menu.setContentSize(0,0);193 return menu;194 }195});196cc.MenuLoader.loader = function () {197 return new cc.MenuLoader();198};199var PROPERTY_BLOCK = "block";200var PROPERTY_ISENABLED = "isEnabled";201cc.MenuItemLoader = cc.NodeLoader.extend({202 _createCCNode:function (parent, ccbReader) {203 return null;204 },205 onHandlePropTypeBlock:function (node, parent, propertyName, blockData, ccbReader) {206 if (propertyName === PROPERTY_BLOCK) {207 if (null != blockData) { // Add this condition to allow CCMenuItemImage without target/selector predefined208 node.setTarget(blockData.selMenuHander, blockData.target);209 }210 } else {211 cc.NodeLoader.prototype.onHandlePropTypeBlock.call(this, node, parent, propertyName, blockData, ccbReader);212 }213 },214 onHandlePropTypeCheck:function (node, parent, propertyName, check, ccbReader) {215 if (propertyName === PROPERTY_ISENABLED) {216 node.setEnabled(check);217 } else {218 cc.NodeLoader.prototype.onHandlePropTypeCheck.call(this, node, parent, propertyName, check, ccbReader);219 }220 }221});222var PROPERTY_NORMALDISPLAYFRAME = "normalSpriteFrame";223var PROPERTY_SELECTEDDISPLAYFRAME = "selectedSpriteFrame";224var PROPERTY_DISABLEDDISPLAYFRAME = "disabledSpriteFrame";225cc.MenuItemImageLoader = cc.MenuItemLoader.extend({226 _createCCNode:function (parent, ccbReader) {227 return new cc.MenuItemImage();228 },229 onHandlePropTypeSpriteFrame:function (node, parent, propertyName, spriteFrame, ccbReader) {230 if (propertyName === PROPERTY_NORMALDISPLAYFRAME) {231 if (spriteFrame != null) {232 node.setNormalSpriteFrame(spriteFrame);233 }234 } else if (propertyName === PROPERTY_SELECTEDDISPLAYFRAME) {235 if (spriteFrame != null) {236 node.setSelectedSpriteFrame(spriteFrame);237 }238 } else if (propertyName === PROPERTY_DISABLEDDISPLAYFRAME) {239 if (spriteFrame != null) {240 node.setDisabledSpriteFrame(spriteFrame);241 }242 } else {243 cc.MenuItemLoader.prototype.onHandlePropTypeSpriteFrame.call(this, node, parent, propertyName, spriteFrame, ccbReader);244 }245 }246});247cc.MenuItemImageLoader.loader = function () {248 return new cc.MenuItemImageLoader();249};250var PROPERTY_FONTNAME = "fontName";251var PROPERTY_FONTSIZE = "fontSize";252var PROPERTY_HORIZONTALALIGNMENT = "horizontalAlignment";253var PROPERTY_VERTICALALIGNMENT = "verticalAlignment";254var PROPERTY_STRING = "string";255var PROPERTY_DIMENSIONS = "dimensions";256cc.LabelTTFLoader = cc.NodeLoader.extend({257 _createCCNode:function (parent, ccbReader) {258 return new cc.LabelTTF();259 },260 onHandlePropTypeColor3:function (node, parent, propertyName, ccColor3B, ccbReader) {261 if (propertyName === PROPERTY_COLOR) {262 if(ccColor3B.r !== 255 || ccColor3B.g !== 255 || ccColor3B.b !== 255){263 node.setColor(ccColor3B);264 }265 } else {266 cc.NodeLoader.prototype.onHandlePropTypeColor3.call(this, node, parent, propertyName, ccColor3B, ccbReader);267 }268 },269 onHandlePropTypeByte:function (node, parent, propertyName, byteValue, ccbReader) {270 if (propertyName === PROPERTY_OPACITY) {271 node.setOpacity(byteValue);272 } else {273 cc.NodeLoader.prototype.onHandlePropTypeByte.call(this, node, parent, propertyName, byteValue, ccbReader);274 }275 },276 onHandlePropTypeBlendFunc:function (node, parent, propertyName, ccBlendFunc, ccbReader) {277 if (propertyName === PROPERTY_BLENDFUNC) {278 node.setBlendFunc(ccBlendFunc);279 } else {280 cc.NodeLoader.prototype.onHandlePropTypeBlendFunc.call(this, node, parent, propertyName, ccBlendFunc, ccbReader);281 }282 },283 onHandlePropTypeFontTTF:function (node, parent, propertyName, fontTTF, ccbReader) {284 if (propertyName === PROPERTY_FONTNAME) {285 node.setFontName(fontTTF);286 } else {287 cc.NodeLoader.prototype.onHandlePropTypeFontTTF.call(this, node, parent, propertyName, fontTTF, ccbReader);288 }289 },290 onHandlePropTypeText:function (node, parent, propertyName, textValue, ccbReader) {291 if (propertyName === PROPERTY_STRING) {292 node.setString(textValue);293 } else {294 cc.NodeLoader.prototype.onHandlePropTypeText.call(this, node, parent, propertyName, textValue, ccbReader);295 }296 },297 onHandlePropTypeFloatScale:function (node, parent, propertyName, floatScale, ccbReader) {298 if (propertyName === PROPERTY_FONTSIZE) {299 node.setFontSize(floatScale);300 } else {301 cc.NodeLoader.prototype.onHandlePropTypeFloatScale.call(this, node, parent, propertyName, floatScale, ccbReader);302 }303 },304 onHandlePropTypeIntegerLabeled:function (node, parent, propertyName, integerLabeled, ccbReader) {305 if (propertyName === PROPERTY_HORIZONTALALIGNMENT) {306 node.setHorizontalAlignment(integerLabeled);307 } else if (propertyName === PROPERTY_VERTICALALIGNMENT) {308 node.setVerticalAlignment(integerLabeled);309 } else {310 cc.NodeLoader.prototype.onHandlePropTypeIntegerLabeled.call(this, node, parent, propertyName, integerLabeled, ccbReader);311 }312 },313 onHandlePropTypeSize:function (node, parent, propertyName, size, ccbReader) {314 if (propertyName === PROPERTY_DIMENSIONS) {315 node.setDimensions(size);316 } else {317 cc.NodeLoader.prototype.onHandlePropTypeSize.call(this, node, parent, propertyName, size, ccbReader);318 }319 }320});321cc.LabelTTFLoader.loader = function () {322 return new cc.LabelTTFLoader();323};324var PROPERTY_FNTFILE = "fntFile";325cc.LabelBMFontLoader = cc.NodeLoader.extend({326 _createCCNode:function (parent, ccbReader) {327 return new cc.LabelBMFont();328 },329 onHandlePropTypeColor3:function (node, parent, propertyName, ccColor3B, ccbReader) {330 if (propertyName === PROPERTY_COLOR) {331 if(ccColor3B.r !== 255 || ccColor3B.g !== 255 || ccColor3B.b !== 255){332 node.setColor(ccColor3B);333 }334 } else {335 cc.NodeLoader.prototype.onHandlePropTypeColor3.call(this, node, parent, propertyName, ccColor3B, ccbReader);336 }337 },338 onHandlePropTypeByte:function (node, parent, propertyName, byteValue, ccbReader) {339 if (propertyName === PROPERTY_OPACITY) {340 node.setOpacity(byteValue);341 } else {342 cc.NodeLoader.prototype.onHandlePropTypeByte.call(this, node, parent, propertyName, byteValue, ccbReader);343 }344 },345 onHandlePropTypeBlendFunc:function (node, parent, propertyName, ccBlendFunc, ccbReader) {346 if (propertyName === PROPERTY_BLENDFUNC) {347 node.setBlendFunc(ccBlendFunc);348 } else {349 cc.NodeLoader.prototype.onHandlePropTypeBlendFunc.call(this, node, parent, propertyName, ccBlendFunc, ccbReader);350 }351 },352 onHandlePropTypeFntFile:function (node, parent, propertyName, fntFile, ccbReader) {353 if (propertyName === PROPERTY_FNTFILE) {354 node.setFntFile(fntFile);355 } else {356 cc.NodeLoader.prototype.onHandlePropTypeFntFile.call(this, node, parent, propertyName, fntFile, ccbReader);357 }358 },359 onHandlePropTypeText:function (node, parent, propertyName, textValue, ccbReader) {360 if (propertyName === PROPERTY_STRING) {361 node.setString(textValue);362 } else {363 cc.NodeLoader.prototype.onHandlePropTypeText.call(this, node, parent, propertyName, textValue, ccbReader);364 }365 }366});367cc.LabelBMFontLoader.loader = function () {368 return new cc.LabelBMFontLoader();369};370var PROPERTY_EMITERMODE = "emitterMode";371var PROPERTY_POSVAR = "posVar";372var PROPERTY_EMISSIONRATE = "emissionRate";373var PROPERTY_DURATION = "duration";374var PROPERTY_TOTALPARTICLES = "totalParticles";375var PROPERTY_LIFE = "life";376var PROPERTY_STARTSIZE = "startSize";377var PROPERTY_ENDSIZE = "endSize";378var PROPERTY_STARTSPIN = "startSpin";379var PROPERTY_ENDSPIN = "endSpin";380var PROPERTY_ANGLE = "angle";381var PROPERTY_GRAVITY = "gravity";382var PROPERTY_SPEED = "speed";383var PROPERTY_TANGENTIALACCEL = "tangentialAccel";384var PROPERTY_RADIALACCEL = "radialAccel";385var PROPERTY_TEXTURE = "texture";386var PROPERTY_STARTRADIUS = "startRadius";387var PROPERTY_ENDRADIUS = "endRadius";388var PROPERTY_ROTATEPERSECOND = "rotatePerSecond";389cc.ParticleSystemLoader = cc.NodeLoader.extend({390 _createCCNode:function (parent, ccbReader) {391 return new cc.ParticleSystem();392 },393 onHandlePropTypeIntegerLabeled:function (node, parent, propertyName, integerLabeled, ccbReader) {394 if (propertyName === PROPERTY_EMITERMODE) {395 node.setEmitterMode(integerLabeled);396 } else {397 cc.NodeLoader.prototype.onHandlePropTypeIntegerLabeled.call(this, node, parent, propertyName, integerLabeled, ccbReader);398 }399 },400 onHandlePropTypePoint:function (node, parent, propertyName, point, ccbReader) {401 if (propertyName === PROPERTY_POSVAR) {402 node.setPosVar(point);403 } else if (propertyName === PROPERTY_GRAVITY) {404 node.setGravity(point);405 } else {406 cc.NodeLoader.prototype.onHandlePropTypePoint.call(this, node, parent, propertyName, point, ccbReader);407 }408 },409 onHandlePropTypeFloat:function (node, parent, propertyName, floatValue, ccbReader) {410 if (propertyName === PROPERTY_EMISSIONRATE) {411 node.setEmissionRate(floatValue);412 } else if (propertyName === PROPERTY_DURATION) {413 node.setDuration(floatValue);414 } else {415 cc.NodeLoader.prototype.onHandlePropTypeFloat.call(this, node, parent, propertyName, floatValue, ccbReader);416 }417 },418 onHandlePropTypeInteger:function (node, parent, propertyName, integerValue, ccbReader) {419 if (propertyName === PROPERTY_TOTALPARTICLES) {420 node.setTotalParticles(integerValue);421 } else {422 cc.NodeLoader.prototype.onHandlePropTypeInteger.call(this, node, parent, propertyName, integerValue, ccbReader);423 }424 },425 onHandlePropTypeFloatVar:function (node, parent, propertyName, floatVar, ccbReader) {426 if (propertyName === PROPERTY_LIFE) {427 node.setLife(floatVar[0]);428 node.setLifeVar(floatVar[1]);429 } else if (propertyName === PROPERTY_STARTSIZE) {430 node.setStartSize(floatVar[0]);431 node.setStartSizeVar(floatVar[1]);432 } else if (propertyName === PROPERTY_ENDSIZE) {433 node.setEndSize(floatVar[0]);434 node.setEndSizeVar(floatVar[1]);435 } else if (propertyName === PROPERTY_STARTSPIN) {436 node.setStartSpin(floatVar[0]);437 node.setStartSpinVar(floatVar[1]);438 } else if (propertyName === PROPERTY_ENDSPIN) {439 node.setEndSpin(floatVar[0]);440 node.setEndSpinVar(floatVar[1]);441 } else if (propertyName === PROPERTY_ANGLE) {442 node.setAngle(floatVar[0]);443 node.setAngleVar(floatVar[1]);444 } else if (propertyName === PROPERTY_SPEED) {445 node.setSpeed(floatVar[0]);446 node.setSpeedVar(floatVar[1]);447 } else if (propertyName === PROPERTY_TANGENTIALACCEL) {448 node.setTangentialAccel(floatVar[0]);449 node.setTangentialAccelVar(floatVar[1]);450 } else if (propertyName === PROPERTY_RADIALACCEL) {451 node.setRadialAccel(floatVar[0]);452 node.setRadialAccelVar(floatVar[1]);453 } else if (propertyName === PROPERTY_STARTRADIUS) {454 node.setStartRadius(floatVar[0]);455 node.setStartRadiusVar(floatVar[1]);456 } else if (propertyName === PROPERTY_ENDRADIUS) {457 node.setEndRadius(floatVar[0]);458 node.setEndRadiusVar(floatVar[1]);459 } else if (propertyName === PROPERTY_ROTATEPERSECOND) {460 node.setRotatePerSecond(floatVar[0]);461 node.setRotatePerSecondVar(floatVar[1]);462 } else {463 cc.NodeLoader.prototype.onHandlePropTypeFloatVar.call(this, node, parent, propertyName, floatVar, ccbReader);464 }465 },466 onHandlePropTypeColor4FVar:function (node, parent, propertyName, ccColor4FVar, ccbReader) {467 if (propertyName === PROPERTY_STARTCOLOR) {468 node.setStartColor(ccColor4FVar[0]);469 node.setStartColorVar(ccColor4FVar[1]);470 } else if (propertyName === PROPERTY_ENDCOLOR) {471 node.setEndColor(ccColor4FVar[0]);472 node.setEndColorVar(ccColor4FVar[1]);473 } else {474 cc.NodeLoader.prototype.onHandlePropTypeColor4FVar.call(this, node, parent, propertyName, ccColor4FVar, ccbReader);475 }476 },477 onHandlePropTypeBlendFunc:function (node, parent, propertyName, ccBlendFunc, ccbReader) {478 if (propertyName === PROPERTY_BLENDFUNC) {479 node.setBlendFunc(ccBlendFunc);480 } else {481 cc.NodeLoader.prototype.onHandlePropTypeBlendFunc.call(this, node, parent, propertyName, ccBlendFunc, ccbReader);482 }483 },484 onHandlePropTypeTexture:function (node, parent, propertyName, ccTexture2D, ccbReader) {485 if (propertyName === PROPERTY_TEXTURE) {486 node.setTexture(ccTexture2D);487 } else {488 cc.NodeLoader.prototype.onHandlePropTypeTexture.call(this, node, parent, propertyName, ccTexture2D, ccbReader);489 }490 }491});492cc.ParticleSystemLoader.loader = function () {493 return new cc.ParticleSystemLoader();...

Full Screen

Full Screen

CCControlLoader.js

Source:CCControlLoader.js Github

copy

Full Screen

1/****************************************************************************2 Copyright (c) 2008-2010 Ricardo Quesada3 Copyright (c) 2011-2012 cocos2d-x.org4 Copyright (c) 2013-2014 Chukong Technologies Inc.5 http://www.cocos2d-x.org6 Permission is hereby granted, free of charge, to any person obtaining a copy7 of this software and associated documentation files (the "Software"), to deal8 in the Software without restriction, including without limitation the rights9 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell10 copies of the Software, and to permit persons to whom the Software is11 furnished to do so, subject to the following conditions:12 The above copyright notice and this permission notice shall be included in13 all copies or substantial portions of the Software.14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE17 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER18 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 IN20 THE SOFTWARE.21 ****************************************************************************/22var PROPERTY_CCBFILE = "ccbFile";23cc.BuilderFileLoader = cc.NodeLoader.extend({24 _createCCNode:function (parent, ccbReader) {25 return cc.BuilderFile.create();26 },27 onHandlePropTypeCCBFile:function (node, parent, propertyName, ccbFileNode, ccbReader) {28 if (propertyName == PROPERTY_CCBFILE) {29 node.setCCBFileNode(ccbFileNode);30 } else {31 cc.NodeLoader.prototype.onHandlePropTypeCCBFile.call(this, node, parent, propertyName, ccbFileNode, ccbReader);32 }33 }34});35cc.BuilderFileLoader.loader = function () {36 return new cc.BuilderFileLoader();37};38var PROPERTY_ENABLED = "enabled";39var PROPERTY_SELECTED = "selected";40var PROPERTY_CCCONTROL = "ccControl";41cc.ControlLoader = cc.NodeLoader.extend({42 _createCCNode:function (parent, ccbReander) {43 },44 onHandlePropTypeBlockCCControl:function (node, parent, propertyName, blockCCControlData, ccbReader) {45 if (propertyName == PROPERTY_CCCONTROL) {46 node.addTargetWithActionForControlEvents(blockCCControlData.target, blockCCControlData.selCCControlHandler, blockCCControlData.controlEvents);47 } else {48 cc.NodeLoader.prototype.onHandlePropTypeBlockCCControl.call(this, node, parent, propertyName, blockCCControlData, ccbReader);49 }50 },51 onHandlePropTypeCheck:function (node, parent, propertyName, check, ccbReader) {52 if (propertyName == PROPERTY_ENABLED) {53 node.setEnabled(check);54 } else if (propertyName == PROPERTY_SELECTED) {55 node.setSelected(check);56 } else {57 cc.NodeLoader.prototype.onHandlePropTypeCheck.call(this, node, parent, propertyName, check, ccbReader);58 }59 }60});61var PROPERTY_ZOOMONTOUCHDOWN = "zoomOnTouchDown";62var PROPERTY_TITLE_NORMAL = "title|1";63var PROPERTY_TITLE_HIGHLIGHTED = "title|2";64var PROPERTY_TITLE_DISABLED = "title|3";65var PROPERTY_TITLECOLOR_NORMAL = "titleColor|1";66var PROPERTY_TITLECOLOR_HIGHLIGHTED = "titleColor|2";67var PROPERTY_TITLECOLOR_DISABLED = "titleColor|3";68var PROPERTY_TITLETTF_NORMAL = "titleTTF|1";69var PROPERTY_TITLETTF_HIGHLIGHTED = "titleTTF|2";70var PROPERTY_TITLETTF_DISABLED = "titleTTF|3";71var PROPERTY_TITLETTFSIZE_NORMAL = "titleTTFSize|1";72var PROPERTY_TITLETTFSIZE_HIGHLIGHTED = "titleTTFSize|2";73var PROPERTY_TITLETTFSIZE_DISABLED = "titleTTFSize|4";74var PROPERTY_LABELANCHORPOINT = "labelAnchorPoint";75var PROPERTY_PREFEREDSIZE = "preferedSize"; // TODO Should be = "preferredSize". This is a typo in cocos2d-iphone, cocos2d-x and CocosBuilder!76var PROPERTY_BACKGROUNDSPRITEFRAME_NORMAL = "backgroundSpriteFrame|1";77var PROPERTY_BACKGROUNDSPRITEFRAME_HIGHLIGHTED = "backgroundSpriteFrame|2";78var PROPERTY_BACKGROUNDSPRITEFRAME_DISABLED = "backgroundSpriteFrame|3";79cc.ControlButtonLoader = cc.ControlLoader.extend({80 _createCCNode:function (parent, ccbReader) {81 return new cc.ControlButton();82 },83 onHandlePropTypeCheck:function (node, parent, propertyName, check, ccbReader) {84 if (propertyName == PROPERTY_ZOOMONTOUCHDOWN) {85 node.setZoomOnTouchDown(check);86 } else {87 cc.ControlLoader.prototype.onHandlePropTypeCheck.call(this, node, parent, propertyName, check, ccbReader);88 }89 },90 onHandlePropTypeString:function (node, parent, propertyName, stringValue, ccbReader) {91 if (propertyName == PROPERTY_TITLE_NORMAL) {92 node.setTitleForState(stringValue, cc.CONTROL_STATE_NORMAL);93 } else if (propertyName == PROPERTY_TITLE_HIGHLIGHTED) {94 node.setTitleForState(stringValue, cc.CONTROL_STATE_HIGHLIGHTED);95 } else if (propertyName == PROPERTY_TITLE_DISABLED) {96 node.setTitleForState(stringValue, cc.CONTROL_STATE_DISABLED);97 } else {98 cc.ControlLoader.prototype.onHandlePropTypeString.call(this, node, parent, propertyName, stringValue, ccbReader);99 }100 },101 onHandlePropTypeFontTTF:function (node, parent, propertyName, fontTTF, ccbReader) {102 if (propertyName == PROPERTY_TITLETTF_NORMAL) {103 node.setTitleTTFForState(fontTTF, cc.CONTROL_STATE_NORMAL);104 } else if (propertyName == PROPERTY_TITLETTF_HIGHLIGHTED) {105 node.setTitleTTFForState(fontTTF, cc.CONTROL_STATE_HIGHLIGHTED);106 } else if (propertyName == PROPERTY_TITLETTF_DISABLED) {107 node.setTitleTTFForState(fontTTF, cc.CONTROL_STATE_DISABLED);108 } else {109 cc.ControlLoader.prototype.onHandlePropTypeFontTTF.call(this, node, parent, propertyName, fontTTF, ccbReader);110 }111 },112 onHandlePropTypeFloatScale:function (node, parent, propertyName, floatScale, ccbReader) {113 if (propertyName == PROPERTY_TITLETTFSIZE_NORMAL) {114 node.setTitleTTFSizeForState(floatScale, cc.CONTROL_STATE_NORMAL);115 } else if (propertyName == PROPERTY_TITLETTFSIZE_HIGHLIGHTED) {116 node.setTitleTTFSizeForState(floatScale, cc.CONTROL_STATE_HIGHLIGHTED);117 } else if (propertyName == PROPERTY_TITLETTFSIZE_DISABLED) {118 node.setTitleTTFSizeForState(floatScale, cc.CONTROL_STATE_DISABLED);119 } else {120 cc.ControlLoader.prototype.onHandlePropTypeFloatScale.call(this, node, parent, propertyName, floatScale, ccbReader);121 }122 },123 onHandlePropTypePoint:function (node, parent, propertyName, point, ccbReader) {124 if (propertyName == PROPERTY_LABELANCHORPOINT) {125 node.setLabelAnchorPoint(point);126 } else {127 cc.ControlLoader.prototype.onHandlePropTypePoint.call(this, node, parent, propertyName, point, ccbReader);128 }129 },130 onHandlePropTypeSize:function (node, parent, propertyName, size, ccbReader) {131 if (propertyName == PROPERTY_PREFEREDSIZE) {132 node.setPreferredSize(size);133 } else {134 cc.ControlLoader.prototype.onHandlePropTypeSize.call(this, node, parent, propertyName, size, ccbReader);135 }136 },137 onHandlePropTypeSpriteFrame:function (node, parent, propertyName, spriteFrame, ccbReader) {138 if (propertyName == PROPERTY_BACKGROUNDSPRITEFRAME_NORMAL) {139 if (spriteFrame != null) {140 node.setBackgroundSpriteFrameForState(spriteFrame, cc.CONTROL_STATE_NORMAL);141 }142 } else if (propertyName == PROPERTY_BACKGROUNDSPRITEFRAME_HIGHLIGHTED) {143 if (spriteFrame != null) {144 node.setBackgroundSpriteFrameForState(spriteFrame, cc.CONTROL_STATE_HIGHLIGHTED);145 }146 } else if (propertyName == PROPERTY_BACKGROUNDSPRITEFRAME_DISABLED) {147 if (spriteFrame != null) {148 node.setBackgroundSpriteFrameForState(spriteFrame, cc.CONTROL_STATE_DISABLED);149 }150 } else {151 cc.ControlLoader.prototype.onHandlePropTypeSpriteFrame.call(this, node, parent, propertyName, spriteFrame, ccbReader);152 }153 },154 onHandlePropTypeColor3:function (node, parent, propertyName, ccColor3B, ccbReader) {155 if (propertyName == PROPERTY_TITLECOLOR_NORMAL) {156 node.setTitleColorForState(ccColor3B, cc.CONTROL_STATE_NORMAL);157 } else if (propertyName == PROPERTY_TITLECOLOR_HIGHLIGHTED) {158 node.setTitleColorForState(ccColor3B, cc.CONTROL_STATE_HIGHLIGHTED);159 } else if (propertyName == PROPERTY_TITLECOLOR_DISABLED) {160 node.setTitleColorForState(ccColor3B, cc.CONTROL_STATE_DISABLED);161 } else {162 cc.ControlLoader.prototype.onHandlePropTypeColor3.call(this, node, parent, propertyName, ccColor3B, ccbReader);163 }164 }165});166cc.ControlButtonLoader.loader = function () {167 return new cc.ControlButtonLoader();168};169var PROPERTY_CONTAINER = "container";170var PROPERTY_DIRECTION = "direction";171var PROPERTY_CLIPSTOBOUNDS = "clipsToBounds";172var PROPERTY_BOUNCES = "bounces";173var PROPERTY_SCALE = "scale";174cc.ScrollViewLoader = cc.NodeLoader.extend({175 _createCCNode:function (parent, ccbReader) {176 return new cc.ScrollView();177 },178 onHandlePropTypeSize:function(node,parent,propertyName,size,ccbReader){179 if(propertyName == PROPERTY_CONTENTSIZE){180 node.setViewSize(size);181 }else{182 cc.NodeLoader.prototype.onHandlePropTypeSize.call(this, node,parent,propertyName,size,ccbReader);183 }184 },185 onHandlePropTypeCCBFile:function (node, parent, propertyName, ccbFileNode, ccbReader) {186 if (propertyName == PROPERTY_CONTAINER) {187 node.setContainer(ccbFileNode);188 node.updateInset();189 } else {190 cc.NodeLoader.prototype.onHandlePropTypeCCBFile.call(this, node, parent, propertyName, ccbFileNode, ccbReader);191 }192 },193 onHandlePropTypeCheck:function (node, parent, propertyName, check, ccbReader) {194 if (propertyName == PROPERTY_CLIPSTOBOUNDS) {195 node.setClippingToBounds(check);196 } else if (propertyName == PROPERTY_BOUNCES) {197 node.setBounceable(check);198 } else {199 cc.NodeLoader.prototype.onHandlePropTypeCheck.call(this, node, parent, propertyName, check, ccbReader);200 }201 },202 onHandlePropTypeFloat:function (node, parent, propertyName, floatValue, ccbReader) {203 if (propertyName == PROPERTY_SCALE) {204 node.setScale(floatValue);205 } else {206 cc.NodeLoader.prototype.onHandlePropTypeFloat.call(this, node, parent, propertyName, floatValue, ccbReader);207 }208 },209 onHandlePropTypeIntegerLabeled:function (node, parent, propertyName, integerLabeled, ccbReader) {210 if (propertyName == PROPERTY_DIRECTION) {211 node.setDirection(integerLabeled);212 } else {213 cc.NodeLoader.prototype.onHandlePropTypeIntegerLabeled.call(this, node, parent, propertyName, integerLabeled, ccbReader);214 }215 }216});217cc.ScrollViewLoader.loader = function () {218 return new cc.ScrollViewLoader();219};220var PROPERTY_CONTENTSIZE = "contentSize";221var PROPERTY_SPRITEFRAME = "spriteFrame";222var PROPERTY_COLOR = "color";223var PROPERTY_OPACITY = "opacity";224var PROPERTY_BLENDFUNC = "blendFunc";225var PROPERTY_INSETLEFT = "insetLeft";226var PROPERTY_INSETTOP = "insetTop" ;227var PROPERTY_INSETRIGHT = "insetRight";228var PROPERTY_INSETBOTTOM = "insetBottom";229cc.Scale9SpriteLoader = cc.NodeLoader.extend({230 _createCCNode:function(parent,ccbReader){231 var sprite = new cc.Scale9Sprite();232 sprite.setAnchorPoint(0, 0);233 return sprite;234 },235 onHandlePropTypeColor3:function(node, parent, propertyName, ccColor3B,ccbReader){236 if(propertyName == PROPERTY_COLOR) {237 if(ccColor3B.r !== 255 || ccColor3B.g !== 255 || ccColor3B.b !== 255){238 node.setColor(ccColor3B);239 }240 } else {241 cc.NodeLoader.prototype.onHandlePropTypeColor3.call(this, node, parent, propertyName, ccColor3B,ccbReader);242 }243 },244 onHandlePropTypeByte:function(node, parent, propertyName, byteValue,ccbReader){245 if(propertyName == PROPERTY_OPACITY) {246 node.setOpacity(byteValue);247 } else {248 cc.NodeLoader.prototype.onHandlePropTypeByte.call(this, node, parent, propertyName, byteValue,ccbReader);249 }250 },251 onHandlePropTypeBlendFunc:function(node, parent, propertyName, ccBlendFunc,ccbReader){252 if(propertyName == PROPERTY_BLENDFUNC) {253 // TODO Not exported by CocosBuilder yet!254 // node.setBlendFunc(ccBlendFunc);255 } else {256 cc.NodeLoader.prototype.onHandlePropTypeBlendFunc.call(this, node, parent, propertyName, ccBlendFunc,ccbReader);257 }258 },259 onHandlePropTypeSpriteFrame:function(node, parent, propertyName, spriteFrame,ccbReader){260 if(propertyName == PROPERTY_SPRITEFRAME) {261 node.setSpriteFrame(spriteFrame);262 } else {263 cc.NodeLoader.prototype.onHandlePropTypeSpriteFrame.call(this, node, parent, propertyName, spriteFrame,ccbReader);264 }265 },266 onHandlePropTypeSize:function(node, parent, propertyName, size,ccbReader){267 if(propertyName == PROPERTY_CONTENTSIZE) {268 //node.setContentSize(size);269 } else if(propertyName == PROPERTY_PREFEREDSIZE) {270 node.setPreferredSize(size);271 } else {272 cc.NodeLoader.prototype.onHandlePropTypeSize.call(this, node, parent, propertyName, size,ccbReader);273 }274 },275 onHandlePropTypeFloat:function(node, parent, propertyName, floatValue,ccbReader){276 if(propertyName == PROPERTY_INSETLEFT) {277 node.setInsetLeft(floatValue);278 } else if(propertyName == PROPERTY_INSETTOP) {279 node.setInsetTop(floatValue);280 } else if(propertyName == PROPERTY_INSETRIGHT) {281 node.setInsetRight(floatValue);282 } else if(propertyName == PROPERTY_INSETBOTTOM) {283 node.setInsetBottom(floatValue);284 } else {285 cc.NodeLoader.prototype.onHandlePropTypeFloat.call(this, node, parent, propertyName, floatValue,ccbReader);286 }287 }288});289cc.Scale9SpriteLoader.loader = function(){290 return new cc.Scale9SpriteLoader();...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3 if (err) return console.error(err);4 console.log('Test status:', data.statusText);5 console.log('Test ID:', data.data.testId);6});7var wpt = require('webpagetest');8var wpt = new WebPageTest('www.webpagetest.org');9 if (err) return console.error(err);10 console.log('Test status:', data.statusText);11 console.log('Test ID:', data.data.testId);12});13var wpt = require('webpagetest');14var wpt = new WebPageTest('www.webpagetest.org');15 if (err) return console.error(err);16 console.log('Test status:', data.statusText);17 console.log('Test ID:', data.data.testId);18});19var wpt = require('webpagetest');20var wpt = new WebPageTest('www.webpagetest.org');21 if (err) return console.error(err);22 console.log('Test status:', data.statusText);23 console.log('Test ID:', data.data.testId);24});25var wpt = require('webpagetest');26var wpt = new WebPageTest('www.webpagetest.org');27 if (err) return console.error(err);28 console.log('Test status:', data.statusText);29 console.log('Test ID:', data.data.testId);30});31var wpt = require('webpagetest');32var wpt = new WebPageTest('www.webpagetest.org');

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3 if (err) {4 return console.error('Error: ' + err);5 }6 console.log('Test Results for ' + data.data.testUrl);7 console.log('First View (load time): ' + data.data.average.firstView.loadTime);8 console.log('Repeat View (load time): ' + data.data.average.repeatView.loadTime);9});10var wpt = require('webpagetest');11var wpt = new WebPageTest('www.webpagetest.org');12 if (err) {13 return console.error('Error: ' + err);14 }15 console.log('Test Results for ' + data.data.testUrl);16 console.log('First View (load time): ' + data.data.average.firstView.loadTime);17 console.log('Repeat View (load time): ' + data.data.average.repeatView.loadTime);18});19var wpt = require('webpagetest');20var wpt = new WebPageTest('www.webpagetest.org');21 if (err) {22 return console.error('Error: ' + err);23 }24 console.log('Test Results for ' + data.data.testUrl);25 console.log('First View (load time): ' + data.data.average.firstView.loadTime);26 console.log('Repeat View (load time): ' + data.data.average.repeatView.loadTime);27});28var wpt = require('webpagetest');29var wpt = new WebPageTest('www.webpagetest.org');30 if (err) {31 return console.error('Error: ' + err);32 }33 console.log('Test Results for ' + data.data.testUrl);34 console.log('First View (load time): ' + data.data.average.firstView

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3 if (err) return console.log(err);4 console.log(data);5 wpt.getTestResults(data.data.testId, function(err, data) {6 if (err) return console.log(err);7 console.log(data);8 });9});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org', 'API_KEY');3}, function(err, data) {4 if (err) return console.error(err);5 console.log(data);6 wpt.getTestResults(data.data.testId, function(err, data) {7 if (err) return console.error(err);8 console.log(data);9 });10});11var wpt = require('webpagetest');12var wpt = new WebPageTest('www.webpagetest.org', 'API_KEY');13}, function(err, data) {14 if (err) return console.error(err);15 console.log(data);16 wpt.getTestResults(data.data.testId, function(err, data) {17 if (err) return console.error(err);18 console.log(data);19 });20});21var wpt = require('webpagetest');22var wpt = new WebPageTest('www.webpagetest.org', 'API_KEY');23}, function(err, data) {24 if (err) return console.error(err);25 console.log(data);26 wpt.getTestResults(data.data.testId, function(err, data) {27 if (err) return console.error(err);28 console.log(data);29 });30});31var wpt = require('webpagetest');32var wpt = new WebPageTest('www.webpagetest.org', 'API_KEY');

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('./wpt.js');2wpt.propertyName('test', 'test', function(data) {3 console.log(data);4});5var wpt = require('webpagetest');6var wpt = new WebPageTest('www.webpagetest.org', 'A.7e0b0c1e7f9b9d2b7c2e0f7c7d0a6e0b');7var propertyName = function(url, location, callback) {8 wpt.runTest(url, {9 }, function(err, data) {10 callback(data);11 });12};13module.exports.propertyName = propertyName;14var wpt = new WebPageTest('www.webpagetest.org', 'A.7e0b0c1e7f9b9d2b7c2e0f7c7d0a6e0b');15var propertyName = function(url, location, callback) {16 wpt.runTest(url, {17 }, function(err, data) {18 callback(data);19 });20};21module.exports.propertyName = propertyName;22var wpt = new WebPageTest('www.webpagetest.org', 'A.7e0b0c1e7f9b9d2b7c2e0f

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful