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


C++ CCSpriteBatchNode::getTexture方法代码示例

本文整理汇总了C++中CCSpriteBatchNode::getTexture方法的典型用法代码示例。如果您正苦于以下问题:C++ CCSpriteBatchNode::getTexture方法的具体用法?C++ CCSpriteBatchNode::getTexture怎么用?C++ CCSpriteBatchNode::getTexture使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CCSpriteBatchNode的用法示例。


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

示例1: init

bool OptionLayer::init() {
    if (!CCLayer::init()) {
        return false;
    }

    _back = CCSprite::create("back.png");
    _back->setPosition(ccp(24 + 40, 800 - 56.5 + 15));
    this->addChild(_back);

    CCSprite * mode = CCSprite::create("mode.png");
    mode->setPosition(ccp(132 + 111, 800 - 103 - 19.5));
    this->addChild(mode);

    CCSpriteBatchNode* batchNode = CCSpriteBatchNode::create("dotted_line.png");
    int dottedLineY[3] = {313, 420, 539};
    for (int i = 0; i < 3; i++) {
        CCSprite * dotLine = CCSprite::createWithTexture(batchNode->getTexture());
        dotLine->setPosition(ccp(27 + 210.5, 800 - dottedLineY[i] - 1.5));
        this->addChild(dotLine);
    }

    _switchIndex = -1;
    _switches[0] = &Settings::showConflictedDigit;
    _switches[1] = &Settings::musicEnabled;
    _switches[2] = &Settings::soundEnabled;
    _switches[3] = &Settings::preventSleeping;
    _switches[4] = &Settings::showTimer;
    _switches[5] = &Settings::autoHighLight;
    _switches[6] = &Settings::autoRemoveNotes;
    _switches[7] = &Settings::removeCompleteDigits;

    CCSpriteBatchNode* maskBatchNode = CCSpriteBatchNode::create("mask.png");
    CCSpriteBatchNode* switchBatch = CCSpriteBatchNode::create("switch.png");
    _switchButtons = CCArray::createWithCapacity(7);
    _switchButtons->retain();
    char opLabel[10];
    int opLabelY[8] = {271, 332, 379, 445, 492, 566, 612, 657};
    for(int i = 0; i < 8; i++) {
        sprintf(opLabel, "op%d.png", i);
        CCSprite * label = CCSprite::create(opLabel);
        label->setPosition(ccp(25 + label->boundingBox().size.width / 2,
                               800 - opLabelY[i] - label->boundingBox().size.height / 2));
        this->addChild(label);

        CCSprite * stencil = CCSprite::createWithTexture(maskBatchNode->getTexture());
        stencil->setPosition(ccp(380 + 39, 800 - opLabelY[i] - label->boundingBox().size.height / 2));
        CCClippingNode * cliper = CCClippingNode::create(stencil);
        cliper->setAlphaThreshold(0);
        CCSprite * switchButton = CCSprite::createWithTexture(switchBatch->getTexture());
        switchButton->setPosition(ccp(*(_switches[i]) ? 394 + 49 : 394, 800 - opLabelY[i] - label->boundingBox().size.height / 2));
        _switchButtons->addObject(switchButton);
        cliper->addChild(switchButton);
        this->addChild(cliper);
    }

    this->setTouchEnabled(true);
    this->setKeypadEnabled(true);

    return true;
}
开发者ID:duongbadu,项目名称:cocos2dx-sudoku,代码行数:60,代码来源:OptionLayer.cpp

示例2: init

NS_CC_EXT_BEGIN

