Skip to content

Commit 136b2bd

Browse files
LiamLiam
Liam
authored and
Liam
committed
Merge branch 'v3.10' of github.com:cocos2d/cocos2d-x into UITest
2 parents 096efe8 + bce8c68 commit 136b2bd

File tree

342 files changed

+19821
-29557
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

342 files changed

+19821
-29557
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ _ReSharper*/
3434
[Tt]est[Rr]esult*
3535
ipch/
3636
*.opensdf
37+
*.opendb
3738
SubmissionInfo
3839
Generated Files
3940
AppPackages

README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,38 @@ $ adb install ../tests/cpp-empty-test/proj.android/bin/CppEmptyTest-debug.apk
259259

260260
Then click item on Android device to run tests. Available value of `-p` is the API level, cocos2d-x supports from level 10.
261261

262+
Learning Resources
263+
--------------------------------
264+
265+
* [Programmers Guide](http://cocos2d-x.org/programmersguide/)
266+
* [Sonar Systems Videos](https://www.youtube.com/user/sonarsystemslimited/search?query=cocos2d-x)
267+
* [Android Fundamentals](https://developer.android.com/guide/components/fundamentals.html)
268+
* [Make School Tutorials](https://www.makeschool.com/tutorials/)
269+
* [Games From Scratch](http://www.gamefromscratch.com/page/Cocos2d-x-CPP-Game-Programming-Tutorial-Series.aspx)
270+
* [Cocos2d sample games](https://github.com/cocos2d/cocos2d-x-samples)
271+
272+
Spreading the word!
273+
--------------------------------
274+
You can help us spread the word about cocos2d-x! We would surely appreciate it!
275+
276+
* Talk about us on Facebook! Our [Facebook Page](https://www.facebook.com/cocos2dx/)
277+
* Tweet, Tweet! Our [Twitter](https://twitter.com/cocos2dx)
278+
* Read our [Blog](http://blog.cocos2d-x.org/) and promote it on your social media.
279+
* Become a [Regional Coordinator](http://discuss.cocos2d-x.org/t/we-need-regional-coordinators/24104)
280+
281+
Where to get help
282+
--------------------------------
283+
284+
* [Forums](http://discuss.cocos2d-x.org)
285+
* [Bug Tracker](https://github.com/cocos2d/cocos2d-x/issues)
286+
* IRC. We are in [Freenode](https://webchat.freenode.net/) in the _#cocos2d_ channel
287+
* `cpp-tests` project. This project is our basis for testing. Use this project to
288+
learn how we implement the functionality of the engine. This project is located in
289+
__cocos2d-x_root/build.__
290+
* [API Reference](http://cocos2d-x.org/wiki/Reference).
291+
* [Temporary Cocos2d-JS documents](http://cocos2d-x.org/docs/manual/framework/html5/en)
292+
* [Latest Release Note](https://github.com/cocos2d/cocos2d-x/blob/v3/docs/RELEASE_NOTES.md)
293+
* [Changelog](https://github.com/cocos2d/cocos2d-x/blob/v3/CHANGELOG)
262294

263295
Contributing to the Project
264296
--------------------------------

cocos/2d/CCActionCatmullRom.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ class CC_DLL CardinalSplineTo : public ActionInterval
173173
* @code
174174
* When this function bound to js or lua,the input params are changed.
175175
* In js: var create(var t,var table)
176-
* In lua: lcaol create(local t, local table)
176+
* In lua: local create(local t, local table)
177177
* @endcode
178178
*/
179179
static CardinalSplineTo* create(float duration, PointArray* points, float tension);
@@ -249,7 +249,7 @@ class CC_DLL CardinalSplineBy : public CardinalSplineTo
249249
* @code
250250
* When this function bound to js or lua,the input params are changed.
251251
* In js: var create(var t,var table).
252-
* In lua: lcaol create(local t, local table).
252+
* In lua: local create(local t, local table).
253253
* @param duration In seconds.
254254
* @param point An PointArray.
255255
* @param tension Goodness of fit.
@@ -285,7 +285,7 @@ class CC_DLL CatmullRomTo : public CardinalSplineTo
285285
* @code
286286
* When this function bound to js or lua,the input params are changed.
287287
* In js: var create(var dt,var table).
288-
* In lua: lcaol create(local dt, local table).
288+
* In lua: local create(local dt, local table).
289289
* @endcode
290290
*/
291291
static CatmullRomTo* create(float dt, PointArray* points);
@@ -318,7 +318,7 @@ class CC_DLL CatmullRomBy : public CardinalSplineBy
318318
* @code
319319
* When this function bound to js or lua,the input params are changed.
320320
* In js: var create(var dt,var table).
321-
* In lua: lcaol create(local dt, local table).
321+
* In lua: local create(local dt, local table).
322322
* @endcode
323323
*/
324324
static CatmullRomBy* create(float dt, PointArray* points);

cocos/2d/CCActionInterval.cpp

Lines changed: 45 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -238,29 +238,30 @@ Sequence* Sequence::createWithVariableList(FiniteTimeAction *action1, va_list ar
238238

239239
Sequence* Sequence::create(const Vector<FiniteTimeAction*>& arrayOfActions)
240240
{
241-
Sequence* ret = nullptr;
242-
do
243-
{
244-
auto count = arrayOfActions.size();
245-
CC_BREAK_IF(count == 0);
241+
Sequence* seq = new (std::nothrow) Sequence;
246242

247-
auto prev = arrayOfActions.at(0);
243+
if (seq && seq->init(arrayOfActions))
244+
seq->autorelease();
245+
return seq;
246+
}
248247

249-
if (count > 1)
250-
{
251-
for (int i = 1; i < count; ++i)
252-
{
253-
prev = createWithTwoActions(prev, arrayOfActions.at(i));
254-
}
255-
}
256-
else
257-
{
258-
// If only one action is added to Sequence, make up a Sequence by adding a simplest finite time action.
259-
prev = createWithTwoActions(prev, ExtraAction::create());
260-
}
261-
ret = static_cast<Sequence*>(prev);
262-
}while (0);
263-
return ret;
248+
bool Sequence::init(const Vector<FiniteTimeAction*>& arrayOfActions)
249+
{
250+
auto count = arrayOfActions.size();
251+
if (count == 0)
252+
return true;
253+
254+
if (count == 1)
255+
return initWithTwoActions(arrayOfActions.at(0), ExtraAction::create());
256+
257+
// else size > 1
258+
auto prev = arrayOfActions.at(0);
259+
for (int i = 1; i < count-1; ++i)
260+
{
261+
prev = createWithTwoActions(prev, arrayOfActions.at(i));
262+
}
263+
264+
return initWithTwoActions(prev, arrayOfActions.at(count-1));
264265
}
265266

266267
bool Sequence::initWithTwoActions(FiniteTimeAction *actionOne, FiniteTimeAction *actionTwo)
@@ -633,27 +634,10 @@ Spawn* Spawn::createWithVariableList(FiniteTimeAction *action1, va_list args)
633634

634635
Spawn* Spawn::create(const Vector<FiniteTimeAction*>& arrayOfActions)
635636
{
636-
Spawn* ret = nullptr;
637-
do
638-
{
639-
auto count = arrayOfActions.size();
640-
CC_BREAK_IF(count == 0);
641-
auto prev = arrayOfActions.at(0);
642-
if (count > 1)
643-
{
644-
for (int i = 1; i < arrayOfActions.size(); ++i)
645-
{
646-
prev = createWithTwoActions(prev, arrayOfActions.at(i));
647-
}
648-
}
649-
else
650-
{
651-
// If only one action is added to Spawn, make up a Spawn by adding a simplest finite time action.
652-
prev = createWithTwoActions(prev, ExtraAction::create());
653-
}
654-
ret = static_cast<Spawn*>(prev);
655-
}while (0);
637+
Spawn* ret = new (std::nothrow) Spawn;
656638

639+
if (ret && ret->init(arrayOfActions))
640+
ret->autorelease();
657641
return ret;
658642
}
659643

@@ -666,6 +650,26 @@ Spawn* Spawn::createWithTwoActions(FiniteTimeAction *action1, FiniteTimeAction *
666650
return spawn;
667651
}
668652

653+
bool Spawn::init(const Vector<FiniteTimeAction*>& arrayOfActions)
654+
{
655+
auto count = arrayOfActions.size();
656+
657+
if (count == 0)
658+
return true;
659+
660+
if (count == 1)
661+
return initWithTwoActions(arrayOfActions.at(0), ExtraAction::create());
662+
663+
// else count > 1
664+
auto prev = arrayOfActions.at(0);
665+
for (int i = 1; i < count-1; ++i)
666+
{
667+
prev = createWithTwoActions(prev, arrayOfActions.at(i));
668+
}
669+
670+
return initWithTwoActions(prev, arrayOfActions.at(count-1));
671+
}
672+
669673
bool Spawn::initWithTwoActions(FiniteTimeAction *action1, FiniteTimeAction *action2)
670674
{
671675
CCASSERT(action1 != nullptr, "action1 can't be nullptr!");

cocos/2d/CCActionInterval.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ class CC_DLL Sequence : public ActionInterval
192192

193193
/** initializes the action */
194194
bool initWithTwoActions(FiniteTimeAction *pActionOne, FiniteTimeAction *pActionTwo);
195+
bool init(const Vector<FiniteTimeAction*>& arrayOfActions);
195196

196197
protected:
197198
FiniteTimeAction *_actions[2];
@@ -393,7 +394,7 @@ class CC_DLL Spawn : public ActionInterval
393394
/** Creates the Spawn action.
394395
*
395396
* @param action1 The first spawned action.
396-
* @param action2 THe second spawned action.
397+
* @param action2 The second spawned action.
397398
* @return An autoreleased Spawn object.
398399
* @js NA
399400
*/
@@ -417,6 +418,7 @@ class CC_DLL Spawn : public ActionInterval
417418

418419
/** initializes the Spawn action with the 2 actions to spawn */
419420
bool initWithTwoActions(FiniteTimeAction *action1, FiniteTimeAction *action2);
421+
bool init(const Vector<FiniteTimeAction*>& arrayOfActions);
420422

421423
protected:
422424
FiniteTimeAction *_one;
@@ -875,7 +877,7 @@ class CC_DLL BezierBy : public ActionInterval
875877
* @code
876878
* When this function bound to js or lua,the input params are changed.
877879
* in js: var create(var t,var table)
878-
* in lua: lcaol create(local t, local table)
880+
* in lua: local create(local t, local table)
879881
* @endcode
880882
*/
881883
static BezierBy* create(float t, const ccBezierConfig& c);
@@ -924,7 +926,7 @@ class CC_DLL BezierTo : public BezierBy
924926
* @code
925927
* when this function bound to js or lua,the input params are changed
926928
* in js: var create(var t,var table)
927-
* in lua: lcaol create(local t, local table)
929+
* in lua: local create(local t, local table)
928930
* @endcode
929931
*/
930932
static BezierTo* create(float t, const ccBezierConfig& c);

cocos/2d/CCAnimation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ AnimationFrame* AnimationFrame::clone() const
8282

8383
// implementation of Animation
8484

85-
Animation* Animation::create(void)
85+
Animation* Animation::create()
8686
{
8787
Animation *animation = new (std::nothrow) Animation();
8888
animation->init();

cocos/2d/CCAtlasNode.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ class CC_DLL AtlasNode : public Node, public TextureProtocol
139139
ssize_t _quadsToDraw;
140140
/** Color uniform. */
141141
GLint _uniformColor;
142-
/** This varible is only used for LabelAtlas FPS display. So plz don't modify its value. */
142+
/** This variable is only used for LabelAtlas FPS display. So plz don't modify its value. */
143143
bool _ignoreContentScaleFactor;
144144
/** Quad command. */
145145
QuadCommand _quadCommand;

cocos/2d/CCCamera.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,4 +481,9 @@ void Camera::setBackgroundBrush(CameraBackgroundBrush* clearBrush)
481481
_clearBrush = clearBrush;
482482
}
483483

484+
bool Camera::isBrushValid()
485+
{
486+
return _clearBrush != nullptr && _clearBrush->isValid();
487+
}
488+
484489
NS_CC_END

cocos/2d/CCCamera.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,9 @@ class CC_DLL Camera :public Node
271271
CameraBackgroundBrush* getBackgroundBrush() const { return _clearBrush; }
272272

273273
virtual void visit(Renderer* renderer, const Mat4 &parentTransform, uint32_t parentFlags) override;
274-
274+
275+
bool isBrushValid();
276+
275277
CC_CONSTRUCTOR_ACCESS:
276278
Camera();
277279
~Camera();

cocos/2d/CCCameraBackgroundBrush.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,8 @@ CameraBackgroundSkyBoxBrush::CameraBackgroundSkyBoxBrush()
232232
, _vertexBuffer(0)
233233
, _indexBuffer(0)
234234
, _texture(nullptr)
235+
, _actived(true)
236+
, _textureValid(true)
235237
{
236238
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
237239
_backToForegroundListener = EventListenerCustom::create(EVENT_RENDERER_RECREATED,
@@ -296,6 +298,9 @@ CameraBackgroundSkyBoxBrush* CameraBackgroundSkyBoxBrush::create()
296298

297299
void CameraBackgroundSkyBoxBrush::drawBackground(Camera* camera)
298300
{
301+
if (!_actived)
302+
return;
303+
299304
Mat4 cameraModelMat = camera->getNodeToWorldTransform();
300305

301306
Vec4 color(1.f, 1.f, 1.f, 1.f);
@@ -427,4 +432,23 @@ void CameraBackgroundSkyBoxBrush::setTexture(TextureCube* texture)
427432
_glProgramState->setUniformTexture("u_Env", _texture);
428433
}
429434

435+
bool CameraBackgroundSkyBoxBrush::isActived() const
436+
{
437+
return _actived;
438+
}
439+
void CameraBackgroundSkyBoxBrush::setActived(bool actived)
440+
{
441+
_actived = actived;
442+
}
443+
444+
void CameraBackgroundSkyBoxBrush::setTextureValid(bool valid)
445+
{
446+
_textureValid = valid;
447+
}
448+
449+
bool CameraBackgroundSkyBoxBrush::isValid()
450+
{
451+
return _actived;
452+
}
453+
430454
NS_CC_END

cocos/2d/CCCameraBackgroundBrush.h

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,10 @@ class CC_DLL CameraBackgroundBrush : public Ref
103103
* draw the background
104104
*/
105105
virtual void drawBackground(Camera* camera) {}
106-
107-
CC_CONSTRUCTOR_ACCESS:
106+
107+
virtual bool isValid() { return true; }
108+
109+
CC_CONSTRUCTOR_ACCESS :
108110
CameraBackgroundBrush();
109111
virtual ~CameraBackgroundBrush();
110112

@@ -227,7 +229,7 @@ class CC_DLL CameraBackgroundSkyBoxBrush : public CameraBackgroundBrush
227229
*/
228230
static CameraBackgroundSkyBoxBrush* create();
229231
/**
230-
* Set skybox texutre
232+
* Set skybox texture
231233
* @param texture Skybox texture
232234
*/
233235
void setTexture(TextureCube* texture);
@@ -236,8 +238,13 @@ class CC_DLL CameraBackgroundSkyBoxBrush : public CameraBackgroundBrush
236238
* Draw background
237239
*/
238240
virtual void drawBackground(Camera* camera) override;
239-
240-
CC_CONSTRUCTOR_ACCESS:
241+
242+
bool isActived() const;
243+
void setActived(bool actived);
244+
virtual void setTextureValid(bool valid);
245+
virtual bool isValid()override;
246+
247+
CC_CONSTRUCTOR_ACCESS :
241248
CameraBackgroundSkyBoxBrush();
242249
virtual ~CameraBackgroundSkyBoxBrush();
243250

@@ -258,6 +265,10 @@ class CC_DLL CameraBackgroundSkyBoxBrush : public CameraBackgroundBrush
258265
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
259266
EventListenerCustom* _backToForegroundListener;
260267
#endif
268+
269+
private:
270+
bool _actived;
271+
bool _textureValid;
261272
};
262273

263274
NS_CC_END

0 commit comments

Comments
 (0)