本文整理汇总了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);
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
示例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();
}
示例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();
}
示例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);
}
示例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 );
}
示例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;
}
示例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));
}
示例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;
}
}
示例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());
}
示例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;
}
示例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;
}
};