modify vec2

This commit is contained in:
cw 2014-05-17 11:35:57 +08:00
parent 5d11c586e2
commit 84e9cd3a77
2 changed files with 26 additions and 26 deletions

View File

@ -41,56 +41,56 @@ Rect VisibleRect::getVisibleRect()
return s_visibleRect; return s_visibleRect;
} }
Vector2 VisibleRect::left() Vec2 VisibleRect::left()
{ {
lazyInit(); lazyInit();
return Vector2(s_visibleRect.origin.x, s_visibleRect.origin.y+s_visibleRect.size.height/2); return Vec2(s_visibleRect.origin.x, s_visibleRect.origin.y+s_visibleRect.size.height/2);
} }
Vector2 VisibleRect::right() Vec2 VisibleRect::right()
{ {
lazyInit(); lazyInit();
return Vector2(s_visibleRect.origin.x+s_visibleRect.size.width, s_visibleRect.origin.y+s_visibleRect.size.height/2); return Vec2(s_visibleRect.origin.x+s_visibleRect.size.width, s_visibleRect.origin.y+s_visibleRect.size.height/2);
} }
Vector2 VisibleRect::top() Vec2 VisibleRect::top()
{ {
lazyInit(); lazyInit();
return Vector2(s_visibleRect.origin.x+s_visibleRect.size.width/2, s_visibleRect.origin.y+s_visibleRect.size.height); return Vec2(s_visibleRect.origin.x+s_visibleRect.size.width/2, s_visibleRect.origin.y+s_visibleRect.size.height);
} }
Vector2 VisibleRect::bottom() Vec2 VisibleRect::bottom()
{ {
lazyInit(); lazyInit();
return Vector2(s_visibleRect.origin.x+s_visibleRect.size.width/2, s_visibleRect.origin.y); return Vec2(s_visibleRect.origin.x+s_visibleRect.size.width/2, s_visibleRect.origin.y);
} }
Vector2 VisibleRect::center() Vec2 VisibleRect::center()
{ {
lazyInit(); lazyInit();
return Vector2(s_visibleRect.origin.x+s_visibleRect.size.width/2, s_visibleRect.origin.y+s_visibleRect.size.height/2); return Vec2(s_visibleRect.origin.x+s_visibleRect.size.width/2, s_visibleRect.origin.y+s_visibleRect.size.height/2);
} }
Vector2 VisibleRect::leftTop() Vec2 VisibleRect::leftTop()
{ {
lazyInit(); lazyInit();
return Vector2(s_visibleRect.origin.x, s_visibleRect.origin.y+s_visibleRect.size.height); return Vec2(s_visibleRect.origin.x, s_visibleRect.origin.y+s_visibleRect.size.height);
} }
Vector2 VisibleRect::rightTop() Vec2 VisibleRect::rightTop()
{ {
lazyInit(); lazyInit();
return Vector2(s_visibleRect.origin.x+s_visibleRect.size.width, s_visibleRect.origin.y+s_visibleRect.size.height); return Vec2(s_visibleRect.origin.x+s_visibleRect.size.width, s_visibleRect.origin.y+s_visibleRect.size.height);
} }
Vector2 VisibleRect::leftBottom() Vec2 VisibleRect::leftBottom()
{ {
lazyInit(); lazyInit();
return s_visibleRect.origin; return s_visibleRect.origin;
} }
Vector2 VisibleRect::rightBottom() Vec2 VisibleRect::rightBottom()
{ {
lazyInit(); lazyInit();
return Vector2(s_visibleRect.origin.x+s_visibleRect.size.width, s_visibleRect.origin.y); return Vec2(s_visibleRect.origin.x+s_visibleRect.size.width, s_visibleRect.origin.y);
} }

View File

@ -8,15 +8,15 @@ class VisibleRect
public: public:
static cocos2d::Rect getVisibleRect(); static cocos2d::Rect getVisibleRect();
static cocos2d::Vector2 left(); static cocos2d::Vec2 left();
static cocos2d::Vector2 right(); static cocos2d::Vec2 right();
static cocos2d::Vector2 top(); static cocos2d::Vec2 top();
static cocos2d::Vector2 bottom(); static cocos2d::Vec2 bottom();
static cocos2d::Vector2 center(); static cocos2d::Vec2 center();
static cocos2d::Vector2 leftTop(); static cocos2d::Vec2 leftTop();
static cocos2d::Vector2 rightTop(); static cocos2d::Vec2 rightTop();
static cocos2d::Vector2 leftBottom(); static cocos2d::Vec2 leftBottom();
static cocos2d::Vector2 rightBottom(); static cocos2d::Vec2 rightBottom();
private: private:
static void lazyInit(); static void lazyInit();
static cocos2d::Rect s_visibleRect; static cocos2d::Rect s_visibleRect;