• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ Touch类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中Touch的典型用法代码示例。如果您正苦于以下问题:C++ Touch类的具体用法?C++ Touch怎么用?C++ Touch使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Touch类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1:

void Game2DStage::touchHandler(JniMethodInfo nativeTouchCallbackMInfo, std::string type, std::vector<cocos2d::Touch *> &touches){
    
    jstring jType = nativeTouchCallbackMInfo.env->NewStringUTF(type.c_str());
    
    int len = touches.size()*2;
    jfloat buf[len];
    jfloatArray arr = nativeTouchCallbackMInfo.env->NewFloatArray(len);
    
    Touch *t = NULL;
    Point p;
    
    int index = 0;
    for (auto it = touches.begin(); it!=touches.end(); it++) {
        t = (Touch*)(*it);
        p = t->getLocation();
        
        buf[index] = p.x;index++;
        buf[index] = p.y;index++;
    }
    
    nativeTouchCallbackMInfo.env->SetFloatArrayRegion(arr, 0, len, buf);
    
    nativeTouchCallbackMInfo.env->CallStaticVoidMethod(nativeTouchCallbackMInfo.classID, nativeTouchCallbackMInfo.methodID,jType,arr);
    
    nativeTouchCallbackMInfo.env->DeleteLocalRef(jType);
    nativeTouchCallbackMInfo.env->DeleteLocalRef(arr);
}
开发者ID:,项目名称:,代码行数:27,代码来源:


示例2: sqrtf

void QTELayer::onTouchesMoved(const std::vector<Touch*>& touches, Event *unused_event)
{
    if(!enableFight) return;
    Touch *touch = touches.at(0);
    Vec2 delta = touch->getDelta();
    Vec2 lastPos = touch->getPreviousLocation();
    Vec2 pos = touch->getLocation();
    
    float dx = pos.x - startTouchPosition.x;
    float dy = pos.y - startTouchPosition.y;
    float dist = sqrtf(dx*dx+dy*dy);
    
    
    streak->setPosition(pos);
    //刀的判断
    dist = pos.distanceSquared(startTouchPosition);
    
    if (dist > 50) {
        //hit test monster
        bool hit = qteMonster->hittestPoint(pos);
        if (hit) {
            hitQteMonster();
        }
    }
}
开发者ID:NjAiYo,项目名称:MonsterGame,代码行数:25,代码来源:QTELayer.cpp


示例3: QObject

Touch::Touch(const Touch &t) : QObject(t.parent())
{
    fixedMiddle = t.fixedMiddle;
    setContours(t.getCvContour());
    found = t.isFound();
    id = t.getId();
}
开发者ID:mcharmas,项目名称:TouchTracer,代码行数:7,代码来源:touch.cpp


示例4: log

void PlaySceneOne::onTouchMoved(Touch* touches, Event* event) 
{
	log("touchMMMMMMMMMOOVVEDDD执行了---------------------------------------------");
	// 获取当前触摸的目标
	Touch* touch = static_cast<Touch*>(touches);
	Point locationInNodelocal = touch->getLocation();

	//log("GameObjHero::onTouchBegan::rx=%0.2f, ry=%0.2f, rw=%0.2f, rh=%0.2f, lx=%0.2f, ly=%0.2f", rect.origin.x, rect.origin.y, rect.size.width, rect.size.height, locationInNode.x, locationInNode.y);
		//左侧手势 
		if (ControlrectMove.containsPoint(locationInNodelocal))
		{
			float adsxL = locationInNodelocal.x - proposL.x;
			float adsyL = locationInNodelocal.y - proposL.y;
			hero->locationInNode = locationInNodelocal;
			if (adsxL <= -50 && hero->state != 1) {	//减少手抖的影响且主角不在空中
				proposL = locationInNodelocal;
				// 设置运动状态:左移
				hero->setState(3); log("MMMMMMMMMOOOOOOOOVVVVEEEEE1");
			}
			else if (adsxL >= 50 && hero->state != 1) {
				proposL = locationInNodelocal;
				// 设置运动状态:右移
				hero->setState(4); log("MMMMMMMMMOOOOOOOOVVVVEEEEE2");
			}
		}
		//右上手势
		else if (ControlrectShot.containsPoint(locationInNodelocal)) {
			log("shotmoved");
			proposM = locationInNodelocal;////////////////////////;
			hero->archAngle = locationInNodelocal;
			hero->rotateArrow(hero->archAngle); hero->setState(7);
		}
}
开发者ID:MulticsYin,项目名称:Archer-cocos2d-x,代码行数:33,代码来源:PlaySceneOne.cpp


