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 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 * 29 * @type Object 30 */ 31 cc.visibleRect = { 32 _topLeft:cc.p(0,0), 33 _topRight:cc.p(0,0), 34 _top:cc.p(0,0), 35 _bottomLeft:cc.p(0,0), 36 _bottomRight:cc.p(0,0), 37 _bottom:cc.p(0,0), 38 _center:cc.p(0,0), 39 _left:cc.p(0,0), 40 _right:cc.p(0,0), 41 _width:0, 42 _height:0, 43 init:function(size){ 44 this._width = size.width; 45 this._height = size.height; 46 47 var w = this._width; 48 var h = this._height; 49 50 //top 51 this._topLeft.y = h; 52 this._topRight.x = w; 53 this._topRight.y = h; 54 this._top.x = w/2; 55 this._top.y = h; 56 57 //bottom 58 this._bottomRight.x = w; 59 this._bottom.x = w/2; 60 61 //center 62 this._center.x = w/2; 63 this._center.y = h/2; 64 65 //left 66 this._left.y = h/2; 67 68 //right 69 this._right.x = w; 70 this._right.y = h/2; 71 } 72 }; 73 74 /** @expose */ 75 cc.visibleRect.width; 76 cc.defineGetterSetter(cc.visibleRect, "width", function(){ 77 return this._width; 78 }); 79 /** @expose */ 80 cc.visibleRect.height; 81 cc.defineGetterSetter(cc.visibleRect, "height", function(){ 82 return this._height; 83 }); 84 /** @expose */ 85 cc.visibleRect.topLeft; 86 cc.defineGetterSetter(cc.visibleRect, "topLeft", function(){ 87 return this._topLeft; 88 }); 89 /** @expose */ 90 cc.visibleRect.topRight; 91 cc.defineGetterSetter(cc.visibleRect, "topRight", function(){ 92 return this._topRight; 93 }); 94 /** @expose */ 95 cc.visibleRect.top; 96 cc.defineGetterSetter(cc.visibleRect, "top", function(){ 97 return this._top; 98 }); 99 /** @expose */ 100 cc.visibleRect.bottomLeft; 101 cc.defineGetterSetter(cc.visibleRect, "bottomLeft", function(){ 102 return this._bottomLeft; 103 }); 104 /** @expose */ 105 cc.visibleRect.bottomRight; 106 cc.defineGetterSetter(cc.visibleRect, "bottomRight", function(){ 107 return this._bottomRight; 108 }); 109 /** @expose */ 110 cc.visibleRect.bottom; 111 cc.defineGetterSetter(cc.visibleRect, "bottom", function(){ 112 return this._bottom; 113 }); 114 /** @expose */ 115 cc.visibleRect.center; 116 cc.defineGetterSetter(cc.visibleRect, "center", function(){ 117 return this._center; 118 }); 119 /** @expose */ 120 cc.visibleRect.left; 121 cc.defineGetterSetter(cc.visibleRect, "left", function(){ 122 return this._left; 123 }); 124 /** @expose */ 125 cc.visibleRect.right; 126 cc.defineGetterSetter(cc.visibleRect, "right", function(){ 127 return this._right; 128 });