当前位置: 首页>>代码示例>>C++>>正文


C++ setTouchEnabled函数代码示例

本文整理汇总了C++中setTouchEnabled函数的典型用法代码示例。如果您正苦于以下问题:C++ setTouchEnabled函数的具体用法?C++ setTouchEnabled怎么用?C++ setTouchEnabled使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了setTouchEnabled函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: menu_selector

void ExtensionsMainLayer::onEnter()
{
    CCLayer::onEnter();

    CCSize s = CCDirector::sharedDirector()->getWinSize();

    m_pItemMenu = CCMenu::create();
    m_pItemMenu->setPosition( CCPointZero );
    CCMenuItemFont::setFontName("Arial");
    CCMenuItemFont::setFontSize(24);
    for (int i = 0; i < TEST_MAX_COUNT; ++i)
    {
        CCMenuItemFont* pItem = CCMenuItemFont::create(testsName[i].c_str(), this,
                                                    menu_selector(ExtensionsMainLayer::menuCallback));
        pItem->setPosition(ccp(s.width / 2, s.height - (i + 1) * LINE_SPACE));
        m_pItemMenu->addChild(pItem, kItemTagBasic + i);
    }
    setTouchEnabled(true);
    addChild(m_pItemMenu);
}
开发者ID:Ratel13,项目名称:Cocos2d-x-For-CocoStudio,代码行数:20,代码来源:ExtensionsTest.cpp

示例2: setSelectedState

bool CheckBox::init(const std::string& backGround,
                    const std::string& backGroundSeleted,
                    const std::string& cross,
                    const std::string& backGroundDisabled,
                    const std::string& frontCrossDisabled,
                    TextureResType texType)
{
    bool ret = true;
    do {
        if (!Widget::init()) {
            ret = false;
            break;
        }
        
        setSelectedState(false);
        setTouchEnabled(true);
        loadTextures(backGround, backGroundSeleted, cross, backGroundDisabled, frontCrossDisabled,texType);
    } while (0);
    return ret;
}
开发者ID:JeeLiu,项目名称:tutorial-puzzle,代码行数:20,代码来源:UICheckBox.cpp

示例3: setTouchEnabled

bool Story::init()
{
	if (!CCLayer::init())
	{
		return false;
	}
	count = 0;
	state = false;			//设置一开始事件不能通过触摸跳转
	const int b_x = 415;
	const int b_y = 50;
	const int t_x =225;
	const int t_y = 310;
	CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("UIS.plist","UIS.png");
	dialogBox_bottom = CCSprite::createWithSpriteFrameName("UI_dialogBox.png");
	dialogBox_top		 = CCSprite::createWithSpriteFrameName("UI_dialogBox.png");

	dialogBox_bottom->setFlipX(true);
	dialogBox_bottom->setPosition(ccp(b_x,b_y));
	dialogBox_top->setPosition(ccp(t_x,t_y));
	CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();

	crctorImage_bottom = CCSprite::create();
	crctorImage_top = CCSprite::create();
	text_bottom = CCSprite::create();
	text_top = CCSprite::create();
	text_bottom->setAnchorPoint(ccp(0,0));
	text_top->setAnchorPoint(ccp(0,0));
	
	crctorImage_top->setPosition(ccp(visibleSize.width / 2,visibleSize.height / 2));
	crctorImage_bottom->setPosition(ccp(visibleSize.width / 2,visibleSize.height / 2));

	this->addChild(dialogBox_top,5);
	this->addChild(dialogBox_bottom,5);
	this->addChild(crctorImage_bottom,10);
	this->addChild(crctorImage_top,10);
	this->addChild(text_bottom,15);
	this->addChild(text_top,15);

	setTouchEnabled(true);			//开启触摸监听
	return true;
}
开发者ID:Jormungendr,项目名称:HotPunch,代码行数:41,代码来源:Story.cpp

