Exemplo n.º 1
0
void ChapterScene::onTouchMoved(Touch* touch, Event* event) {
    Point point = this->convertTouchToNodeSpace(touch);

    Point vectorMove = Point::ZERO;
    if (!this->isMoved) {
        vectorMove = point - this->firstPoint;
    } else {
        vectorMove = point - this->movePoint;
    }
    this->updateChapterLayer(vectorMove);
    this->movePoint = point;
    this->isMoved = true;
    
    // update flash
    {
        Point point = this->convertTouchToNodeSpace(touch);
        point = point - this->chapterLayer->getPosition();
        
        for (int i = 0; i < this->chapterLayer->getChildren().size(); i++) {
            Face* chapterFace = dynamic_cast<Face*>(this->chapterLayer->getChildren().at(i));
            if (chapterFace != NULL) {
                this->flashOff(chapterFace);
                RectBody* chapterBody = new RectBody(chapterFace->getContentSize().width, chapterFace->getContentSize().height);
                chapterBody->setPosition(chapterFace->getPosition());
                
                if (chapterBody->contains(point)) {
                    this->flashOn(chapterFace);
                }
            }
        }
    }
}
Exemplo n.º 2
0
bool LevelScene::onTouchBegan(Touch* touch, Event* event) {
    Point point = this->convertTouchToNodeSpace(touch);
    
    this->isMoved = false;
    this->isTouched = false;
    RectBody* chapterLayerBody = new RectBody(this->levelLayer->getContentSize().width, this->levelLayer->getContentSize().height);
    chapterLayerBody->setPosition(this->levelLayer->getPosition() + Point(chapterLayerBody->getWidth() / 2, chapterLayerBody->getHeight() / 2));
    
    if (chapterLayerBody->contains(point)) {
        this->isTouched = true;
        this->firstPoint = point;
        
        // update flash
        {
            Point point = this->convertTouchToNodeSpace(touch);
            point = point - this->levelLayer->getPosition();
            
            for (int i = 0; i < this->levelLayer->getChildren().size(); i++) {
                CSprite* levelFace = dynamic_cast<CSprite*>(this->levelLayer->getChildren().at(i));
                if (levelFace != NULL) {
                    RectBody* levelBody = new RectBody(levelFace->getContentSize().width, levelFace->getContentSize().height);
                    levelBody->setPosition(levelFace->getPosition());
                }
            }
        }
        return true;
    }
    return false;
}
Exemplo n.º 3
0
bool ChapterScene::onTouchBegan(Touch* touch, Event* event) {
    if (this->shareLayer->isVisible() ||
        this->chapterMoving) {
        return false;
    }
    Point point = this->convertTouchToNodeSpace(touch);
    
    this->isMoved = false;
    this->isTouched = false;
    RectBody* chapterLayerBody = new RectBody(this->chapterLayer->getContentSize().width, this->chapterLayer->getContentSize().height);
    chapterLayerBody->setPosition(this->chapterLayer->getPosition() + Point(chapterLayerBody->getWidth() / 2, chapterLayerBody->getHeight() / 2));
    
    if (chapterLayerBody->contains(point)) {
        this->isTouched = true;
        this->firstPoint = point;
        
        // update flash
        {
            Point point = this->convertTouchToNodeSpace(touch);
            point = point - this->chapterLayer->getPosition();
            
            for (int i = 0; i < this->chapterLayer->getChildren().size(); i++) {
                Face* chapterFace = dynamic_cast<Face*>(this->chapterLayer->getChildren().at(i));
                if (chapterFace != NULL) {
                    this->flashOff(chapterFace);
                    RectBody* chapterBody = new RectBody(chapterFace->getContentSize().width, chapterFace->getContentSize().height);
                    chapterBody->setPosition(chapterFace->getPosition());
                    
                    if (chapterBody->contains(point)) {
                        this->flashOn(chapterFace);
                    }
                }
            }
        }
        return true;
    }
    return false;
}
Exemplo n.º 4
0
void ChapterScene::onTouchEnded(Touch* touch, Event* event) {
    GameModel* gameModel = GameModel::getInstance();
    this->updatePageAuto();
    
    Point point = this->convertTouchToNodeSpace(touch);
    bool moveTooFar = false;
    float dx = point.x - this->firstPoint.x;
    float dy = point.y - this->firstPoint.y;
    if (abs(dx) > CONF_TOUCH_RANGE || abs(dy) > CONF_TOUCH_RANGE) {
        moveTooFar = true;
    }
    point = point - this->chapterLayer->getPosition();
    
    for (int i = 0; i < this->chapterLayer->getChildren().size(); i++) {
        Face* chapterFace = dynamic_cast<Face*>(this->chapterLayer->getChildren().at(i));
        if (chapterFace != NULL) {
            RectBody* chapterBody = new RectBody(chapterFace->getContentSize().width, chapterFace->getContentSize().height);
            chapterBody->setPosition(chapterFace->getPosition());
            
            if (chapterBody->contains(point)) {
                if (!moveTooFar && chapterFace->getTag() != -1) {
                    if (!gameModel->checkLevelRequireSocial(i + 1)) {
                        this->shareLayer->show(TXT_REQUIRE_SHARE);
                        GameEvent* gameEvent = new GameEvent();
                        gameEvent->setEventCode(EVT_SHOW_SHARE_REQUIRED);
                        this->fireEvent(gameEvent);
                    } else {
                        DataEvent* gameEvent = new DataEvent();
                        gameEvent->setEventCode(EVT_START_PLAY);
                        gameEvent->setArgumentInt(chapterFace->getTag());
                        this->fireEvent(gameEvent);
                        
                        this->_eventDispatcher->removeEventListener(this->touchListener);
                    }
                }
                this->flash(chapterFace);
                break;
            }
        }
    }
}
Exemplo n.º 5
0
void LevelScene::onTouchEnded(Touch* touch, Event* event) {
    if (this->dialogLayer->isVisible()) {
        return;
    }
    
    this->updatePageAuto();
    
    Point point = this->convertTouchToNodeSpace(touch);
    bool moveTooFar = false;
    float dx = point.x - this->firstPoint.x;
    float dy = point.y - this->firstPoint.y;
    if (abs(dx) > CONF_TOUCH_RANGE || abs(dy) > CONF_TOUCH_RANGE) {
        moveTooFar = true;
    }
    point = point - this->levelLayer->getPosition();
    
    for (int i = 0; i < this->levelLayer->getChildren().size(); i++) {
        CSprite* levelFace = dynamic_cast<CSprite*>(this->levelLayer->getChildren().at(i));
        if (levelFace != NULL) {
            RectBody* levelBody = new RectBody(levelFace->getContentSize().width, levelFace->getContentSize().height);
            levelBody->setPosition(levelFace->getPosition());
            
            if (levelBody->contains(point)) {
                if (!moveTooFar && levelFace->getTag() != -1) {
                    DataEvent* gameEvent = new DataEvent();
                    gameEvent->setEventCode(EVT_START_LEVEL);
                    gameEvent->setArgumentInt(levelFace->getTag());
                    this->fireEvent(gameEvent);
                    
                    this->_eventDispatcher->removeEventListener(this->touchListener);
                }
                break;
            }
        }
    }
}