本文整理汇总了C++中CCTouch类的典型用法代码示例。如果您正苦于以下问题:C++ CCTouch类的具体用法?C++ CCTouch怎么用?C++ CCTouch使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CCTouch类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnPointerOff
void CCTouchDispatcher::OnPointerOff(const InputPointerEvent* evt)
{
map<Ref<InputPointer>, CCTouch*>::type::iterator itr = m_Touches.find(evt->getSource());
if (itr == m_Touches.end())
return;
CCSet set;
CCTouch* pTouch = itr->second;
m_Touches.erase(itr);
pTouch->SetTouchInfo(0, evt->getPos().x, evt->getPos().y);
set.addObject(pTouch);
// LOG(0, ".. off %.3f %.3f\n", evt->GetPos().x, evt->GetPos().y);
touchesEnded(&set);
pTouch->release();
}
示例2: onTouchesMoved
void Clayer_ripple_horizontal::onTouchesMoved(const std::vector<Touch*>& touches, Event *unused_event)
{
CCTouch* touch;
for(auto it = touches.begin(); it != touches.end(); it++)
{
touch = (CCTouch*)(*it);
if(!touch)
break;
CCPoint location = touch->getLocationInView();
location = CCDirector::sharedDirector()->convertToGL(location);
// cout<<"mos pos:"<<location.x<<" "<<location.y<<endl;
m_ripple_horizontalNode->pressAtX(location.x, 0.8);
break;
}
}
示例3: ccTouchesBegan
void HudLayer::ccTouchesBegan(CCSet *pTouches, CCEvent *pEvent) {
if (Utils::gameLayer()->getState() == kEditMode) {
CCTouch *pTouch;
CCSetIterator setIter;
for (setIter = pTouches->begin(); setIter != pTouches->end(); ++setIter) {
pTouch = (CCTouch *)(*setIter);
_touches->addObject(pTouch);
}
pTouch = (CCTouch *) _touches->objectAtIndex(0);
CCPoint location = pTouch->getLocation();
for (int i = 0; i < _tools->count(); i++) {
Tool *tool = (Tool *) _tools->objectAtIndex(i);
if (tool->touchingTool(location)) {
_movingTool = i;
Utils::gameLayer()->setShouldPan(false);
}
}
}
}
示例4: OnPenDown
Boolean CCEGLView::OnPenDown(EventType* pEvent, Int32 nIndex)
{
if (m_pDelegate && nIndex < MAX_TOUCHES)
{
CCTouch* pTouch = s_pTouches[nIndex];
if (!pTouch)
{
pTouch = new CCTouch;
}
pTouch->SetTouchInfo(0, (float)(pEvent->sParam1 - m_rcViewPort.X()) / m_fScreenScaleFactor,
(float)(pEvent->sParam2 - m_rcViewPort.Y()) / m_fScreenScaleFactor);
s_pTouches[nIndex] = pTouch;
CCSet set;
set.addObject(pTouch);
m_pDelegate->touchesBegan(&set, NULL);
}
return FALSE;
}
示例5: ccTouchesEnded
void TestController::ccTouchesEnded(CCSet *pTouches, CCEvent *pEvent)
{
CCAction* delaytime = CCActionManager::sharedManager()->getActionByTag(99,this);
if(delaytime != NULL)
if(delaytime->isDone() == false)
{
CCSetIterator it = pTouches->begin();
CCTouch* touch = (CCTouch*)(*it);
CCPoint p1 = m_tBeginPos;
CCPoint p2 = touch->locationInView(touch->view());
float x = m_pItmeMenu->getPosition().x + (p2.x - p1.x) * 5;
if(x>= 0)
x = 0;
else if(x <= -m_pItmeMenu->getContentSize().width)
x = -m_pItmeMenu->getContentSize().width;
CCMoveTo* move = CCMoveTo::actionWithDuration(1,CCPointMake(x,0));
CCActionInterval* ease = CCEaseOut::actionWithAction(move,3.0);
m_pItmeMenu->runAction(ease);
}
}
示例6: onTouchesEnded
void Clayer_ripple_horizontal::onTouchesEnded(const std::vector<Touch*>& touches, Event *unused_event)
{
//Add a new body/atlas sprite at the touched location
CCTouch* touch;
for(auto it = touches.begin(); it != touches.end(); it++)
{
touch = (CCTouch*)(*it);
if(!touch)
break;
CCPoint location = touch->getLocationInView();
location = CCDirector::sharedDirector()->convertToGL(location);
// cout<<"mos pos:"<<location.x<<" "<<location.y<<endl;
break;
}
}
示例7: ccTouchesEnded
void CtestLayer::ccTouchesEnded(CCSet* touches, CCEvent* event)
{
CCSetIterator it;
CCTouch* touch;
for( it = touches->begin(); it != touches->end(); it++)
{
touch = (CCTouch*)(*it);
if(!touch)
break;
CCPoint pointInWinSpace = touch->getLocationInView();
//----update mos
m_mosPosf=m_mosPos;
m_mosPos=pointInWinSpace;
}
}
示例8: ccTouchesBegan
void HelloWorld::ccTouchesBegan(CCSet *touches,CCEvent *event){
if (_mouseJoint!=NULL) return;
CCTouch *myTouch =(CCTouch*) touches->anyObject();
CCPoint location = myTouch->getLocationInView();
location = CCDirector::sharedDirector()->convertToGL(location);
b2Vec2 locationWorld = b2Vec2(location.x/PTM_RATIO, location.y/PTM_RATIO);
if (resinBallBody->_ballBody->GetFixtureList()->TestPoint(locationWorld)) {
b2MouseJointDef md;
md.bodyA = _groundBody;
md.bodyB =resinBallBody->_ballBody;
md.target =resinBallBody->_ballBody->GetWorldCenter();
md.collideConnected =true;
md.maxForce =1000.0f* resinBallBody->_ballBody->GetMass();
_mouseJoint = (b2MouseJoint *)_world->CreateJoint(&md);
resinBallBody->_ballBody->SetAwake(true);
}
}
示例9: ccTouchesEnded
void SceneNode::ccTouchesEnded(CCSet* touches, CCEvent* event)
{
touchValid=false;
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
CCSetIterator it;
CCTouch* touch;
for( it = touches->begin(); it != touches->end(); it++)
{
touch = (CCTouch*)(*it);
if(!touch)
break;
CCPoint loc_winSpace = touch->getLocationInView();
CCPoint loc_GLSpace = CCDirector::sharedDirector()->convertToGL(loc_winSpace);
}
}
示例10: ccTouchesEnded
void HelloWorld::ccTouchesEnded(CCSet* touches, CCEvent* event)
{
//Add a new body/atlas sprite at the touched location
CCSetIterator it;
CCTouch* touch;
for( it = touches->begin(); it != touches->end(); it++)
{
touch = (CCTouch*)(*it);
if(!touch)
break;
CCPoint location = touch->getLocationInView();
location = CCDirector::sharedDirector()->convertToGL(location);
addNewSpriteAtPosition( location );
}
}
示例11: ccTouchesEnded
void Clayer_ripple_horizontal::ccTouchesEnded(CCSet* touches, CCEvent* event)
{
//Add a new body/atlas sprite at the touched location
CCSetIterator it;
CCTouch* touch;
for( it = touches->begin(); it != touches->end(); it++)
{
touch = (CCTouch*)(*it);
if(!touch)
break;
CCPoint location = touch->getLocationInView();
location = CCDirector::sharedDirector()->convertToGL(location);
// cout<<"mos pos:"<<location.x<<" "<<location.y<<endl;
break;
}
}
示例12: ccTouchesBegan
void GamePlay::ccTouchesBegan(cocos2d::CCSet* touches, cocos2d::CCEvent* event) {
CCTouch* touch = (CCTouch*)(touches->anyObject());
CCPoint location = touch->getLocationInView();
location = CCDirector::sharedDirector()->convertToGL(location);
int width = CCEGLView::sharedOpenGLView()->getDesignResolutionSize().width;
if(location.x < width/2) {
// move left
int x = mUserCar->getPositionX() - width/mNumLane;
if(x > mUserCar->getContentSize().width /2) {
mUserCar->setPositionX(x);
}
} else {
// move right
int x = mUserCar->getPositionX() + width/mNumLane;
if(x < width - mUserCar->getContentSize().width /2) {
mUserCar->setPositionX(x);
}
}
}
示例13:
void Box2DTestLayer::ccTouchesEnded(CCSet* touches, CCEvent* event)
{
//Add a new body/atlas sprite at the touched location
CCSetIterator it;
CCTouch* touch;
for( it = touches->begin(); it != touches->end(); it++)
{
touch = (CCTouch*)(*it);
if(!touch)
break;
CCPoint location = touch->locationInView(touch->view());
location = CCDirector::sharedDirector()->convertToGL(location);
addNewSpriteWithCoords( location );
}
}
示例14: ccTouchesBegan
void GameLayer::ccTouchesBegan(CCSet* pTouches, CCEvent* pEvent)
{
for (CCSetIterator iter = pTouches->begin(); iter != pTouches->end(); ++ iter)
{
CCTouch* pTouch = (CCTouch*)(*iter);
if (pTouch)
{
CCPoint tap = pTouch->getLocation();
for (int p = 0; p < 2; ++ p)
{
GameSprite* pGS = (GameSprite*)m_pArrPlayers->objectAtIndex(p);
if (pGS->boundingBox().containsPoint(tap))
{
pGS->setTouch(pTouch);
}
}
}
}
}
示例15: ccTouchesBegan
void GameState::ccTouchesBegan(CCSet *pTouches, CCEvent *pEvent)
{
CCTouch* touch = (CCTouch*)( pTouches->anyObject() );
CCPoint location = touch->getLocation();
touchPoint = location;
pressing = true;
if(stageManager->getPlayer()->weaponManager->containPointWithReloadSpr(touchPoint))
{
isPressReload = true;
SoundManager::getInstance()->playEffect("music/ui/ui_reload.ogg");
stageManager->getPlayer()->weaponManager->pressingReloadSpr();
}
if(tutorialManager->getCurrentPage() == 5)
{
this->resumeSchedulerAndActions();
tutorialManager->increasePage();
}
}