本文整理汇总了C++中CCSet::addObject方法的典型用法代码示例。如果您正苦于以下问题:C++ CCSet::addObject方法的具体用法?C++ CCSet::addObject怎么用?C++ CCSet::addObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCSet
的用法示例。
在下文中一共展示了CCSet::addObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testLoadProducts
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);
}
示例2: 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;
}
示例3: 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);
}
示例4: OnPenMove
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;
}
示例5:
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);
}
示例6: ccTouchBegan
bool ScrollMenu::ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent)
{
CCSet set;
set.addObject(pTouch);
scrollView->ccTouchesBegan(&set, pEvent);
return true;
}
示例7: OnPointerPressed
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);
}
示例8: 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);
}
示例9: 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;
}
}
示例10: update
void TouchGrabber::update(float delta)
{
mPlayDeltaTime += delta;
if (bPlaying == false) return;
if (mTouchVecIndice >= mTouchesRecVector.size()) {
stop();
return;
}
TouchRecord rec = mTouchesRecVector.at(mTouchVecIndice);
///CCLOG("rec time: %f play dt: %f",rec.time / 1000.f, mPlayDeltaTime);
if (rec.time / 1000.f > mPlayDeltaTime) return;
CCTouchDispatcher *dispatcher = CCDirector::sharedDirector()->getTouchDispatcher();
CCSet set;
switch (rec.event) {
case kTouchBegan:
mTouch = new CCTouch(); /// Touch will be destroyed when ended/cancelled
mTouch->setTouchInfo(0, rec.x, rec.y);
set.addObject(mTouch);
dispatcher->touchesBegan(&set, NULL);
break;
case kTouchMoved:
mTouch->setTouchInfo(0, rec.x, rec.y);
set.addObject(mTouch);
dispatcher->touchesMoved(&set, NULL);
break;
case kTouchEnded:
mTouch->setTouchInfo(0, rec.x, rec.y);
set.addObject(mTouch);
dispatcher->touchesEnded(&set, NULL);
break;
case kTouchCancelled:
mTouch->setTouchInfo(0, rec.x, rec.y);
set.addObject(mTouch);
dispatcher->touchesCancelled(&set, NULL);
break;
default: CCAssert(false, "Unknown touch event."); break;
}
mTouchVecIndice++;
}
示例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: getCurrentSetOfTouches
void CCEGLViewProtocol::getCurrentSetOfTouches(CCSet& set)
{
int i;
int temp = s_indexBitsUsed;
for (i = 0; i < CC_MAX_TOUCHES; i++) {
if ( temp & 0x00000001) {
set.addObject(s_pTouches[i]);
}
temp >>= 1;
}
}
示例13: 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);
}
示例14: cancelAndStoleTouch
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);
}
示例15: 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();
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;
}
CCEvent event;
CCSet *allTouches= new CCSet;
allTouches->autorelease();
getCurrentSetOfTouches(*allTouches);
event.setAllTouches(allTouches);
m_pDelegate->touchesBegan(&set, &event);
}