1 /**************************************************************************** 2 Copyright (c) 2011-2012 cocos2d-x.org 3 Copyright (c) 2013-2014 Chukong Technologies Inc. 4 5 http://www.cocos2d-x.org 6 7 Permission is hereby granted, free of charge, to any person obtaining a copy 8 of this software and associated documentation files (the "Software"), to deal 9 in the Software without restriction, including without limitation the rights 10 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 copies of the Software, and to permit persons to whom the Software is 12 furnished to do so, subject to the following conditions: 13 14 The above copyright notice and this permission notice shall be included in 15 all copies or substantial portions of the Software. 16 17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 THE SOFTWARE. 24 ****************************************************************************/ 25 26 /** 27 * Base class for ccs.DecorativeDisplay 28 * @class 29 * @extends ccs.Class 30 */ 31 ccs.DecorativeDisplay = ccs.Class.extend(/** @lends ccs.DecorativeDisplay# */{ 32 _display:null, 33 _colliderDetector:null, 34 _displayData:null, 35 36 ctor:function () { 37 this._display = null; 38 this._colliderDetector = null; 39 this._displayData = null; 40 }, 41 42 init:function () { 43 return true; 44 }, 45 46 /** 47 * display setter 48 * @param {cc.Node} display 49 */ 50 setDisplay:function (display) { 51 this._display = display; 52 }, 53 54 /** 55 * display getter 56 * @returns {cc.Node} 57 */ 58 getDisplay:function () { 59 return this._display; 60 }, 61 62 /** 63 * colliderDetector setter 64 * @param {ccs.ColliderDetector} colliderDetector 65 */ 66 setColliderDetector:function (colliderDetector) { 67 this._colliderDetector = colliderDetector; 68 }, 69 70 /** 71 * colliderDetector getter 72 * @returns {ccs.ColliderDetector} 73 */ 74 getColliderDetector:function () { 75 return this._colliderDetector; 76 }, 77 78 /** 79 * display data setter 80 * @param {ccs.DisplayData} displayData 81 */ 82 setDisplayData:function (displayData) { 83 this._displayData = displayData; 84 }, 85 86 /** 87 * display data getter 88 * @returns {ccs.DisplayData} 89 */ 90 getDisplayData:function () { 91 return this._displayData; 92 }, 93 release:function () { 94 CC_SAFE_RELEASE(this._display); 95 this._display = null; 96 CC_SAFE_RELEASE(this._displayData); 97 this._displayData = null; 98 CC_SAFE_RELEASE(this._colliderDetector); 99 this._colliderDetector = null; 100 } 101 102 }); 103 104 /** 105 * allocates and initializes a decorative display. 106 * @constructs 107 * @return {ccs.DecorativeDisplay} 108 * @example 109 * // example 110 * var display = ccs.DecorativeDisplay.create(); 111 */ 112 ccs.DecorativeDisplay.create = function () { 113 var decorativeDisplay = new ccs.DecorativeDisplay(); 114 if (decorativeDisplay && decorativeDisplay.init()) { 115 return decorativeDisplay; 116 } 117 return null; 118 };