Example #1
0
CCRect LotteryRotateView::getViewRect()
{
    CCSize size = getPanelChild()->getContentSize();
    CCPoint screenPos = this->convertToWorldSpace(CCPointZero);
    
    float scaleX = this->getScaleX();
    float scaleY = this->getScaleY();
    
    for (CCNode *p = _parent; p != NULL; p = p->getParent()) {
        scaleX *= p->getScaleX();
        scaleY *= p->getScaleY();
    }
    
    if(scaleX<0.f) {
        screenPos.x += size.width*scaleX;
        scaleX = -scaleX;
    }
    
    if(scaleY<0.f) {
        screenPos.y += size.height*scaleY;
        scaleY = -scaleY;
    }

    return CCRectMake(getPanelChild()->getPositionX() - size.width/2, getPanelChild()->getPositionY() - size.height/2, size.width, size.height);
}
Example #2
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 #3
0
void APSScaleAction::saveNodeState() {
    APSGraphic *graphic = this->getTargetGraphic();
    if (graphic) {
        CCNode *node = graphic->getNode();
        this->m_startScale.x = node->getScaleX();
        this->m_startScale.y = node->getScaleY();
    }
}
Example #4
0
	void CCMenu::alignItemsVerticallyWithPadding(float padding)
	{
		float height = -padding;
		if (m_pChildren && m_pChildren->count() > 0)
		{
            CCObject* pObject = NULL;
            CCARRAY_FOREACH(m_pChildren, pObject)
            {
                CCNode* pChild = (CCNode*) pObject;
                if (pChild)
                {
                    height += pChild->getContentSize().height * pChild->getScaleY() + padding;
                }
            }
Example #5
0
void MDragDownView::updateRect()
{
    CCPoint worldPosition = this->convertToWorldSpace(CCPointZero);
    
    float fScaleX = this->getScaleX();
    float fScaleY = this->getScaleY();
    
    for (CCNode *p = m_pParent; p != NULL; p = p->getParent())
    {
        fScaleX *= p->getScaleX();
        fScaleY *= p->getScaleY();
    }
    
    if(fScaleX < 0.f)
    {
        worldPosition.x += m_viewSize.width * fScaleX;
        fScaleX = -fScaleX;
    }
    if(fScaleY < 0.f)
    {
        worldPosition.y += m_viewSize.height * fScaleY;
        fScaleY = -fScaleY;
    }
    
    m_viewRect.setRect(worldPosition.x,
                       worldPosition.y + (m_fViewMaxHeight - m_viewSize.height) * fScaleY,
                       m_viewSize.width * fScaleX,
                       m_viewSize.height * fScaleY);
    
    if (m_pDragBar)
    {
        auto dragSize = m_pDragBar->getContentSize();
        auto dragFixSize = CCSizeMake(dragSize.width * m_pDragBar->getScaleX() * fScaleX,
                                      dragSize.height * m_pDragBar->getScaleY() * fScaleY);
        float fWidth = dragFixSize.width < m_viewRect.size.width ? dragFixSize.width : m_viewRect.size.width;
        float fHeight = dragFixSize.height < m_viewRect.size.height ? dragFixSize.height : m_viewRect.size.height;
        m_dragBarRect.setRect(m_viewRect.origin.x + (m_viewRect.size.width-fWidth)*0.5,
                              m_viewRect.origin.y, fWidth, fHeight);
    }
    /*
    CCLog("[%.0f, %.0f, %.0f, %.0f], [%.0f, %.0f, %.0f, %.0f]",
          m_viewRect.origin.x, m_viewRect.origin.y,
          m_viewRect.size.width, m_viewRect.size.height,
          m_dragBarRect.origin.x, m_dragBarRect.origin.y,
          m_dragBarRect.size.width, m_dragBarRect.size.height);//*/
}
Example #6
0
// Sets the value of originalScale from the current parent.
void CCNodeAdornmentScaler::setOriginalScaleFromParent()
{
	CCNode* p = getParent();
	if ( p )
		_originalScale = CCSizeMake(p->getScaleX(), p->getScaleY());
}
void CCINode::showFrame(){
    //std::vector<CCIMovieTag *> tags = this->swfMovie->getTags();

    while (true) {
        CCIMovieTag * tag = NULL;
        
        if (currentTag<tags.size()) {
            tag = tags[currentTag++];
        }else{
            
            this->removeAllChildrenWithCleanup(true);
            //this->stop();
            currentTag = 0;
            currentFrame = 0;
            break;
        }
        if(tag->getTagType()==TagTypePlaceObject||tag->getTagType()==TagTypePlaceObject2||tag->getTagType()==TagTypePlaceObject3){
            CCIPlaceObject * placeTag = (CCIPlaceObject *)tag;
            
            int charactorId = placeTag->getCharacterId();
            int depth = placeTag->getDepth();
            
            
            CCIPlaceObject2 * placeTag2 = NULL;
            if (tag->getTagType()==TagTypePlaceObject2||tag->getTagType()==TagTypePlaceObject3) {
                placeTag2 = (CCIPlaceObject2 *)tag;
            }
            
            CCNode * node;
            if (!placeTag2||placeTag2->placeType==PlaceObjectTypeNew) {
                //place1 or placetag2 new
                node = (CCNode *)this->nodes->objectForKey(charactorId);
                if (node&&node->getParent()==NULL) {
                    this->addChild(node, depth, depth);
                    CCInteger * nodeType = (CCInteger *)node->getUserObject();
                    if (nodeType->getValue()==NodeTypeCCINode) {
                        CCINode * ccinode = (CCINode *)node;
                        ccinode->play();
                    }
                }
            }else if(placeTag2&&placeTag2->placeType==PlaceObjectTypeModify){
                node = (CCNode *)this->getChildByTag(depth);
            }else if(placeTag2&&placeTag2->placeType==PlaceObjectTypeReplace){
                
                CCNode * newNode = (CCNode *)this->nodes->objectForKey(charactorId);
                
                node = (CCNode *)this->getChildByTag(depth);
                if (node) {
                    if (newNode) {
                        //get last transform matrix
                        newNode->setPosition(node->getPosition());
                        newNode->setScaleX(node->getScaleX());
                        newNode->setScaleY(node->getScaleY());
                        newNode->setSkewX(node->getSkewX());
                        newNode->setSkewY(node->getSkewY());
                    }
                    CCInteger * nodeType = (CCInteger *)node->getUserObject();
                    if (nodeType->getValue()==NodeTypeCCINode) {
                        CCINode * ccinode = (CCINode *)node;
                        ccinode->stop();
                    }
                    node->removeFromParentAndCleanup(true);
                }
                
                node = newNode;
                if (node&&node->getParent()==NULL) {
                    this->addChild(node, depth, depth);
                    CCInteger * nodeType = (CCInteger *)node->getUserObject();
                    if (nodeType->getValue()==NodeTypeCCINode) {
                        CCINode * ccinode = (CCINode *)node;
                        ccinode->play();
                    }
                }
                
            }
            
            if (node) {
                CCIMatrix * matrix = placeTag->getMatrix();
                if (matrix) {
                    int x = matrix->getTranslateX();
                    int y = matrix->getTranslateY();
                    
                    node->setPosition(this->swfMovie->getHeader()->getBounds()->convertToCCSpace(x, y));
                    //restore
                    float scaleX = 1.0;
                    float scaleY = 1.0;
                    node->setScaleX(1);
                    node->setScaleY(1);
                    node->setSkewX(0);
                    node->setSkewY(0);
                    
                    if (matrix->HasScale) {
                        scaleX = matrix->getScaleX();
                        scaleY = matrix->getScaleY();
                        node->setScaleX(scaleX);
                        node->setScaleY(scaleY);
                    }
                    if (matrix->HasRotate) {
                        float skewX = matrix->getSkewX();
                        float skewY = matrix->getSkewY();
                        
                        this->applySkew(node, skewX, skewY,false);
                    }
                    
                }
                CCICxform * colorTransform = placeTag->getColorTransform();
                
                int red = 255;
                int green = 255;
                int blue = 255;
                int alpha = 255;
                
                if (colorTransform) {
                    if (colorTransform->HasMultTerms) {
                        red = colorTransform->RedMultTerm-1;
                        green = colorTransform->GreenMultTerm-1;
                        blue = colorTransform->BlueMultTerm-1;
                        if (colorTransform->hasAlpha()) {
                            CCICxformWithAlpha * cxformAlpha = (CCICxformWithAlpha *)colorTransform;
                            alpha = cxformAlpha->AlphaMultTerm-1;
                        }
                    }
                    
                    if (colorTransform->HasAddTerms) {
                        //TODO no add term
                    }
                    if (red==-1) {
                        red = 0;
                    }
                    if (green ==-1) {
                        green = 0;
                    }
                    if (blue == -1) {
                        blue = 0;
                    }
                    if (alpha ==-1) {
                        alpha = 0;
                    }
                }
                
                this->applyColorTransform(node, ccc4(red, green, blue, alpha));
                
                if (tag->getTagType()==TagTypePlaceObject3) {
                    //check filters
                    CCIPlaceObject3 * placeTag3 = (CCIPlaceObject3 *)tag;
                    
                    CCIFilterList * filterList = placeTag3->getFilterList();
                        
                    if (filterList) {
                        //apply filter list
                        for (int i=0; i<filterList->NumberOfFilters; i++) {
                            //CCIFilter * filter = filterList->Filter[i];
                            
                        }
                    }
                }
            }
        }else if (tag->getTagType()==TagTypeRemoveObject||tag->getTagType()==TagTypeRemoveObject2){
            CCIRemoveObject * removeTag = (CCIRemoveObject *)tag;
            int depth = removeTag->getDepth();
            CCNode * node = this->getChildByTag(depth);
            if (node) {
                CCInteger * nodeType = (CCInteger *)node->getUserObject();
                if (nodeType->getValue()==NodeTypeCCINode) {
                    CCINode * ccinode = (CCINode *)node;
                    ccinode->stop();
                }
                node->removeFromParentAndCleanup(true);
            }
        }else if(tag->getTagType()==TagTypeFrameLabel){
            if (isPlayingFrameLabel&&currentTag!=frameLabelIndex) {
                currentTag = frameLabelIndex;
                currentFrame = 0;
                //this->removeAllChildrenWithCleanup(true);
                break;
            }
        }else if(tag->getTagType()==TagTypeShowFrame){
            if (this->delegate) {
                this->delegate->didEnterFrame(currentFrame, this->frameLabel);
            }
            currentFrame++;
            
            break;
        }
    }
}