Skip to content

Commit 0c4b392

Browse files
committed
Merge pull request #4 from cocos2d/develop
update
2 parents 8e58d37 + 7d5b57c commit 0c4b392

File tree

28 files changed

+502
-194
lines changed

28 files changed

+502
-194
lines changed

.travis.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ language: cpp
22
env:
33
matrix:
44
- GEN_JSB=YES
5-
- PLATFORM=linux DEBUG=1
5+
- PLATFORM=linux DEBUG=1 CC_COMPILER=gcc CXX_COMPILER=g++
6+
- PLATFORM=linux DEBUG=1 CC_COMPILER=clang CXX_COMPILER=clang++
67
# Since switching to C++11 only the ARM version of the nactive client
78
# port currently builds. TODO(sbc): Re-enable all architectures.
89
# Disabled travis-ci build for native client port since it doesn't support std::thread, std::mutex.
@@ -23,6 +24,8 @@ env:
2324
9lV+vgJQDRcFe7dKwtC86vk10EU7Ym2bhVmhMxi/AlmJXgavjmPVdizRT7rh
2425
X2Ry/Nb6hGRkH3WS0T3D/KG1+e7lP/TMB9bvo6/locLJ2A6Z1YI=
2526
script:
27+
- export CC=$CC_COMPILER
28+
- export CXX=$CXX_COMPILER
2629
- tools/travis-scripts/run-script.sh
2730
before_install:
2831
- tools/travis-scripts/before-install.sh

AUTHORS

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,7 @@ Developers:
356356

357357
ThePickleMan
358358
Adding 'rotationIsDir' property to ParticleSystem.
359+
DrawNode supports to draw triangle, quad bezier, cubic bezier.
359360

360361
Jianghua (jxhgzs)
361362
Adding an additional transform for CCNode.
@@ -519,6 +520,7 @@ Developers:
519520
Correcting the type detecting order for Lua CCBProxy::getNodeTypeName.
520521
Casting variables to their own type, and print warning info if no corresponding lua callback function instead of crash.
521522
fix of WebSocket url parse error for 'ws://domain.com/websocket' pattern.
523+
Fixed a bug that Websocket doesn't support send/receive data which larger than 4096 bytes.
522524

523525
musikov
524526
Fixing a bug that missing precision when getting strokeColor and fontFillColor
@@ -657,6 +659,7 @@ Developers:
657659

658660
xhcnb
659661
Device::setAccelerometerEnabled needs to be invoked before adding ACC listener.
662+
Fixed a bug that it will get wrong custom properties when use different count custom properties in CocosBuilder.
660663

661664
bopohaa
662665
Fixed a bug that Webp test crashes.
@@ -704,6 +707,10 @@ Developers:
704707
daltomi
705708
Fixed a typo in Director class.
706709
Removed an unnecessary boolean flag in CCFontAtlasCache.cpp.
710+
711+
v1ctor
712+
ControlSlider supports to set selected thumb sprite.
713+
ControlButton supports to set scale ratio of touchdown state
707714

708715
Retired Core Developers:
709716
WenSheng Yang

CHANGELOG

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
cocos2d-x-3.0final ?.? ?
22
[All]
33
[FIX] Crash was triggered if there is not `textureFileName`section in particle plist file.
4+
[FIX] ControlSlider doesn't support to set selected thumb sprite.
5+
[FIX] ControlButton doesn't support to set scale ratio of touchdown state.
6+
[FIX] Websocket doesn't support send/receive data which larger than 4096 bytes.
7+
[NEW] DrawNode supports to draw triangle, quad bezier, cubic bezier.
48
cocos2d-x-3.0beta Jan.7 2014
59
[All]
610
[NEW] New label: shadow, outline, glow support

cocos/2d/CCDirector.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -948,17 +948,20 @@ void Director::createStatsLabel()
948948
*/
949949
float factor = EGLView::getInstance()->getDesignResolutionSize().height / 320.0f;
950950

951-
_FPSLabel = new LabelAtlas;
951+
_FPSLabel = LabelAtlas::create();
952+
_FPSLabel->retain();
952953
_FPSLabel->setIgnoreContentScaleFactor(true);
953954
_FPSLabel->initWithString("00.0", texture, 12, 32 , '.');
954955
_FPSLabel->setScale(factor);
955956

956-
_SPFLabel = new LabelAtlas;
957+
_SPFLabel = LabelAtlas::create();
958+
_SPFLabel->retain();
957959
_SPFLabel->setIgnoreContentScaleFactor(true);
958960
_SPFLabel->initWithString("0.000", texture, 12, 32, '.');
959961
_SPFLabel->setScale(factor);
960962

961-
_drawsLabel = new LabelAtlas;
963+
_drawsLabel = LabelAtlas::create();
964+
_drawsLabel->retain();
962965
_drawsLabel->setIgnoreContentScaleFactor(true);
963966
_drawsLabel->initWithString("000", texture, 12, 32, '.');
964967
_drawsLabel->setScale(factor);

