本文整理汇总了C++中setTouchEnabled函数的典型用法代码示例。如果您正苦于以下问题:C++ setTouchEnabled函数的具体用法?C++ setTouchEnabled怎么用?C++ setTouchEnabled使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setTouchEnabled函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: setTouchEnabled
////////////////////////////////////////////////////////
//
// ExtensionsMainLayer
//
////////////////////////////////////////////////////////
void ExtensionsMainLayer::onEnter()
{
Layer::onEnter();
auto s = Director::getInstance()->getWinSize();
_itemMenu = Menu::create();
_itemMenu->setPosition( Point::ZERO );
MenuItemFont::setFontName("Arial");
MenuItemFont::setFontSize(24);
for (int i = 0; i < g_maxTests; ++i)
{
auto pItem = MenuItemFont::create(g_extensionsTests[i].name, g_extensionsTests[i].callback);
pItem->setPosition(Point(s.width / 2, s.height - (i + 1) * LINE_SPACE));
_itemMenu->addChild(pItem, kItemTagBasic + i);
}
setTouchEnabled(true);
addChild(_itemMenu);
}
开发者ID:0x0c,项目名称:cocos2d-x,代码行数:26,代码来源:ExtensionsTest.cpp
示例17: menu_selector
bool IntroScene::init(){
if (!CCLayer::init()){ //初始化父类
return false;
}
char * pics[6] = { "storylead1.jpg", "storylead2.jpg", "storylead3.jpg", "storylead4.jpg", "storylead5.jpg", "storylead6.jpg" };
for (int i = 0; i < 6; ++i){
IntroScene::picSrc[i] = pics[i];
}
IntroScene::currPic = 0;
CCDirector::sharedDirector()->getTouchDispatcher()->addTargetedDelegate(this, 0, true);
//获取屏幕大小
CCSize visibleSize = CCDirector::sharedDirector()->getWinSize();
IntroScene::IntroBackground1 = CCSprite::create(picSrc[0]);
CCSize pictureSize1 = IntroScene::IntroBackground1->getContentSize();
IntroScene::IntroBackground1->setScaleX(visibleSize.width / pictureSize1.width);
IntroScene::IntroBackground1->setScaleY(visibleSize.height / pictureSize1.height);
IntroScene::IntroBackground1->setPosition(ccp(visibleSize.width / 2.0f, visibleSize.height / 2.0f));
this->addChild(IntroScene::IntroBackground1);
IntroScene::IntroBackground2 = CCSprite::create(picSrc[1]);
CCSize pictureSize2 = IntroScene::IntroBackground2->getContentSize();
IntroScene::IntroBackground2->setScaleX(visibleSize.width / pictureSize2.width);
IntroScene::IntroBackground2->setScaleY(visibleSize.height / pictureSize2.height);
IntroScene::IntroBackground2->setPosition(ccp(visibleSize.width / 2.0f, visibleSize.height / 2.0f));
this->addChild(IntroScene::IntroBackground2);
IntroScene::IntroBackground2->setVisible(false);
CCLabelTTF * skipLabel = CCLabelTTF::create("skip", "arial", 32);
skipLabel->setColor(ccc3(0, 0, 0));
CCMenuItemLabel * skip = CCMenuItemLabel::create(skipLabel, this, menu_selector(IntroScene::introSkipCall));
skip->setPosition(ccp(visibleSize.width*0.9, visibleSize.height*0.2));
auto menu = CCMenu::create(skip, NULL);
menu->setAnchorPoint(CCPointZero);
menu->setPosition(CCPointZero);
this->addChild(menu);
setTouchEnabled(true);
return true;
}
开发者ID:AllenShieh,项目名称:LegendaryMonsters,代码行数:40,代码来源:IntroScene.cpp
示例18: m_tBeginPos
TestController::TestController()
: m_tBeginPos(CCPointZero)
{
// add close menu
CCMenuItemImage *pCloseItem = CCMenuItemImage::create(s_pPathClose, s_pPathClose, this, menu_selector(TestController::closeCallback) );
CCMenu* pMenu =CCMenu::create(pCloseItem, NULL);
pMenu->setPosition( CCPointZero );
pCloseItem->setPosition(ccp( VisibleRect::right().x - 30, VisibleRect::top().y - 30));
// add menu items for tests
m_pItemMenu = CCMenu::create();
for (int i = 0; i < TESTS_COUNT; ++i)
{
// #if (CC_TARGET_PLATFORM == CC_PLATFORM_MARMALADE)
// CCLabelBMFont* label = CCLabelBMFont::create(g_aTestNames[i].c_str(), "fonts/arial16.fnt");
// #else
CCLabelTTF* label = CCLabelTTF::create(g_aTestNames[i].c_str(), "Arial", 24);
// #endif
CCMenuItemLabel* pMenuItem = CCMenuItemLabel::create(label, this, menu_selector(TestController::menuCallback));
m_pItemMenu->addChild(pMenuItem, i + 10000);
pMenuItem->setPosition( ccp( VisibleRect::center().x, (VisibleRect::top().y - (i + 1) * LINE_SPACE) ));
if (!isTestDemoEnabled(i))
{
pMenuItem->setColor(ccGRAY);
pMenuItem->setEnabled(false);
}
}
m_pItemMenu->setContentSize(CCSizeMake(VisibleRect::getVisibleRect().size.width, (TESTS_COUNT + 1) * (LINE_SPACE)));
m_pItemMenu->setPosition(s_tCurPos);
addChild(m_pItemMenu);
setTouchEnabled(true);
addChild(pMenu, 1);
}
开发者ID:aselushat,项目名称:Cocos2d-WindowsPhone,代码行数:40,代码来源:controller.cpp
示例19: CC_CONTENT_SCALE_FACTOR
//-------------------------------------------------------------------------
bool FKCW_UI_ProgressIndicator::initWithMessage(const string& message)
{
if(!CCLayerColor::initWithColor(m_tagDimColor))
{
return false;
}
// 保存消息
m_strMessage = message;
// 创建Label
m_pMsgLabel = CCLabelTTF::create(m_strMessage.c_str(),
"Helvetica",
28 / CC_CONTENT_SCALE_FACTOR());
// 提示器
CCImage* image = new CCImage();
image->initWithImageData((void*)s_SpinnerPng, 1043);
CCTexture2D* tex = new CCTexture2D();
tex->initWithImage(image);
m_pIndicator = CCSprite::createWithTexture(tex);
CC_SAFE_RETAIN(m_pIndicator);
image->release();
tex->release();
_RelayOut();
addChild(m_pIndicator);
addChild(m_pMsgLabel);
// 开启事件
setTouchEnabled(true);
setTouchMode(kCCTouchesOneByOne);
setTouchPriority(-MAX_INT);
setKeypadEnabled(true);
// 开启帧更新
scheduleUpdate();
return true;
}
开发者ID:duzhi5368,项目名称:FKCocos2dxWrapper_2.x,代码行数:41,代码来源:FKCW_UI_ProgressIndicator.cpp
示例20: CC_BREAK_IF
bool BuoyancyScene::init()
{
bool bRet = false;
do
{
// Initiate CCLayer
CC_BREAK_IF(! CCLayer::init());
// Initiate Physics
physics = PhysicsWorld::create();
if(NULL == physics) return false;
createMap();
schedule(schedule_selector(BuoyancyScene::updateWorld), physics->getUpdateTime());
setTouchEnabled(true);
bRet = true;
} while (0);
return bRet;
}
开发者ID:BellyWong,项目名称:graduation,代码行数:22,代码来源:BuoyancyScene.cpp
注:本文中的setTouchEnabled函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论