示例4: CC_ASSERT

	bool CCScrollLayer::initWithLayers(CCArray* layers, int widthOffset)
	{
		if (!CCLayer::init())
			return false;
		CC_ASSERT(layers && layers->count());
		
		setTouchEnabled(true);
        
		m_bStealTouches = true;
		
		// Set default minimum touch length to scroll.
		m_fMinimumTouchLengthToSlide = 30.0f;
		m_fMinimumTouchLengthToChangePage = 100.0f;
		
		m_fMarginOffset = CCDirector::sharedDirector()->getWinSize().width;
        
		// Show indicator by default.
		m_bShowPagesIndicator = true;
		m_tPagesIndicatorPosition = ccp(0.5f * m_obContentSize.width, ceilf(m_obContentSize.height / 8.0f));
        
		// Set up the starting variables
		m_uCurrentScreen = 0;
        
		// Save offset.
		m_fPagesWidthOffset = (CGFloat)widthOffset;
        
		// Save array of layers.
        // Can't use createWithArray because layer does not implemnt CCCopying
		// m_pLayers = CCArray::createWithArray(layers);
        m_pLayers = CCArray::create();
        m_pLayers->addObjectsFromArray(layers);
		layers->release();
		m_pLayers->retain();
        
        CCSize size = CCDirector::sharedDirector()->getWinSize();
        this->setRectLayer(CCRect(0, 0, size.width, size.height));
        
		updatePages();
        
		return true;
	}
开发者ID:haquangvu,项目名称:TrangQuynh-V2,代码行数:41,代码来源:CCScrollLayer.cpp

示例5: Point

bool MainScene::init()
{
    Size sizeWin = DIRECTOR->getWinSize();
    float listWidth = sizeWin.width - sizeWin.height;
    
    // background layout
    auto layerColor = LayerColor::create(Color4B::WHITE, sizeWin.width, sizeWin.height);
    auto drawNodeV = DrawNode::create();
    drawNodeV->drawSegment(Point(listWidth, 0), Point(listWidth, sizeWin.height), 2, Color4F::GRAY);
    layerColor->addChild(drawNodeV);
    auto drawNodeH = DrawNode::create();
    drawNodeH->drawSegment(Point(listWidth, sizeWin.height / 3), Point(sizeWin.width, sizeWin.height / 3), 2, Color4F::GRAY);
    layerColor->addChild(drawNodeH);
    addChild(layerColor);
    
    // title
    auto btnTitle = Button::create();
    btnTitle->setTouchEnabled(true);
    btnTitle->ignoreContentAdaptWithSize(false);
    btnTitle->setTitleFontName("Marker Felt");
    btnTitle->setTitleText("Cocos2d Manual");
    btnTitle->setTitleColor(Color3B::GREEN);
    btnTitle->setTitleFontSize(30);
    btnTitle->setSize(Size(listWidth, 40));
    btnTitle->setPosition(Point(listWidth / 2, sizeWin.height - 30));
    BIND_LISTENER_TOUCH(btnTitle, this, MainScene::onTouchTitle);
    addChild(btnTitle);
    
    // manual layer
    auto layerDisplay = ManualDisplay::create();
    auto layerCode = ManualCode::create();
    auto layerList = ManualList::create();
    layerCode->setDisplay(layerDisplay);
    layerCode->setTag(Tag::TAG_CODELAYER);
    layerList->setCode(layerCode);
    addChild(layerDisplay);
    addChild(layerCode);
    addChild(layerList);
    
    return Layer::init();
}
开发者ID:JiangySky,项目名称:CocosManual,代码行数:41,代码来源:MainScene.cpp

示例6: removeAllChildren

void HelloWorld::startGame( float dt)
{
	delete this->world;
	this->score = 0;
	this->down_bar = NULL;
	this->Xdownbar = 0;
	this->Xbird = 0;
	barTag = 0;
	barArray[0]=false;
	barArray[1]=false;

	isTouch = false;
	gameend = false;

	removeAllChildren();

	setTouchEnabled(true);
	
	initWorld();


	CCLabelAtlas* label2 = CCLabelAtlas::create("0123456789", "1.png", 17, 22, '0');
	addChild(label2, 1, 9);
	label2->setPosition(ccp(this->screenSize.width/2-30,this->screenSize.height/2+360));
	//label2->setColor(ccWHITE);
	label2->setScale(4);
	char string[12] = {0};
	sprintf(string,"%d",this->score);
	label2->setString(string);

	scheduleUpdate();
	schedule(schedule_selector(HelloWorld::addBar),1);
	//scheduleOnce(schedule_selector(HelloWorld::addBar),1);

	addBg();
	addGround(123);
	addBrid();
	addBarContainer();


}
开发者ID:verylove,项目名称:YtTouchBird,代码行数:41,代码来源:HelloWorldScene.cpp

