当前位置: 首页>>代码示例>>C++>>正文


C++ CCTouch::getLocation方法代码示例

本文整理汇总了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;
	
}
开发者ID:jijinlong,项目名称:SyGame,代码行数:11,代码来源:StartScene.cpp

示例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);
    }
}
开发者ID:GhostSoar,项目名称:Cocos2dWindows,代码行数:11,代码来源:MutiTouchTest.cpp

示例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;
    }
}
开发者ID:zhangyu4760,项目名称:Cocos2dXLessons20130907,代码行数:11,代码来源:HelloWorldScene.cpp

示例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");
        }
    }
}
开发者ID:zhangyu4760,项目名称:Cocos2dXLessons20130907,代码行数:11,代码来源:HelloWorldScene.cpp

示例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);
	}
	
}
开发者ID:13609594236,项目名称:ph-open,代码行数:12,代码来源:PageScrollView.cpp

示例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());
					}
				}
			}
		}
	}
	
}
开发者ID:luozhonghai,项目名称:puzzle,代码行数:53,代码来源:ChessBoard.cpp

示例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);
	}
	

}
开发者ID:SongCF,项目名称:game-LostStar,代码行数:53,代码来源:BaseContentWrapLayer.cpp

示例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);
    }
}
开发者ID:Ratel13,项目名称:moon-herder-cocos2d-x,代码行数:12,代码来源:GameLayer.cpp

示例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");
}
开发者ID:KiiPlatform,项目名称:Cocos2d-x,代码行数:53,代码来源:HelloWorldScene.cpp

示例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");
}
开发者ID:SakuraSinojun,项目名称:touhou,代码行数:13,代码来源:GameScene.cpp

示例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);
}
开发者ID:Asheng321,项目名称:PopStar,代码行数:13,代码来源:MainMenuLayer.cpp

示例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;
	}
}
开发者ID:krbod,项目名称:FlyHigh,代码行数:13,代码来源:MenuLayer.cpp

示例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();
    }
}
开发者ID:SakuraSinojun,项目名称:touhou,代码行数:39,代码来源:GameScene.cpp

示例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();

}
开发者ID:jiz869,项目名称:cocos2dx_pr1,代码行数:14,代码来源:HelloWorldScene.cpp

示例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;
}
开发者ID:mcodegeeks,项目名称:OpenKODE-Framework,代码行数:14,代码来源:Ch7_GridPathfinding.cpp


注:本文中的CCTouch::getLocation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。