示例5: OnTouchPressed

void BadaAppForm::OnTouchPressed(const Control& source, 
																 const Point& currentPosition, 
																 const TouchEventInfo& touchInfo) {
	Touch touch;
	_touchCount = touch.GetPointCount();
	if (_touchCount > 1) {
		int index = getShortcutIndex();
		_shortcutIndex = (index == -1 ? 0 : index + 1);
		_shortcutTimer = g_system->getMillis();
		
		switch (_shortcutIndex) {
		case SHORTCUT_F5:
			g_system->displayMessageOnOSD(_("Game Menu"));
			break;
			
		case SHORTCUT_ESCAPE:
			g_system->displayMessageOnOSD(_("Escape"));
			break;
			
		default:
			g_system->displayMessageOnOSD(_("Swap Buttons"));
			_shortcutIndex = SHORTCUT_SWAP_MOUSE;
		}
	}	else if (getShortcutIndex() == -1) {
		pushEvent(_buttonState == LeftButton ? Common::EVENT_LBUTTONDOWN : Common::EVENT_RBUTTONDOWN,
							currentPosition);
	}
}
开发者ID:chrisws,项目名称:scummvm,代码行数:28,代码来源:form.cpp


示例6: ccTouchesMoved

void CocosDenshionTest::ccTouchesMoved(Set *pTouches, Event *pEvent)
{
    Touch* touch = (Touch*)pTouches->anyObject();

    Point touchLocation = touch->getLocation();
    float nMoveY = touchLocation.y - _beginPos.y;

    Point curPos  = _itmeMenu->getPosition();
    Point nextPos = ccp(curPos.x, curPos.y + nMoveY);

    if (nextPos.y < 0.0f)
    {
        _itmeMenu->setPosition(PointZero);
        return;
    }

    if (nextPos.y > ((_testCount + 1)* LINE_SPACE - VisibleRect::getVisibleRect().size.height))
    {
        _itmeMenu->setPosition(ccp(0, ((_testCount + 1)* LINE_SPACE - VisibleRect::getVisibleRect().size.height)));
        return;
    }

    _itmeMenu->setPosition(nextPos);
    _beginPos = touchLocation;
}
开发者ID:bassarisse,项目名称:LostInCaves,代码行数:25,代码来源:CocosDenshionTest.cpp


示例7: screenToWorld

// check if the touch was on one of the flipper buttons
void PinballRUBELayer::onTouchesBegan(const std::vector<Touch *> &touches, cocos2d::Event *event)
{
    // Calling the superclass handles the mouse joint dragging for the launcher,
    // but it also allows the user to grab the ball, and zoom and pan the scene.
    // For a real application you would want to implement a better method here.
    //  RUBELayer::onTouchesBegan(touches, event);
    
    for (auto it = touches.begin(); it != touches.end(); ++it)
    {
        Touch* touch = (Touch*)*it;
        Point screenPos = touch->getLocationInView();
        b2Vec2 worldPos = screenToWorld(screenPos);
        
        CCLOG("Touch began at x: %f y: %f", screenPos.x, screenPos.y);
        
        // Make a small box around the touched point to query for overlapping fixtures
        b2AABB aabb;
        b2Vec2 d(0.001f, 0.001f);
        aabb.lowerBound = worldPos - d;
        aabb.upperBound = worldPos + d;
        
        // Query the world for overlapping fixtures (the TouchDownQueryCallback simply
        // looks for any fixture that contains the touched point)
        TouchDownQueryCallback callback(worldPos);
        m_world->QueryAABB(&callback, aabb);
        
        // if the touched fixture was one of the flipper buttons, set that touch as
        // the current touch for that button
        if (callback.m_fixture == m_leftFlipperButtonFixture)
            m_leftFlipperTouch = touch;
        if (callback.m_fixture == m_rightFlipperButtonFixture)
            m_rightFlipperTouch = touch;
    }
}
开发者ID:iSevenDays,项目名称:RUBEExamples,代码行数:35,代码来源:PinballRUBELayer.cpp