bool CCControlColourPicker::init()
{
    if (CCControl::init())
    {
        setTouchEnabled(true);
        // Cache the sprites
        CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("extensions/CCControlColourPickerSpriteSheet.plist");
        
        // Create the sprite batch node
        CCSpriteBatchNode *spriteSheet  = CCSpriteBatchNode::create("extensions/CCControlColourPickerSpriteSheet.png");
        addChild(spriteSheet);
        
        // MIPMAP
        ccTexParams params  = {GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR, GL_REPEAT, GL_REPEAT};
        spriteSheet->getTexture()->setAliasTexParameters();
        spriteSheet->getTexture()->setTexParameters(&params);
        spriteSheet->getTexture()->generateMipmap();

        // Init default color
        m_hsv.h = 0;
        m_hsv.s = 0;
        m_hsv.v = 0;
        
        // Add image
        m_background=CCControlUtils::addSpriteToTargetWithPosAndAnchor("menuColourPanelBackground.png", spriteSheet, CCPointZero, ccp(0.5f, 0.5f));
       
        CCPoint backgroundPointZero = ccpSub(m_background->getPosition(), ccp (m_background->getContentSize().width / 2, m_background->getContentSize().height / 2));
        
        // Setup panels . currently hard-coded...
        float hueShift                = 8;
        float colourShift             = 28;
        
        m_huePicker=CCControlHuePicker::create(spriteSheet, ccp(backgroundPointZero.x + hueShift, backgroundPointZero.y + hueShift));
        m_colourPicker=CCControlSaturationBrightnessPicker::create(spriteSheet, ccp(backgroundPointZero.x + colourShift, backgroundPointZero.y + colourShift));
        
        // Setup events
        m_huePicker->addTargetWithActionForControlEvents(this, cccontrol_selector(CCControlColourPicker::hueSliderValueChanged), CCControlEventValueChanged);
        m_colourPicker->addTargetWithActionForControlEvents(this, cccontrol_selector(CCControlColourPicker::colourSliderValueChanged), CCControlEventValueChanged);
       
        // Set defaults
        updateHueAndControlPicker();
        addChild(m_huePicker);
        addChild(m_colourPicker);

        // Set content size
        setContentSize(m_background->getContentSize());
        return true;
    }
    else
        return false;
}
开发者ID:136446529,项目名称:book-code,代码行数:53,代码来源:CCControlColourPicker.cpp

示例3:

bool Recipe30::init()
{
    if ( !RecipeBase::init() )
    {
        return false;
    }

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

    CCSpriteBatchNode* pBatchNode = CCSpriteBatchNode::create("recipe30_uhhoi.png");
    this->addChild(pBatchNode);
    
    for (int i=0; i<300; i++) {
        CCSprite* sprite = CCSprite::createWithTexture(pBatchNode->getTexture());
        float x = CCRANDOM_0_1()*size.width;
        float y = CCRANDOM_0_1()*size.height;
        sprite->setPosition(ccp(x, y));
        pBatchNode->addChild(sprite);
        
        CCFadeOut* fade = CCFadeOut::create(CCRANDOM_0_1()*10.0f);
        sprite->runAction(fade);
    }

    
    return true;
}
开发者ID:DPigpen,项目名称:cocos2dx_recipe,代码行数:26,代码来源:Recipe30.cpp

示例4: loadUI

void SpriteBatchNodeTestPage::loadUI()
{
    setTouchEnabled(true);
    setTouchMode(kCCTouchesOneByOne);

    auto winSize = CocosWindow::size();
    auto origin = CocosWindow::origin();

    const std::string pic("Images/grossini_dance_01.png");
    size_t num(1000);

    /*for (size_t i=0; i<num; ++i)
    {
    auto dance = CCSprite::create(pic.c_str());
    CCPoint pos;
    pos.x = winSize.width * CCRANDOM_0_1();
    pos.y = winSize.height * CCRANDOM_0_1();
    dance->setPosition(pos);
    addChildRaw(dance);
    }*/

    CCSpriteBatchNode *batch = CCSpriteBatchNode::create(pic.c_str());
    for (size_t i=0; i<num; ++i) {
        auto dance = CCSprite::createWithTexture(batch->getTexture());
        CCPoint pos;
        pos.x = winSize.width * CCRANDOM_0_1();
        pos.y = winSize.height * CCRANDOM_0_1();
        dance->setPosition(pos);
        batch->addChild(dance);
    }
    ADD_CHILD(batch);
}
开发者ID:elloop,项目名称:cocos2d-x-cpp-demos-2.x,代码行数:32,代码来源:SpriteBatchNodeTestPage.cpp

示例5: setTouchEnabled

