bool LsTouch::containsCCTouchPoint(CCTouch* ccTouch)
{
    CCNode* dis = getChildByTag(TAG_DISPLAY);
    CCSprite* sprite = dynamic_cast<CCSprite*>(dis);
    CCPoint point = sprite->convertTouchToNodeSpaceAR(ccTouch);
    CCSize s = sprite->getContentSize();//sprite->getTexture()->getContentSize();
    CCRect rect = CCRectMake(-s.width / 2, -s.height / 2, s.width, s.height);
    return rect.containsPoint(point);
}
Example #2
0
void Menu::ccTouchEnded(cocos2d::CCTouch *pTouch, cocos2d::CCEvent *pEvent)
{
    CCPoint point = pTouch->getLocation();
    CCSprite* background = (CCSprite*)this->getParent()->getChildByTag(2);
    //相対座標の変換
    CCPoint convertPoint = background->convertTouchToNodeSpaceAR(pTouch);
    CCSprite* decisionSprite = CCSprite::createWithTexture(this->getTexture());

    decisionSprite->setScale(0.7);
    decisionSprite->setPosition(convertPoint);
    background->addChild(decisionSprite);

//    CCLabelTTF* timer = CCLabelTTF::create("2日 12時間32分54秒", "arial", 20);
//    timer->CCNode::setPosition(decisionSprite->getContentSize().width / 2, decisionSprite->getContentSize().height / 2 + 80);
//    decisionSprite->addChild(timer);

    this->getParent()->removeChildByTag(1);
}