cocos/2d/CCDrawNode.cpp

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,86 @@ void DrawNode::drawPolygon(Point *verts, int count, const Color4F &fillColor, fl
456456
free(extrude);
457457
}
458458

459+
void DrawNode::drawTriangle(const Point &p1, const Point &p2, const Point &p3, const Color4F &color)
460+
{
461+
unsigned int vertex_count = 2*3;
462+
ensureCapacity(vertex_count);
463+
464+
Color4B col = Color4B(color);
465+
V2F_C4B_T2F a = {Vertex2F(p1.x, p1.y), col, Tex2F(0.0, 0.0) };
466+
V2F_C4B_T2F b = {Vertex2F(p2.x, p2.y), col, Tex2F(0.0, 0.0) };
467+
V2F_C4B_T2F c = {Vertex2F(p3.x, p3.y), col, Tex2F(0.0, 0.0) };
468+
469+
V2F_C4B_T2F_Triangle *triangles = (V2F_C4B_T2F_Triangle *)(_buffer + _bufferCount);
470+
V2F_C4B_T2F_Triangle triangle = {a, b, c};
471+
triangles[0] = triangle;
472+
473+
_bufferCount += vertex_count;
474+
_dirty = true;
475+
}
476+
477+
void DrawNode::drawCubicBezier(const Point& from, const Point& control1, const Point& control2, const Point& to, unsigned int segments, const Color4F &color)
478+
{
479+
unsigned int vertex_count = (segments + 1) * 3;
480+
ensureCapacity(vertex_count);
481+
482+
Tex2F texCoord = Tex2F(0.0, 0.0);
483+
Color4B col = Color4B(color);
484+
Vertex2F vertex;
485+
Vertex2F firstVertex = Vertex2F(from.x, from.y);
486+
Vertex2F lastVertex = Vertex2F(to.x, to.y);
487+
488+
float t = 0;
489+
for(unsigned int i = segments + 1; i > 0; i--)
490+
{
491+
float x = powf(1 - t, 3) * from.x + 3.0f * powf(1 - t, 2) * t * control1.x + 3.0f * (1 - t) * t * t * control2.x + t * t * t * to.x;
492+
float y = powf(1 - t, 3) * from.y + 3.0f * powf(1 - t, 2) * t * control1.y + 3.0f * (1 - t) * t * t * control2.y + t * t * t * to.y;
493+
vertex = Vertex2F(x, y);
494+
495+
V2F_C4B_T2F a = {firstVertex, col, texCoord };
496+
V2F_C4B_T2F b = {lastVertex, col, texCoord };
497+
V2F_C4B_T2F c = {vertex, col, texCoord };
498+
V2F_C4B_T2F_Triangle triangle = {a, b, c};
499+
((V2F_C4B_T2F_Triangle *)(_buffer + _bufferCount))[0] = triangle;
500+
501+
lastVertex = vertex;
502+
t += 1.0f / segments;
503+
_bufferCount += 3;
504+
}
505+
_dirty = true;
506+
}
507+
508+
void DrawNode::drawQuadraticBezier(const Point& from, const Point& control, const Point& to, unsigned int segments, const Color4F &color)
509+
{
510+
unsigned int vertex_count = (segments + 1) * 3;
511+
ensureCapacity(vertex_count);
512+
513+
Tex2F texCoord = Tex2F(0.0, 0.0);
514+
Color4B col = Color4B(color);
515+
Vertex2F vertex;
516+
Vertex2F firstVertex = Vertex2F(from.x, from.y);
517+
Vertex2F lastVertex = Vertex2F(to.x, to.y);
518+
519+
float t = 0;
520+
for(unsigned int i = segments + 1; i > 0; i--)
521+
{
522+
float x = powf(1 - t, 2) * from.x + 2.0f * (1 - t) * t * control.x + t * t * to.x;
523+
float y = powf(1 - t, 2) * from.y + 2.0f * (1 - t) * t * control.y + t * t * to.y;
524+
vertex = Vertex2F(x, y);
525+
526+
V2F_C4B_T2F a = {firstVertex, col, texCoord };
527+
V2F_C4B_T2F b = {lastVertex, col, texCoord };
528+
V2F_C4B_T2F c = {vertex, col, texCoord };
529+
V2F_C4B_T2F_Triangle triangle = {a, b, c};
530+
((V2F_C4B_T2F_Triangle *)(_buffer + _bufferCount))[0] = triangle;
531+
532+
lastVertex = vertex;
533+
t += 1.0f / segments;
534+
_bufferCount += 3;
535+
}
536+
_dirty = true;
537+
}
538+
459539
void DrawNode::clear()
460540
{
461541
_bufferCount = 0;

cocos/2d/CCDrawNode.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,15 @@ class CC_DLL DrawNode : public Node
6363
* @endcode
6464
*/
6565
void drawPolygon(Point *verts, int count, const Color4F &fillColor, float borderWidth, const Color4F &borderColor);
66+
67+
/** draw a triangle with color */
68+
void drawTriangle(const Point &p1, const Point &p2, const Point &p3, const Color4F &color);
69+
70+
/** draw a cubic bezier curve with color and number of segments */
71+
void drawCubicBezier(const Point& from, const Point& control1, const Point& control2, const Point& to, unsigned int segments, const Color4F &color);
72+
73+
/** draw a quadratic bezier curve with color and number of segments */
74+
void drawQuadraticBezier(const Point& from, const Point& control, const Point& to, unsigned int segments, const Color4F &color);
6675

6776
/** Clear the geometry in the node's buffer. */
6877
void clear();

cocos/2d/CCLabelAtlas.cpp

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,30 @@ NS_CC_BEGIN
4343

4444
//CCLabelAtlas - Creation & Init
4545

46+
LabelAtlas* LabelAtlas::create()
47+
{
48+
LabelAtlas* ret = new LabelAtlas();
49+
if (ret)
50+
{
51+
ret->autorelease();
52+
}
53+
else
54+
{
55+
CC_SAFE_RELEASE_NULL(ret);
56+
}
57+
58+
return ret;
59+
}
60+
4661
LabelAtlas* LabelAtlas::create(const std::string& string, const std::string& charMapFile, int itemWidth, int itemHeight, int startCharMap)
4762
{
48-
LabelAtlas *pRet = new LabelAtlas();
49-
if(pRet && pRet->initWithString(string, charMapFile, itemWidth, itemHeight, startCharMap))
63+
LabelAtlas* ret = new LabelAtlas();
64+
if(ret && ret->initWithString(string, charMapFile, itemWidth, itemHeight, startCharMap))
5065
{
51-
pRet->autorelease();
52-
return pRet;
66+
ret->autorelease();
67+
return ret;
5368
}
54-
CC_SAFE_DELETE(pRet);
69+
CC_SAFE_DELETE(ret);
5570
return nullptr;
5671
}
5772

cocos/2d/CCLabelAtlas.h

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -52,23 +52,11 @@ A more flexible class is LabelBMFont. It supports variable width characters and
5252
class CC_DLL LabelAtlas : public AtlasNode, public LabelProtocol
5353
{
5454
public:
55-
/**
56-
* @js ctor
57-
*/
58-
LabelAtlas()
59-
:_string("")
60-
{}
61-
/**
62-
* @js NA
63-
* @lua NA
64-
*/
65-
virtual ~LabelAtlas()
66-
{
67-
_string.clear();
68-
}
69-
55+
/** creates an empty LabelAtlas, user need to call initWithString(...) later to make this object work properly **/
56+
static LabelAtlas* create();
57+
7058
/** creates the LabelAtlas with a string, a char map file(the atlas), the width and height of each element and the starting char of the atlas */
71-
static LabelAtlas * create(const std::string& string, const std::string& charMapFile, int itemWidth, int itemHeight, int startCharMap);
59+
static LabelAtlas* create(const std::string& string, const std::string& charMapFile, int itemWidth, int itemHeight, int startCharMap);
7260

7361
/** creates the LabelAtlas with a string and a configuration file
7462
@since v2.0
@@ -98,6 +86,15 @@ class CC_DLL LabelAtlas : public AtlasNode, public LabelProtocol
9886
#endif
9987

10088
protected:
89+
LabelAtlas()
90+
:_string("")
91+
{}
92+
93+
virtual ~LabelAtlas()
94+
{
95+
_string.clear();
96+
}
97+
10198
// string to render
10299
std::string _string;
103100
// the first char in the charmap

cocos/2d/CCMenuItem.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,9 +348,8 @@ bool MenuItemAtlasFont::initWithString(const std::string& value, const std::stri
348348
bool MenuItemAtlasFont::initWithString(const std::string& value, const std::string& charMapFile, int itemWidth, int itemHeight, char startCharMap, const ccMenuCallback& callback)
349349
{
350350
CCASSERT( value.size() != 0, "value length must be greater than 0");
351-
LabelAtlas *label = new LabelAtlas();
351+
LabelAtlas *label = LabelAtlas::create();
352352
label->initWithString(value, charMapFile, itemWidth, itemHeight, startCharMap);
353-
label->autorelease();
354353
if (MenuItemLabel::initWithLabel(label, callback))
355354
{
356355
// do something ?

cocos/2d/CCTextureCache.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ void TextureCache::loadImage()
183183
break;
184184
}
185185
_imageInfoMutex.unlock();
186-
if(infoSize > 0 && pos < infoSize)
186+
if(infoSize == 0 || pos < infoSize)
187187
generateImage = true;
188188
}
189189

0 commit comments

Comments
 (0)