axmol/cocos/2d/renderer/CCNewSpriteBatchNode.cpp

67 lines
1.5 KiB
C++
Raw Normal View History

//
// Created by NiTe Luo on 11/11/13.
//
#include "CCNewSpriteBatchNode.h"
#include "CCDirector.h"
#include "CCShaderCache.h"
#include "CCTextureCache.h"
#include "CCSprite.h"
#include "CCNewSprite.h"
#include "QuadCommand.h"
#include "Renderer.h"
NS_CC_BEGIN
NewSpriteBatchNode *NewSpriteBatchNode::createWithTexture(Texture2D *tex, int capacity)
{
NewSpriteBatchNode* batchNode = new NewSpriteBatchNode();
batchNode->initWithTexture(tex, capacity);
batchNode->autorelease();
return batchNode;
}
NewSpriteBatchNode *NewSpriteBatchNode::create(const char *fileImage, long capacity)
{
NewSpriteBatchNode* batchNode = new NewSpriteBatchNode();
batchNode->initWithFile(fileImage, capacity);
batchNode->autorelease();
2013-11-13 03:53:53 +08:00
return batchNode;
}
NewSpriteBatchNode::NewSpriteBatchNode()
:SpriteBatchNode()
{
}
NewSpriteBatchNode::~NewSpriteBatchNode()
{
}
bool NewSpriteBatchNode::init()
{
Texture2D* texture = new Texture2D();
texture->autorelease();
return this->initWithTexture(texture, 0);
}
void NewSpriteBatchNode::draw()
{
// Optimization: Fast Dispatch
if( _textureAtlas->getTotalQuads() == 0 )
{
return;
}
arrayMakeObjectsPerformSelector(_children, updateTransform, NewSprite*);
2013-11-16 03:29:11 +08:00
QuadCommand* cmd = new QuadCommand(0, _vertexZ, _textureAtlas->getTexture()->getName(), _shaderProgram, _blendFunc, _textureAtlas->getQuads(), _textureAtlas->getTotalQuads());
2013-11-15 08:39:03 +08:00
Renderer::getInstance()->addCommand(cmd);
}
NS_CC_END