CCRect UIWidget::getRelativeRect()
{
    CCNode* validNode = getValidNode();
    float width = 0.0f;
    float height = 0.0f;
    float anchorPointX = 0.0f;
    float anchorPointY = 0.0f;
    CCSize nodeSize = validNode->getContentSize();
    width = nodeSize.width*getScaleX();
    height = nodeSize.height*getScaleY();
    CCPoint nodeAnchorPoint = validNode->getAnchorPoint();
    anchorPointX = nodeAnchorPoint.x;
    anchorPointY = nodeAnchorPoint.y;
    switch (m_WidgetType)
    {
        case WidgetTypeWidget:
            m_relativeRect.origin.x = getPosition().x - width * anchorPointX;
            m_relativeRect.origin.y = getPosition().y - height * anchorPointY;
            break;
        case WidgetTypeContainer:
            m_relativeRect.origin.x = getPosition().x;
            m_relativeRect.origin.y = getPosition().y;
            break;
    }
    m_relativeRect.size.width = width;
    m_relativeRect.size.height = height;
    return m_relativeRect;
}
Example #2
0
void HRootLayer::relayoutAsVertical(CCArray *nodes, CCPoint basePos, int interval) {
    for (int i = 0; i < nodes->count(); ++i) {
        CCNode *node = (CCNode *)nodes->objectAtIndex(i);
        node->setPosition(CCPointMake(basePos.x, basePos.y + node->getAnchorPoint().y * node->getContentSize().height));
        basePos.y += node->getContentSize().height + interval;
    }
}
Example #3
0
void HRootLayer::relayoutAsHorizontal(CCArray *nodes, CCPoint basePos, int interval) {
    for (int i = 0; i < nodes->count(); ++i) {
        CCNode *node = (CCNode *)nodes->objectAtIndex(i);
        node->setPosition(CCPointMake(basePos.x + node->getAnchorPoint().x * node->getContentSize().width * node->getScaleX(), basePos.y));
        basePos.x += node->getContentSize().width * node->getScaleX() + interval;
    }
}
Example #4
0
void CCBClippingNode::visit(){
    
    CCNode* hock = this->getChildByTag(htag);
    if (hock==NULL) {
        getStencil()->setPosition(0, 0);
        getStencil()->setScaleX(1);
        getStencil()->setScaleY(1);
        getStencil()->setRotationX(0);
        getStencil()->setRotationY(0);
        getStencil()->setSkewX(0);
        getStencil()->setSkewY(0);
        getStencil()->setAnchorPoint(ccp(0.5, 0.5));
    }else{
        getStencil()->setPosition(hock->getPositionX(),hock->getPositionY());
        getStencil()->setScaleX(hock->getScaleX());
        getStencil()->setScaleY(hock->getScaleY());
        getStencil()->setRotationX(hock->getRotationX());
        getStencil()->setRotationY(hock->getRotationY());
        getStencil()->setSkewX(hock->getSkewX());
        getStencil()->setSkewY(hock->getSkewY());
        getStencil()->setAnchorPoint(hock->getAnchorPoint());
    }
    
    CCClippingNode::visit();
}
Example #5
0
void E002_C010_P230::_setPositionOutParent(CCNode* child, CCNode* newParent)
{
    CCNode* parent = (CCNode*)child->getParent();
    if (parent && child) {
    
        child->retain();
        
        CCSize parentSize = parent->getContentSize();
        CCPoint parentAnchor = parent->getAnchorPoint();
        
        float posX =  parent->getPositionX() - parentSize.width*parentAnchor.x + child->getPositionX();
        float posY =  parent->getPositionY() - parentSize.height*parentAnchor.y + child->getPositionY();
    
        child->removeFromParentAndCleanup(false);
        child->setPosition(ccp(posX, posY));
        this->addChild(child);
        
        child->release();
    }
    
}