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


C++ EventMouse类代码示例

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


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

示例1: onMouseMove

///Referencing previous location results in garbage values
///Use only for hover
void HelloWorld::onMouseMove(Event* event)
{
#ifdef MOUSE_DOUBLE_LISTEN_FUDGE
    mouseMoveFudge = !mouseMoveFudge;
    if(!mouseMoveFudge)
        return;
#endif
    EventMouse* e = (EventMouse*)event;
    lastCursor.x = e->getCursorX();
    lastCursor.y = e->getCursorY();
    repaintCursor();
    Protractor* p = (Protractor*)protractor;
    p->setCursorAngle(StaticHelpers::headingAngle(lastCursor - Director::getInstance()->getVisibleSize()/2));

    if(isMouseDown[0])
    {//LMB drag

    }
    if(isMouseDown[1])
    {//RMB drag

    }
    if(isMouseDown[2])
    {//MMB drag

    }

    std::stringstream ss;
    ss << "MousePosition X:";
    ss << e->getCursorX() << " Y:" << e->getCursorY();
}
开发者ID:dare0021,项目名称:October3rd,代码行数:33,代码来源:HelloWorldScene.cpp

示例2: onMouseUp

void MouseTest::onMouseUp(Event *event)
{
    EventMouse* e = (EventMouse*)event;
    std::string str = "Mouse Up detected, Key: ";
    str += tostr(e->getMouseButton());
    _labelAction->setString(str.c_str());
}
开发者ID:fordream,项目名称:Snake,代码行数:7,代码来源:MouseTest.cpp

示例3: onMouseDown

void HelloWorld::onMouseDown(Event* event)
{
#ifdef MOUSE_DOUBLE_LISTEN_FUDGE
    mouseDownFudge = !mouseDownFudge;
    if(!mouseDownFudge)
        return;
#endif
    EventMouse* e = (EventMouse*)event;
    isMouseDown[e->getMouseButton()] = true;
    std::stringstream ss;
    ss << "Mouse Down ";
    ss << e->getMouseButton();

    if(e->getMouseButton() == 1)
    {
        if(!getChildByName("animtest"))
        {
            auto s = new O3Sprite("", true);
            addSprite(s);
            s->addAnimation("idle", "animtest", 9, 12);
            s->setAnimation("idle");
            s->playAnimation();
            s->setName("animtest");
        }
        else
        {
            removeChildByName("animtest");
        }
    }
}
开发者ID:dare0021,项目名称:October3rd,代码行数:30,代码来源:HelloWorldScene.cpp

示例4: onMouseMove

void MouseTest::onMouseMove(Event *event)
{
    EventMouse* e = (EventMouse*)event;
    std::string str = "MousePosition X:";
    str = str + tostr(e->getCursorX()) + " Y:" + tostr(e->getCursorY());
    _labelPosition->setString(str.c_str());
}
开发者ID:fordream,项目名称:Snake,代码行数:7,代码来源:MouseTest.cpp

示例5: log

void HelloWorld::testMouseEvent()
{
	auto listener = EventListenerMouse::create();

	listener->onMouseDown = [&](Event* event){
		log("onMouseDown");
	};

	listener->onMouseMove = [&](Event* event){
		log("onMouseMove");
		EventMouse* e = (EventMouse*)event;
		touch_pos = e->getLocation();
		streak->setPosition(touch_pos);
	};

	listener->onMouseUp = [&](Event* event){
		log("onMouseUp");
	};

	listener->onMouseScroll = [&](Event* event){
		log("onMouseScroll");
	};

	dispatcher->addEventListenerWithSceneGraphPriority(listener, this);
}
开发者ID:huangjj27,项目名称:mosad,代码行数:25,代码来源:HelloWorldScene.cpp

示例6: onMouseUp

