本文整理汇总了C++中SpriteBatchNode类的典型用法代码示例。如果您正苦于以下问题:C++ SpriteBatchNode类的具体用法?C++ SpriteBatchNode怎么用?C++ SpriteBatchNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SpriteBatchNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createRemovablePlats
void LevelTwo::createRemovablePlats()
{
std::shared_ptr<GameData> ptr = GameData::sharedGameData();
SpriteBatchNode* spritebatch = SpriteBatchNode::create(ptr->m_textureAtlasImageFile);
for (int i = 0; i < 4; i++)
{
if (i == 0)
{
TowerBase * removablePlats = TowerBase::create(Vec2(200, 338), m_gameState, 5);
m_removablePlats.push_back(removablePlats);
spritebatch->addChild(removablePlats, -5);
}
else if (i == 1)
{
TowerBase * removablePlats = TowerBase::create(Vec2(245, 338), m_gameState, 5);
m_removablePlats.push_back(removablePlats);
spritebatch->addChild(removablePlats, -5);
}
else if (i == 2)
{
TowerBase * removablePlats = TowerBase::create(Vec2(200, -100), m_gameState, 6);
m_removablePlats.push_back(removablePlats);
spritebatch->addChild(removablePlats, -5);
}
else if (i == 3)
{
TowerBase * removablePlats = TowerBase::create(Vec2(245, -100), m_gameState, 6);
m_removablePlats.push_back(removablePlats);
spritebatch->addChild(removablePlats, -5);
}
}
this->addChild(spritebatch, 1, END_SPRITE_BATCH);
}
示例2: addChild
void HelloWorld::createMapAndGetTile()
{
auto mapnotchange = TMXTiledMap::create("orthogonal-test4.tmx");
addChild(mapnotchange, 0, 1);
mapnotchange->setPosition(50,240);
auto map = TMXTiledMap::create("orthogonal-test4.tmx");
addChild(map, 0, 2);
map->setPosition(570,240);
SpriteBatchNode* child = nullptr;
auto& children = map->getChildren();
for(const auto &node : children) {
child = static_cast<SpriteBatchNode*>(node);
child->getTexture()->setAntiAliasTexParameters();
}
map->setAnchorPoint(Point(0, 0));
auto layer = map->getLayer("Layer 0");
auto s = layer->getLayerSize();
Sprite* sprite;
sprite = layer->getTileAt(Point(0,0));
sprite->setScale(2);
sprite = layer->getTileAt(Point(s.width-1,0));
sprite->setScale(2);
sprite = layer->getTileAt(Point(0,s.height-1));
sprite->setScale(2);
sprite = layer->getTileAt(Point(s.width-1,s.height-1));
sprite->setScale(2);
}
示例3: addChild
//------------------------------------------------------------------
//
// TMXOrthoTest4
//
//------------------------------------------------------------------
TMXOrthoTest4::TMXOrthoTest4()
{
auto map = TMXTiledMap::create("TileMaps/orthogonal-test4.tmx");
addChild(map, 0, kTagTileMap);
Size CC_UNUSED s1 = map->getContentSize();
CCLOG("ContentSize: %f, %f", s1.width,s1.height);
SpriteBatchNode* child = nullptr;
auto& children = map->getChildren();
for(const auto &node : children) {
child = static_cast<SpriteBatchNode*>(node);
child->getTexture()->setAntiAliasTexParameters();
}
map->setAnchorPoint(Vec2(0, 0));
auto layer = map->getLayer("Layer 0");
auto s = layer->getLayerSize();
Sprite* sprite;
sprite = layer->getTileAt(Vec2(0,0));
sprite->setScale(2);
sprite = layer->getTileAt(Vec2(s.width-1,0));
sprite->setScale(2);
sprite = layer->getTileAt(Vec2(0,s.height-1));
sprite->setScale(2);
sprite = layer->getTileAt(Vec2(s.width-1,s.height-1));
sprite->setScale(2);
schedule( schedule_selector(TMXOrthoTest4::removeSprite), 2 );
}
示例4: init
// on "init" you need to initialize your instance
bool HelloWorld::init()
{
//////////////////////////////
// 1. super init first
if ( !LayerColor::initWithColor(Color4B(255,255,255,255)) )
{
return false;
}
Texture2D *texture = TextureCache::sharedTextureCache()->addImage("Icon.png");
SpriteBatchNode* batch = SpriteBatchNode::createWithTexture(texture, 800);
this->addChild(batch);
for (int i = 0; i < 800; ++i)
{
int index = (i % 50) * 8;
int rowIndex = (i / 50) * 8;
Sprite *temp = Sprite::createWithTexture(texture);
temp->setPosition(Vec2(index, rowIndex));
batch->addChild(temp);
}
return true;
}
示例5: addChild
//------------------------------------------------------------------
//
// TMXOrthoTest
//
//------------------------------------------------------------------
TMXOrthoTest::TMXOrthoTest()
{
//
// Test orthogonal with 3d camera and anti-alias textures
//
// it should not flicker. No artifacts should appear
//
//auto color = LayerColor::create( Color4B(64,64,64,255) );
//addChild(color, -1);
auto map = TMXTiledMap::create("TileMaps/orthogonal-test2.tmx");
addChild(map, 0, kTagTileMap);
Size CC_UNUSED s = map->getContentSize();
CCLOG("ContentSize: %f, %f", s.width,s.height);
auto pChildrenArray = map->getChildren();
SpriteBatchNode* child = NULL;
Object* pObject = NULL;
CCARRAY_FOREACH(pChildrenArray, pObject)
{
child = static_cast<SpriteBatchNode*>(pObject);
if(!child)
break;
child->getTexture()->setAntiAliasTexParameters();
}
示例6: InitAnimation
//INITS
void GameScreen::InitAnimation()
{
SpriteBatchNode* spritebatch = SpriteBatchNode::create("Assets/Animation/Idle.png");
SpriteFrameCache* cache = SpriteFrameCache::getInstance();
cache->addSpriteFramesWithFile("Assets/Animation/Idle.plist");
_santaPaused = Sprite::createWithSpriteFrameName("Assets/Santa/idle_0001.png");
spritebatch->addChild(_santaPaused);
addChild(spritebatch);
_santaPaused->setPosition(Vec2(-_winSizeW*0.5f, _winSizeH*0.7f));
Vector<SpriteFrame*> animFrames;
char str[100] = { 0 };
for (int i = 1; i <= 12; i++)
{
sprintf(str, "Assets/Santa/idle_%04d.png", i);
SpriteFrame* frame = cache->getSpriteFrameByName(str);
animFrames.pushBack(frame);
}
Animation* animation = Animation::createWithSpriteFrames(animFrames, 0.1f);
_santaPaused->runAction(RepeatForever::create(Animate::create(animation)));
}
示例7: new
SpriteBatchNode* SpriteBatchNode::create(const std::string& fileImage, ssize_t capacity/* = DEFAULT_CAPACITY*/)
{
SpriteBatchNode *batchNode = new (std::nothrow) SpriteBatchNode();
batchNode->initWithFile(fileImage, capacity);
batchNode->autorelease();
return batchNode;
}
示例8: SpriteBatchNode
SpriteBatchNode* SpriteBatchNode::create(const char *fileImage, int capacity/* = kDefaultSpriteBatchCapacity*/)
{
SpriteBatchNode *batchNode = new SpriteBatchNode();
batchNode->initWithFile(fileImage, capacity);
batchNode->autorelease();
return batchNode;
}
示例9: createEndGame
void LevelTwo::createEndGame()
{
std::shared_ptr<GameData> ptr = GameData::sharedGameData();
SpriteBatchNode* spritebatch = SpriteBatchNode::create(ptr->m_textureAtlasImageFile);
for (int i = 0; i < ptr->m_numEndGame; i++)
{
endGame * endGame = endGame::create(Vec2(ptr->m_endGameX[i], ptr->m_endGameY[i]), 1);
m_end.push_back(endGame);
spritebatch->addChild(endGame, -5);
}
this->addChild(spritebatch, 1, END_SPRITE_BATCH);
}
示例10: createTrucks
void Tutorial::createTrucks()//creates the trucks
{
std::shared_ptr<GameData> ptr = GameData::sharedGameData();
SpriteBatchNode* spritebatch = SpriteBatchNode::create(ptr->m_textureAtlasImageFile);
for (int i = 0; i < 10; i++)//loops thru the trucks for tutorial
{
Truck * base = Truck::create(Vec2(ptr->m_truckPosX[i], ptr->m_truckPosY[i]), m_gameState);
m_trucks.push_back(base);
spritebatch->addChild(base, 1);
}
this->addChild(spritebatch, 1, COINS_SPRITE_BATCH);
}
示例11: createAmbulances
void Tutorial::createAmbulances()//creates the ambulances
{
std::shared_ptr<GameData> ptr = GameData::sharedGameData();
SpriteBatchNode* spritebatch = SpriteBatchNode::create(ptr->m_textureAtlasImageFile);
for (int i = 22; i < ptr->m_numberOfAmbulance; i++)//loops thru the ambulances for tutorial
{
Ambulance * base = Ambulance::create(Vec2(ptr->m_ambulancePosX[i], ptr->m_ambulancePosY[i]), m_gameState);
m_ambulances.push_back(base);
spritebatch->addChild(base, 1);
}
this->addChild(spritebatch, 1, COINS_SPRITE_BATCH);
}
示例12: createCoins
void Tutorial::createCoins()//creates the coins
{
std::shared_ptr<GameData> ptr = GameData::sharedGameData();
SpriteBatchNode* spritebatch = SpriteBatchNode::create(ptr->m_textureAtlasImageFile);
for (int i = 92; i < 104; i++)//loops thru the coins for tutorial
{
Coin * base = Coin::create(Vec2(ptr->m_coinPosX[i], ptr->m_coinPosY[i]), m_gameState);
m_coins.push_back(base);
spritebatch->addChild(base, 1);
}
this->addChild(spritebatch, 4, COINS_SPRITE_BATCH);
}
示例13: createTowerBases
void Tutorial::createTowerBases()//creates the taxis
{
std::shared_ptr<GameData> ptr = GameData::sharedGameData();
SpriteBatchNode* spritebatch = SpriteBatchNode::create(ptr->m_textureAtlasImageFile);
for (int i = 24; i < ptr->m_numberOfTowerBases; i++)//loops thru the taxi for tutorial
{
TowerBase * base = TowerBase::create(Vec2(ptr->m_towerBaseX[i], ptr->m_towerBaseY[i]), m_gameState);
m_towerBases.push_back(base);
spritebatch->addChild(base, 1);
}
this->addChild(spritebatch, 1, TOWERS_SPRITE_BATCH);
}
示例14: createHiddenPlatforms
void LevelTwo::createHiddenPlatforms()
{
std::shared_ptr<GameData> ptr = GameData::sharedGameData();
SpriteBatchNode* spritebatch = SpriteBatchNode::create(ptr->m_textureAtlasImageFile);
for (int i = 0; i < ptr->m_numberOfHiddenPlatforms; i++)
{
TowerBase * HiddenPlat = TowerBase::create(Vec2(380, 470), m_gameState, 4);
m_hiddenPlats.push_back(HiddenPlat);
spritebatch->addChild(HiddenPlat, -5);
}
this->addChild(spritebatch, 1, HIDDEN_SPRITE_BATCH);
}
示例15: createPlatforms
void LevelTwo::createPlatforms()
{
std::shared_ptr<GameData> ptr = GameData::sharedGameData();
SpriteBatchNode* spritebatch = SpriteBatchNode::create(ptr->m_textureAtlasImageFile);
for (int i = 0; i < ptr->m_numberOfLevelTwoPlats; i++)
{
TowerBase * base = TowerBase::create(Vec2(ptr->m_levelTwoPlatformsX[i], ptr->m_levelTwoPlatformsY[i]), m_gameState, 3);
m_levelTwoPlat.push_back(base);
spritebatch->addChild(base, -5);
}
this->addChild(spritebatch, 1, LEVELTWO_SPRITE_BATCH);
}