mirror of https://github.com/axmolengine/axmol.git
Merge pull request #355 from minggo/master
Fix some bugs when upgrading to rc3
This commit is contained in:
commit
4f419f3a61
|
@ -233,7 +233,7 @@ protected:
|
|||
/** Is the emitter active */
|
||||
CC_PROPERTY_READONLY(bool, m_bIsActive, IsActive)
|
||||
/** Quantity of particles that are being simulated at the moment */
|
||||
CC_PROPERTY_READONLY(int, m_nParticleCount, ParticleCount)
|
||||
CC_PROPERTY_READONLY(unsigned int, m_uParticleCount, ParticleCount)
|
||||
/** How many seconds the emitter wil run. -1 means 'forever' */
|
||||
CC_PROPERTY(float, m_fDuration, Duration)
|
||||
/** sourcePosition of the emitter */
|
||||
|
@ -308,7 +308,7 @@ public:
|
|||
/** emission rate of the particles */
|
||||
CC_PROPERTY(float, m_fEmissionRate, EmissionRate)
|
||||
/** maximum particles of the system */
|
||||
CC_PROPERTY(int, m_nTotalParticles, TotalParticles)
|
||||
CC_PROPERTY(unsigned int, m_uTotalParticles, TotalParticles)
|
||||
/** conforms to CocosNodeTexture protocol */
|
||||
CC_PROPERTY(CCTexture2D*, m_pTexture, Texture)
|
||||
/** conforms to CocosNodeTexture protocol */
|
||||
|
|
|
@ -96,7 +96,7 @@ void CCProgressTimer::setPercentage(float fPercentage)
|
|||
{
|
||||
if (m_fPercentage != fPercentage)
|
||||
{
|
||||
m_fPercentage = clampf(m_fPercentage, 0, 100);
|
||||
m_fPercentage = clampf(fPercentage, 0, 100);
|
||||
updateProgress();
|
||||
}
|
||||
}
|
||||
|
@ -164,7 +164,7 @@ ccVertex2F CCProgressTimer::vertexFromTexCoord(cocos2d::CCPoint texCoord)
|
|||
|
||||
void CCProgressTimer::updateColor(void)
|
||||
{
|
||||
GLbyte op = m_pSprite->getOpacity();
|
||||
GLubyte op = m_pSprite->getOpacity();
|
||||
ccColor3B c3b = m_pSprite->getColor();
|
||||
|
||||
ccColor4B color = {c3b.r, c3b.g, c3b.b, op};
|
||||
|
|
|
@ -72,7 +72,7 @@ bool CCParticleFire::initWithTotalParticles(unsigned int numberOfParticles)
|
|||
m_fEndSize = kCCParticleStartSizeEqualToEndSize;
|
||||
|
||||
// emits per frame
|
||||
m_fEmissionRate = m_nTotalParticles/m_fLife;
|
||||
m_fEmissionRate = m_uTotalParticles/m_fLife;
|
||||
|
||||
// color of particles
|
||||
m_tStartColor.r = 0.76f;
|
||||
|
@ -135,7 +135,7 @@ bool CCParticleFireworks::initWithTotalParticles(unsigned int numberOfParticles)
|
|||
this->m_fLifeVar = 1;
|
||||
|
||||
// emits per frame
|
||||
this->m_fEmissionRate = m_nTotalParticles/m_fLife;
|
||||
this->m_fEmissionRate = m_uTotalParticles/m_fLife;
|
||||
|
||||
// color of particles
|
||||
m_tStartColor.r = 0.5f;
|
||||
|
@ -213,7 +213,7 @@ bool CCParticleSun::initWithTotalParticles(unsigned int numberOfParticles)
|
|||
m_fEndSize = kCCParticleStartSizeEqualToEndSize;
|
||||
|
||||
// emits per seconds
|
||||
m_fEmissionRate = m_nTotalParticles/m_fLife;
|
||||
m_fEmissionRate = m_uTotalParticles/m_fLife;
|
||||
|
||||
// color of particles
|
||||
m_tStartColor.r = 0.76f;
|
||||
|
@ -285,7 +285,7 @@ bool CCParticleGalaxy::initWithTotalParticles(unsigned int numberOfParticles)
|
|||
m_fEndSize = kCCParticleStartSizeEqualToEndSize;
|
||||
|
||||
// emits per second
|
||||
m_fEmissionRate = m_nTotalParticles/m_fLife;
|
||||
m_fEmissionRate = m_uTotalParticles/m_fLife;
|
||||
|
||||
// color of particles
|
||||
m_tStartColor.r = 0.12f;
|
||||
|
@ -359,7 +359,7 @@ bool CCParticleFlower::initWithTotalParticles(unsigned int numberOfParticles)
|
|||
m_fEndSize = kCCParticleStartSizeEqualToEndSize;
|
||||
|
||||
// emits per second
|
||||
m_fEmissionRate = m_nTotalParticles/m_fLife;
|
||||
m_fEmissionRate = m_uTotalParticles/m_fLife;
|
||||
|
||||
// color of particles
|
||||
m_tStartColor.r = 0.50f;
|
||||
|
@ -432,7 +432,7 @@ bool CCParticleMeteor::initWithTotalParticles(unsigned int numberOfParticles)
|
|||
m_fEndSize = kCCParticleStartSizeEqualToEndSize;
|
||||
|
||||
// emits per second
|
||||
m_fEmissionRate = m_nTotalParticles/m_fLife;
|
||||
m_fEmissionRate = m_uTotalParticles/m_fLife;
|
||||
|
||||
// color of particles
|
||||
m_tStartColor.r = 0.2f;
|
||||
|
@ -506,7 +506,7 @@ bool CCParticleSpiral::initWithTotalParticles(unsigned int numberOfParticles)
|
|||
m_fEndSize = kCCParticleStartSizeEqualToEndSize;
|
||||
|
||||
// emits per second
|
||||
m_fEmissionRate = m_nTotalParticles/m_fLife;
|
||||
m_fEmissionRate = m_uTotalParticles/m_fLife;
|
||||
|
||||
// color of particles
|
||||
m_tStartColor.r = 0.5f;
|
||||
|
@ -579,7 +579,7 @@ bool CCParticleExplosion::initWithTotalParticles(unsigned int numberOfParticles)
|
|||
m_fEndSize = kCCParticleStartSizeEqualToEndSize;
|
||||
|
||||
// emits per second
|
||||
m_fEmissionRate = m_nTotalParticles/m_fDuration;
|
||||
m_fEmissionRate = m_uTotalParticles/m_fDuration;
|
||||
|
||||
// color of particles
|
||||
m_tStartColor.r = 0.7f;
|
||||
|
@ -649,7 +649,7 @@ bool CCParticleSmoke::initWithTotalParticles(unsigned int numberOfParticles)
|
|||
m_fEndSize = kCCParticleStartSizeEqualToEndSize;
|
||||
|
||||
// emits per frame
|
||||
m_fEmissionRate = m_nTotalParticles/m_fLife;
|
||||
m_fEmissionRate = m_uTotalParticles/m_fLife;
|
||||
|
||||
// color of particles
|
||||
m_tStartColor.r = 0.8f;
|
||||
|
|
|
@ -87,7 +87,7 @@ CCParticleSystem::CCParticleSystem()
|
|||
,m_pProfilingTimer(NULL)
|
||||
#endif
|
||||
,m_bIsActive(true)
|
||||
,m_nParticleCount(0)
|
||||
,m_uParticleCount(0)
|
||||
,m_fDuration(0)
|
||||
,m_tSourcePosition(CCPointZero)
|
||||
,m_tPosVar(CCPointZero)
|
||||
|
@ -104,7 +104,7 @@ CCParticleSystem::CCParticleSystem()
|
|||
,m_fEndSpin(0)
|
||||
,m_fEndSpinVar(0)
|
||||
,m_fEmissionRate(0)
|
||||
,m_nTotalParticles(0)
|
||||
,m_uTotalParticles(0)
|
||||
,m_pTexture(NULL)
|
||||
,m_bIsBlendAdditive(false)
|
||||
,m_ePositionType(kCCPositionTypeFree)
|
||||
|
@ -259,7 +259,7 @@ bool CCParticleSystem::initWithDictionary(CCDictionary<std::string, CCObject*> *
|
|||
m_fLifeVar = (float)atof(valueForKey("particleLifespanVariance", dictionary));
|
||||
|
||||
// emission Rate
|
||||
m_fEmissionRate = m_nTotalParticles / m_fLife;
|
||||
m_fEmissionRate = m_uTotalParticles / m_fLife;
|
||||
|
||||
// texture
|
||||
// Try to get the texture from the cache
|
||||
|
@ -292,7 +292,7 @@ bool CCParticleSystem::initWithDictionary(CCDictionary<std::string, CCObject*> *
|
|||
if(dataLen != 0)
|
||||
{
|
||||
// if it fails, try to get it from the base64-gzipped data
|
||||
int decodeLen = base64Decode((unsigned char*)textureData, dataLen, &buffer);
|
||||
int decodeLen = base64Decode((unsigned char*)textureData, (unsigned int)dataLen, &buffer);
|
||||
CCAssert( buffer != NULL, "CCParticleSystem: error decoding textureImageData");
|
||||
CC_BREAK_IF(!buffer);
|
||||
|
||||
|
@ -322,11 +322,11 @@ bool CCParticleSystem::initWithDictionary(CCDictionary<std::string, CCObject*> *
|
|||
}
|
||||
bool CCParticleSystem::initWithTotalParticles(unsigned int numberOfParticles)
|
||||
{
|
||||
m_nTotalParticles = numberOfParticles;
|
||||
m_uTotalParticles = numberOfParticles;
|
||||
|
||||
CC_SAFE_DELETE_ARRAY(m_pParticles);
|
||||
|
||||
m_pParticles = new tCCParticle[m_nTotalParticles];
|
||||
m_pParticles = new tCCParticle[m_uTotalParticles];
|
||||
|
||||
if( ! m_pParticles )
|
||||
{
|
||||
|
@ -385,9 +385,9 @@ bool CCParticleSystem::addParticle()
|
|||
return false;
|
||||
}
|
||||
|
||||
tCCParticle * particle = &m_pParticles[ m_nParticleCount ];
|
||||
tCCParticle * particle = &m_pParticles[ m_uParticleCount ];
|
||||
this->initParticle(particle);
|
||||
++m_nParticleCount;
|
||||
++m_uParticleCount;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -510,7 +510,7 @@ void CCParticleSystem::resetSystem()
|
|||
{
|
||||
m_bIsActive = true;
|
||||
m_fElapsed = 0;
|
||||
for (m_nParticleIdx = 0; m_nParticleIdx < m_nParticleCount; ++m_nParticleIdx)
|
||||
for (m_nParticleIdx = 0; m_nParticleIdx < m_uParticleCount; ++m_nParticleIdx)
|
||||
{
|
||||
tCCParticle *p = &m_pParticles[m_nParticleIdx];
|
||||
p->timeToLive = 0;
|
||||
|
@ -518,7 +518,7 @@ void CCParticleSystem::resetSystem()
|
|||
}
|
||||
bool CCParticleSystem::isFull()
|
||||
{
|
||||
return (m_nParticleCount == m_nTotalParticles);
|
||||
return (m_uParticleCount == m_uTotalParticles);
|
||||
}
|
||||
|
||||
// ParticleSystem - MainLoop
|
||||
|
@ -528,7 +528,7 @@ void CCParticleSystem::update(ccTime dt)
|
|||
{
|
||||
float rate = 1.0f / m_fEmissionRate;
|
||||
m_fEmitCounter += dt;
|
||||
while( m_nParticleCount < m_nTotalParticles && m_fEmitCounter > rate )
|
||||
while( m_uParticleCount < m_uTotalParticles && m_fEmitCounter > rate )
|
||||
{
|
||||
this->addParticle();
|
||||
m_fEmitCounter -= rate;
|
||||
|
@ -563,7 +563,7 @@ void CCParticleSystem::update(ccTime dt)
|
|||
currentPosition.y *= CC_CONTENT_SCALE_FACTOR();
|
||||
}
|
||||
|
||||
while( m_nParticleIdx < m_nParticleCount )
|
||||
while( m_nParticleIdx < m_uParticleCount )
|
||||
{
|
||||
tCCParticle *p = &m_pParticles[m_nParticleIdx];
|
||||
|
||||
|
@ -647,13 +647,13 @@ void CCParticleSystem::update(ccTime dt)
|
|||
else
|
||||
{
|
||||
// life < 0
|
||||
if( m_nParticleIdx != m_nParticleCount-1 )
|
||||
if( m_nParticleIdx != m_uParticleCount-1 )
|
||||
{
|
||||
m_pParticles[m_nParticleIdx] = m_pParticles[m_nParticleCount-1];
|
||||
m_pParticles[m_nParticleIdx] = m_pParticles[m_uParticleCount-1];
|
||||
}
|
||||
--m_nParticleCount;
|
||||
--m_uParticleCount;
|
||||
|
||||
if( m_nParticleCount == 0 && m_bIsAutoRemoveOnFinish )
|
||||
if( m_uParticleCount == 0 && m_bIsAutoRemoveOnFinish )
|
||||
{
|
||||
this->unscheduleUpdate();
|
||||
m_pParent->removeChild(this, true);
|
||||
|
@ -865,9 +865,9 @@ bool CCParticleSystem::getIsActive()
|
|||
{
|
||||
return m_bIsActive;
|
||||
}
|
||||
int CCParticleSystem::getParticleCount()
|
||||
unsigned int CCParticleSystem::getParticleCount()
|
||||
{
|
||||
return m_nParticleCount;
|
||||
return m_uParticleCount;
|
||||
}
|
||||
float CCParticleSystem::getDuration()
|
||||
{
|
||||
|
@ -1029,13 +1029,13 @@ void CCParticleSystem::setEmissionRate(float var)
|
|||
{
|
||||
m_fEmissionRate = var;
|
||||
}
|
||||
int CCParticleSystem::getTotalParticles()
|
||||
unsigned int CCParticleSystem::getTotalParticles()
|
||||
{
|
||||
return m_nTotalParticles;
|
||||
return m_uTotalParticles;
|
||||
}
|
||||
void CCParticleSystem::setTotalParticles(int var)
|
||||
void CCParticleSystem::setTotalParticles(unsigned int var)
|
||||
{
|
||||
m_nTotalParticles = var;
|
||||
m_uTotalParticles = var;
|
||||
}
|
||||
ccBlendFunc CCParticleSystem::getBlendFunc()
|
||||
{
|
||||
|
|
|
@ -33,7 +33,7 @@ bool CCParticleSystemPoint::initWithTotalParticles(unsigned int numberOfParticle
|
|||
{
|
||||
if( CCParticleSystem::initWithTotalParticles(numberOfParticles) )
|
||||
{
|
||||
m_pVertices = new ccPointSprite[m_nTotalParticles];
|
||||
m_pVertices = new ccPointSprite[m_uTotalParticles];
|
||||
|
||||
if( ! m_pVertices )
|
||||
{
|
||||
|
@ -47,7 +47,7 @@ bool CCParticleSystemPoint::initWithTotalParticles(unsigned int numberOfParticle
|
|||
|
||||
// initial binding
|
||||
glBindBuffer(GL_ARRAY_BUFFER, m_uVerticesID);
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(ccPointSprite)*m_nTotalParticles, m_pVertices, GL_DYNAMIC_DRAW);
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(ccPointSprite)*m_uTotalParticles, m_pVertices, GL_DYNAMIC_DRAW);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
#endif
|
||||
return true;
|
||||
|
@ -80,14 +80,14 @@ void CCParticleSystemPoint::updateQuadWithParticle(tCCParticle* particle, CCPoin
|
|||
// place vertices and colos in array
|
||||
m_pVertices[m_nParticleIdx].pos = vertex2(newPosition.x, newPosition.y);
|
||||
m_pVertices[m_nParticleIdx].size = particle->size;
|
||||
ccColor4B color = {(GLubyte)particle->color.r * 255, (GLubyte)particle->color.g * 255, (GLubyte)particle->color.b * 255, (GLubyte)particle->color.a * 255};
|
||||
ccColor4B color = {particle->color.r * 255, particle->color.g * 255, particle->color.b * 255, particle->color.a * 255};
|
||||
m_pVertices[m_nParticleIdx].color = color;
|
||||
}
|
||||
void CCParticleSystemPoint::postStep()
|
||||
{
|
||||
#if CC_USES_VBO
|
||||
glBindBuffer(GL_ARRAY_BUFFER, m_uVerticesID);
|
||||
glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(ccPointSprite)*m_nParticleCount, m_pVertices);
|
||||
glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(ccPointSprite)*m_uParticleCount, m_pVertices);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
#endif
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ void CCParticleSystemPoint::draw()
|
|||
glBindBuffer(GL_ARRAY_BUFFER, m_uVerticesID);
|
||||
|
||||
#if CC_ENABLE_CACHE_TEXTTURE_DATA
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(ccPointSprite)*m_nTotalParticles, m_pVertices, GL_DYNAMIC_DRAW);
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(ccPointSprite)*m_uTotalParticles, m_pVertices, GL_DYNAMIC_DRAW);
|
||||
#endif
|
||||
|
||||
glVertexPointer(2,GL_FLOAT,kPointSize,0);
|
||||
|
|
|
@ -40,8 +40,8 @@ bool CCParticleSystemQuad::initWithTotalParticles(unsigned int numberOfParticles
|
|||
if( CCParticleSystem::initWithTotalParticles(numberOfParticles) )
|
||||
{
|
||||
// allocating data space
|
||||
m_pQuads = new ccV2F_C4B_T2F_Quad[m_nTotalParticles];
|
||||
m_pIndices = new GLushort[m_nTotalParticles * 6];
|
||||
m_pQuads = new ccV2F_C4B_T2F_Quad[m_uTotalParticles];
|
||||
m_pIndices = new GLushort[m_uTotalParticles * 6];
|
||||
|
||||
if( !m_pQuads || !m_pIndices)
|
||||
{
|
||||
|
@ -72,7 +72,7 @@ bool CCParticleSystemQuad::initWithTotalParticles(unsigned int numberOfParticles
|
|||
|
||||
// initial binding
|
||||
glBindBuffer(GL_ARRAY_BUFFER, m_uQuadsID);
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(m_pQuads[0])*m_nTotalParticles, m_pQuads, GL_DYNAMIC_DRAW);
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(m_pQuads[0])*m_uTotalParticles, m_pQuads, GL_DYNAMIC_DRAW);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
#endif
|
||||
return true;
|
||||
|
@ -136,7 +136,7 @@ void CCParticleSystemQuad::initTexCoordsWithRect(CCRect pointRect)
|
|||
// Important. Texture in cocos2d are inverted, so the Y component should be inverted
|
||||
CC_SWAP( top, bottom, float);
|
||||
|
||||
for(int i=0; i<m_nTotalParticles; i++)
|
||||
for(int i=0; i<m_uTotalParticles; i++)
|
||||
{
|
||||
// bottom-left vertex:
|
||||
m_pQuads[i].bl.texCoords.u = left;
|
||||
|
@ -179,7 +179,7 @@ void CCParticleSystemQuad::setDisplayFrame(CCSpriteFrame *spriteFrame)
|
|||
}
|
||||
void CCParticleSystemQuad::initIndices()
|
||||
{
|
||||
for( int i = 0; i < m_nTotalParticles; ++i)
|
||||
for( int i = 0; i < m_uTotalParticles; ++i)
|
||||
{
|
||||
const unsigned int i6 = i*6;
|
||||
const unsigned int i4 = i*4;
|
||||
|
@ -197,8 +197,8 @@ void CCParticleSystemQuad::updateQuadWithParticle(tCCParticle* particle, CCPoint
|
|||
// colors
|
||||
ccV2F_C4B_T2F_Quad *quad = &(m_pQuads[m_nParticleIdx]);
|
||||
|
||||
ccColor4B color = {(GLbyte)particle->color.r * 255, (GLbyte)particle->color.g * 255, (GLbyte)particle->color.b * 255,
|
||||
(GLbyte)particle->color.b * 255};
|
||||
ccColor4B color = {particle->color.r * 255, particle->color.g * 255, particle->color.b * 255,
|
||||
particle->color.b * 255};
|
||||
quad->bl.colors = color;
|
||||
quad->br.colors = color;
|
||||
quad->tl.colors = color;
|
||||
|
@ -265,7 +265,7 @@ void CCParticleSystemQuad::postStep()
|
|||
{
|
||||
#if CC_USES_VBO
|
||||
glBindBuffer(GL_ARRAY_BUFFER, m_uQuadsID);
|
||||
glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(m_pQuads[0])*m_nParticleCount, m_pQuads);
|
||||
glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(m_pQuads[0])*m_uParticleCount, m_pQuads);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
#endif
|
||||
}
|
||||
|
@ -284,7 +284,7 @@ void CCParticleSystemQuad::draw()
|
|||
glBindBuffer(GL_ARRAY_BUFFER, m_uQuadsID);
|
||||
|
||||
#if CC_ENABLE_CACHE_TEXTTURE_DATA
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(m_pQuads[0])*m_nTotalParticles, m_pQuads, GL_DYNAMIC_DRAW);
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(m_pQuads[0])*m_uTotalParticles, m_pQuads, GL_DYNAMIC_DRAW);
|
||||
#endif
|
||||
|
||||
glVertexPointer(2,GL_FLOAT, kQuadSize, 0);
|
||||
|
@ -316,9 +316,9 @@ void CCParticleSystemQuad::draw()
|
|||
glBlendFunc( m_tBlendFunc.src, m_tBlendFunc.dst );
|
||||
}
|
||||
|
||||
CCAssert( m_nParticleIdx == m_nParticleCount, "Abnormal error in particle quad");
|
||||
CCAssert( m_nParticleIdx == m_uParticleCount, "Abnormal error in particle quad");
|
||||
|
||||
glDrawElements(GL_TRIANGLES, (GLsizei)m_nParticleIdx*6, GL_UNSIGNED_SHORT, m_pIndices);
|
||||
glDrawElements(GL_TRIANGLES, (GLsizei)(m_nParticleIdx*6), GL_UNSIGNED_SHORT, m_pIndices);
|
||||
|
||||
// restore blend state
|
||||
if( newBlend )
|
||||
|
|
|
@ -44,6 +44,9 @@ CCTextureAtlas::CCTextureAtlas()
|
|||
:m_pIndices(NULL)
|
||||
,m_pTexture(NULL)
|
||||
,m_pQuads(NULL)
|
||||
#if CC_USES_VBO
|
||||
, m_bDirty(false)
|
||||
#endif
|
||||
{}
|
||||
|
||||
CCTextureAtlas::~CCTextureAtlas()
|
||||
|
|
Loading…
Reference in New Issue