void LCBattleScene::onMouseUp(Event *event)
{
    EventMouse* e = (EventMouse*)event;
    //world->setGravity(Point(0 ,-98));
    //world->setSpeed(1);
//    Vect vct = world->getGravity();
//    float speed = world->getSpeed();
    // right clicked move hero
    if(e->getMouseButton() == 1) {
        // retain screen double length
        //Point pos = CCDirector::getInstance()->convertToGL(Point(e->getCursorX(), e->getCursorY()));//glLocation, origin(0,0)
        //pos.y = CCDirector::getInstance()->getWinSize().height - pos.y / 2;
        //CCLOG("%f %f", pos.x, pos.y);

        //Point origin = hero->getrootObj()->getPosition();

        //CCLOG("%f %f", origin.x, origin.y);

        //Point convertedToNodeLocation = backGround->convertToNodeSpace(pos);

        //Point p = getPointInMap();
        hero->actionWalk(this, backGround->convertToNodeSpace(Point(e->getCursorX(), e->getCursorY())));
    } else if(e->getMouseButton() == 0) {
        hero->actionAttack();
    }
}
开发者ID:rotonlin,项目名称:Fighter,代码行数:26,代码来源:fighter.cpp

示例7: onMouseUp

void Tower::onMouseUp(cocos2d::Event* _event)
{
    if(_isClosing == true || _returnFromSave == true)
    {
        _returnFromSave = false;
        return;// if we are pressing the close button, we dont want to build things!
    }
    
	EventMouse* e = (EventMouse*)_event;

	if(_isMovingToolPanal == true)
	{
		_isMovingToolPanal = false;

		return; //if we are moving a window, we dont want to build things!
	}

	if(_isBuildingFloor == true)
	{
		_isBuildingFloor = false;
	}

	float mPPY = e->getCursorY()+_mouseYOffset;
	float mPPX = e->getCursorX();
    
    this->createStructure(Vec2(mPPX,mPPY));
    
}
开发者ID:binarybird,项目名称:OpenTower,代码行数:28,代码来源:TowerScene.cpp

示例8: onMouseDown

void Tower::onMouseDown(cocos2d::Event* _event)
{
    if(_isClosing == true || _returnFromSave == true)
        return;// if we are pressing the close button, we dont want to build things!
    
	EventMouse* e = (EventMouse*)_event;

	Vec2 tPP = _toolPanalLayer->getPosition();
	float mPPY = e->getCursorY();
	float mPPX = e->getCursorX();

	mPPY=mPPY+_mouseYOffset;

	if(mPPY < tPP.y + TOOLPANAL_HEIGHT+2 && mPPY > tPP.y-2)
		if(mPPX > tPP.x -2 && mPPX < tPP.x + TOOLPANAL_WIDTH+2){
			_isMovingToolPanal = true;
			
			_windowOffsetX = mPPX - tPP.x;
			_windowOffsetY = mPPY - tPP.y;
			return;
		}

	if(_currentStructure == OT::OTFLOOR)
	{
		_isBuildingFloor = true;//have to handle differently from other structures
	}
}
开发者ID:binarybird,项目名称:OpenTower,代码行数:27,代码来源:TowerScene.cpp

示例9: getch

void InputManager::getInput()
{
	int c = getch();

	if (c != ERR)
	{
		MEVENT m_event;
		if ((c == KEY_MOUSE) && (getmouse(&m_event) != ERR))
		{
			if (m_event.bstate & BUTTON1_CLICKED)
			{
				int y = m_event.y;
				int x = m_event.x;

				EventMouse m;

				m.setMouseY(y);
				m.setMouseX(x);
				m.setMouseAction(LEFT_BUTTON_CLICK);

				onEvent((Event*) &m);
			}

		}
		else
		{

			EventKeyboard k;
			k.setKey(c);

			onEvent((Event*) &k);
		}
	}
}
开发者ID:jakehaas,项目名称:K9-Engine-Console,代码行数:34,代码来源:InputManager.cpp

示例10: onMouseScroll

void MouseTest::onMouseScroll(Event *event)
{
    EventMouse* e = (EventMouse*)event;
    std::string str = "Mouse Scroll detected, X: ";
    str = str + tostr(e->getScrollX()) + " Y: " + tostr(e->getScrollY());
    _labelAction->setString(str.c_str());
}
开发者ID:fordream,项目名称:Snake,代码行数:7,代码来源:MouseTest.cpp

示例11: qDebug