示例8: while

void SelectStage::onTouchesEnded(const vector<Touch *> & touches, Event * event)
{
    vector<Touch *>::const_iterator it = touches.begin();
    while (it != touches.end()) {
        Touch * touch = (Touch *) (* it);
        
        if (touch) {
            Point tap = touch->getLocation();
            Rect select;
            Scene * gameScene;
            
            select = _stageSun->getBoundingBox();
            if (select.containsPoint(tap)) {
                gameScene = TransitionFlipY::create(0.5f,GameLayer::scene(),TransitionScene::Orientation::RIGHT_OVER);
                Director::getInstance()->replaceScene(gameScene);
                
            } else if (!select.containsPoint(tap) &&
                       _stageSea->getBoundingBox().containsPoint(tap)) {
//                gameScene = TransitionFlipY::create(0.5f, GameLayer::scene(), TransitionScene::Orientation::RIGHT_OVER);
//                Director::getInstance()->replaceScene(gameScene);
                
            } else {
                
            }
        }
        
        it++;
    }
    
}
开发者ID:kubocker,项目名称:SpaceShooting,代码行数:30,代码来源:SelectStageLayer.cpp


示例9: while

void MainThread::run() {

  serial.blocking = true;
  serial.baud = 115200;
  serial.echo = true;

  if (serial.open() != Uart0::kOK)
    Board::reboot();

  Touch touch;
  bool touchOk = touch.setup();
  if (!touchOk) {
    serial << "Error during touch sensor setup." << Uart0::endl;
  }

  while (1) {
    if (touch.checkSensor()) {
      serial << "Touch sensor ok." << Uart0::endl;
    }
    else {
      serial << "Touch sensor error." << Uart0::endl;
    }
    sleep_ms(500);
  }
}
开发者ID:DKrepsky,项目名称:Interruptor,代码行数:25,代码来源:main_thread.cpp


示例10: executeTouchCancelledAfterLongClickHandler

void CWidgetWindow::onTouchesCancelled(const std::vector<Touch*>&touches, Event *unused_event)
{
	for(unsigned int i=0;i<touches.size(); i++)
	{
		Touch* pTouch = touches.at(i);
		map<int, __ccMULTITOUCHTARGET>::iterator mitr = m_mMultiTouchKeeper.find(pTouch->getID());
		if( mitr != m_mMultiTouchKeeper.end() )
		{
			if( mitr->second.pWidget )
			{
				if( mitr->second.pWidget->isTouchInterrupted() )
				{
					if( mitr->second.pLongClickedWidgetObject )
					{
						executeTouchCancelledAfterLongClickHandler(mitr->second.pLongClickedWidgetObject, pTouch, mitr->second.fTouchedDuration);
					}
				}
				else
				{
					mitr->second.pWidget->interruptTouchCascade(pTouch, mitr->second.fTouchedDuration);
				}
			}
			m_mMultiTouchKeeper.erase(mitr);
		}
	}
}
开发者ID:110440,项目名称:Tui-x,代码行数:26,代码来源:WidgetWindow.cpp


示例11: CCLOG

