void UIWidget::copyProperties(UIWidget *widget) { setEnabled(widget->isEnabled()); setVisible(widget->isVisible()); setBright(widget->isBright()); setTouchEnabled(widget->isTouchEnabled()); m_bTouchPassedEnabled = false; setZOrder(widget->getZOrder()); setUpdateEnabled(widget->isUpdateEnabled()); setTag(widget->getTag()); setName(widget->getName()); setActionTag(widget->getActionTag()); m_bIgnoreSize = widget->m_bIgnoreSize; m_tSize = widget->m_tSize; m_tCustomSize = widget->m_tCustomSize; copySpecialProperties(widget); m_eSizeType = widget->getSizeType(); m_tSizePercent = widget->m_tSizePercent; m_ePositionType = widget->m_ePositionType; m_tPositionPercent = widget->m_tPositionPercent; setPosition(widget->getPosition()); setAnchorPoint(widget->getAnchorPoint()); setScaleX(widget->getScaleX()); setScaleY(widget->getScaleY()); setRotation(widget->getRotation()); setRotationX(widget->getRotationX()); setRotationY(widget->getRotationY()); setFlipX(widget->isFlipX()); setFlipY(widget->isFlipY()); setColor(widget->getColor()); setOpacity(widget->getOpacity()); setCascadeOpacityEnabled(widget->isCascadeOpacityEnabled()); setCascadeColorEnabled(widget->isCascadeColorEnabled()); onSizeChanged(); }
bool CCControl::init() { if (CCNode::init()) { //this->setTouchEnabled(true); //m_bIsTouchEnabled=true; // Initialise instance variables m_eState=CCControlStateNormal; setCascadeOpacityEnabled(true); setCascadeColorEnabled(true); setEnabled(true); setSelected(false); setHighlighted(false); // Initialise the tables m_pDispatchTable = new CCDictionary(); // Initialise the mapHandleOfControlEvents m_mapHandleOfControlEvent.clear(); return true; } else { return false; } }
void Widget::copyProperties(Widget *widget) { setEnabled(widget->isEnabled()); setVisible(widget->isVisible()); setBright(widget->isBright()); setTouchEnabled(widget->isTouchEnabled()); _touchPassedEnabled = false; setLocalZOrder(widget->getLocalZOrder()); setTag(widget->getTag()); setName(widget->getName()); setActionTag(widget->getActionTag()); _ignoreSize = widget->_ignoreSize; _size = widget->_size; _customSize = widget->_customSize; copySpecialProperties(widget); _sizeType = widget->getSizeType(); _sizePercent = widget->_sizePercent; _positionType = widget->_positionType; _positionPercent = widget->_positionPercent; setPosition(widget->getPosition()); setAnchorPoint(widget->getAnchorPoint()); setScaleX(widget->getScaleX()); setScaleY(widget->getScaleY()); setRotation(widget->getRotation()); setRotationX(widget->getRotationX()); setRotationY(widget->getRotationY()); setFlipX(widget->isFlipX()); setFlipY(widget->isFlipY()); setColor(widget->getColor()); setOpacity(widget->getOpacity()); setCascadeOpacityEnabled(widget->isCascadeOpacityEnabled()); setCascadeColorEnabled(widget->isCascadeColorEnabled()); onSizeChanged(); }
void S9CascadeOpacityAndColor::onEnter() { S9SpriteTestDemo::onEnter(); auto winSize = Director::getInstance()->getWinSize(); float x = winSize.width / 2; float y = 0 + (winSize.height / 2); auto rgba = Layer::create(); rgba->setCascadeColorEnabled(true); rgba->setCascadeOpacityEnabled(true); this->addChild(rgba); log("S9CascadeOpacityAndColor ..."); auto blocks_scaled_with_insets = Scale9Sprite::createWithSpriteFrameName("blocks9r.png"); log("... created"); blocks_scaled_with_insets->setPosition(Vec2(x, y)); log("... setPosition"); rgba->addChild(blocks_scaled_with_insets); auto actions = Sequence::create(FadeIn::create(1), TintTo::create(1, 0, 255, 0), TintTo::create(1, 255, 255, 255), FadeOut::create(1), NULL); auto repeat = RepeatForever::create(actions); rgba->runAction(repeat); log("this->addChild"); log("... S9CascadeOpacityAndColor done."); }
Scene* BattleScene::createScene() { auto scene = Scene::create(); auto layer = BattleScene::create(); layer->setCascadeColorEnabled(true); scene->addChild(layer); return scene; }
bool CProgressBar::init() { setCascadeColorEnabled(true); setCascadeOpacityEnabled(true); setAnchorPoint(CCWIDGET_BASIC_DEFAULT_ANCHOR_POINT); setContentSize(CCWIDGET_BASIC_DEFAULT_CONTENT_SIZE); return true; }
//------------------------------------------------------------------------- bool FKCW_UIWidget_ControlView::init() { setCascadeColorEnabled(true); setCascadeOpacityEnabled(true); setAnchorPoint(FKCW_UIWIDGET_BASIC_DEFAULT_ANCHOR_POINT); setContentSize(FKCW_UIWIDGET_BASIC_DEFAULT_CONTENT_SIZE); return true; }
//------------------------------------------------------------------------- bool FKCW_UIWidget_Layout::init() { setCascadeColorEnabled(true); setCascadeOpacityEnabled(true); setContentSize(FKCW_UIWIDGET_LAYOUT_DEFAULT_CONTENT_SIZE); setAnchorPoint(FKCW_UIWIDGET_LAYOUT_DEFAULT_ANCHOR_POINT); setPosition(CCPointZero); return true; }
bool CLayout::init() { setCascadeColorEnabled(true); setCascadeOpacityEnabled(true); setContentSize(CCWIDGET_LAYOUT_DEFAULT_CONTENT_SIZE); setAnchorPoint(CCWIDGET_LAYOUT_DEFAULT_ANCHOR_POINT); setPosition(Point::ZERO); return true; }
bool MenuItemLabel::initWithLabel(Node* label, const ccMenuCallback& callback) { MenuItem::initWithCallback(callback); _originalScale = 1.0f; _colorBackup = Color3B::WHITE; setDisabledColor(Color3B(126,126,126)); this->setLabel(label); setCascadeColorEnabled(true); setCascadeOpacityEnabled(true); return true; }
bool CCMenuItemLabel::initWithLabel(CCNode* label, CCObject* target, SEL_MenuHandler selector) { CCMenuItem::initWithTarget(target, selector); m_fOriginalScale = 1.0f; m_tColorBackup = ccWHITE; setDisabledColor(ccc3(126,126,126)); this->setLabel(label); setCascadeColorEnabled(true); setCascadeOpacityEnabled(true); return true; }
bool Widget::init() { if (Node::init()) { initRenderer(); setCascadeColorEnabled(true); setCascadeOpacityEnabled(true); setBright(true); ignoreContentAdaptWithSize(true); setAnchorPoint(Point(0.5f, 0.5f)); return true; } return false; }
bool MenuItemToggle::initWithItem(MenuItem *item) { MenuItem::initWithCallback((const ccMenuCallback&)nullptr); if (item) { _subItems.pushBack(item); } _selectedIndex = UINT_MAX; this->setSelectedIndex(0); setCascadeColorEnabled(true); setCascadeOpacityEnabled(true); return true; }
bool LayerRGBA::init() { if (Layer::init()) { m_cDisplayedOpacity = m_cRealOpacity = 255; m_tDisplayedColor = m_tRealColor = Color3B::WHITE; setCascadeOpacityEnabled(false); setCascadeColorEnabled(false); return true; } else { return false; } }
static void setEnableRecursiveCascading(Node* node, bool enable) { auto rgba = dynamic_cast<RGBAProtocol*>(node); if (rgba) { rgba->setCascadeColorEnabled(enable); rgba->setCascadeOpacityEnabled(enable); } Object* obj; auto children = node->getChildren(); CCARRAY_FOREACH(children, obj) { auto child = static_cast<Node*>(obj); setEnableRecursiveCascading(child, enable); }
NS_CC_WIDGET_BEGIN CControlView::CControlView() : m_pBaseBoard(NULL) , m_pJoystick(NULL) , m_fRadius(100.0f) , m_tCenterPoint(CCPointZero) , m_bRelocateWithAnimation(true) , m_bAnimationUpdate(false) , m_bExecuteEventUpdate(false) , m_tLastPoint(CCPointZero) { setThisObject(this); setCascadeColorEnabled(true); setCascadeOpacityEnabled(true); }
bool CCLayerRGBA::init() { if (CCLayer::init()) { _displayedOpacity = _realOpacity = 255; _displayedColor = _realColor = ccWHITE; setCascadeOpacityEnabled(false); setCascadeColorEnabled(false); return true; } else { return false; } }
NS_CC_WIDGET_BEGIN CCheckBox::CCheckBox() : m_pNormal(NULL) , m_pNormalPress(NULL) , m_pChecked(NULL) , m_pCheckedPress(NULL) , m_pDisabledNormal(NULL) , m_pDisabledChecked(NULL) { setThisObject(this); setCascadeColorEnabled(true); setCascadeOpacityEnabled(true); setAnchorPoint(CCWIDGET_BASIC_DEFAULT_ANCHOR_POINT); setContentSize(CCWIDGET_BASIC_DEFAULT_CONTENT_SIZE); }
bool Scale9Sprite::init(cocos2d::Texture2D *tex, cocos2d::Rect rect, cocos2d::Rect capInsets) { if (!DynamicBatchNode::init(tex)) { return false; } if (rect.equals(cocos2d::Rect::ZERO)) { rect.size = getTexture()->getContentSize(); } _textureRect = rect; _capInsets = capInsets; _contentSize = _textureRect.size; setCascadeColorEnabled(true); setCascadeOpacityEnabled(true); return true; }
bool MenuItemSprite::initWithNormalSprite(Node* normalSprite, Node* selectedSprite, Node* disabledSprite, const ccMenuCallback& callback) { MenuItem::initWithCallback(callback); setNormalImage(normalSprite); setSelectedImage(selectedSprite); setDisabledImage(disabledSprite); if(_normalImage) { this->setContentSize(_normalImage->getContentSize()); } setCascadeColorEnabled(true); setCascadeOpacityEnabled(true); return true; }
bool CCMenuItemToggle::initWithItem(CCMenuItem *item) { CCMenuItem::initWithTarget(NULL, NULL); setSubItems(CCArray::create()); if (item) { m_pSubItems->addObject(item); } m_uSelectedIndex = UINT_MAX; this->setSelectedIndex(0); setCascadeColorEnabled(true); setCascadeOpacityEnabled(true); return true; }
bool CCMenuItemSprite::initWithNormalSprite(CCNode* normalSprite, CCNode* selectedSprite, CCNode* disabledSprite, CCObject* target, SEL_MenuHandler selector) { CCMenuItem::initWithTarget(target, selector); setNormalImage(normalSprite); setSelectedImage(selectedSprite); setDisabledImage(disabledSprite); if(m_pNormalImage) { this->setContentSize(m_pNormalImage->getContentSize()); } setCascadeColorEnabled(true); setCascadeOpacityEnabled(true); return true; }
// LayerTestCascadingOpacityB void LayerTestCascadingOpacityB::onEnter() { LayerTest::onEnter(); auto s = Director::getInstance()->getWinSize(); auto layer1 = LayerColor::create(Color4B(192, 0, 0, 255), s.width, s.height/2); layer1->setCascadeColorEnabled(false); layer1->setPosition( Vec2(0, s.height/2)); auto sister1 = Sprite::create("Images/grossinis_sister1.png"); auto sister2 = Sprite::create("Images/grossinis_sister2.png"); auto label = Label::createWithBMFont("fonts/bitmapFontTest.fnt", "Test"); layer1->addChild(sister1); layer1->addChild(sister2); layer1->addChild(label); this->addChild( layer1, 0, kTagLayer); sister1->setPosition( Vec2( s.width*1/3, 0)); sister2->setPosition( Vec2( s.width*2/3, 0)); label->setPosition( Vec2( s.width/2, 0)); layer1->runAction( RepeatForever::create( Sequence::create( FadeTo::create(4, 0), FadeTo::create(4, 255), DelayTime::create(1), nullptr))); sister1->runAction( RepeatForever::create( Sequence::create( FadeTo::create(2, 0), FadeTo::create(2, 255), FadeTo::create(2, 0), FadeTo::create(2, 255), DelayTime::create(1), nullptr))); // Enable cascading in scene setEnableRecursiveCascading(this, true); }
ScrollViewBar::ScrollViewBar(ScrollView* parent, ScrollView::Direction direction): _parent(parent), _direction(direction), _upperHalfCircle(nullptr), _lowerHalfCircle(nullptr), _body(nullptr), _opacity(255 * DEFAULT_SCROLLBAR_OPACITY), _marginFromBoundary(DEFAULT_MARGIN), _marginForLength(DEFAULT_MARGIN), _touching(false), _autoHideEnabled(true), _autoHideTime(DEFAULT_AUTO_HIDE_TIME), _autoHideRemainingTime(0) { CCASSERT(parent != nullptr, "Parent scroll view must not be null!"); CCASSERT(direction != ScrollView::Direction::BOTH, "Illegal scroll direction for scroll bar!"); setCascadeColorEnabled(true); setCascadeOpacityEnabled(true); }
bool Widget::init() { if (CCNodeRGBA::init()) { _widgetChildren = CCArray::create(); CC_SAFE_RETAIN(_widgetChildren); _layoutParameterDictionary = CCDictionary::create(); CC_SAFE_RETAIN(_layoutParameterDictionary); _nodes = CCArray::create(); CC_SAFE_RETAIN(_nodes); initRenderer(); setCascadeColorEnabled(true); setCascadeOpacityEnabled(true); setBright(true); ignoreContentAdaptWithSize(true); setAnchorPoint(CCPoint(0.5f, 0.5f)); return true; } return false; }
NS_CC_WIDGET_BEGIN CProgressBar::CProgressBar() : m_pProgressSprite(NULL) , m_eDirection(eProgressBarDirectionLeftToRight) , m_nMaxValue(100) , m_nMinValue(0) , m_nValue(0) , m_bFirstTick(true) , m_fLapsed(0.0f) , m_fDuration(0.0f) , m_nToValue(0) , m_nFromValue(0) , m_bProgressing(false) , m_tProgressSize(CCSizeZero) , m_tCenterPoint(CCPointZero) , m_pBackgroundImage(NULL) { setCascadeColorEnabled(true); setCascadeOpacityEnabled(true); }
bool DBCCArmatureNode::initWithDBCCArmature(DBCCArmature *armature, WorldClock *clock) { if (armature != nullptr) { _armature = armature; _clock = clock; if (clock) { clock->add(this); }else { scheduleUpdate(); } addChild(armature->getCCDisplay()); setCascadeOpacityEnabled(true); setCascadeColorEnabled(true); return true; } return false; }
bool ScrollMenu::initWithEffectiveRange(cocos2d::Vec2 leftDownPos, cocos2d::Size rectSize) { if (!Layer::init()) return false; _enabled = true; // menu in the center of the screen Size s = Director::getInstance()->getWinSize(); this->ignoreAnchorPointForPosition(true); setAnchorPoint(Vec2(0.5f, 0.5f)); this->setContentSize(s); setPosition(Vec2(s.width / 2, s.height / 2)); _selectedItem = nullptr; _state = Menu::State::WAITING; // enable cascade color and opacity on menus setCascadeColorEnabled(true); setCascadeOpacityEnabled(true); auto touchListener = EventListenerTouchOneByOne::create(); // here we do not swallow the touches, so parent tableview will get them touchListener->setSwallowTouches(false); touchListener->onTouchBegan = CC_CALLBACK_2(ScrollMenu::onTouchBegan, this); touchListener->onTouchMoved = CC_CALLBACK_2(ScrollMenu::onTouchMoved, this); touchListener->onTouchEnded = CC_CALLBACK_2(ScrollMenu::onTouchEnded, this); touchListener->onTouchCancelled = CC_CALLBACK_2(ScrollMenu::onTouchCancelled, this); _eventDispatcher->addEventListenerWithSceneGraphPriority(touchListener, this); m_iEffectiveRange.setRect(leftDownPos.x, leftDownPos.y, rectSize.width, rectSize.height); return true; }
bool CCMenuItemSprite::initWithNormalSprite(CCNode* normalSprite, CCNode* selectedSprite, CCNode* disabledSprite, CCObject* target, SEL_MenuHandler selector) { CCMenuItem::initWithTarget(target, selector); setNormalImage(normalSprite); setSelectedImage(selectedSprite); setDisabledImage(disabledSprite); if(m_pNormalImage) { this->setContentSize(m_pNormalImage->getContentSize()); // #HLP_BEGIN // #resource_scale_fix if(getTag() != TAG_INTERNET_MENU_ITEM_IMAGE){ setScale(getScale() * CC_CONTENT_SCALE_FACTOR() / CC_RESOURCE_SCALE_FACTOR()); } // #HLP_END } setCascadeColorEnabled(true); setCascadeOpacityEnabled(true); return true; }
void NovelLayer::updateSpeechBalloon(std::shared_ptr<NovelAction> action) { int actionIdx = this->beginAction(); auto targetBalloon = NovelBalloon::create(action, _balloonIdx, [this, actionIdx]() { this->_touchAbsorber = NULL; this->completeAction(actionIdx); if (_debugSkip == 1) { this->endScene(); } }); targetBalloon->setCascadeColorEnabled(true); _balloonIdx++; float offset = 0.0f; if (action->getTarget() == NovelAction::Target::Right) { offset = -50.0f; } else if (action->getTarget() == NovelAction::Target::Left) { offset = 50.0f; } auto currentPos = targetBalloon->getPosition(); currentPos.x -= offset; targetBalloon->setPosition(currentPos); targetBalloon->runAction(EaseExponentialOut::create(MoveBy::create(0.15f, Point(offset, 0)))); targetBalloon->playBalloonSpecificAnimation(); this->_touchAbsorber = targetBalloon; if (action->getTarget() == NovelAction::Target::Right) { if (this->_rightBalloon) { this->_rightBalloon->removeFromParent(); } if (this->_defaultBalloon) { this->_defaultBalloon->removeFromParent(); } if (this->_leftBalloon) { this->_leftBalloon->setOpacity(128); this->_rightNode->setZOrder(2); this->_leftNode->setZOrder(1); } _rightNode->addChild(targetBalloon); this->_rightBalloon = targetBalloon; } else if (action->getTarget() == NovelAction::Target::Left) { if (this->_leftBalloon) { this->_leftBalloon->removeFromParent(); } if (this->_defaultBalloon) { this->_defaultBalloon->removeFromParent(); } if (this->_rightBalloon) { this->_rightBalloon->setOpacity(128); this->_rightNode->setZOrder(1); this->_leftNode->setZOrder(2); } _leftNode->addChild(targetBalloon); this->_leftBalloon = targetBalloon; } else if (action->getTarget() == NovelAction::Target::Narration) { if (this->_leftBalloon) { this->_leftBalloon->setOpacity(128); } if (this->_rightBalloon) { this->_rightBalloon->setOpacity(128); } if (this->_defaultBalloon) { this->_defaultBalloon->removeFromParent(); } this->_defaultBalloon = targetBalloon; this->addChild(targetBalloon); } }