本文整理汇总了C++中CCTouch::getLocation方法的典型用法代码示例。如果您正苦于以下问题:C++ CCTouch::getLocation方法的具体用法?C++ CCTouch::getLocation怎么用?C++ CCTouch::getLocation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCTouch
的用法示例。
在下文中一共展示了CCTouch::getLocation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ccTouchesBegan
void StartScene::ccTouchesBegan(cocos2d::CCSet *pTouches, cocos2d::CCEvent *pEvent)
{
CCTouch* touch = (CCTouch*)(* pTouches->begin());
CCPoint pos = touch->getLocation();
/**
* 处理窗口
*/
if (mainUI->touchDown(pos.x,pos.y)) return;
}
示例2: ccTouchesMoved
void MutiTouchTestLayer::ccTouchesMoved(CCSet *pTouches, CCEvent *pEvent)
{
CCSetIterator iter = pTouches->begin();
for (; iter != pTouches->end(); iter++)
{
CCTouch* pTouch = (CCTouch*)(*iter);
TouchPoint* pTP = (TouchPoint*)s_dic.objectForKey(pTouch->getID());
CCPoint location = pTouch->getLocation();
pTP->setTouchPos(location);
}
}
示例3: ccTouchesBegan
void HelloWorld::ccTouchesBegan(cocos2d::CCSet *pTouches, cocos2d::CCEvent *pEvent){
CCTouch* t = (CCTouch*)pTouches->anyObject();
touchStart = t->getLocation();
if(img->boundingBox().containsPoint(touchStart)){
imgStart = img->getPosition();
dragenabled = true;
}
}
示例4: ccTouchesMoved
void HelloWorld::ccTouchesMoved(cocos2d::CCSet *pTouches, cocos2d::CCEvent *pEvent){
CCTouch* t = (CCTouch*)pTouches->anyObject();
if (dragenabled) {
img->setPosition(t->getLocation()-touchStart+imgStart);
if (img->boundingBox().intersectsRect(img1->boundingBox())) {
CCLog("intersect\n");
}
}
}
示例5: ccTouchesMoved
void PageScrollView::ccTouchesMoved(cocos2d::CCSet *pTouches, cocos2d::CCEvent *pEvent)
{
CCTouch *touch = (CCTouch *)pTouches->anyObject();
CCPoint currentPoint = (CCPoint)touch->getLocation();
CCPoint prePoint = (CCPoint)touch->getPreviousLocation();
if(isTouchMoving){
v = currentPoint.x - prePoint.x;
content->setPositionX(content->getPositionX() + v);
}
}
示例6: ccTouchesMoved
void ChessBoard::ccTouchesMoved(CCSet *pTouches, CCEvent *pEvent)
{
CCPoint pos;
CCSetIterator i;
CCTouch* touch;
ChessBall* sprite;
_cancelling = true;
if (_roundEnd)
{
return;
}
int count = _chessArray->count();
for (i = pTouches->begin(); i != pTouches->end(); i++)
{
touch = (CCTouch*)(*i);
if (touch != NULL)
{
pos = touch->getLocation();
_pickedChess->setPositionX(pos.x);
_pickedChess->setPositionY(pos.y + _chessYOffset);
for (int j = 0; j < count; j++)
{
sprite = (ChessBall*)_chessArray->objectAtIndex(j);
if (sprite->boundingBox().containsPoint(pos))
{
// sprite->setOpacity(128);
if (_activeCell->ball != NULL && _activeCell->ball != sprite)
{
CCMoveTo * move = CCMoveTo::create(0.1f, _activeCell->ball->getPosition());
CCCallFuncND * end = CCCallFuncND::create(this, callfuncND_selector(ChessBoard::chessMoveEnd), _activeCell->ball);
CCAction * action = CCSequence::create(move, end,NULL);
_moveChess->setVisible(true);
_moveChess->setChessProperty(sprite->getChessProperty());
_moveChess->setPosition(sprite->getPosition());
_moveChess->runAction(action);
_activeCell->ball->setOpacity(0);
_activeCell->ball->setChessProperty(sprite->getChessProperty());
_activeCell->ball = sprite;
_activeCell->ball->setOpacity(128);
_activeCell->ball->setChessProperty(_pickedChess->getChessProperty());
}
}
}
}
}
}
示例7: ccTouchesMoved
void BaseContentWrapLayer::ccTouchesMoved (CCSet *pTouches, CCEvent *pEvent)
{
if (!mBaseScene->getCollisionEnable())
{
return;
}
if (mFixedScaling)
{
return;
}
CCTouch* touch = (CCTouch*)(*(pTouches->begin()));
if(touch->getID() != 0 || pTouches->count() > 1)
return;
CCPoint currentPos = touch->getLocation();
mVCalculate->addTouchMoveRecord(currentPos);
float x_offset = currentPos.x - mLastTouchPos.x;
float y_offset = currentPos.y - mLastTouchPos.y;
setPositionX(getPositionX() + x_offset);
setPositionY(getPositionY() + y_offset);
mLastTouchPos = currentPos;
float min_x;
float min_y;
float max_x;
float max_y;
getBoarderPos(min_x,min_y,max_x,max_y);
if (getPositionX() < min_x)
{
setPositionX(min_x);
}
if (getPositionX() > max_x)
{
setPositionX(max_x);
}
if (getPositionY() < min_y)
{
setPositionY(min_y);
}
if (getPositionY() > max_y)
{
setPositionY(max_y);
}
}
示例8: ccTouchesBegan
void GameLayer::ccTouchesBegan(cocos2d::CCSet* touches, cocos2d::CCEvent* event) {
if (_gameState != kGameStatePlay) return;
CCTouch *touch = (CCTouch *) touches->anyObject();
if (touch) {
CCPoint tap = touch->getLocation();
_drawLayer->setStartPoint(tap);
}
}
示例9: ccTouchesEnded
// cpp with cocos2d-x
void HelloWorld::ccTouchesEnded(CCSet* touches, CCEvent* event)
{
//jni_test();
// Choose one of the touches to work with
CCTouch* touch = (CCTouch*)( touches->anyObject() );
CCPoint location = touch->getLocation();
//CCLog("++++++++after x:%f, y:%f", location.x, location.y);
// Set up initial location of projectile
CCSize winSize = CCDirector::sharedDirector()->getVisibleSize();
CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();
CCSprite *projectile = CCSprite::create("Projectile.png", CCRectMake(0, 0, 20, 20));
projectile->setPosition( ccp(origin.x+20, origin.y+winSize.height/2) );
// Determinie offset of location to projectile
float offX = location.x - projectile->getPosition().x;
float offY = location.y - projectile->getPosition().y;
// Bail out if we are shooting down or backwards
if (offX <= 0) return;
// Ok to add now - we've double checked position
this->addChild(projectile);
// Determine where we wish to shoot the projectile to
float realX = origin.x+winSize.width + (projectile->getContentSize().width/2);
float ratio = offY / offX;
float realY = (realX * ratio) + projectile->getPosition().y;
CCPoint realDest = ccp(realX, realY);
// Determine the length of how far we're shooting
float offRealX = realX - projectile->getPosition().x;
float offRealY = realY - projectile->getPosition().y;
float length = sqrtf((offRealX * offRealX) + (offRealY*offRealY));
float velocity = 480/1; // 480pixels/1sec
float realMoveDuration = length/velocity;
// Move projectile to actual endpoint
projectile->runAction( CCSequence::create(
CCMoveTo::create(realMoveDuration, realDest),
CCCallFuncN::create(this,
callfuncN_selector(HelloWorld::spriteMoveFinished)),
NULL) );
// Add to projectiles array
projectile->setTag(2);
_projectiles->addObject(projectile);
CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("pew-pew-lei.wav");
}
示例10: ccTouchesEnded
void GameScene::ccTouchesEnded(cocos2d::CCSet* touches, cocos2d::CCEvent* event)
{
CCTouch* touch = (CCTouch*)(touches->anyObject());
CCPoint pt = touch->getLocation();
CCPoint d = ccpSub(pt, mClickPoint);
if (fabs(d.x) < 2.0f && fabs(d.y) < 2.0f) {
onClick(pt);
}
lastScale = 0.0f;
mScaleDistance = 0.0f;
pDebug->setString("END");
}
示例11: ccTouchesEnded
void MainMenuLayer::ccTouchesEnded(CCSet* touches, CCEvent* event) {
CCTouch* touch = (CCTouch*)( touches->anyObject() );
CCPoint location = touch->getLocation();
if (!m_sound->boundingBox().containsPoint(location))
return;
bool mute = !Config::instance()->mute();
Config::instance()->setMute(mute);
if (mute)
m_sound->setDisplayFrame(m_muteFrame);
else
m_sound->setDisplayFrame(m_soundFrame);
}
示例12: ccTouchesBegan
void CMenuLayer::ccTouchesBegan(CCSet* pTouches, CCEvent* event)
{
if( _mGameStart )
return;
for( CCSetIterator it = pTouches->begin(); it != pTouches->end(); ++it )
{
CCTouch* touch = (CCTouch*)(*it);
CCPoint touchPoint = touch->getLocation();
_mOldTouch = touchPoint;
}
}
示例13: ccTouchesMoved
void GameScene::ccTouchesMoved(CCSet *pTouches, CCEvent *pEvent)
{
if (pTouches->count() == 2) {
CCSetIterator it1 = pTouches->begin();
CCSetIterator it2 = it1;
it2++;
CCPoint pt1 = ((CCTouch*)(*it1))->getLocation();
CCPoint pt2 = ((CCTouch*)(*it2))->getLocation();
float dist = sqrt((pt1.x - pt2.x) * (pt1.x - pt2.x) + (pt1.y - pt2.y) * (pt1.y - pt2.y));
if (lastScale < 1.0f || mScaleDistance == 0.0f) {
lastScale = this->getScale();
mScaleDistance = dist;
}
float scale = lastScale * (dist / mScaleDistance);
{
char temp[4096];
snprintf(temp, sizeof(temp), "%f/%f/%f", dist, mScaleDistance, scale);
pDebug->setString(temp);
}
if (scale < 1.0f)
scale = 1.0f;
if (scale > 2.0f)
scale = 2.0f;
lastScale = scale;
mScaleDistance = dist;
this->setScale(scale);
} else {
CCTouch* touch = (CCTouch*)(pTouches->anyObject());
singleTouchDragging(mDragStartPoint, touch->getLocation());
mDragStartPoint = touch->getLocation();
}
}
示例14: ccTouchesEnded
// cpp with cocos2d-x
void HelloWorld::ccTouchesEnded(CCSet* touches, CCEvent* event)
{
// Choose one of the touches to work with
CCTouch* touch = (CCTouch*)( touches->anyObject() );
CCPoint location = touch->getLocation();
CCLog("++++++++after x:%f, y:%f", location.x, location.y);
// Set up initial location of projectile
CCSize winSize = CCDirector::sharedDirector()->getVisibleSize();
CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();
}
示例15: ccp
/// Process touching and moving to add/remove walls
KDvoid Ch7_GridPathfinding::ccTouchesBegan ( CCSet* pTouches, CCEvent* pEvent )
{
CCTouch* pTouch = (CCTouch*) pTouches->anyObject ( );
CCPoint tPoint = pTouch->getLocation ( );
KDint x = (KDint) ( ( tPoint.x - m_pGridNode->getPosition ( ).x ) / m_fNodeSpace );
KDint y = (KDint) ( ( tPoint.y - m_pGridNode->getPosition ( ).y ) / m_fNodeSpace );
CCPoint tTouchedNode = ccp ( x, y );
m_bTouchedNodeIsNew = KD_TRUE;
m_tTouchedNode = tTouchedNode;
}