// on "init" you need to initialize your instance
bool HelloWorld::init()
{
    if ( !Layer::init() )
    {
        return false;
    }
	FileUtils::getInstance()->addSearchPath("../QtCocos2d/Resources");
	FileUtils::getInstance()->addSearchResolutionsOrder("resource-auto");
	Director::getInstance()->setContentScaleFactor(2.0f);
	Director::getInstance()->setAnimationInterval(FLT_MIN);

    Size visibleSize = Director::getInstance()->getVisibleSize();
    Vec2 origin = Director::getInstance()->getVisibleOrigin();


	auto centerNode = Node::create();
	centerNode->setAnchorPoint(Point::ANCHOR_MIDDLE);
//	centerNode->setContentSize(visibleSize);
	centerNode->setPosition(origin + visibleSize/2);
	this->addChild(centerNode);

	auto frame = Sprite::create("system/frame_iphone4.png");
	frame->setAnchorPoint(Point::ANCHOR_MIDDLE);
	centerNode->addChild(frame);

	auto worldPos = centerNode->convertToWorldSpace(frame->getPosition());
	qDebug() << worldPos.x << "," << worldPos.y;

	auto listener = EventListenerMouse::create();
	listener->onMouseScroll = [this, frame](Event* event){
		EventMouse *e = dynamic_cast<EventMouse *>(event);
		if (NULL != e)
		{
			float scrollY = e->getScrollY();
			frame->setScale(scrollY / 10.0f + frame->getScale());
		}
	};
	_eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);

	auto baseNode = Node::create();
	baseNode->setContentSize(Size(480, 320));
	baseNode->setPosition(baseNode->getContentSize() / -2 + frame->getContentSize()/2);
	frame->addChild(baseNode);
	worldPos = frame->convertToWorldSpace(baseNode->getPosition());
	qDebug() << worldPos.x << "," << worldPos.y;
	/*
	ControlButton * button = ControlButton::create();
	button->setTitleLabelForState(Label::createWithSystemFont("aaa", "MS Gothic", 12), Control::State::NORMAL);
	baseNode->addChild(button);
	*/
	_metaInfo = InterfaceLoader::getInstance().loadJSon("interface/scene/scenetest.json");
	if (_metaInfo)
	{
		_metaInfo->retain();
		baseNode->addChild(_metaInfo->getBaseNode());
	}
	    
    return true;
}
开发者ID:d66abd0f,项目名称:3457dd3536d9ef5d5a686613d6448b0e,代码行数:60,代码来源:HelloWorldScene.cpp

示例12: OnMouseMove

void GameMenu::OnMouseMove(Event *event)
{
	EventMouse *e = (EventMouse*)event;

	int x = e->getCursorX();
	int y = e->getCursorY();

<<<<<<< HEAD
开发者ID:alexgrao,项目名称:TheCatacombsCocos,代码行数:8,代码来源:GameMenu.cpp

示例13: onMouseMove

void HelloWorld::onMouseMove(Event* event) {
	EventMouse* e = (EventMouse*)event;
	CCPoint mousePosition = CCPoint(e->getCursorX(), e->getCursorY() + 640);

	auto block1 = startMenuItem->getBoundingBox();
	if (block1.containsPoint(mousePosition)) largerItem(startMenuItem, 1);
	else largerItem(NULL, 0);
}
开发者ID:dengysh,项目名称:CatapultGame,代码行数:8,代码来源:HelloWorldScene.cpp

示例14: onMouseMove

void GameLayer::onMouseMove(cocos2d::Event* event)
{
	EventMouse* e = (EventMouse*)event;

	auto p = Vec2(e->getCursorX(), e->getCursorY());

	auto pPlayer = dynamic_cast<LeadingMan*>(this->getChildByTag(kTagPlayer));

}
开发者ID:zuokaihuang,项目名称:MyFlow,代码行数:9,代码来源:GameLayer.cpp

示例15: onMouseScroll

void Tower::onMouseScroll(cocos2d::Event* _event)
{
    if(_isClosing == true || _returnFromSave == true)
        return;// if we are pressing the close button, we dont want to build things!
    
	EventMouse* e = (EventMouse*)_event;

	_towerLayer->runAction(MoveBy::create(1/SCROLL_SPEED ,Vec2((-1*e->getScrollX())*SCROLL_MULTIPLIER, e->getScrollY()*SCROLL_MULTIPLIER)));
}
开发者ID:binarybird,项目名称:OpenTower,代码行数:9,代码来源:TowerScene.cpp


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