本文整理汇总了C++中EventMouse::getCursorX方法的典型用法代码示例。如果您正苦于以下问题:C++ EventMouse::getCursorX方法的具体用法?C++ EventMouse::getCursorX怎么用?C++ EventMouse::getCursorX使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EventMouse
的用法示例。
在下文中一共展示了EventMouse::getCursorX方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
示例2: onMouseMove
void Tower::onMouseMove(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)
{
Vec2 tPP = _toolPanalLayer->getPosition();
float mPPY = e->getCursorY();
float mPPX = e->getCursorX();
mPPY=mPPY+_mouseYOffset;
_toolPanalLayer->setPosition(Vec2(mPPX-_windowOffsetX,mPPY-_windowOffsetY));
}
if(_isBuildingFloor == true)
{
float mPPY = e->getCursorY()+_mouseYOffset;
float mPPX = e->getCursorX();
createStructure(Vec2(mPPX,mPPY));
}
_mouseLayer->setPosition(e->getCursorX()-_currentStructureSize.width/2, _mouseYOffset + e->getCursorY() - _currentStructureSize.height/2);
}
示例3: 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());
}
示例4: 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();
}
}
示例5: 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
}
}
示例6: 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));
}
示例7: OnMouseMove
void GameMenu::OnMouseMove(Event *event)
{
EventMouse *e = (EventMouse*)event;
int x = e->getCursorX();
int y = e->getCursorY();
<<<<<<< HEAD
示例8: 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);
}
示例9: 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));
}
示例10: init
bool SplashLayer::init() {
if (!Layer::init()) {
return false;
}
//get Size
Size visibleSize = Director::getInstance()->getVisibleSize();
//change splash image here:
auto splash = Sprite::create("Splash.png");
splash->setPosition(Vec2(visibleSize.width / 2, visibleSize.height / 2));
this->addChild(splash);
auto start = Sprite::create("Splash_start.png");
start->setPosition(Vec2(visibleSize.width / 2, 300));
this->addChild(start);
auto quit = Sprite::create("Splash_quit.png");
quit->setPosition(Vec2(visibleSize.width / 2, 200));
this->addChild(quit);
//鼠标悬停,start按钮变大
auto startlistener = EventListenerMouse::create();
startlistener->onMouseMove = [=](Event* event) {
Sprite* start = static_cast<Sprite*>(event->getCurrentTarget());
EventMouse* mouse = static_cast<EventMouse*>(event);
if (mouse->getCursorX() > 417 && mouse->getCursorX() < 607 &&
mouse->getCursorY() > -484 && mouse->getCursorY() < -452) {
if (aboveStart) {
auto scale = ScaleTo::create(0.1f, 1.2f);
start->runAction(scale);
aboveStart = false;
notAboveStart = true;
}
}
else {
if (notAboveStart) {
auto scaleback = ScaleTo::create(0.1f, 1);
start->runAction(scaleback);
aboveStart = true;
notAboveStart = false;
}
}
};
_eventDispatcher->addEventListenerWithSceneGraphPriority(startlistener, start);
//鼠标悬停,quit按钮变大
auto quitlistener = EventListenerMouse::create();
quitlistener->onMouseMove = [=](Event* event) {
Sprite* quit = static_cast<Sprite*>(event->getCurrentTarget());
EventMouse* mouse = static_cast<EventMouse*>(event);
if (mouse->getCursorX() > 446 && mouse->getCursorX() < 578 &&
mouse->getCursorY() > -585 && mouse->getCursorY() < -551) {
if (aboveQuit) {
auto scale = ScaleTo::create(0.1f, 1.2f);
quit->runAction(scale);
aboveQuit = false;
notAboveQuit = true;
}
}
else {
if (notAboveQuit) {
auto scaleback = ScaleTo::create(0.1f, 1);
quit->runAction(scaleback);
aboveQuit = true;
notAboveQuit = false;
}
}
};
_eventDispatcher->addEventListenerWithSceneGraphPriority(quitlistener, quit);
//点击start按钮,场景切换进入关卡选择界面
auto startclick = EventListenerMouse::create();
startclick->onMouseDown = [](Event* event) {
EventMouse* mouse = static_cast<EventMouse*>(event);
if (mouse->getCursorX() > 417 && mouse->getCursorX() < 607 &&
mouse->getCursorY() > -484 && mouse->getCursorY() < -452) {
//获取当前时间作为随机数种子
srand((unsigned int)time(nullptr));
//生成范围为[1, 20]的随机数,20中随机动画
int a = (rand() % 20) + 1;
switch (a) {
case 1:
Director::getInstance()->replaceScene(TransitionProgressRadialCCW::create(0.5f, HomeScene::create()));
break;
case 2:
Director::getInstance()->replaceScene(TransitionProgressRadialCW::create(0.5f, HomeScene::create()));
break;
case 3:
Director::getInstance()->replaceScene(TransitionProgressHorizontal::create(0.5f, HomeScene::create()));
break;
case 4:
Director::getInstance()->replaceScene(TransitionProgressVertical::create(0.5f, HomeScene::create()));
break;
case 5:
//.........这里部分代码省略.........