void LevelLayer::onTouchEnded(Touch *touch, Event *event) { touchUpPoint = touch->getLocation(); auto dis= touchUpPoint.getDistance(touchDownPoint); auto width = WINDOW_WIDTH/5; if(dis <= TAP_LENGTH) { Node* page = getChildByTag(curPageNode); LevelSelLayer* sel = dynamic_cast<LevelSelLayer*>(page); if(sel && curPageNode < (pageNode - 1) && sel->isTapToMove()) { ++curPageNode; goToCurrNode(); } return; } if (dis >= SHORTEST_SLIDE_LENGTH ) { int offset = getPositionX() + curPageNode * WINDOW_WIDTH; if (offset > width) { if (curPageNode > 0) { --curPageNode; } } else if (offset < -width) { if (curPageNode < (pageNode - 1)) { ++curPageNode; } } goToCurrNode(); } }
void LevelLayer::onTouchEnded(Touch *touch, Event *event) { touchUpPoint = touch->getLocation(); auto dis= touchUpPoint.getDistance(touchDownPoint); auto sprite1 =Sprite::createWithSpriteFrameName("page_mark1.png"); auto width = sprite1->getContentSize().width; if (dis >= SHORTEST_SLIDE_LENGTH ) { int offset = getPositionX() - curPageNode * (-WINDOW_WIDTH); if (offset > width) { if (curPageNode > 0) { --curPageNode; Sprite *sprite = (Sprite *)LevelScene::getInstance()->getChildByTag(888); sprite->setPosition(Point(sprite->getPositionX()-width,sprite->getPositionY())); } } else if (offset < -width) { if (curPageNode < (pageNode - 1)) { ++curPageNode; Sprite *sprite = (Sprite *)LevelScene::getInstance()->getChildByTag(888); sprite->setPosition(Point(sprite->getPositionX()+width,sprite->getPositionY())); } } goToCurrNode(); } }