本文整理汇总了C++中CCTouch::setTouchInfo方法的典型用法代码示例。如果您正苦于以下问题:C++ CCTouch::setTouchInfo方法的具体用法?C++ CCTouch::setTouchInfo怎么用?C++ CCTouch::setTouchInfo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCTouch
的用法示例。
在下文中一共展示了CCTouch::setTouchInfo方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
示例2: 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;
}
}
示例3: 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);
}
示例4: 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);
}
示例5: HandleTouchesEnd
void App::HandleTouchesEnd(int num, int ids[], float xs[], float ys[])
{
int i;
int id;
float x;
float y;
CCSet set;
CCTouch* pTouch;
CCInteger* pIndex;
for (i = 0; i < num; ++i)
{
id = ids[i];
x = xs[i];
y = ys[i];
pIndex = (CCInteger*)s_TouchesIntergerDict.objectForKey(id);
if (pIndex == NULL)
{
CCLOG("if the index doesn't exist, it is an error");
continue;
}
pTouch = s_pTouches[pIndex->getValue()];
if (pTouch)
{
CCLOGINFO("Ending touches with id: %d, x=%f, y=%f", id, x, y);
pTouch->setTouchInfo(pIndex->getValue(), x, y);
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;
}
}
CCDirector::sharedDirector()->getTouchDispatcher()->touchesEnded(&set, NULL);
}
示例6: HandleTouchesBegin
void App::HandleTouchesBegin(int num, int ids[], float xs[], float ys[])
{
int i;
int id;
int nUnusedIndex;
float x;
float y;
CCSet set;
CCTouch* pTouch;
CCInteger* pIndex;
CCInteger* pInterObj;
for (i = 0; i < num; ++i)
{
id = ids[i];
x = xs[i];
y = ys[i];
pIndex = (CCInteger*)s_TouchesIntergerDict.objectForKey(id);
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;
}
pTouch = s_pTouches[nUnusedIndex] = new CCTouch();
pTouch->setTouchInfo( nUnusedIndex, x, y );
pInterObj = new CCInteger(nUnusedIndex);
s_TouchesIntergerDict.setObject(pInterObj, id);
set.addObject(pTouch);
pInterObj->release();
}
}
if (set.count() > 0)
{
CCDirector::sharedDirector()->getTouchDispatcher()->touchesBegan(&set, NULL);
}
}
示例7: HandleTouchesMove
void App::HandleTouchesMove(int num, int ids[], float xs[], float ys[])
{
int i;
int id;
float x;
float y;
CCSet set;
CCTouch* pTouch;
CCInteger* pIndex;
for (i = 0; i < num; ++i)
{
id = ids[i];
x = xs[i];
y = ys[i];
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);
pTouch = s_pTouches[pIndex->getValue()];
if (pTouch)
{
pTouch->setTouchInfo(pIndex->getValue(), x, y);
set.addObject(pTouch);
}
else
{
// It is error, should return.
CCLOG("Moving touches with id: %d error", id);
return;
}
}
if (set.count() > 0)
{
CCDirector::sharedDirector()->getTouchDispatcher()->touchesMoved(&set, NULL);
}
}
示例8: responseMenu
void WHScrollView::responseMenu(CCTouch *pTouch, CCEvent *pEvent, bool bEnd)
{
if (!_touchMoved && !_dragging)
{
for (int i = 0; i < m_TouchLayer.size(); i++)
{
if (m_TouchLayerTouched[i])
{
m_TouchLayerTouched[i] = false;
if (canResponseMenu(pTouch))
{
CCLayer* pTouchLayer = m_TouchLayer[i];
if (bEnd)
pTouchLayer->onTouchEnded(pTouch, pEvent);
else
pTouchLayer->onTouchCancelled(pTouch, pEvent);
}
else
{
int offset = 10000;
CCTouch touch;
CCPoint screenPos = pTouch->getLocationInView();
screenPos.x += offset;
screenPos.y += offset;
touch.setTouchInfo(pTouch->getID(), screenPos.x, screenPos.y);
CCLayer* pTouchLayer = m_TouchLayer[i];
pTouchLayer->onTouchMoved(&touch, pEvent);
if (bEnd)
pTouchLayer->onTouchEnded(&touch, pEvent);
else
pTouchLayer->onTouchCancelled(&touch, pEvent);
}
}
}
}
}
示例9: CCTouch
CCTouch *CCTouch::copy()
{
CCTouch *copy = new CCTouch();
copy->setTouchInfo(getID(), m_point.x, m_point.y);
return copy;
}