check sprite == nullptr

remove unneeded namespace
This commit is contained in:
songchengjiang 2015-03-03 11:52:55 +08:00
parent 6b046c5236
commit e650ef2b4d
3 changed files with 12 additions and 2 deletions

View File

@ -240,6 +240,11 @@ void Particle3DModelRender::render(Renderer* renderer, const Mat4 &transform, Pa
if (_spriteList.empty()){ if (_spriteList.empty()){
for (unsigned int i = 0; i < particleSystem->getParticleQuota(); ++i){ for (unsigned int i = 0; i < particleSystem->getParticleQuota(); ++i){
Sprite3D *sprite = Sprite3D::create(_modelFile); Sprite3D *sprite = Sprite3D::create(_modelFile);
if (sprite == nullptr)
{
CCLOG("failed to load file %s", _modelFile.c_str());
continue;
}
sprite->setTexture(_texFile); sprite->setTexture(_texFile);
sprite->retain(); sprite->retain();
_spriteList.push_back(sprite); _spriteList.push_back(sprite);

View File

@ -377,7 +377,7 @@ void PUParticle3DQuadRender::determineUVCoords( PUParticle3D *particle )
particle->rt_uv = particle->lb_uv + Vec2(_textureCoordsColStep, _textureCoordsRowStep); particle->rt_uv = particle->lb_uv + Vec2(_textureCoordsColStep, _textureCoordsRowStep);
} }
void PUParticle3DQuadRender::fillVertex( unsigned short index, const cocos2d::Vec3 &pos, const cocos2d::Vec4 &color, const cocos2d::Vec2 &uv ) void PUParticle3DQuadRender::fillVertex( unsigned short index, const Vec3 &pos, const Vec4 &color, const Vec2 &uv )
{ {
_vertices[index].position = pos; _vertices[index].position = pos;
_vertices[index].color = color; _vertices[index].color = color;
@ -439,6 +439,11 @@ void PUParticle3DModelRender::render( Renderer* renderer, const Mat4 &transform,
if (_spriteList.empty()){ if (_spriteList.empty()){
for (unsigned int i = 0; i < particleSystem->getParticleQuota(); ++i){ for (unsigned int i = 0; i < particleSystem->getParticleQuota(); ++i){
Sprite3D *sprite = Sprite3D::create(_modelFile); Sprite3D *sprite = Sprite3D::create(_modelFile);
if (sprite == nullptr)
{
CCLOG("failed to load file %s", _modelFile.c_str());
continue;
}
sprite->setTexture(_texFile); sprite->setTexture(_texFile);
sprite->retain(); sprite->retain();
_spriteList.push_back(sprite); _spriteList.push_back(sprite);

View File

@ -161,7 +161,7 @@ protected:
void getOriginOffset(int &offsetX, int &offsetY); void getOriginOffset(int &offsetX, int &offsetY);
void determineUVCoords(PUParticle3D *particle); void determineUVCoords(PUParticle3D *particle);
void fillVertex(unsigned short index, const cocos2d::Vec3 &pos, const cocos2d::Vec4 &color, const cocos2d::Vec2 &uv); void fillVertex(unsigned short index, const Vec3 &pos, const Vec4 &color, const Vec2 &uv);
void fillTriangle(unsigned short index, unsigned short v0, unsigned short v1, unsigned short v2); void fillTriangle(unsigned short index, unsigned short v0, unsigned short v1, unsigned short v2);
protected: protected: