void UtilManager::toast(string text, CAViewController* object) { CAApplication::getApplication()->getRootWindow()->removeSubviewByTag(TOAST_VIEW_TAG); CCSize winSize = CAApplication::getApplication()->getWinSize(); //CAView *back = CAView::createWithCenter(CCRect(winSize.width*0.5, winSize.height*0.5, _dip(winSize.width)*0.3, _dip(winSize.height)*0.3)); CAView *back = CAView::createWithCenter(CCRect(winSize.width*0.5, winSize.height*0.5, 180 * getScale(), 30 * getScale())); back->setTag(TOAST_VIEW_TAG); back->setColor(ccc4(31, 31, 31, 200));//40 CALabel *title = CALabel::createWithCenter(CADipRect(_dip(back->getBounds().size.width*0.5), _dip(back->getBounds().size.height*0.5), 180 * getScale(), 30 * getScale())); // title->setText(UTF8ToGBK::transferToGbk(text)); title->setText(text); //title->setText("sssss"); // title->setFontName(getChineseFont()); title->setColor(CAColor_white); title->setTextAlignment(CATextAlignmentCenter); title->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter); title->setFontSize(_px(15)); back->addSubview(title); //CAApplication::getApplication()->getRootWindow()->getRootViewController()->getView()->addSubview(back); back->runAction(CCFadeOut::create(1)); //CAApplication::getApplication()->getRootWindow()->addSubview(back); object->getView()->addSubview(back); //CCLog("%s", get_date_now().c_str()); scheduleOnce(schedule_selector(UtilManager::removeToast), this, TOAST_TIME); }
void CAWindow::presentModalViewController(CAViewController* controller, bool animated) { CC_RETURN_IF(controller == NULL); CC_RETURN_IF(m_pModalViewController); CC_SAFE_RETAIN(controller); m_pModalViewController = controller; m_pModalViewController->addViewFromSuperview(this); m_pModalViewController->getView()->setZOrder(CAWindowZoderCenter); if (animated) { CAView* view = m_pModalViewController->getView(); CCRect frame = view->getFrame(); frame.origin.y = frame.size.height; view->setFrame(frame); CCRect endFrame = CCRectZero; endFrame.size = view->getFrame().size; CCCallFunc* start = CCCallFunc::create(this, callfunc_selector(CAWindow::presentStart)); CCCallFunc* end = CCCallFunc::create(this, callfunc_selector(CAWindow::presentEnd)); CCDelayTime* delayTime = CCDelayTime::create(0.1f); CCFrameTo* frameTo = CCFrameTo::create(0.3f, endFrame); CCEaseSineOut* easeBack = CCEaseSineOut::create(frameTo); CCSequence* allActions = CCSequence::create(start, delayTime, easeBack, end, NULL); view->runAction(allActions); } }
void CCTransitionFade :: onEnter() { CCTransitionScene::onEnter(); CCSize size = CCDirector::sharedDirector()->getWinSize(); CAView* l = CAView::createWithFrame(CCRect(0, 0, size.width, size.height)); l->setColor(ccc3(m_tColor.r, m_tColor.g, m_tColor.b)); l->setOpacity(m_tColor.a); m_pInScene->setVisible(false); l->setTag(kSceneFade); insertSubview(l, 2); CAView* f = getSubviewByTag(kSceneFade); CCActionInterval* a = (CCActionInterval *)CCSequence::create ( CCFadeIn::create(m_fDuration/2), CCCallFunc::create(this, callfunc_selector(CCTransitionScene::hideOutShowIn)),//CCCallFunc::create:self selector:@selector(hideOutShowIn)], CCFadeOut::create(m_fDuration/2), CCCallFunc::create(this, callfunc_selector(CCTransitionScene::finish)), //:self selector:@selector(finish)], NULL ); f->runAction(a); }
void CAWindow::dismissModalViewController(bool animated) { CC_RETURN_IF(m_pModalViewController == NULL); if (animated) { CAView* view = m_pModalViewController->getView(); CCRect endFrame = view->getFrame(); endFrame.origin.y = endFrame.size.height; CCCallFunc* start = CCCallFunc::create(this, callfunc_selector(CAWindow::dismissStart)); CCCallFunc* end = CCCallFunc::create(this, callfunc_selector(CAWindow::dismissEnd)); CCFrameTo* frameTo = CCFrameTo::create(0.3f, endFrame); CCEaseSineIn* easeBack = CCEaseSineIn::create(frameTo); CCSequence* allActions = CCSequence::create(start, easeBack, end, NULL); view->runAction(allActions); } else { this->dismissEnd(); } }