Search code examples
cocos2d-iphonevisiblecocos2d-x

Cocos2dx visible area


how can I find the visible region of the layer, preferably in the form of CCRect because my sprite to move only in the visible region, regardless of what part of the background image is visible


Solution

  • It would be useful have to qualify "visible region" a bit further and tell us more about your CCLayer/CCNode hierarchical setup.

    That said, I assume you have tried things like

    CCSize size = CCDirector::sharedDirector()->getWinSize();
    

    which gives you the screen frame, or

    layer->getPosition()    
    layer->getContentSize()
    

    on your layer to get its boundaries/origin, or even

    layer->boundingBox()
    

    which gives you a CCRect?