void LHScenePhysicsTransformationsDemo::onTouchesBegan(const std::vector<Touch*>& touches, Event* event)
{
    if(touches.size() < 1){
        return;
    }
    Touch* touch = touches[0];
    

    Point location = touch->getLocation();
    
    
    __Array* allPhysicalChildren = this->getGameWorldNode()->getChildrenOfType<Node*>();
    
    for(int i = 0; i < allPhysicalChildren->count(); ++i)
    {
        Node* node = (Node*)allPhysicalChildren->getObjectAtIndex(i);
        
        if(node && node->getBoundingBox().containsPoint(location))
        {
//            node->removeFromParent();//this will remove the node together with its physical body (if any)
            
            CCLOG("SETTING NODE %p TO LOCATION %f %f", node, location.x, location.y);
            node->setPosition(location);
            node->setRotation(LHUtils::LHRandomFloat(0, 360));
            node->setScaleX(LHUtils::LHRandomFloat(0.2, 1.5f));
            node->setScaleY(LHUtils::LHRandomFloat(0.2, 1.5f));
            return;
        }
    }
    //dont forget to call super
    LHScene::onTouchesBegan(touches, event);
}
开发者ID:anilgulgor,项目名称:myGame,代码行数:32,代码来源:LHScenePhysicsTransformationsDemo.cpp


示例12: AddTouchEventListener

result CCEGLView::OnInitializing(void)
{
	result r = E_SUCCESS;

	AddTouchEventListener(*this);
	Touch touch;
	touch.SetMultipointEnabled(*this, true);

    m_pKeypad = new Keypad();
    m_pKeypad->Construct(KEYPAD_STYLE_NORMAL, KEYPAD_MODE_ALPHA);
    m_pKeypad->AddTextEventListener(*this);

	Rectangle rc = GetBounds();
	if ((rc.width == 480 && rc.height == 720)
			|| (rc.width == 720 && rc.height == 480))
	{
		m_bNotHVGA = false;
		m_sSizeInPixel.width = rc.width / 1.5f;
		m_sSizeInPixel.height = rc.height / 1.5f;
	}
	else
	{
		m_bNotHVGA = true;
		m_sSizeInPixel.width = rc.width;
		m_sSizeInPixel.height = rc.height;
	}

	// calculate the factor and the rect of viewport
	m_fScreenScaleFactor =  MIN((float)m_sSizeInPixel.width / m_sSizeInPoint.width,
		                         (float)m_sSizeInPixel.height / m_sSizeInPoint.height);
	//CCLOG("rc.width = %d, rc.height = %d, m_fScreenScaleFactor = %f", rc.width, rc.height, m_fScreenScaleFactor);
	resize(m_sSizeInPoint.width, m_sSizeInPoint.height);

	return r;
}
开发者ID:Avnerus,项目名称:ichigo,代码行数:35,代码来源:CCEGLView_bada.cpp


示例13: screenToWorld

// Override this to find the body that was touched and remove it.
void DestroyBodyLayer::onTouchesBegan(const std::vector<Touch*>& touches, Event *unused_event)
{   
    Touch *touch = (Touch*)touches[0];
    Point screenPos = touch->getLocationInView();
    b2Vec2 worldPos = screenToWorld(screenPos);
    
    // Make a small box around the touched point to query for overlapping fixtures
    b2AABB aabb;
    b2Vec2 d(0.001f, 0.001f);
    aabb.lowerBound = worldPos - d;
    aabb.upperBound = worldPos + d;
    
    // Query the world for overlapping fixtures (the TouchDownQueryCallback simply
    // looks for any fixture that contains the touched point)
    TouchDownQueryCallback callback(worldPos);
    m_world->QueryAABB(&callback, aabb);
    
    // Check if we found something, and it was a dynamic body (could also destroy static
    // bodies but we want to keep the pinch-zoom and pan from the superclass, and it's
    // hard not to touch the ground body in this scene)
    if (callback.m_fixture && callback.m_fixture->GetBody()->GetType() == b2_dynamicBody)
    {
        b2Body* touchedBody = callback.m_fixture->GetBody();
        removeBodyFromWorld(touchedBody);
    }
}
开发者ID:dabing1022,项目名称:rock_box2d,代码行数:27,代码来源:DestroyBodyLayer.cpp


