Example #1
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;
}
Example #2
0
void Level::checkTouchLeaf(Point point) {
    if (this->hanged || this->done) {
        return;
    }
    
    if (this->frog->getJumping()) {
        return;
    }
    
    __Array* allLeavesKey = this->getLeaves()->allKeys();
    for (int i = 0; i < allLeavesKey->count(); i++) {
        __Integer* key = (__Integer*) allLeavesKey->getObjectAtIndex(i);
        Leaf* leaf = (Leaf*) this->getLeaves()->objectForKey(key->getValue());
        if (leaf->getDrowning()) {
            continue;
        }
        
        RectBody* leafBody = (RectBody*) leaf->getBody();
        if (CPointUtil::isPointInRectangle(point, leaf->getPosition(), leafBody->getWidth(), leafBody->getHeight())) {
            ViewDirection willingDirection = this->checkJumpable(leaf);
            if (willingDirection != VIEW_NONE) {
                this->frog->setViewDirection(willingDirection);
                this->frogJump(leaf);
            }
            break;
        }
    }
}
Example #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;
}