HelloWorld::HelloWorld()
{
    setTouchEnabled( true );
    setAccelerometerEnabled( true );
    setKeypadEnabled( true );

    CCSize s = CCDirector::sharedDirector()->getWinSize();
    // init physics
    this->initPhysics();

    CCSpriteBatchNode *parent = CCSpriteBatchNode::create("blocks.png", 100);
    m_pSpriteTexture = parent->getTexture();

    addChild(parent, 0, kTagParentNode);


    addNewSpriteAtPosition(ccp(s.width/2, s.height/2));

    CCLabelTTF *label = CCLabelTTF::create("Tap screen", "Marker Felt", 32);
    addChild(label, 0);
    label->setColor(ccc3(0,0,255));
    label->setPosition(ccp( s.width/2, s.height-50));
    
    scheduleUpdate();
}
开发者ID:studiopangea,项目名称:Box2DSample,代码行数:25,代码来源:HelloWorldScene.cpp

示例6: setTouchEnabled

Box2DTestLayer::Box2DTestLayer()
: m_pSpriteTexture(NULL)
{
    setTouchEnabled( true );
    setAccelerometerEnabled( true );

    // init physics
    this->initPhysics();
    // create reset button
    this->createResetButton();

    //Set up sprite
#if 1
    // Use batch node. Faster
    CCSpriteBatchNode *parent = CCSpriteBatchNode::create("Images/blocks.png", 100);
    m_pSpriteTexture = parent->getTexture();
#else
    // doesn't use batch node. Slower
    m_pSpriteTexture = CCTextureCache::sharedTextureCache()->addImage("Images/blocks.png");
    CCNode *parent = CCNode::create();
#endif
    addChild(parent, 0, kTagParentNode);


    addNewSpriteAtPosition(VisibleRect::center());

    CCLabelTTF *label = CCLabelTTF::create("Tap screen", "Marker Felt", 32);
    addChild(label, 0);
    label->setColor(ccc3(0,0,255));
    label->setPosition(ccp( VisibleRect::center().x, VisibleRect::top().y-50));
    
    scheduleUpdate();
}
开发者ID:ZheNanXu,项目名称:Billiard-2D,代码行数:33,代码来源:Box2dTest.cpp

示例7: ccp

bool T08CCSpriteBatchNode::init()
{
	if (!BaseLayer::init())
		return false;

	CCSize winSize = CCDirector::sharedDirector()->getWinSize();
	CCPoint ptCenter = ccp(winSize.width / 2, winSize.height / 2);

	/*
		CCSpriteBatchNode是一个容器,只能包容CCSprite对象,要求这些精灵来自同一个纹理
	*/

	CCSpriteBatchNode* pBatch = CCSpriteBatchNode::create("CloseNormal.png");
	addChild(pBatch);
	pBatch->setTag(10);

	CCSprite *pSprite = CCSprite::createWithTexture(pBatch->getTexture());
	pBatch->addChild(pSprite);
	pSprite->setPosition(ptCenter);

	setTouchEnabled(true);
	setTouchMode(kCCTouchesOneByOne);

	return true;
}
开发者ID:dfwxb,项目名称:cocos_lesson2,代码行数:25,代码来源:T08CCSpriteBatchNode.cpp

示例8: CCRectMake

void Box2DTestLayer::addNewSpriteWithCoords(CCPoint p)
{
	//UXLOG(L"Add sprite %0.2f x %02.f",p.x,p.y);
	CCSpriteBatchNode* batch = (CCSpriteBatchNode*)getChildByTag(kTagSpriteManager);
	
	//We have a 64x64 sprite sheet with 4 different 32x32 images.  The following code is
	//just randomly picking one of the images
	int idx = (CCRANDOM_0_1() > .5 ? 0:1);
	int idy = (CCRANDOM_0_1() > .5 ? 0:1);
	CCSprite *sprite = CCSprite::spriteWithTexture(batch->getTexture(), CCRectMake(32 * idx,32 * idy,32,32));
	batch->addChild(sprite);
	
	sprite->setPosition( CCPointMake( p.x, p.y) );
	
	// Define the dynamic body.
	//Set up a 1m squared box in the physics world
	b2BodyDef bodyDef;
	bodyDef.type = b2_dynamicBody;
	bodyDef.position.Set(p.x/PTM_RATIO, p.y/PTM_RATIO);
	bodyDef.userData = sprite;
	b2Body *body = world->CreateBody(&bodyDef);
	
	// Define another box shape for our dynamic body.
	b2PolygonShape dynamicBox;
	dynamicBox.SetAsBox(.5f, .5f);//These are mid points for our 1m box
	
	// Define the dynamic body fixture.
	b2FixtureDef fixtureDef;
	fixtureDef.shape = &dynamicBox;	
	fixtureDef.density = 1.0f;
	fixtureDef.friction = 0.3f;
	body->CreateFixture(&fixtureDef);
}
开发者ID:ccjimmy,项目名称:TweeJump4wp8,代码行数:33,代码来源:Box2dTest.cpp