示例14: ccTouchesMoved

void BLevelMenu::ccTouchesMoved(Set *pTouches, Event *pEvent)
{
    Touch* touch = (Touch*)pTouches->anyObject();
    
    Point touchLocation = touch->getLocation();
    float nMoveY = touchLocation.y - beginPos.y;
    
    Point curPos  = itemMenu->getPosition();
    Point nextPos = Point(curPos.x, curPos.y + nMoveY);
    
    if (nextPos.y < 0.0f)
    {
        itemMenu->setPosition(Point::ZERO);
        return;
    }
    
    if (nextPos.y > ((levelCount + 1)* LINE_SPACE - visRect.size.height))
    {
        itemMenu->setPosition(Point(0, ((levelCount + 1)* LINE_SPACE - visRect.size.height)));
        return;
    }
    
    itemMenu->setPosition(nextPos);
    beginPos = touchLocation;
    s_tCurPos   = nextPos;
}
开发者ID:Ben-Cortina,项目名称:GameBox,代码行数:26,代码来源:BoundLevelMenu.cpp


示例15: CCLOG

void GLView::handleTouchesOfEndOrCancel(EventTouch::EventCode eventCode, int num, intptr_t ids[], float xs[], float ys[])
{
    intptr_t id = 0;
    float x = 0.0f;
    float y = 0.0f;
    EventTouch touchEvent;
    
    for (int i = 0; i < num; ++i)
    {
        id = ids[i];
        x = xs[i];
        y = ys[i];

        auto iter = g_touchIdReorderMap.find(id);
        if (iter == g_touchIdReorderMap.end())
        {
            CCLOG("if the index doesn't exist, it is an error");
            continue;
        }
        
        /* Add to the set to send to the director */
        Touch* touch = g_touches[iter->second];
        if (touch)
        {
            CCLOGINFO("Ending touches with id: %d, x=%f, y=%f", id, x, y);
            touch->setTouchInfo(iter->second, (x - _viewPortRect.origin.x) / _scaleX,
                                (y - _viewPortRect.origin.y) / _scaleY);

            touchEvent._touches.push_back(touch);
            
            g_touches[iter->second] = nullptr;
            removeUsedIndexBit(iter->second);

            g_touchIdReorderMap.erase(id);
        } 
        else
        {
            CCLOG("Ending touches with id: %ld error", static_cast<long>(id));
            return;
        } 

    }

    if (touchEvent._touches.size() == 0)
    {
        CCLOG("touchesEnded or touchesCancel: size = 0");
        return;
    }
    
    touchEvent._eventCode = eventCode;
    auto dispatcher = Director::getInstance()->getEventDispatcher();
    dispatcher->dispatchEvent(&touchEvent);
    
    for (auto& touch : touchEvent._touches)
    {
        // release the touch object.
        touch->release();
    }
}
开发者ID:boruis,项目名称:cocos2dx-lite,代码行数:59,代码来源:CCGLView.cpp


示例16: if