示例7: setTouchEnabled

Prototype::Prototype() {
	setTouchEnabled(true);
	CCSize size = CCDirector::sharedDirector()->getWinSize();
	srand ( time(NULL) );
	m_bodyDef.type = b2_dynamicBody;
    m_fixtureDef.restitution = 0.4f;
    m_fixtureDef.friction = 0.2f;
    m_fixtureDef.density = 4;
    m_centerPoint = CCPointMake(0.5*size.width, 0.5*size.height);

	try {
		testSimple();
		testSeparator();
	}
	catch(exception e) {
		CCLog("Oops...%s", e.what());
	}

	scheduleUpdate();

}
开发者ID:delorenj,项目名称:Thermite,代码行数:21,代码来源:Prototype.cpp

示例8: addChild

RemoveMenuItemWhenMove::RemoveMenuItemWhenMove()
{
    CCSize s = CCDirector::sharedDirector()->getWinSize();
    
    CCLabelTTF* label = CCLabelTTF::create("click item and move, should not crash", "Arial", 20);
    label->setPosition(ccp(s.width/2, s.height - 30));
    addChild(label);
    
    item = CCMenuItemFont::create("item 1");
    item->retain();
    
    CCMenuItemFont *back = CCMenuItemFont::create("go back", this, menu_selector(RemoveMenuItemWhenMove::goBack));
    
    CCMenu *menu = CCMenu::create(item, back, NULL);
    addChild(menu);
    menu->alignItemsVertically();
    
    menu->setPosition(ccp(s.width/2, s.height/2));
    
    setTouchEnabled(true);
}
开发者ID:0309,项目名称:cocos2d-x,代码行数:21,代码来源:MenuTest.cpp

示例9: createScreen

GameLayer::GameLayer() {
    
    
    _screenSize = CCDirector::sharedDirector()->getWinSize();
    _running = false;
    
    createScreen();
    
    std::string levelsFile = CCFileUtils::sharedFileUtils()->fullPathForFilename("levels.plist");
    _levels = CCArray::createWithContentsOfFileThreadSafe(levelsFile.c_str());
    _levels->retain();
    
    initPhysics();
    
    createPools();
    
    setTouchEnabled( true );
    setAccelerometerEnabled( true );
    
    
}
开发者ID:pdpdds,项目名称:cocos2dx-dev,代码行数:21,代码来源:GameLayer.cpp

示例10: addChild

bool GameSceneLayer::init(){
    
    CCSize size = CCDirector::sharedDirector()->getWinSize();
    
    CCLayer::init();
    CCSprite* s = CCSprite::create("game.jpg");
    addChild(s);
    
    s->setPosition(ccp(size.width/2, size.height/2));
    
    labelBack = CCLabelTTF::create();
    labelBack->setString("Back");
    labelBack->setFontSize(48);
    addChild(labelBack);
    labelBack->setAnchorPoint(ccp(0, 1));
    labelBack->setPosition(ccp(0, size.height));
    
    setTouchEnabled(true);
    
    return true;
}
开发者ID:plter,项目名称:AndroidLessons20130708,代码行数:21,代码来源:GameScene.cpp

示例11: setTouchEnabled

void PauseLayer::onEnterTransitionDidFinish() {
	setTouchEnabled(true);
	CCPoint delta = ccp(winSize.width / 2, winSize.height - 500)
			- pMenusResume->getPosition();
	CCActionInterval* move = CCMoveBy::create(0.5, delta);
	CCActionInterval* move_ease_out = CCEaseBackOut::create(
			(CCActionInterval*) (move->copy()->autorelease()));
	pMenusResume->runAction(CCSequence::create(move_ease_out, NULL));

	delta = ccp(winSize.width / 2, winSize.height - 780)
			- pMenusBackToMenu->getPosition();
	move = CCMoveBy::create(0.5, delta);
	move_ease_out = CCEaseBackOut::create(
			(CCActionInterval*) (move->copy()->autorelease()));
	pMenusBackToMenu->runAction(CCSequence::create(move_ease_out, NULL));

	pMenusResume->runAction(CCSequence::create(CCFadeIn::create(0.5f), NULL));
	pMenusSetting->runAction(CCSequence::create(CCFadeIn::create(0.5f), NULL));
	pMenusBackToMenu->runAction(
			CCSequence::create(CCFadeIn::create(0.5f), NULL));
}
开发者ID:qsz13,项目名称:Bounce,代码行数:21,代码来源:PauseLayer.cpp

