Пример #1
0
void KingdomOfficalsCell::onEnter(){
    CCNode::onEnter();
    setSwallowsTouches(false);
    setTouchEnabled(true);
    CCSafeNotificationCenter::sharedNotificationCenter()->addObserver(this, callfuncO_selector(KingdomOfficalsCell::refresh), REMOVE_APPOINT_OFFICER, NULL);
//    //CCDirector::sharedDirector()->getTouchDispatcher()->addTargetedDelegate(this, Touch_Default, false);
}
Пример #2
0
void AllianceFlagPar::onEnter(){
    CCNode::onEnter();
    setSwallowsTouches(false);
    setTouchMode(Touch::DispatchMode::ONE_BY_ONE);
    setTouchEnabled(true);
    //CCDirector::sharedDirector()->getTouchDispatcher()->addTargetedDelegate(this, Touch_Popup, false);
}
Пример #3
0
////////////////////////////////////////////////////////
//
// TouchesPerformTest1
//
////////////////////////////////////////////////////////
void TouchesPerformTest1::onEnter()
{
    TouchesMainScene::onEnter();
    setTouchEnabled(true);
    setTouchMode(Touch::DispatchMode::ONE_BY_ONE);
    setSwallowsTouches(true);
}
Пример #4
0
bool HUDLayer::init()
{
    

    Node* node = CSLoader::createNode("res/CSres/public/HUDlayer.csb");
    addChild(node);
    
    
    Button* btn = (Button*)node->getChildByTag(782);
    btn->addTouchEventListener(CC_CALLBACK_2(HUDLayer::eventTouch, this));
    
    
    setSwallowsTouches(false);
    setTouchEnabled(true);
    setTouchMode(Touch::DispatchMode::ONE_BY_ONE);
    
    log("HUDLayer::init");
    
    return true;
}
Пример #5
0
void HUDLayer::eventTouch(Ref* pSender, Widget::TouchEventType type)
{
    
    Button* bbb = (Button*)pSender;
    
    if(type == Widget::TouchEventType::BEGAN)
    {
        Vec2 vStart = bbb->getTouchBeganPosition();
        vStartPosition = bbb->getPosition();
        vSum = vStartPosition - vStart;
        log("HUDLayer::eventTouch BEGAN");
    }
    
    if(type == Widget::TouchEventType::MOVED)
    {
        bbb->setPosition(bbb->getTouchMovePosition() + vSum);
        Vec2 vPosition = bbb->getPosition();
        if(fabsf((vPosition-vStartPosition).x) > 5 || fabsf((vPosition-vStartPosition).y) > 5)
        {
            canMove = true;
        }
    }
    
    if(type == Widget::TouchEventType::ENDED)
    {
        if(canMove)
        {
            
        }
        else
        {
            GameIni::getInstance()->screenShoot();      //截屏发送分享流程    不可删除 IMAGE_SCREENSHOOT_FILENAME
            setSwallowsTouches(true);
        }
        canMove = false;
        vSum = Vec2(0,0);
        
    }
}
Пример #6
0
void AllianceIntroTip::onEnter(){
    setSwallowsTouches(true);
    setTouchMode(Touch::DispatchMode::ONE_BY_ONE);
    setTouchEnabled(true);
    CCNode::onEnter();
}
Пример #7
0
bool infoLayer::init()
{
    if (!Layer::init())
    {
        return false;
    }
    
    
    
    //亲密值
    Relation= UserDefault::getInstance()->getIntegerForKey("RELATION", 0);
    
    //成长值
    UserDefault::getInstance()->setIntegerForKey("GROWTH", 0);
    growth= UserDefault::getInstance()->getIntegerForKey("GROWTH", 0);
    
    
    //星星的生成:starNum\shineStarNum\collensation
    stars =new randomStars(this,starNum,shineStarNum,collensation);
    size=Director::getInstance()->getVisibleSize();
    
    //背景
    Sprite* backGround=Sprite::create("bg_L.png");
    backGround->setPosition(size.width/2,size.height/2);
    this->addChild(backGround,0);
    
    
    backGround2=Sprite::create("bg_2.png");
    backGround2->setPosition(size.width/2,backGround2->getContentSize().height/2);
    // backGround->setScale(1.2);
    this->addChild(backGround2,1);
    
    //布置星星
    stars->randomPosition();
    
    
    
    //boy
    Sprite* boy=Sprite::create("boy-hand.png");
    boy->setPosition(200,100);
    boy->setScale(0.8f);
    this->addChild(boy,102,101);
    
    
    
    //暂停按钮
    auto pasueLabel=Label::createWithTTF("退出", "fonts/china.ttf" ,40);
    pasueLabel->setColor(Color3B::RED);
    auto pasueButton=MenuItemLabel::create(pasueLabel,CC_CALLBACK_1(infoLayer::goBackCallBack, this));
    pasueButton->setPosition(pasueButton->getContentSize().width/2+5,size.height-pasueButton->getContentSize().height);
    auto menu=Menu::create(pasueButton, NULL);
    menu->setPosition(0,0);
    this->addChild(menu);
    
    
    
    
    //hand
    pointer=Sprite::create("hand.png");
    pointer->setAnchorPoint(Point(0,0.5));
    pointer->setScale(1.5);
    pointer->setPosition(215,95);
    this->addChild(pointer,103,102);
    pointToStar();
    
    
    
    
    //timer
    moon=Sprite::create("moon_2.png");
    moon->setPosition(Point(moon->getContentSize().width,490));
    moon->setAnchorPoint(Point(0,0));
    moon->setTag(10);
    this->addChild(moon,0);
    //this->schedule(schedule_selector(infoLayer::timerFunc), 0.1f);
    
    
    //开启触摸
    setTouchEnabled(true);
    setSwallowsTouches(true);
    setTouchMode(kCCTouchesOneByOne);
    
    
 
    
     jiantou=Sprite::create("jiantou.png");
    jiantou->setAnchorPoint(Point(0,0));
    jiantou->setPosition(pointer->getPosition()+Point(20,40));
    this->addChild(jiantou,999);
    jiantou->setTag(2);
    
    
    infoLabel=Sprite::create("info1.png");
    infoLabel->setPosition(jiantou->getPosition()+Point(0,70));
    infoLabel->setScale(2);
    this->addChild(infoLabel,1000);
    infoLabel->setTag(1);
    
    
    
//    auto okLabel=Label::createWithSystemFont("Ok", "Maker Flet.ttf", 50);
//    okLabel->setColor(Color3B::RED);
//    auto okButton=MenuItemLabel::create(okLabel, CC_CALLBACK_1(infoLayer::infoCallBak, this));
//    okButton->setPosition(800,60);
//    auto menu2=Menu::create(okButton, NULL);
//    menu2->setPosition(0,0);
//    this->addChild(menu2,1001);
    
    
    
    
    return true;
}
Пример #8
0
void HUDLayer::onTouchEnded(Touch *touch, Event *unused_event)
{
    setSwallowsTouches(false);
}