示例9: addChild

//------------------------------------------------------------------
//
// TMXOrthoTest
//
//------------------------------------------------------------------
TMXOrthoTest::TMXOrthoTest()
{
    //
    // Test orthogonal with 3d camera and anti-alias textures
    //
    // it should not flicker. No artifacts should appear
    //
    //CCLayerColor* color = CCLayerColor::create( ccc4(64,64,64,255) );
    //addChild(color, -1);

    CCTMXTiledMap* map = CCTMXTiledMap::create("TileMaps/orthogonal-test2.tmx");
    addChild(map, 0, kTagTileMap);
    
    CCSize s = map->getContentSize();
    CCLOG("ContentSize: %f, %f", s.width,s.height);
    
    CCArray * pChildrenArray = map->getChildren();
    CCSpriteBatchNode* child = NULL;
    CCObject* pObject = NULL;
    CCARRAY_FOREACH(pChildrenArray, pObject)
    {
        child = (CCSpriteBatchNode*)pObject;

        if(!child)
            break;

        child->getTexture()->setAntiAliasTexParameters();
    }
开发者ID:firedragonpzy,项目名称:DirectFire-android,代码行数:33,代码来源:TileMapTest.cpp

示例10: setTouchEnabled

HelloWorld::HelloWorld()
{
    setTouchEnabled( true );
    setAccelerometerEnabled( true );

    CCSize s = CCDirector::sharedDirector()->getWinSize();
    // init physics
    this->initPhysics();

    CCSpriteBatchNode *parent = CCSpriteBatchNode::create("blocks.png", 100);
    m_pSpriteTexture = parent->getTexture();

    addChild(parent, 0, kTagParentNode);


    addNewSpriteAtPosition(ccp(s.width/2, s.height/2));

    CCLabelTTF *label = CCLabelTTF::create("Tap screen", "Marker Felt", 32);
    addChild(label, 0);
    label->setColor(ccc3(0,0,255));
    label->setPosition(ccp( s.width/2, s.height-50));
    
//    增加一个sprite
    CCSprite *aSprite = CCSprite::create("an1_anim1.png");
    aSprite->setPosition(ccp(s.width/2, s.height-50));
    addChild(aSprite,0);
//    移动sprite
    CCPoint target = ccp(100, 100);
    this->runAction(CCSequence::create(
   CCMoveTo::create(2 ,target),
//   CCCallFunc::create(this, callfunc_selector(Player::removeTarget))
   NULL));
    
    scheduleUpdate();
}
开发者ID:anjsoft,项目名称:SpaceVikingX-old,代码行数:35,代码来源:HelloWorldScene.cpp

示例11: updateNote

void GameLayer::updateNote(int x, int y) {
	int totalNote = Sudoku::notes[x][y].total();
	int k = 0, offset = totalNote * (totalNote - 1) / 2;
	for(int i = 0; i < 9; i++) {
		if(Sudoku::notes[x][y].has(i+1)) {
			if(!_notes[x][y][i]) {
				CCSpriteBatchNode * batch = (CCSpriteBatchNode*)_numNoteBatch->objectAtIndex(i);
				CCSprite * littleNote = CCSprite::createWithTexture(batch->getTexture());
				littleNote->setZOrder(2);
				_notes[x][y][i] = littleNote;
				this->addChild(littleNote);
			}
			// position it
			_notes[x][y][i]->setPosition(ccp(
					NOTE_NUM_RX[offset + k] + 26 + x * 49 + x / 3 * 3,
					-NOTE_NUM_RY[offset + k] + 800 - 141 - y * 49 - y / 3 * 3));
			CCLog("total note: %d", totalNote);
			_notes[x][y][i]->setScale(SCALE[totalNote - 1]);
			CCLog("here");
			k++;
		} else {
			if(_notes[x][y][i]) {
				this->removeChild(_notes[x][y][i]);
				_notes[x][y][i] = NULL;
			}
		}
	}
}
开发者ID:coderlongren,项目名称:cocos2dx-sudoku,代码行数:28,代码来源:GameLayer.cpp

示例12: setTouchEnabled

ChipmunkTestLayer::ChipmunkTestLayer()
{
#if CC_ENABLE_CHIPMUNK_INTEGRATION      
    // enable events
    setTouchEnabled(true);
    setAccelerometerEnabled(true);

    // title
    CCLabelTTF *label = CCLabelTTF::create("Multi touch the screen", "Marker Felt", 36);
    label->setPosition(ccp( VisibleRect::center().x, VisibleRect::top().y - 30));
    this->addChild(label, -1);

    // reset button
    createResetButton();

    // init physics
    initPhysics();

#if 1
    // Use batch node. Faster
    CCSpriteBatchNode *parent = CCSpriteBatchNode::create("Images/grossini_dance_atlas.png", 100);
    m_pSpriteTexture = parent->getTexture();
#else
    // doesn't use batch node. Slower
    m_pSpriteTexture = CCTextureCache::sharedTextureCache()->addImage("Images/grossini_dance_atlas.png");
    CCNode *parent = CCNode::create();
#endif
    addChild(parent, 0, kTagParentNode);

    addNewSpriteAtPosition(ccp(200,200));

    // menu for debug layer
    CCMenuItemFont::setFontSize(18);
    CCMenuItemFont *item = CCMenuItemFont::create("Toggle debug", this, menu_selector(ChipmunkTestLayer::toggleDebugCallback));

    CCMenu *menu = CCMenu::create(item, NULL);
    this->addChild(menu);
    menu->setPosition(ccp(VisibleRect::right().x-100, VisibleRect::top().y-60));

    scheduleUpdate();
#else
    CCLabelTTF *pLabel = CCLabelTTF::create("Should define CC_ENABLE_CHIPMUNK_INTEGRATION=1\n to run this test case",
                                            "Arial",
                                            18);
    CCSize size = CCDirector::sharedDirector()->getWinSize();
    pLabel->setPosition(ccp(size.width/2, size.height/2));
    
    addChild(pLabel);
    
#endif
    
}
开发者ID:645286681,项目名称:cocos2d-x,代码行数:52,代码来源:ChipmunkTest.cpp

示例13: antiAliasMap

void MPMapLayer::antiAliasMap(CCTMXTiledMap * map)
{
    CCArray * pChildrenArray = map->getChildren();
    CCSpriteBatchNode* child = NULL;
    CCObject* pObject = NULL;
    CCARRAY_FOREACH(pChildrenArray, pObject)
    {
        child = (CCSpriteBatchNode*)pObject;
        
        if(!child)
            break;
        
        child->getTexture()->setAntiAliasTexParameters();
    }
开发者ID:Daniel-Martin11,项目名称:multiproj,代码行数:14,代码来源:MPMapLayer.cpp

示例14: _initPlatform

void GameLayer::_initPlatform()
{
    CCRect rect;
    switch((int)CCRANDOM_0_1() * 2)
    {
        case 0:
            rect = CCRectMake(608, 64, 102, 36);
            break;
        case 1:
            rect = CCRectMake(608, 128, 90, 32);
            break;
    }
    CCSpriteBatchNode* batchNode = dynamic_cast<CCSpriteBatchNode*>(getChildByTag(kSpriteManager));
    CCSprite* platform = CCSprite::createWithTexture(batchNode->getTexture(), rect);
    batchNode->addChild(platform, 3, currentPlatformTag);
}
开发者ID:GameLearning,项目名称:rocket-man-game,代码行数:16,代码来源:GameLayer.cpp

示例15: enableTileGrid

void LevelLoader::enableTileGrid(CCTMXTiledMap *map)
{
	//디버깅용 타일 경계선 그리기
	// All the tiles by default will be aliased. If you want to create anti-alias tiles, you should do:
	// iterate over all the "layers" (atlas sprite managers)
	// and set them as 'antialias' 
	CCArray * pChildrenArray = map->getChildren();
	CCSpriteBatchNode* child = NULL;
	CCObject* pObject = NULL;
	CCARRAY_FOREACH(pChildrenArray, pObject) {
		child = (CCSpriteBatchNode*)pObject;
		if(!child) {
			break;
		}
		child->getTexture()->setAntiAliasTexParameters();
	}
开发者ID:if1live,项目名称:dont-see,代码行数:16,代码来源:level_loader.cpp


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