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); m_pModalViewController->viewDidAppear(); CAApplication::getApplication()->getTouchDispatcher()->setDispatchEventsFalse(); if (animated) { CAView* view = m_pModalViewController->getView(); DRect frame = view->getFrame(); frame.origin.y = frame.size.height; view->setFrame(frame); DRect endFrame = DRectZero; endFrame.size = view->getFrame().size; CAViewAnimation::beginAnimations("", NULL); CAViewAnimation::setAnimationDuration(0.25f); CAViewAnimation::setAnimationDelay(0.1f); CAViewAnimation::setAnimationCurve(CAViewAnimationCurveLinear); CAViewAnimation::setAnimationDidStopSelector(this, CAViewAnimation0_selector(CAWindow::presentEnd)); view->setFrame(endFrame); CAViewAnimation::commitAnimations(); } else { this->presentEnd(); } }
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 CAWindow::dismissModalViewController(bool animated) { CC_RETURN_IF(m_pModalViewController == NULL); if (m_pRootViewController) { m_pRootViewController->viewDidAppear(); } CAApplication::getApplication()->getTouchDispatcher()->setDispatchEventsFalse(); if (animated) { CAView* view = m_pModalViewController->getView(); DRect endFrame = view->getFrame(); endFrame.origin.y = endFrame.size.height; CAViewAnimation::beginAnimations("", NULL); CAViewAnimation::setAnimationDuration(0.25f); CAViewAnimation::setAnimationDelay(0.1f); CAViewAnimation::setAnimationCurve(CAViewAnimationCurveLinear); CAViewAnimation::setAnimationDidStopSelector(this, CAViewAnimation0_selector(CAWindow::dismissEnd)); view->setFrame(endFrame); CAViewAnimation::commitAnimations(); } else { this->dismissEnd(); } }
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(); } }