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 9 Permission is hereby granted, free of charge, to any person obtaining a copy 10 of this software and associated documentation files (the "Software"), to deal 11 in the Software without restriction, including without limitation the rights 12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 copies of the Software, and to permit persons to whom the Software is 14 furnished to do so, subject to the following conditions: 15 16 The above copyright notice and this permission notice shall be included in 17 all copies or substantial portions of the Software. 18 19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 THE SOFTWARE. 26 ****************************************************************************/ 27 28 /** 29 * 30 * @type Object 31 */ 32 cc.visibleRect = { 33 _topLeft:cc.p(0,0), 34 _topRight:cc.p(0,0), 35 _top:cc.p(0,0), 36 _bottomLeft:cc.p(0,0), 37 _bottomRight:cc.p(0,0), 38 _bottom:cc.p(0,0), 39 _center:cc.p(0,0), 40 _left:cc.p(0,0), 41 _right:cc.p(0,0), 42 _width:0, 43 _height:0, 44 init:function(size){ 45 this._width = size.width; 46 this._height = size.height; 47 48 var w = this._width; 49 var h = this._height; 50 51 //top 52 this._topLeft.y = h; 53 this._topRight.x = w; 54 this._topRight.y = h; 55 this._top.x = w/2; 56 this._top.y = h; 57 58 //bottom 59 this._bottomRight.x = w; 60 this._bottom.x = w/2; 61 62 //center 63 this._center.x = w/2; 64 this._center.y = h/2; 65 66 //left 67 this._left.y = h/2; 68 69 //right 70 this._right.x = w; 71 this._right.y = h/2; 72 } 73 }; 74 75 /** @expose */ 76 cc.visibleRect.width; 77 cc.defineGetterSetter(cc.visibleRect, "width", function(){ 78 return this._width; 79 }); 80 /** @expose */ 81 cc.visibleRect.height; 82 cc.defineGetterSetter(cc.visibleRect, "height", function(){ 83 return this._height; 84 }); 85 /** @expose */ 86 cc.visibleRect.topLeft; 87 cc.defineGetterSetter(cc.visibleRect, "topLeft", function(){ 88 return this._topLeft; 89 }); 90 /** @expose */ 91 cc.visibleRect.topRight; 92 cc.defineGetterSetter(cc.visibleRect, "topRight", function(){ 93 return this._topRight; 94 }); 95 /** @expose */ 96 cc.visibleRect.top; 97 cc.defineGetterSetter(cc.visibleRect, "top", function(){ 98 return this._top; 99 }); 100 /** @expose */ 101 cc.visibleRect.bottomLeft; 102 cc.defineGetterSetter(cc.visibleRect, "bottomLeft", function(){ 103 return this._bottomLeft; 104 }); 105 /** @expose */ 106 cc.visibleRect.bottomRight; 107 cc.defineGetterSetter(cc.visibleRect, "bottomRight", function(){ 108 return this._bottomRight; 109 }); 110 /** @expose */ 111 cc.visibleRect.bottom; 112 cc.defineGetterSetter(cc.visibleRect, "bottom", function(){ 113 return this._bottom; 114 }); 115 /** @expose */ 116 cc.visibleRect.center; 117 cc.defineGetterSetter(cc.visibleRect, "center", function(){ 118 return this._center; 119 }); 120 /** @expose */ 121 cc.visibleRect.left; 122 cc.defineGetterSetter(cc.visibleRect, "left", function(){ 123 return this._left; 124 }); 125 /** @expose */ 126 cc.visibleRect.right; 127 cc.defineGetterSetter(cc.visibleRect, "right", function(){ 128 return this._right; 129 });