示例12: setTouchEnabled

bool CCControlSaturationBrightnessPicker::initWithTargetAndPos(CCNode* target, CCPoint pos)
{
    if (CCControl::init())
    {
        setTouchEnabled(true);
        // Add background and slider sprites
        m_background=CCControlUtils::addSpriteToTargetWithPosAndAnchor("colourPickerBackground.png", target, pos, ccp(0.0f, 0.0f));
        m_overlay=CCControlUtils::addSpriteToTargetWithPosAndAnchor("colourPickerOverlay.png", target, pos, ccp(0.0f, 0.0f));
        m_shadow=CCControlUtils::addSpriteToTargetWithPosAndAnchor("colourPickerShadow.png", target, pos, ccp(0.0f, 0.0f));
        m_slider=CCControlUtils::addSpriteToTargetWithPosAndAnchor("colourPicker.png", target, pos, ccp(0.5f, 0.5f));
                
        m_startPos=pos; // starting position of the colour picker        
        boxPos          = 35;    // starting position of the virtual box area for picking a colour
        boxSize         = m_background->getContentSize().width / 2;;    // the size (width and height) of the virtual box for picking a colour from
        return true;
    }
    else
    {
        return false;
    }
}
开发者ID:1901,项目名称:CCDate,代码行数:21,代码来源:CCControlSaturationBrightnessPicker.cpp

示例13: setTouchEnabled

bool SlidingMenuGrid::initWithArray(CCArray *items, int cols, int rows, CCPoint pos , CCPoint pad, bool vertical, float threshold)
{
	if( !CCLayer::init() )
	{
		return false;
	}
    
	selectedItem = NULL;
	setTouchEnabled(true);
    CCDirector::sharedDirector()->getTouchDispatcher()->addTargetedDelegate(this,0,true);
	pMenu=new CCMenu;
	addChild(pMenu,0);
    
    CCObject *object;
    CCMenuItemSprite *getItem;
    
    CCARRAY_FOREACH(items, object)
    {
        getItem = (CCMenuItemSprite*)object;
        pMenu->addChild(getItem, 1, getItem->getTag());
    }
开发者ID:BellyWong,项目名称:KrealX,代码行数:21,代码来源:SlidingMenu.cpp

示例14: initWorld

// on "init" you need to initialize your instance
bool HelloWorld::init()
{
    //////////////////////////////
    // 1. super init first
    if ( !CCLayer::init() )
    {
        return false;
    }
    
    screenSize = CCDirector::sharedDirector()->getVisibleSize();
    
    initWorld();
    addBarContainer();
    addBird();
    addGround();
    setTouchEnabled(true);
    startGame();
    
    
    return true;
}
开发者ID:joyfish,项目名称:code,代码行数:22,代码来源:HelloWorldScene.cpp

示例15: setTouchEnabled

void BBAbstractSceneView::onEnter()
{
	CCLayer::onEnter();
	
	BBTouchManager::shared()->setCurrentMultiTouchEvents(this);
	
	setTouchEnabled(true);
	
	//决定最小分辨率
	CCSize szWin = CCDirector::sharedDirector()->getWinSize();
	float sX = szWin.width / m_szOriginal.width;
	float sY = szWin.height / m_szOriginal.height;
	if(sX > sY)
	{
		m_nScaleMin = sX;
	}
	else
	{
		m_nScaleMin = sY;
	}
};
开发者ID:newcl,项目名称:boom,代码行数:21,代码来源:BBAbstractSceneView.cpp


注:本文中的setTouchEnabled函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。