2013-11-13 03:14:34 +08:00
|
|
|
//
|
|
|
|
// 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;
|
2013-11-13 03:14:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
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*);
|
|
|
|
|
|
|
|
QuadCommand* cmd = new QuadCommand(0, 0, _textureAtlas->getTexture()->getName(), _shaderProgram, _blendFunc, _textureAtlas->getQuads(), _textureAtlas->getTotalQuads());
|
2013-11-15 08:39:03 +08:00
|
|
|
Renderer::getInstance()->addCommand(cmd);
|
2013-11-13 03:14:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_CC_END
|