本文整理汇总了C++中Touch::getLocation方法的典型用法代码示例。如果您正苦于以下问题:C++ Touch::getLocation方法的具体用法?C++ Touch::getLocation怎么用?C++ Touch::getLocation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Touch
的用法示例。
在下文中一共展示了Touch::getLocation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onTouchesBegan
void Joystick::onTouchesBegan(const std::vector<Touch*>& touches, Event *unused_event)
{
std::vector<Touch*>::const_iterator touchIter = touches.begin();
Touch* touch = (Touch*)(*touchIter);
if(m_pJoystick->getBoundingBox().containsPoint(touch->getLocation()))
{
this->showJoystick();
updateJoystick(touch);
CCLOG("***");
CCLOG("update touch:%f %f",touch->getLocation().x,touch->getLocation().y);
return;
}
}
示例2: onTouchesEnded
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++;
}
}
示例3: onTouchMoved
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);
}
}
示例4: 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;
}
示例5: onTouchesMoved
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();
}
}
}
示例6: 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;
}
示例7:
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);
}
示例8: onTouchesBegan
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);
}
示例9: 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();
}
示例10:
void MotionStreakTest2::ccTouchesMoved(Set* touches, Event* event)
{
Touch* touch = static_cast<Touch*>( touches->anyObject() );
Point touchLocation = touch->getLocation();
streak->setPosition( touchLocation );
}
示例11: onTouchesMoved
void Joystick::onTouchesMoved(const std::vector<Touch *> &touches, Event *event)
{
if (_isPressed)
{
Touch *touch = touches[0];
Vec2 touchPoint = touch->getLocation();
this->updateVelocity(touchPoint);
}
}
示例12: onTouchesBegan
void GameLayer::onTouchesBegan(const std::vector<Touch*>& touches, Event * event) {
if(_gameOver || _is_character_moving)
return;
Touch* touch = touches[0];
Vec2 location = touch->getLocation();
_startTouchPoint = location;
_touchingTime = 0;
_isTouching = true;
}
示例13: onTouchesBegan
void Joystick::onTouchesBegan(const std::vector<Touch *> &touches, Event *event)
{
Touch *touch = touches[0];
Vec2 touchPoint = touch->getLocation();
if (isPointInCircle(touchPoint, _center, _joystickRadius))
{
_isPressed = true;
this->updateVelocity(touchPoint);
}
}
示例14: onTouchesBegan
void OperateLayer::onTouchesBegan(const vector<Touch*>& touches, Event *unused_event)
{
Size winSize = Director::getInstance()->getWinSize();
vector<Touch*>::const_iterator touchIter = touches.begin();
while(touchIter != touches.end())
{
Touch *pTouch = (Touch*)(*touchIter);
Point p = pTouch->getLocation();
++ touchIter;
}
}
示例15: onTouchesMoved
void SelectStage::onTouchesMoved(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();
}
}
}