123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- /****************************************************************************
- Copyright (c) 2010-2012 cocos2d-x.org
- Copyright (c) 2008-2010 Ricardo Quesada
- Copyright (c) 2011 Zynga Inc.
- http://www.cocos2d-x.org
- Permission is hereby granted, free of charge, to any person obtaining a copy
- of this software and associated documentation files (the "Software"), to deal
- in the Software without restriction, including without limitation the rights
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- copies of the Software, and to permit persons to whom the Software is
- furnished to do so, subject to the following conditions:
- The above copyright notice and this permission notice shall be included in
- all copies or substantial portions of the Software.
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- THE SOFTWARE.
- ****************************************************************************/
- /**
- *
- * @type Object
- */
- cc.VisibleRect = {
- _topLeft:cc.p(0,0),
- _topRight:cc.p(0,0),
- _top:cc.p(0,0),
- _bottomLeft:cc.p(0,0),
- _bottomRight:cc.p(0,0),
- _bottom:cc.p(0,0),
- _center:cc.p(0,0),
- _left:cc.p(0,0),
- _right:cc.p(0,0),
- _width:0,
- _height:0,
- init:function(size){
- this._width = size.width;
- this._height = size.height;
- var w = this._width;
- var h = this._height;
- //top
- this._topLeft.y = h;
- this._topRight.x = w;
- this._topRight.y = h;
- this._top.x = w/2;
- this._top.y = h;
- //bottom
- this._bottomRight.x = w;
- this._bottom.x = w/2;
- //center
- this._center.x = w/2;
- this._center.y = h/2;
- //left
- this._left.y = h/2;
- //right
- this._right.x = w;
- this._right.y = h/2;
- },
- getWidth:function(){
- return this._width;
- },
- getHeight:function(){
- return this._height;
- },
- topLeft:function(){
- return cc.p(this._topLeft);
- },
- topRight:function(){
- return cc.p(this._topRight);
- },
- top:function(){
- return cc.p(this._top);
- },
- bottomLeft:function(){
- return cc.p(this._bottomLeft);
- },
- bottomRight:function(){
- return cc.p(this._bottomRight);
- },
- bottom:function(){
- return cc.p(this._bottom);
- },
- center:function(){
- return cc.p(this._center);
- },
- left:function(){
- return cc.p(this._left);
- },
- right:function(){
- return cc.p(this._right);
- }
- };
|