void PluginView::handleTouchEvent(TouchEvent* event)
{
    if (!m_window->isAcceptingEvent(kTouch_ANPEventFlag))
        return;

    if (!m_window->inFullScreen() && m_parentFrame->document()->focusedNode() != m_element)
        return;

    ANPEvent evt;
    SkANP::InitEvent(&evt, kMultiTouch_ANPEventType);

    const AtomicString& type = event->type();
    if (eventNames().touchstartEvent == type)
        evt.data.multiTouch.action = kDown_ANPTouchAction;
    else if (eventNames().touchendEvent == type)
        evt.data.multiTouch.action = kUp_ANPTouchAction;
    else if (eventNames().touchmoveEvent == type)
        evt.data.multiTouch.action = kMove_ANPTouchAction;
    else if (eventNames().touchcancelEvent == type)
        evt.data.multiTouch.action = kCancel_ANPTouchAction;
    else if (eventNames().touchlongpressEvent == type)
        evt.data.multiTouch.action = kLongPress_ANPTouchAction;
    else if (eventNames().touchdoubletapEvent == type)
        evt.data.multiTouch.action = kDoubleTap_ANPTouchAction;
    else
        return;

    // set the id and timestamp
    evt.data.multiTouch.id = 0; // TODO
    evt.data.multiTouch.timestamp = 0; // TODO

    // In the event of a touchend (up) or touchcancel event, we must ask the changedTouch for the
    // co-ordinates as there is no touch in touches anymore.
    TouchList* touches = (evt.data.multiTouch.action == kUp_ANPTouchAction
        || evt.data.multiTouch.action == kCancel_ANPTouchAction) ? event->changedTouches() : event->touches();

    // set each touchPoint
    int pointerCount = touches->length();
    evt.data.multiTouch.pointerCount = pointerCount;
    evt.data.multiTouch.touchPoint = new TouchPoint[pointerCount];

    for (int x = 0; x < evt.data.multiTouch.pointerCount; x++) {
        Touch* touch = touches->item(x);
        // Convert to coordinates that are relative to the plugin.
        IntPoint localPos = roundedIntPoint(m_element->renderer()->absoluteToLocal(IntPoint(touch->pageX(), touch->pageY())));

        evt.data.multiTouch.touchPoint[x].id = touch->identifier();
        evt.data.multiTouch.touchPoint[x].x = localPos.x();
        evt.data.multiTouch.touchPoint[x].y = localPos.y();
        evt.data.multiTouch.touchPoint[x].pressure = 1; // TODO
        evt.data.multiTouch.touchPoint[x].size = 1; // TODO
    }

    if (m_window->sendEvent(evt))
        event->preventDefault();

    // cleanup the touch points we allocated
    delete[] evt.data.multiTouch.touchPoint;
}
开发者ID:AndDiSa,项目名称:platform_external_webkit,代码行数:59,代码来源:PluginViewAndroid.cpp


示例17:

void MotionStreakTest2::ccTouchesMoved(Set* touches, Event* event)
{
    Touch* touch = static_cast<Touch*>( touches->anyObject() );

    Point touchLocation = touch->getLocation();    
    
    streak->setPosition( touchLocation );
}
开发者ID:CBanDa,项目名称:cocos2d-x-3.0alpha0-pre,代码行数:8,代码来源:MotionStreakTest.cpp


示例18: jsTouchIdentifier

JSValue jsTouchIdentifier(ExecState* exec, JSValue slotBase, const Identifier&)
{
    JSTouch* castedThis = static_cast<JSTouch*>(asObject(slotBase));
    UNUSED_PARAM(exec);
    Touch* imp = static_cast<Touch*>(castedThis->impl());
    JSValue result = jsNumber(imp->identifier());
    return result;
}
开发者ID:13W,项目名称:phantomjs,代码行数:8,代码来源:JSTouch.cpp


示例19: jsTouchTarget

JSValue jsTouchTarget(ExecState* exec, JSValue slotBase, const Identifier&)
{
    JSTouch* castedThis = static_cast<JSTouch*>(asObject(slotBase));
    UNUSED_PARAM(exec);
    Touch* imp = static_cast<Touch*>(castedThis->impl());
    JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->target()));
    return result;
}
开发者ID:13W,项目名称:phantomjs,代码行数:8,代码来源:JSTouch.cpp


示例20: onTouchesMoved

void GameLayer::onTouchesMoved(const std::vector<Touch*>& touches, Event * event) {
    
    if(_gameOver || _is_character_moving)
        return;
    
    Touch* touch = touches[0];
    Vec2 location = touch->getLocation();
}
开发者ID:Ratel13,项目名称:VitrumProjects,代码行数:8,代码来源:GameLayer.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ TouchButton类代码示例发布时间:2022-05-31
下一篇:
C++ TorControlConnection类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap