Skip to content

Commit d0ae760

Browse files
author
minggo
committed
Merge pull request cocos2d#355 from minggo/master
Fix some bugs when upgrading to rc3
2 parents b37b4b8 + c909d0c commit d0ae760

File tree

8 files changed

+156
-51
lines changed

8 files changed

+156
-51
lines changed

cocos2dx/include/CCParticleSystem.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ class CC_DLL CCParticleSystem : public CCNode, public CCTextureProtocol
233233
/** Is the emitter active */
234234
CC_PROPERTY_READONLY(bool, m_bIsActive, IsActive)
235235
/** Quantity of particles that are being simulated at the moment */
236-
CC_PROPERTY_READONLY(int, m_nParticleCount, ParticleCount)
236+
CC_PROPERTY_READONLY(unsigned int, m_uParticleCount, ParticleCount)
237237
/** How many seconds the emitter wil run. -1 means 'forever' */
238238
CC_PROPERTY(float, m_fDuration, Duration)
239239
/** sourcePosition of the emitter */
@@ -308,7 +308,7 @@ class CC_DLL CCParticleSystem : public CCNode, public CCTextureProtocol
308308
/** emission rate of the particles */
309309
CC_PROPERTY(float, m_fEmissionRate, EmissionRate)
310310
/** maximum particles of the system */
311-
CC_PROPERTY(int, m_nTotalParticles, TotalParticles)
311+
CC_PROPERTY(unsigned int, m_uTotalParticles, TotalParticles)
312312
/** conforms to CocosNodeTexture protocol */
313313
CC_PROPERTY(CCTexture2D*, m_pTexture, Texture)
314314
/** conforms to CocosNodeTexture protocol */

cocos2dx/misc_nodes/CCProgressTimer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ void CCProgressTimer::setPercentage(float fPercentage)
9696
{
9797
if (m_fPercentage != fPercentage)
9898
{
99-
m_fPercentage = clampf(m_fPercentage, 0, 100);
99+
m_fPercentage = clampf(fPercentage, 0, 100);
100100
updateProgress();
101101
}
102102
}
@@ -164,7 +164,7 @@ ccVertex2F CCProgressTimer::vertexFromTexCoord(cocos2d::CCPoint texCoord)
164164

