#include "VisibleRect.h" Rect VisibleRect::s_visibleRect; void VisibleRect::lazyInit() { if (s_visibleRect.size.width == 0.0f && s_visibleRect.size.height == 0.0f) { EGLView* pEGLView = EGLView::sharedOpenGLView(); s_visibleRect.origin = pEGLView->getVisibleOrigin(); s_visibleRect.size = pEGLView->getVisibleSize(); } } Rect VisibleRect::getVisibleRect() { lazyInit(); return CCRectMake(s_visibleRect.origin.x, s_visibleRect.origin.y, s_visibleRect.size.width, s_visibleRect.size.height); } Point VisibleRect::left() { lazyInit(); return ccp(s_visibleRect.origin.x, s_visibleRect.origin.y+s_visibleRect.size.height/2); } Point VisibleRect::right() { lazyInit(); return ccp(s_visibleRect.origin.x+s_visibleRect.size.width, s_visibleRect.origin.y+s_visibleRect.size.height/2); } Point VisibleRect::top() { lazyInit(); return ccp(s_visibleRect.origin.x+s_visibleRect.size.width/2, s_visibleRect.origin.y+s_visibleRect.size.height); } Point VisibleRect::bottom() { lazyInit(); return ccp(s_visibleRect.origin.x+s_visibleRect.size.width/2, s_visibleRect.origin.y); } Point VisibleRect::center() { lazyInit(); return ccp(s_visibleRect.origin.x+s_visibleRect.size.width/2, s_visibleRect.origin.y+s_visibleRect.size.height/2); } Point VisibleRect::leftTop() { lazyInit(); return ccp(s_visibleRect.origin.x, s_visibleRect.origin.y+s_visibleRect.size.height); } Point VisibleRect::rightTop() { lazyInit(); return ccp(s_visibleRect.origin.x+s_visibleRect.size.width, s_visibleRect.origin.y+s_visibleRect.size.height); } Point VisibleRect::leftBottom() { lazyInit(); return s_visibleRect.origin; } Point VisibleRect::rightBottom() { lazyInit(); return ccp(s_visibleRect.origin.x+s_visibleRect.size.width, s_visibleRect.origin.y); }