本文整理汇总了C++中CCSet类的典型用法代码示例。如果您正苦于以下问题:C++ CCSet类的具体用法?C++ CCSet怎么用?C++ CCSet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CCSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ccTouchBegan
bool ScrollMenu::ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent)
{
CCSet set;
set.addObject(pTouch);
scrollView->ccTouchesBegan(&set, pEvent);
return true;
}
示例2: setIndentLevel
void CCPrettyPrinter::visit(const CCSet *p)
{
_result += "\n";
_result += _indentStr;
_result += "<set>\n";
setIndentLevel(_indentLevel+1);
int i = 0;
CCSet* tmp = const_cast<CCSet*>(p);
CCSetIterator it = tmp->begin();
for (; it != tmp->end(); ++it, ++i) {
if (i > 0) {
_result += "\n";
}
_result += _indentStr.c_str();
CCPrettyPrinter v(_indentLevel);
(*it)->acceptVisitor(v);
_result += v.getResult();
}
setIndentLevel(_indentLevel-1);
_result += "\n";
_result += _indentStr;
_result += "</set>\n";
}
示例3: OnPenUp
Boolean CCEGLView::OnPenUp(EventType* pEvent, Int32 nIndex)
{
if (m_pDelegate && nIndex < MAX_TOUCHES)
{
CCTouch* pTouch = s_pTouches[nIndex];
if (pTouch)
{
CCSet set;
pTouch->SetTouchInfo(0, (float)pEvent->sParam1, (float)pEvent->sParam2);
set.addObject(pTouch);
m_pDelegate->touchesEnded(&set, NULL);
pTouch->release();
for (Int32 i = nIndex; i < MAX_TOUCHES; ++i)
{
if (i != (MAX_TOUCHES - 1))
{
s_pTouches[i] = s_pTouches[i + 1];
}
else
{
s_pTouches[i] = NULL;
}
}
}
}
return FALSE;
}
示例4: CCTouch
void CCEGLView::OnPointerPressed(int id, const CCPoint& point)
{
// prepare CCTouch
CCTouch* pTouch = m_pTouches[id];
if (! pTouch)
{
pTouch = new CCTouch();
m_pTouches[id] = pTouch;
}
// prepare CCSet
CCSet* pSet = m_pSets[id];
if (! pSet)
{
pSet = new CCSet();
m_pSets[id] = pSet;
}
if (! pTouch || ! pSet)
return;
float x = point.x;
float y = point.y;
ConvertPointerCoords(x, y);
pTouch->SetTouchInfo(x, y);
pSet->addObject(pTouch);
m_pDelegate->touchesBegan(pSet, NULL);
}
示例5: onTouchesMove
void CCEGLView::onTouchesMove(int id[], float x[], float y[], int pointerNumber)
{
result r = E_SUCCESS;
CCSet set;
for(int i = 0 ; i < pointerNumber ; i++ ) {
CCLOG("Moving touches with id: %d, x=%f, y=%f", id[i], x[i], y[i]);
CCTouch *pTouch = NULL;
r = s_mapTouches.GetValue(id[i], pTouch);
if (E_SUCCESS == r && pTouch != NULL)
{
pTouch->SetTouchInfo(0, (x[i] - m_rcViewPort.origin.x) / m_fScreenScaleFactor ,
(y[i] - m_rcViewPort.origin.y) / m_fScreenScaleFactor);
set.addObject(pTouch);
}
else
{
// It is error, should return.
CCLOG("Moving touches with id: %d error", id[i]);
return;
}
}
m_pDelegate->touchesMoved(&set, NULL);
}
示例6: Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeTouchesCancel
void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeTouchesCancel(JNIEnv* env, jobject thiz, jintArray ids, jfloatArray xs, jfloatArray ys)
{
int size = env->GetArrayLength(ids);
jint id[size];
jfloat x[size];
jfloat y[size];
CCRect rcRect = CCEGLView::sharedOpenGLView().getViewPort();
CCSet set;
env->GetIntArrayRegion(ids, 0, size, id);
env->GetFloatArrayRegion(xs, 0, size, x);
env->GetFloatArrayRegion(ys, 0, size, y);
for( int i = 0 ; i < size ; i++ ) {
cocos2d::CCTouch* pTouch = s_pTouches[id[i]];
if (pTouch)
{
pTouch->SetTouchInfo(0, x[i] - rcRect.origin.x,
y[i] - rcRect.origin.y, id[i]);
set.addObject(pTouch);
s_pTouches[id[i]] = NULL;
pTouch->release();
}
}
cocos2d::CCDirector::sharedDirector()->getOpenGLView()->getDelegate()->touchesCancelled(&set, NULL);
}
示例7: Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeTouchesMove
void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeTouchesMove(JNIEnv* env, jobject thiz, jintArray ids, jfloatArray xs, jfloatArray ys)
{
int size = env->GetArrayLength(ids);
jint id[size];
jfloat x[size];
jfloat y[size];
CCRect rcRect = CCEGLView::sharedOpenGLView().getViewPort();
CCSet set;
env->GetIntArrayRegion(ids, 0, size, id);
env->GetFloatArrayRegion(xs, 0, size, x);
env->GetFloatArrayRegion(ys, 0, size, y);
for( int i = 0 ; i < size ; i++ ) {
LOGD("Moving touches with id: %d, x=%f, y=%f", id[i], x[i], y[i]);
cocos2d::CCTouch* pTouch = s_pTouches[id[i]];
if (pTouch)
{
pTouch->SetTouchInfo(0, x[i] - rcRect.origin.x ,
y[i] - rcRect.origin.y, id[i]);
set.addObject(pTouch);
}
else
{
// It is error, should return.
LOGD("Moving touches with id: %d error", id[i]);
return;
}
}
cocos2d::CCDirector::sharedDirector()->getOpenGLView()->getDelegate()->touchesMoved(&set, NULL);
}
示例8: CC_BREAK_IF
Boolean CCEGLView::OnPenMove(EventType* pEvent)
{
do
{
CC_BREAK_IF(!m_pDelegate);
Int32 nCount = EvtGetPenMultiPointCount(pEvent);
CC_BREAK_IF(nCount <= 0 || nCount > MAX_TOUCHES);
CCSet set;
Int32 nPosX, nPosY;
for (Int32 i = 0; i < nCount; ++i)
{
CCTouch* pTouch = s_pTouches[i];
CC_BREAK_IF(!pTouch);
EvtGetPenMultiPointXY(pEvent, i, &nPosX, &nPosY);
pTouch->SetTouchInfo(0, (float) nPosX, (float) nPosY);
set.addObject(pTouch);
}
m_pDelegate->touchesMoved(&set, NULL);
} while (0);
return FALSE;
}
示例9: handleTouchesBegin
void CCEGLViewProtocol::handleTouchesBegin(int num, int ids[], float xs[],
float ys[])
{
CCSet set;
for (int i = 0; i < num; ++i)
{
int id = ids[i];
float x = xs[i];
float y = ys[i];
CCInteger* pIndex = (CCInteger*) s_TouchesIntergerDict.objectForKey(id);
int nUnusedIndex = 0;
// it is a new touch
if (pIndex == NULL)
{
nUnusedIndex = getUnUsedIndex();
// The touches is more than MAX_TOUCHES ?
if (nUnusedIndex == -1)
{
CCLOG("The touches is more than MAX_TOUCHES, nUnusedIndex = %d",
nUnusedIndex);
continue;
}
CCTouch* pTouch = s_pTouches[nUnusedIndex] = new CCTouch();
if (m_bIsRetinaEnabled)
{
// on iOS, though retina is enabled, the value got from os is also
// relative to its original size
pTouch->setTouchInfo(nUnusedIndex,
(x - m_obViewPortRect.origin.x),
(y - m_obViewPortRect.origin.y));
}
else
{
pTouch->setTouchInfo(nUnusedIndex,
(x - m_obViewPortRect.origin.x) / m_fScaleX,
(y - m_obViewPortRect.origin.y) / m_fScaleY);
}
//CCLOG("x = %f y = %f", pTouch->getLocationInView().x, pTouch->getLocationInView().y);
CCInteger* pInterObj = new CCInteger(nUnusedIndex);
s_TouchesIntergerDict.setObject(pInterObj, id);
set.addObject(pTouch);
pInterObj->release();
}
}
if (set.count() == 0)
{
CCLOG("touchesBegan: count = 0");
return;
}
m_pDelegate->touchesBegan(&set, NULL);
}
示例10: getSetOfTouchesEndOrCancel
void CCEGLViewProtocol::getSetOfTouchesEndOrCancel(CCSet& set, int num,
int ids[], float xs[], float ys[])
{
for (int i = 0; i < num; ++i)
{
int id = ids[i];
float x = xs[i];
float y = ys[i];
CCInteger* pIndex = (CCInteger*) s_TouchesIntergerDict.objectForKey(id);
if (pIndex == NULL)
{
CCLOG("if the index doesn't exist, it is an error");
continue;
}
/* Add to the set to send to the director */
CCTouch* pTouch = s_pTouches[pIndex->getValue()];
if (pTouch)
{
CCLOGINFO("Ending touches with id: %d, x=%f, y=%f", id, x, y);
if (m_bIsRetinaEnabled)
{
pTouch->setTouchInfo(pIndex->getValue(),
(x - m_obViewPortRect.origin.x),
(y - m_obViewPortRect.origin.y));
}
else
{
pTouch->setTouchInfo(pIndex->getValue(),
(x - m_obViewPortRect.origin.x) / m_fScaleX,
(y - m_obViewPortRect.origin.y) / m_fScaleY);
}
set.addObject(pTouch);
// release the object
pTouch->release();
s_pTouches[pIndex->getValue()] = NULL;
removeUsedIndexBit(pIndex->getValue());
s_TouchesIntergerDict.removeObjectForKey(id);
}
else
{
CCLOG("Ending touches with id: %d error", id);
return;
}
}
if (set.count() == 0)
{
CCLOG("touchesEnded or touchesCancel: count = 0");
return;
}
}
示例11: ccTouchEnded
void ScrollMenu::ccTouchEnded(CCTouch *pTouch, CCEvent *pEvent)
{
CCSet set;
set.addObject(pTouch);
scrollView->ccTouchesEnded(&set, pEvent);
if(scrollView->getCurrentNodeId() == 0)
menuLeft();
else if(scrollView->getCurrentNodeId() == scrollView->endNodeIndex)
menuRight();
}
示例12: handleTouchesMove
void CCEGLViewProtocol::handleTouchesMove(int num, int ids[], float xs[],
float ys[])
{
CCSet set;
for (int i = 0; i < num; ++i)
{
int id = ids[i];
float x = xs[i];
float y = ys[i];
CCInteger* pIndex = (CCInteger*) s_TouchesIntergerDict.objectForKey(id);
if (pIndex == NULL)
{
CCLOG("if the index doesn't exist, it is an error");
continue;
}
CCLOGINFO("Moving touches with id: %d, x=%f, y=%f", id, x, y);
CCTouch* pTouch = s_pTouches[pIndex->getValue()];
if (pTouch)
{
if (m_bIsRetinaEnabled)
{
pTouch->setTouchInfo(pIndex->getValue(),
(x - m_obViewPortRect.origin.x),
(y - m_obViewPortRect.origin.y));
}
else
{
pTouch->setTouchInfo(pIndex->getValue(),
(x - m_obViewPortRect.origin.x) / m_fScaleX,
(y - m_obViewPortRect.origin.y) / m_fScaleY);
}
set.addObject(pTouch);
}
else
{
// It is error, should return.
CCLOG("Moving touches with id: %d error", id);
return;
}
}
if (set.count() == 0)
{
CCLOG("touchesMoved: count = 0");
return;
}
m_pDelegate->touchesMoved(&set, NULL);
}
示例13: CCSet
void UIScrollLayer::cancelAndStoleTouch(CCTouch* pTouch, CCEvent* pEvent)
{
// Throw Cancel message for everybody in TouchDispatcher.
CCSet* touchSet = new CCSet();
touchSet->addObject(pTouch);
touchSet->autorelease();
CCDirector::sharedDirector()->getTouchDispatcher()->touchesCancelled(touchSet, pEvent);
//< after doing this touch is already removed from all targeted handlers
// Squirrel away the touch
claimTouch(pTouch);
}
示例14: CCSet
void CCStoreScene::testLoadProducts(CCObject* pSender)
{
CCSet* productsId = new CCSet();
productsId->autorelease();
CCNative::createAlert("Waiting", "Retrieving Product Information", NULL);
CCNative::showAlert();
// SET YOUR IAP PRODUCT ID TO HERE
productsId->addObject(newCCString("org.cocos2d-x.games.demo.iap01"));
productsId->addObject(newCCString("org.cocos2d-x.games.demo.iap02"));
productsId->addObject(newCCString("org.cocos2d-x.games.demo.iap03"));
CCStore::sharedStore()->loadProducts(productsId, this);
}
示例15: useForFileExtensions
bool CC3STBImage::shouldUseForFileExtension( const std::string& fileExtension )
{
CCSet* pExtensions = useForFileExtensions();
CCString *pExt;
CCSetIterator setIter;
for (setIter = pExtensions->begin(); setIter != pExtensions->end(); ++setIter)
{
pExt = (CCString *)(*setIter);
if ( pExt->compare( fileExtension.c_str() ) == 0 )
return true;
}
return false;
}