165165
void CCProgressTimer::updateColor(void)
166166
{
167-
GLbyte op = m_pSprite->getOpacity();
167+
GLubyte op = m_pSprite->getOpacity();
168168
ccColor3B c3b = m_pSprite->getColor();
169169

170170
ccColor4B color = {c3b.r, c3b.g, c3b.b, op};

cocos2dx/particle_nodes/CCParticleExamples.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ bool CCParticleFire::initWithTotalParticles(unsigned int numberOfParticles)
7272
m_fEndSize = kCCParticleStartSizeEqualToEndSize;
7373

7474
// emits per frame
75-
m_fEmissionRate = m_nTotalParticles/m_fLife;
75+
m_fEmissionRate = m_uTotalParticles/m_fLife;
7676

7777
// color of particles
7878
m_tStartColor.r = 0.76f;
@@ -135,7 +135,7 @@ bool CCParticleFireworks::initWithTotalParticles(unsigned int numberOfParticles)
135135
this->m_fLifeVar = 1;
136136

137137
// emits per frame
138-
this->m_fEmissionRate = m_nTotalParticles/m_fLife;
138+
this->m_fEmissionRate = m_uTotalParticles/m_fLife;
139139

140140
// color of particles
141141
m_tStartColor.r = 0.5f;
@@ -213,7 +213,7 @@ bool CCParticleSun::initWithTotalParticles(unsigned int numberOfParticles)
213213
m_fEndSize = kCCParticleStartSizeEqualToEndSize;
214214

215215
// emits per seconds
216-
m_fEmissionRate = m_nTotalParticles/m_fLife;
216+
m_fEmissionRate = m_uTotalParticles/m_fLife;
217217

218218
// color of particles
219219
m_tStartColor.r = 0.76f;
@@ -285,7 +285,7 @@ bool CCParticleGalaxy::initWithTotalParticles(unsigned int numberOfParticles)
285285
m_fEndSize = kCCParticleStartSizeEqualToEndSize;
286286

287287
// emits per second
288-
m_fEmissionRate = m_nTotalParticles/m_fLife;
288+
m_fEmissionRate = m_uTotalParticles/m_fLife;
289289

290290
// color of particles
291291
m_tStartColor.r = 0.12f;
@@ -359,7 +359,7 @@ bool CCParticleFlower::initWithTotalParticles(unsigned int numberOfParticles)
359359
m_fEndSize = kCCParticleStartSizeEqualToEndSize;
360360

361361
// emits per second
362-
m_fEmissionRate = m_nTotalParticles/m_fLife;
362+
m_fEmissionRate = m_uTotalParticles/m_fLife;
363363

364364
// color of particles
365365
m_tStartColor.r = 0.50f;
@@ -432,7 +432,7 @@ bool CCParticleMeteor::initWithTotalParticles(unsigned int numberOfParticles)
432432
m_fEndSize = kCCParticleStartSizeEqualToEndSize;
433433

434434
// emits per second
435-
m_fEmissionRate = m_nTotalParticles/m_fLife;
435+
m_fEmissionRate = m_uTotalParticles/m_fLife;
436436

437437
// color of particles
438438
m_tStartColor.r = 0.2f;
@@ -506,7 +506,7 @@ bool CCParticleSpiral::initWithTotalParticles(unsigned int numberOfParticles)
506506
m_fEndSize = kCCParticleStartSizeEqualToEndSize;
507507

508508
// emits per second
509-
m_fEmissionRate = m_nTotalParticles/m_fLife;
509+
m_fEmissionRate = m_uTotalParticles/m_fLife;
510510

511511
// color of particles
512512
m_tStartColor.r = 0.5f;
@@ -579,7 +579,7 @@ bool CCParticleExplosion::initWithTotalParticles(unsigned int numberOfParticles)
579579
m_fEndSize = kCCParticleStartSizeEqualToEndSize;
580580

581581
// emits per second
582-
m_fEmissionRate = m_nTotalParticles/m_fDuration;
582+
m_fEmissionRate = m_uTotalParticles/m_fDuration;
583583

584584
// color of particles
585585
m_tStartColor.r = 0.7f;
@@ -649,7 +649,7 @@ bool CCParticleSmoke::initWithTotalParticles(unsigned int numberOfParticles)
649649
m_fEndSize = kCCParticleStartSizeEqualToEndSize;
650650

651651
// emits per frame
652-
m_fEmissionRate = m_nTotalParticles/m_fLife;
652+
m_fEmissionRate = m_uTotalParticles/m_fLife;
653653

654654
// color of particles
655655
m_tStartColor.r = 0.8f;

cocos2dx/particle_nodes/CCParticleSystem.cpp

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ CCParticleSystem::CCParticleSystem()
8787
,m_pProfilingTimer(NULL)
8888
#endif
8989
,m_bIsActive(true)
90-
,m_nParticleCount(0)
90+
,m_uParticleCount(0)
9191
,m_fDuration(0)
9292
,m_tSourcePosition(CCPointZero)
9393
,m_tPosVar(CCPointZero)
@@ -104,7 +104,7 @@ CCParticleSystem::CCParticleSystem()
104104
,m_fEndSpin(0)
105105
,m_fEndSpinVar(0)
106106
,m_fEmissionRate(0)
107-
,m_nTotalParticles(0)
107+
,m_uTotalParticles(0)
108108
,m_pTexture(NULL)
109109
,m_bIsBlendAdditive(false)
110110
,m_ePositionType(kCCPositionTypeFree)
@@ -259,7 +259,7 @@ bool CCParticleSystem::initWithDictionary(CCDictionary<std::string, CCObject*> *
259259
m_fLifeVar = (float)atof(valueForKey("particleLifespanVariance", dictionary));
260260

261261
// emission Rate
262-
m_fEmissionRate = m_nTotalParticles / m_fLife;
262+
m_fEmissionRate = m_uTotalParticles / m_fLife;
263263

264264
// texture
265265
// Try to get the texture from the cache
@@ -292,7 +292,7 @@ bool CCParticleSystem::initWithDictionary(CCDictionary<std::string, CCObject*> *
292292
if(dataLen != 0)
293293
{
294294
// if it fails, try to get it from the base64-gzipped data
295-
int decodeLen = base64Decode((unsigned char*)textureData, dataLen, &buffer);
295+
int decodeLen = base64Decode((unsigned char*)textureData, (unsigned int)dataLen, &buffer);
296296
CCAssert( buffer != NULL, "CCParticleSystem: error decoding textureImageData");
297297
CC_BREAK_IF(!buffer);
298298

@@ -322,11 +322,11 @@ bool CCParticleSystem::initWithDictionary(CCDictionary<std::string, CCObject*> *
322322
}
323323
bool CCParticleSystem::initWithTotalParticles(unsigned int numberOfParticles)
324324
{
325-
m_nTotalParticles = numberOfParticles;
325+
m_uTotalParticles = numberOfParticles;
326326

327327
CC_SAFE_DELETE_ARRAY(m_pParticles);
328328

329-
m_pParticles = new tCCParticle[m_nTotalParticles];
329+
m_pParticles = new tCCParticle[m_uTotalParticles];
330330

331331
if( ! m_pParticles )
332332
{
@@ -385,9 +385,9 @@ bool CCParticleSystem::addParticle()
385385
return false;
386386
}
387387

388-
tCCParticle * particle = &m_pParticles[ m_nParticleCount ];
388+
tCCParticle * particle = &m_pParticles[ m_uParticleCount ];
389389
this->initParticle(particle);
390-
++m_nParticleCount;
390+
++m_uParticleCount;
391391

392392
return true;
393393
}
@@ -510,15 +510,15 @@ void CCParticleSystem::resetSystem()
510510
{
511511
m_bIsActive = true;
512512
m_fElapsed = 0;
513-
for (m_nParticleIdx = 0; m_nParticleIdx < m_nParticleCount; ++m_nParticleIdx)
513+
for (m_nParticleIdx = 0; m_nParticleIdx < m_uParticleCount; ++m_nParticleIdx)
514514
{
515515
tCCParticle *p = &m_pParticles[m_nParticleIdx];
516516
p->timeToLive = 0;
517517
}
518518
}
519519
bool CCParticleSystem::isFull()
520520
{
521-
return (m_nParticleCount == m_nTotalParticles);
521+
return (m_uParticleCount == m_uTotalParticles);
522522
}
523523

524524
// ParticleSystem - MainLoop
@@ -528,7 +528,7 @@ void CCParticleSystem::update(ccTime dt)
528528
{
529529
float rate = 1.0f / m_fEmissionRate;
530530
m_fEmitCounter += dt;
531-
while( m_nParticleCount < m_nTotalParticles && m_fEmitCounter > rate )
531+
while( m_uParticleCount < m_uTotalParticles && m_fEmitCounter > rate )
532532
{
533533
this->addParticle();
534534
m_fEmitCounter -= rate;
@@ -563,7 +563,7 @@ void CCParticleSystem::update(ccTime dt)
563563
currentPosition.y *= CC_CONTENT_SCALE_FACTOR();
564564
}
565565

566-
while( m_nParticleIdx < m_nParticleCount )
566+
while( m_nParticleIdx < m_uParticleCount )
567567
{
568568
tCCParticle *p = &m_pParticles[m_nParticleIdx];
569569

@@ -647,13 +647,13 @@ void CCParticleSystem::update(ccTime dt)
647647
else
648648
{
649649
// life < 0
650-
if( m_nParticleIdx != m_nParticleCount-1 )
650+
if( m_nParticleIdx != m_uParticleCount-1 )
651651
{
652-
m_pParticles[m_nParticleIdx] = m_pParticles[m_nParticleCount-1];
652+
m_pParticles[m_nParticleIdx] = m_pParticles[m_uParticleCount-1];
653653
}
654-
--m_nParticleCount;
654+
--m_uParticleCount;
655655

656-
if( m_nParticleCount == 0 && m_bIsAutoRemoveOnFinish )
656+
if( m_uParticleCount == 0 && m_bIsAutoRemoveOnFinish )
657657
{
658658
this->unscheduleUpdate();
659659
m_pParent->removeChild(this, true);
@@ -865,9 +865,9 @@ bool CCParticleSystem::getIsActive()
865865
{
866866
return m_bIsActive;
867867
}
868-
int CCParticleSystem::getParticleCount()
868+
unsigned int CCParticleSystem::getParticleCount()
869869
{
870-
return m_nParticleCount;
870+
return m_uParticleCount;
871871
}
872872
float CCParticleSystem::getDuration()
873873
{
@@ -1029,13 +1029,13 @@ void CCParticleSystem::setEmissionRate(float var)
10291029
{
10301030
m_fEmissionRate = var;
10311031
}
1032-
int CCParticleSystem::getTotalParticles()
1032+
unsigned int CCParticleSystem::getTotalParticles()
10331033
{
1034-
return m_nTotalParticles;
1034+
return m_uTotalParticles;
10351035
}
1036-
void CCParticleSystem::setTotalParticles(int var)
1036+
void CCParticleSystem::setTotalParticles(unsigned int var)
10371037
{
1038-
m_nTotalParticles = var;
1038+
m_uTotalParticles = var;
10391039
}
10401040
ccBlendFunc CCParticleSystem::getBlendFunc()
10411041
{

cocos2dx/particle_nodes/CCParticleSystemPoint.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ bool CCParticleSystemPoint::initWithTotalParticles(unsigned int numberOfParticle
3333
{
3434
if( CCParticleSystem::initWithTotalParticles(numberOfParticles) )
3535
{
36-
m_pVertices = new ccPointSprite[m_nTotalParticles];
36+
m_pVertices = new ccPointSprite[m_uTotalParticles];
3737

3838
if( ! m_pVertices )
3939
{
@@ -47,7 +47,7 @@ bool CCParticleSystemPoint::initWithTotalParticles(unsigned int numberOfParticle
4747

4848
// initial binding
4949
glBindBuffer(GL_ARRAY_BUFFER, m_uVerticesID);
50-
glBufferData(GL_ARRAY_BUFFER, sizeof(ccPointSprite)*m_nTotalParticles, m_pVertices, GL_DYNAMIC_DRAW);
50+
glBufferData(GL_ARRAY_BUFFER, sizeof(ccPointSprite)*m_uTotalParticles, m_pVertices, GL_DYNAMIC_DRAW);
5151
glBindBuffer(GL_ARRAY_BUFFER, 0);
5252
#endif
5353
return true;
@@ -80,14 +80,14 @@ void CCParticleSystemPoint::updateQuadWithParticle(tCCParticle* particle, CCPoin
8080
// place vertices and colos in array
8181
m_pVertices[m_nParticleIdx].pos = vertex2(newPosition.x, newPosition.y);
8282
m_pVertices[m_nParticleIdx].size = particle->size;
83-
ccColor4B color = {(GLubyte)particle->color.r * 255, (GLubyte)particle->color.g * 255, (GLubyte)particle->color.b * 255, (GLubyte)particle->color.a * 255};
83+
ccColor4B color = {particle->color.r * 255, particle->color.g * 255, particle->color.b * 255, particle->color.a * 255};
8484
m_pVertices[m_nParticleIdx].color = color;
8585
}
8686
void CCParticleSystemPoint::postStep()
8787
{
8888
#if CC_USES_VBO
8989
glBindBuffer(GL_ARRAY_BUFFER, m_uVerticesID);
90-
glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(ccPointSprite)*m_nParticleCount, m_pVertices);
90+
glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(ccPointSprite)*m_uParticleCount, m_pVertices);
9191
glBindBuffer(GL_ARRAY_BUFFER, 0);
9292
#endif
9393
}
@@ -114,7 +114,7 @@ void CCParticleSystemPoint::draw()
114114
glBindBuffer(GL_ARRAY_BUFFER, m_uVerticesID);
115115

116116
#if CC_ENABLE_CACHE_TEXTTURE_DATA
117-
glBufferData(GL_ARRAY_BUFFER, sizeof(ccPointSprite)*m_nTotalParticles, m_pVertices, GL_DYNAMIC_DRAW);
117+
glBufferData(GL_ARRAY_BUFFER, sizeof(ccPointSprite)*m_uTotalParticles, m_pVertices, GL_DYNAMIC_DRAW);
118118
#endif
119119

120120
glVertexPointer(2,GL_FLOAT,kPointSize,0);

cocos2dx/particle_nodes/CCParticleSystemQuad.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ bool CCParticleSystemQuad::initWithTotalParticles(unsigned int numberOfParticles
4040
if( CCParticleSystem::initWithTotalParticles(numberOfParticles) )
4141
{
4242
// allocating data space
43-
m_pQuads = new ccV2F_C4B_T2F_Quad[m_nTotalParticles];
44-
m_pIndices = new GLushort[m_nTotalParticles * 6];
43+
m_pQuads = new ccV2F_C4B_T2F_Quad[m_uTotalParticles];
44+
m_pIndices = new GLushort[m_uTotalParticles * 6];
4545

4646
if( !m_pQuads || !m_pIndices)
4747
{
@@ -72,7 +72,7 @@ bool CCParticleSystemQuad::initWithTotalParticles(unsigned int numberOfParticles
7272

7373
// initial binding
7474
glBindBuffer(GL_ARRAY_BUFFER, m_uQuadsID);
75-
glBufferData(GL_ARRAY_BUFFER, sizeof(m_pQuads[0])*m_nTotalParticles, m_pQuads, GL_DYNAMIC_DRAW);
75+
glBufferData(GL_ARRAY_BUFFER, sizeof(m_pQuads[0])*m_uTotalParticles, m_pQuads, GL_DYNAMIC_DRAW);
7676
glBindBuffer(GL_ARRAY_BUFFER, 0);
7777
#endif
7878
return true;
@@ -136,7 +136,7 @@ void CCParticleSystemQuad::initTexCoordsWithRect(CCRect pointRect)
136136
// Important. Texture in cocos2d are inverted, so the Y component should be inverted
137137
CC_SWAP( top, bottom, float);
138138

139-
for(int i=0; i<m_nTotalParticles; i++)
139+
for(int i=0; i<m_uTotalParticles; i++)
140140
{
141141
// bottom-left vertex:
142142
m_pQuads[i].bl.texCoords.u = left;
@@ -179,7 +179,7 @@ void CCParticleSystemQuad::setDisplayFrame(CCSpriteFrame *spriteFrame)
179179
}
180180
void CCParticleSystemQuad::initIndices()
181181
{
182-
for( int i = 0; i < m_nTotalParticles; ++i)
182+
for( int i = 0; i < m_uTotalParticles; ++i)
183183
{
184184
const unsigned int i6 = i*6;
185185
const unsigned int i4 = i*4;
@@ -197,8 +197,8 @@ void CCParticleSystemQuad::updateQuadWithParticle(tCCParticle* particle, CCPoint
197197
// colors
198198
ccV2F_C4B_T2F_Quad *quad = &(m_pQuads[m_nParticleIdx]);
199199

200-
ccColor4B color = {(GLbyte)particle->color.r * 255, (GLbyte)particle->color.g * 255, (GLbyte)particle->color.b * 255,
201-
(GLbyte)particle->color.b * 255};
200+
ccColor4B color = {particle->color.r * 255, particle->color.g * 255, particle->color.b * 255,
201+
particle->color.b * 255};
202202
quad->bl.colors = color;
203203
quad->br.colors = color;
204204
quad->tl.colors = color;
@@ -265,7 +265,7 @@ void CCParticleSystemQuad::postStep()
265265
{
266266
#if CC_USES_VBO
267267
glBindBuffer(GL_ARRAY_BUFFER, m_uQuadsID);
268-
glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(m_pQuads[0])*m_nParticleCount, m_pQuads);
268+
glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(m_pQuads[0])*m_uParticleCount, m_pQuads);
269269
glBindBuffer(GL_ARRAY_BUFFER, 0);
270270
#endif
271271
}
@@ -284,7 +284,7 @@ void CCParticleSystemQuad::draw()
284284
glBindBuffer(GL_ARRAY_BUFFER, m_uQuadsID);
285285

286286
#if CC_ENABLE_CACHE_TEXTTURE_DATA
287-
glBufferData(GL_ARRAY_BUFFER, sizeof(m_pQuads[0])*m_nTotalParticles, m_pQuads, GL_DYNAMIC_DRAW);
287+
glBufferData(GL_ARRAY_BUFFER, sizeof(m_pQuads[0])*m_uTotalParticles, m_pQuads, GL_DYNAMIC_DRAW);
288288
#endif
289289

290290
glVertexPointer(2,GL_FLOAT, kQuadSize, 0);
@@ -316,9 +316,9 @@ void CCParticleSystemQuad::draw()
316316
glBlendFunc( m_tBlendFunc.src, m_tBlendFunc.dst );
317317
}
318318

319-
CCAssert( m_nParticleIdx == m_nParticleCount, "Abnormal error in particle quad");
319+
CCAssert( m_nParticleIdx == m_uParticleCount, "Abnormal error in particle quad");
320320

321-
glDrawElements(GL_TRIANGLES, (GLsizei)m_nParticleIdx*6, GL_UNSIGNED_SHORT, m_pIndices);
321+
glDrawElements(GL_TRIANGLES, (GLsizei)(m_nParticleIdx*6), GL_UNSIGNED_SHORT, m_pIndices);
322322

323323
// restore blend state
324324
if( newBlend )

cocos2dx/textures/CCTextureAtlas.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ CCTextureAtlas::CCTextureAtlas()
4444
:m_pIndices(NULL)
4545
,m_pTexture(NULL)
4646
,m_pQuads(NULL)
47+
#if CC_USES_VBO
48+
, m_bDirty(false)
49+
#endif
4750
{}
4851

4952
CCTextureAtlas::~CCTextureAtlas()

0 commit comments

Comments
 (0)