Skip to content

Commit

Permalink
Merge branch 'v3' of https://github.com/cocos2d/cocos2d-x into v3
Browse files Browse the repository at this point in the history
  • Loading branch information
pandamicro committed Jul 15, 2015
2 parents 7f7cf92 + dcf0d9b commit 3c08b49
Show file tree
Hide file tree
Showing 266 changed files with 6,016 additions and 4,062 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -146,3 +146,4 @@ tests/cpp-tests/Resources/audio
/*/*/prebuilt-mk/Android.mk
/*/*/*/prebuilt-mk/Android.mk
/*/*/*/*/prebuilt-mk/Android.mk
*.xcscmblueprint
16 changes: 16 additions & 0 deletions build/cocos2d_tests.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -883,6 +883,10 @@
688669711AE8E8B500C2CFD9 /* SpritePolygonTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6886696F1AE8E8B500C2CFD9 /* SpritePolygonTest.cpp */; };
688669721AE8E8B500C2CFD9 /* SpritePolygonTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6886696F1AE8E8B500C2CFD9 /* SpritePolygonTest.cpp */; };
826294431AAF071500CB7CF7 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 826294421AAF071500CB7CF7 /* Security.framework */; };
94D793D91B4B7A3600F60F10 /* Bug-CCDrawNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94D793D51B4B7A3600F60F10 /* Bug-CCDrawNode.cpp */; };
94D793DA1B4B7A3600F60F10 /* Bug-CCDrawNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94D793D51B4B7A3600F60F10 /* Bug-CCDrawNode.cpp */; };
94D793DB1B4B7A3600F60F10 /* Bug-PageViewLayout.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94D793D71B4B7A3600F60F10 /* Bug-PageViewLayout.cpp */; };
94D793DC1B4B7A3600F60F10 /* Bug-PageViewLayout.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94D793D71B4B7A3600F60F10 /* Bug-PageViewLayout.cpp */; };
A05FCACA177C124500BE600E /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64822165F391E007D4F18 /* Cocoa.framework */; };
A07A521E1783A1D20073F6A7 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C6482E165F399D007D4F18 /* libz.dylib */; };
A07A521F1783A1D20073F6A7 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64832165F3AFD007D4F18 /* Foundation.framework */; };
Expand Down Expand Up @@ -1945,6 +1949,10 @@
70A7F72D191D3E4900F0F206 /* shaderTest.psh.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = shaderTest.psh.h; sourceTree = "<group>"; };
70A7F730191D421B00F0F206 /* ShaderTest.vsh.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ShaderTest.vsh.h; sourceTree = "<group>"; };
826294421AAF071500CB7CF7 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; };
94D793D51B4B7A3600F60F10 /* Bug-CCDrawNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = "Bug-CCDrawNode.cpp"; sourceTree = "<group>"; };
94D793D61B4B7A3600F60F10 /* Bug-CCDrawNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "Bug-CCDrawNode.h"; sourceTree = "<group>"; };
94D793D71B4B7A3600F60F10 /* Bug-PageViewLayout.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = "Bug-PageViewLayout.cpp"; sourceTree = "<group>"; };
94D793D81B4B7A3600F60F10 /* Bug-PageViewLayout.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "Bug-PageViewLayout.h"; sourceTree = "<group>"; };
A035A71117822E9E00987F6C /* libsqlite3.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libsqlite3.dylib; path = usr/lib/libsqlite3.dylib; sourceTree = SDKROOT; };
A07A52291783A1D20073F6A7 /* cpp-tests iOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "cpp-tests iOS.app"; sourceTree = BUILT_PRODUCTS_DIR; };
A07A52B71783AE6D0073F6A7 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk/System/Library/Frameworks/UIKit.framework; sourceTree = DEVELOPER_DIR; };
Expand Down Expand Up @@ -2733,6 +2741,10 @@
1AC3597618CECF0B00F37B72 /* BugsTest */ = {
isa = PBXGroup;
children = (
94D793D51B4B7A3600F60F10 /* Bug-CCDrawNode.cpp */,
94D793D61B4B7A3600F60F10 /* Bug-CCDrawNode.h */,
94D793D71B4B7A3600F60F10 /* Bug-PageViewLayout.cpp */,
94D793D81B4B7A3600F60F10 /* Bug-PageViewLayout.h */,
1AC3597718CECF0B00F37B72 /* Bug-1159.cpp */,
1AC3597818CECF0B00F37B72 /* Bug-1159.h */,
1AC3597918CECF0B00F37B72 /* Bug-1174.cpp */,
Expand Down Expand Up @@ -5388,6 +5400,7 @@
1AC35BEB18CECF0C00F37B72 /* CCControlSliderTest.cpp in Sources */,
1AC35C4D18CECF0C00F37B72 /* SpineTest.cpp in Sources */,
3E92EA821921A1400094CD21 /* Sprite3DTest.cpp in Sources */,
94D793DB1B4B7A3600F60F10 /* Bug-PageViewLayout.cpp in Sources */,
1AC35C1D18CECF0C00F37B72 /* NewRendererTest.cpp in Sources */,
1AC35B6718CECF0C00F37B72 /* AnimationsTestLayer.cpp in Sources */,
29080DB7191B595E0066F8DF /* UIListViewTest_Editor.cpp in Sources */,
Expand Down Expand Up @@ -5533,6 +5546,7 @@
1AC35B2518CECF0C00F37B72 /* ActionsProgressTest.cpp in Sources */,
1AC35B6518CECF0C00F37B72 /* EffectsTest.cpp in Sources */,
1AC35B7118CECF0C00F37B72 /* TestHeaderLayer.cpp in Sources */,
94D793D91B4B7A3600F60F10 /* Bug-CCDrawNode.cpp in Sources */,
29080D93191B595E0066F8DF /* CustomImageTest.cpp in Sources */,
1AC35B2118CECF0C00F37B72 /* ActionManagerTest.cpp in Sources */,
1AC35C3D18CECF0C00F37B72 /* PhysicsTest.cpp in Sources */,
Expand Down Expand Up @@ -5673,6 +5687,7 @@
1AC35B2818CECF0C00F37B72 /* ActionsTest.cpp in Sources */,
1AC35C4A18CECF0C00F37B72 /* ShaderTest.cpp in Sources */,
B609E67419C18DAD003D0074 /* BillBoardTest.cpp in Sources */,
94D793DC1B4B7A3600F60F10 /* Bug-PageViewLayout.cpp in Sources */,
C04F935B1941B05400E9FEAB /* TileMapTest2.cpp in Sources */,
1AC35B4418CECF0C00F37B72 /* Bug-624.cpp in Sources */,
1AC35BF818CECF0C00F37B72 /* SocketIOTest.cpp in Sources */,
Expand Down Expand Up @@ -5781,6 +5796,7 @@
1AC35BEA18CECF0C00F37B72 /* CCControlSceneManager.cpp in Sources */,
182C5CBB1A95B30500C30D34 /* CocosStudio3DTest.cpp in Sources */,
1AC35B7418CECF0C00F37B72 /* TimelineCallbackTestLayer.cpp in Sources */,
94D793DA1B4B7A3600F60F10 /* Bug-CCDrawNode.cpp in Sources */,
29080D9E191B595E0066F8DF /* CustomParticleWidgetReader.cpp in Sources */,
1AC35BFC18CECF0C00F37B72 /* NotificationCenterTest.cpp in Sources */,
29FBBBFF196A9ECD00E65826 /* CocostudioParserJsonTest.cpp in Sources */,
Expand Down
1 change: 1 addition & 0 deletions cocos/2d/CCAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Action::Action()
:_originalTarget(nullptr)
,_target(nullptr)
,_tag(Action::INVALID_TAG)
,_flags(0)
{
}

Expand Down
12 changes: 12 additions & 0 deletions cocos/2d/CCAction.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,16 @@ class CC_DLL Action : public Ref, public Clonable
* @param tag Used to identify the action easily.
*/
inline void setTag(int tag) { _tag = tag; }
/** Returns a flag field that is used to group the actions easily.
*
* @return A tag.
*/
inline unsigned int getFlags() const { return _flags; }
/** Changes the flag field that is used to group the actions easily.
*
* @param tag Used to identify the action easily.
*/
inline void setFlags(unsigned int flags) { _flags = flags; }

CC_CONSTRUCTOR_ACCESS:
Action();
Expand All @@ -159,6 +169,8 @@ class CC_DLL Action : public Ref, public Clonable
Node *_target;
/** The action tag. An identifier of the action. */
int _tag;
/** The action flag field. To categorize action into certain groups.*/
unsigned int _flags;

private:
CC_DISALLOW_COPY_AND_ASSIGN(Action);
Expand Down
2 changes: 1 addition & 1 deletion cocos/2d/CCActionEase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ NS_CC_BEGIN

bool ActionEase::initWithAction(ActionInterval *action)
{
CCASSERT(action != nullptr, "");
CCASSERT(action != nullptr, "action couldn't be nullptr!");

if (ActionInterval::initWithDuration(action->getDuration()))
{
Expand Down
6 changes: 3 additions & 3 deletions cocos/2d/CCActionGrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ void GridAction::startWithTarget(Node *target)
if (targetGrid && targetGrid->getReuseGrid() > 0)
{
if (targetGrid->isActive() && targetGrid->getGridSize().width == _gridSize.width
&& targetGrid->getGridSize().height == _gridSize.height /*&& dynamic_cast<GridBase*>(targetGrid) != nullptr*/)
&& targetGrid->getGridSize().height == _gridSize.height)
{
targetGrid->reuse();
}
else
{
CCASSERT(0, "");
CCASSERT(0, "Invalid grid parameters!");
}
}
else
Expand Down Expand Up @@ -93,7 +93,7 @@ GridAction* GridAction::reverse() const
GridBase* GridAction::getGrid()
{
// Abstract class needs implementation
CCASSERT(0, "");
CCASSERT(0, "Subclass should implement this method!");

return nullptr;
}
Expand Down
22 changes: 12 additions & 10 deletions cocos/2d/CCActionInterval.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,13 @@ void ActionInterval::setAmplitudeRate(float amp)
{
CC_UNUSED_PARAM(amp);
// Abstract class needs implementation
CCASSERT(0, "");
CCASSERT(0, "Subclass should implement this method!");
}

float ActionInterval::getAmplitudeRate()
{
// Abstract class needs implementation
CCASSERT(0, "");
CCASSERT(0, "Subclass should implement this method!");

return 0;
}
Expand Down Expand Up @@ -248,8 +248,8 @@ Sequence* Sequence::create(const Vector<FiniteTimeAction*>& arrayOfActions)

bool Sequence::initWithTwoActions(FiniteTimeAction *actionOne, FiniteTimeAction *actionTwo)
{
CCASSERT(actionOne != nullptr, "");
CCASSERT(actionTwo != nullptr, "");
CCASSERT(actionOne != nullptr, "actionOne can't be nullptr!");
CCASSERT(actionTwo != nullptr, "actionTwo can't be nullptr!");

float d = actionOne->getDuration() + actionTwo->getDuration();
ActionInterval::initWithDuration(d);
Expand Down Expand Up @@ -504,7 +504,7 @@ RepeatForever *RepeatForever::create(ActionInterval *action)

bool RepeatForever::initWithAction(ActionInterval *action)
{
CCASSERT(action != nullptr, "");
CCASSERT(action != nullptr, "action can't be nullptr!");
action->retain();
_innerAction = action;
return true;
Expand Down Expand Up @@ -645,8 +645,8 @@ Spawn* Spawn::createWithTwoActions(FiniteTimeAction *action1, FiniteTimeAction *

bool Spawn::initWithTwoActions(FiniteTimeAction *action1, FiniteTimeAction *action2)
{
CCASSERT(action1 != nullptr, "");
CCASSERT(action2 != nullptr, "");
CCASSERT(action1 != nullptr, "action1 can't be nullptr!");
CCASSERT(action2 != nullptr, "action2 can't be nullptr!");

bool ret = false;

Expand Down Expand Up @@ -2189,8 +2189,8 @@ ReverseTime* ReverseTime::create(FiniteTimeAction *action)

bool ReverseTime::initWithAction(FiniteTimeAction *action)
{
CCASSERT(action != nullptr, "");
CCASSERT(action != _other, "");
CCASSERT(action != nullptr, "action can't be nullptr!");
CCASSERT(action != _other, "action doesn't equal to _other!");

if (ActionInterval::initWithDuration(action->getDuration()))
{
Expand Down Expand Up @@ -2270,6 +2270,7 @@ Animate::Animate()
, _executedLoops(0)
, _animation(nullptr)
, _frameDisplayedEvent(nullptr)
, _currFrameIndex(0)
{

}
Expand Down Expand Up @@ -2383,7 +2384,8 @@ void Animate::update(float t)
float splitTime = _splitTimes->at(i);

if( splitTime <= t ) {
AnimationFrame* frame = frames.at(i);
_currFrameIndex = i;
AnimationFrame* frame = frames.at(_currFrameIndex);
frameToDisplay = frame->getSpriteFrame();
static_cast<Sprite*>(_target)->setSpriteFrame(frameToDisplay);

Expand Down
6 changes: 6 additions & 0 deletions cocos/2d/CCActionInterval.h
Original file line number Diff line number Diff line change
Expand Up @@ -1439,6 +1439,11 @@ class CC_DLL Animate : public ActionInterval
Animation* getAnimation() { return _animation; }
const Animation* getAnimation() const { return _animation; }

/**
* Gets the index of sprite frame currently displayed.
* @return int the index of sprite frame currently displayed.
*/
int getCurrentFrameIndex() { return _currFrameIndex; }
//
// Overrides
//
Expand All @@ -1462,6 +1467,7 @@ class CC_DLL Animate : public ActionInterval
std::vector<float>* _splitTimes;
int _nextFrame;
SpriteFrame* _origFrame;
int _currFrameIndex;
unsigned int _executedLoops;
Animation* _animation;

Expand Down
47 changes: 39 additions & 8 deletions cocos/2d/CCActionManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ void ActionManager::resumeTargets(const Vector<Node*>& targetsToResume)

void ActionManager::addAction(Action *action, Node *target, bool paused)
{
CCASSERT(action != nullptr, "");
CCASSERT(target != nullptr, "");
CCASSERT(action != nullptr, "action can't be nullptr!");
CCASSERT(target != nullptr, "target can't be nullptr!");

tHashElement *element = nullptr;
// we should convert it to Ref*, because we save it as Ref*
Expand All @@ -186,7 +186,7 @@ void ActionManager::addAction(Action *action, Node *target, bool paused)

actionAllocWithHashElement(element);

CCASSERT(! ccArrayContainsObject(element->actions, action), "");
CCASSERT(! ccArrayContainsObject(element->actions, action), "action already be added!");
ccArrayAppendObject(element->actions, action);

action->startWithTarget(target);
Expand Down Expand Up @@ -265,8 +265,8 @@ void ActionManager::removeAction(Action *action)

void ActionManager::removeActionByTag(int tag, Node *target)
{
CCASSERT(tag != Action::INVALID_TAG, "");
CCASSERT(target != nullptr, "");
CCASSERT(tag != Action::INVALID_TAG, "Invalid tag value!");
CCASSERT(target != nullptr, "target can't be nullptr!");

tHashElement *element = nullptr;
HASH_FIND_PTR(_targets, &target, element);
Expand All @@ -289,8 +289,8 @@ void ActionManager::removeActionByTag(int tag, Node *target)

void ActionManager::removeAllActionsByTag(int tag, Node *target)
{
CCASSERT(tag != Action::INVALID_TAG, "");
CCASSERT(target != nullptr, "");
CCASSERT(tag != Action::INVALID_TAG, "Invalid tag value!");
CCASSERT(target != nullptr, "target can't be nullptr!");

tHashElement *element = nullptr;
HASH_FIND_PTR(_targets, &target, element);
Expand All @@ -315,13 +315,44 @@ void ActionManager::removeAllActionsByTag(int tag, Node *target)
}
}

void ActionManager::removeActionsByFlags(unsigned int flags, Node *target)
{
if (flags == 0)
{
return;
}
CCASSERT(target != nullptr, "target can't be nullptr!");

tHashElement *element = nullptr;
HASH_FIND_PTR(_targets, &target, element);

if (element)
{
auto limit = element->actions->num;
for (int i = 0; i < limit;)
{
Action *action = (Action*)element->actions->arr[i];

if ((action->getFlags() & flags) != 0 && action->getOriginalTarget() == target)
{
removeActionAtIndex(i, element);
--limit;
}
else
{
++i;
}
}
}
}

// get

// FIXME: Passing "const O *" instead of "const O&" because HASH_FIND_IT requries the address of a pointer
// and, it is not possible to get the address of a reference
Action* ActionManager::getActionByTag(int tag, const Node *target) const
{
CCASSERT(tag != Action::INVALID_TAG, "");
CCASSERT(tag != Action::INVALID_TAG, "Invalid tag value!");

tHashElement *element = nullptr;
HASH_FIND_PTR(_targets, &target, element);
Expand Down
8 changes: 8 additions & 0 deletions cocos/2d/CCActionManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,14 @@ class CC_DLL ActionManager : public Ref
*/
void removeAllActionsByTag(int tag, Node *target);

/** Removes all actions matching at least one bit in flags and the target.
*
* @param flags The flag field to match the actions' flags based on bitwise AND.
* @param target A certain target.
* @js NA
*/
void removeActionsByFlags(unsigned int flags, Node *target);

/** Gets an action given its tag an a target.
*
* @param tag The action's tag.
Expand Down
4 changes: 2 additions & 2 deletions cocos/2d/CCCamera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ Vec2 Camera::project(const Vec3& src) const
Vec4 clipPos;
getViewProjectionMatrix().transformVector(Vec4(src.x, src.y, src.z, 1.0f), &clipPos);

CCASSERT(clipPos.w != 0.0f, "");
CCASSERT(clipPos.w != 0.0f, "clipPos.w can't be 0.0f!");
float ndcX = clipPos.x / clipPos.w;
float ndcY = clipPos.y / clipPos.w;

Expand All @@ -255,7 +255,7 @@ Vec2 Camera::projectGL(const Vec3& src) const
Vec4 clipPos;
getViewProjectionMatrix().transformVector(Vec4(src.x, src.y, src.z, 1.0f), &clipPos);

CCASSERT(clipPos.w != 0.0f, "");
CCASSERT(clipPos.w != 0.0f, "clipPos.w can't be 0.0f!");
float ndcX = clipPos.x / clipPos.w;
float ndcY = clipPos.y / clipPos.w;

Expand Down
8 changes: 6 additions & 2 deletions cocos/2d/CCDrawNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,9 @@ void DrawNode::onDrawGLLine(const Mat4 &transform, uint32_t flags)
auto glProgram = GLProgramCache::getInstance()->getGLProgram(GLProgram::SHADER_NAME_POSITION_LENGTH_TEXTURE_COLOR);
glProgram->use();
glProgram->setUniformsForBuiltins(transform);


GL::blendFunc(_blendFunc.src, _blendFunc.dst);

if (_dirtyGLLine)
{
glBindBuffer(GL_ARRAY_BUFFER, _vboGLLine);
Expand Down Expand Up @@ -415,7 +417,9 @@ void DrawNode::onDrawGLPoint(const Mat4 &transform, uint32_t flags)
auto glProgram = GLProgramCache::getInstance()->getGLProgram(GLProgram::SHADER_NAME_POSITION_COLOR_TEXASPOINTSIZE);
glProgram->use();
glProgram->setUniformsForBuiltins(transform);


GL::blendFunc(_blendFunc.src, _blendFunc.dst);

if (_dirtyGLPoint)
{
glBindBuffer(GL_ARRAY_BUFFER, _vboGLPoint);
Expand Down
2 changes: 1 addition & 1 deletion cocos/2d/CCFontAtlas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ bool FontAtlas::prepareLetterDefinitions(const std::u16string& utf16String)

if (bitmapHeight > _currLineHeight)
{
_currLineHeight = bitmapHeight + 1;
_currLineHeight = static_cast<int>(bitmapHeight) + 1;
}
if (_currentPageOrigX + tempDef.width > CacheTextureWidth)
{
Expand Down
Loading

0 comments on commit 3c08b49

Please sign in to comment.