Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cocos/platform/android/CCFileUtils-android.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ bool FileUtilsAndroid::isDirectoryExistInternal(const std::string& dirPath) cons
{
// find it in apk's assets dir
// Found "assets/" at the beginning of the path and we don't want it
CCLOG("find in apk dirPath(%s)", s);
//CCLOG("find in apk dirPath(%s)", s);
if (dirPath.find(ASSETS_FOLDER_NAME) == 0)
{
s += ASSETS_FOLDER_NAME_LENGTH;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8540,6 +8540,75 @@ static int tolua_cocos2d_Vec3_cross(lua_State* tolua_S)
#endif
}

static int tolua_cocos2d_random01(lua_State* tolua_S)
{
lua_pushnumber(tolua_S, CCRANDOM_0_1());
return 1;
}

static int tolua_cocos2d_Vec2_isLineIntersect(lua_State* tolua_S)
{
int argc = lua_gettop(tolua_S);

#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif

if (4 == argc)
{
#if COCOS2D_DEBUG >= 1
if (!tolua_istable(tolua_S, 1, 0, &tolua_err) ||
!tolua_istable(tolua_S, 2, 0, &tolua_err) ||
!tolua_istable(tolua_S, 3, 0, &tolua_err)||
!tolua_istable(tolua_S, 4, 0, &tolua_err))
goto tolua_lerror;
else
#endif
{
cocos2d::Vec2 x1,y1;
cocos2d::Vec2 x2,y2;

float s =0.0f, t = 0.0f;

bool ok = true;

ok &= luaval_to_vec2(tolua_S, 1, &x1);
if (!ok)
return 0;

ok &= luaval_to_vec2(tolua_S, 2, &y1);
if (!ok)
return 0;

ok &= luaval_to_vec2(tolua_S, 3, &x2);
if (!ok)
return 0;

ok &= luaval_to_vec2(tolua_S, 4, &y2);
if (!ok)
return 0;

bool intersects = Vec2::isLineIntersect(x1, y1, x2, y2, &s, &t);

lua_pushboolean(tolua_S, intersects);
lua_pushnumber(tolua_S, s);
lua_pushnumber(tolua_S, t);
return 3;
}
}else
{
lua_pushboolean(tolua_S, false);
lua_pushnumber(tolua_S, 0);
lua_pushnumber(tolua_S, 0);
return 3;
}
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'vec2_isLineIntersect'.",&tolua_err);
return 0;
#endif
}

static int tolua_cocos2d_Mat4_multiply(lua_State* tolua_S)
{
#if COCOS2D_DEBUG >= 1
Expand Down Expand Up @@ -8825,6 +8894,8 @@ int register_all_cocos2dx_math_manual(lua_State* tolua_S)
tolua_function(tolua_S, "mat4_createTranslation", tolua_cocos2d_Mat4_createTranslation);
tolua_function(tolua_S, "mat4_createRotation", tolua_cocos2d_Mat4_createRotation);
tolua_function(tolua_S, "vec3_cross", tolua_cocos2d_Vec3_cross);
tolua_function(tolua_S, "vec2_isLineIntersect", tolua_cocos2d_Vec2_isLineIntersect);
tolua_function(tolua_S, "cc_mathutils_random", tolua_cocos2d_random01);
tolua_endmodule(tolua_S);
return 0;
}
33 changes: 6 additions & 27 deletions cocos/scripting/lua-bindings/script/cocos2d/Cocos2d.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@

cc = cc or {}


function cc.random()
return cc_mathutils_random()
end

function cc.clampf(value, min_inclusive, max_inclusive)
-- body
local temp = 0
Expand Down Expand Up @@ -89,33 +94,7 @@ function cc.pGetDistance(startP,endP)
end

function cc.pIsLineIntersect(A, B, C, D, s, t)
if ((A.x == B.x) and (A.y == B.y)) or ((C.x == D.x) and (C.y == D.y))then
return false, s, t
end

local BAx = B.x - A.x
local BAy = B.y - A.y
local DCx = D.x - C.x
local DCy = D.y - C.y
local ACx = A.x - C.x
local ACy = A.y - C.y

local denom = DCy * BAx - DCx * BAy
s = DCx * ACy - DCy * ACx
t = BAx * ACy - BAy * ACx

if (denom == 0) then
if (s == 0 or t == 0) then
return true, s , t
end

return false, s, t
end

s = s / denom
t = t / denom

return true,s,t
return vec2_isLineIntersect(A, B, C, D)
end

function cc.pPerp(pt)
Expand Down
1 change: 1 addition & 0 deletions tests/cpp-tests/Classes/BugsTest/Bug-1159.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class Bug1159Layer : public BugsTestBase
public:
virtual bool init() override;
virtual void onExit() override;
virtual std::string title() const override { return "Bug1159";}

void callBack(cocos2d::Ref* sender);

Expand Down
3 changes: 2 additions & 1 deletion tests/cpp-tests/Classes/BugsTest/Bug-1174.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ class Bug1174Layer : public BugsTestBase
{
public:
CREATE_FUNC(Bug1174Layer);

virtual std::string title() const override { return "Bug1174";}
virtual std::string subtitle() const override {return "view console output";}
virtual bool init() override;
};

Expand Down
1 change: 1 addition & 0 deletions tests/cpp-tests/Classes/BugsTest/Bug-12847.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class Bug12847Layer : public BugsTestBase

virtual bool init() override;

virtual std::string title() const override { return "12874";}
protected:
virtual void update(float dt) override;
virtual void onEnter() override;
Expand Down
1 change: 1 addition & 0 deletions tests/cpp-tests/Classes/BugsTest/Bug-14327.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class Bug14327Layer : public BugsTestBase, public cocos2d::ui::EditBoxDelegate
CREATE_FUNC(Bug14327Layer);

virtual bool init() override;
virtual std::string title() const override { return "Bug14327";}

virtual void editBoxEditingDidBegin(cocos2d::ui::EditBox* editBox) override;
virtual void editBoxEditingDidEnd(cocos2d::ui::EditBox* editBox) override;
Expand Down
1 change: 1 addition & 0 deletions tests/cpp-tests/Classes/BugsTest/Bug-15594.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class Bug15594Layer : public BugsTestBase
{
public:
CREATE_FUNC(Bug15594Layer);
virtual std::string title() const override { return "Bug15594";}

virtual bool init() override;
};
Expand Down
1 change: 0 additions & 1 deletion tests/cpp-tests/Classes/BugsTest/Bug-15776.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ class Bug15776Layer : public BugsTestBase
CREATE_FUNC(Bug15776Layer);

virtual bool init() override;

virtual std::string title() const override;
virtual std::string subtitle() const override;
};
Expand Down
1 change: 1 addition & 0 deletions tests/cpp-tests/Classes/BugsTest/Bug-350.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class Bug350Layer : public BugsTestBase
CREATE_FUNC(Bug350Layer);

virtual bool init() override;
virtual std::string title() const override { return "Bug350";}
};

#endif // __BUG_350_H__
1 change: 1 addition & 0 deletions tests/cpp-tests/Classes/BugsTest/Bug-422.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class Bug422Layer : public BugsTestBase

virtual bool init() override;

virtual std::string title() const override { return "Bug422";}
void reset();
void check(Node* target);
void menuCallback(cocos2d::Ref* sender);
Expand Down
3 changes: 3 additions & 0 deletions tests/cpp-tests/Classes/BugsTest/Bug-624.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class Bug624Layer : public BugsTestBase
void switchLayer(float dt);
virtual void onAcceleration(cocos2d::Acceleration* acc, cocos2d::Event* event);

virtual std::string title() const override { return "Bug624";}
CREATE_FUNC(Bug624Layer);
};

Expand All @@ -44,6 +45,8 @@ class Bug624Layer2 : public BugsTestBase
virtual ~Bug624Layer2();
virtual bool init() override;
void switchLayer(float dt);
virtual std::string title() const override { return "Bug624-2";}

virtual void onAcceleration(cocos2d::Acceleration* acc, cocos2d::Event* event);

CREATE_FUNC(Bug624Layer2);
Expand Down
1 change: 1 addition & 0 deletions tests/cpp-tests/Classes/BugsTest/Bug-886.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class Bug886Layer : public BugsTestBase
public:
CREATE_FUNC(Bug886Layer);

virtual std::string title() const override { return "Bug886";}
virtual bool init() override;
};

Expand Down
1 change: 1 addition & 0 deletions tests/cpp-tests/Classes/BugsTest/Bug-899.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class Bug899Layer : public BugsTestBase
public:
CREATE_FUNC(Bug899Layer);

virtual std::string title() const override { return "Bug899";}
virtual bool init() override;
};

Expand Down
1 change: 1 addition & 0 deletions tests/cpp-tests/Classes/BugsTest/Bug-914.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class Bug914Layer : public BugsTestBase
public:
virtual bool init() override;

virtual std::string title() const override { return "Bug914";}
void onTouchesMoved(const std::vector<cocos2d::Touch*>& touches, cocos2d::Event* event);
void onTouchesBegan(const std::vector<cocos2d::Touch*>& touches, cocos2d::Event* event);
void restart(cocos2d::Ref* sender);
Expand Down
3 changes: 2 additions & 1 deletion tests/cpp-tests/Classes/BugsTest/Bug-CCDrawNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ class BugDrawNodeLayer : public BugsTestBase
public:
CREATE_FUNC(BugDrawNodeLayer);

virtual std::string title() const override { return "BugDrawNode";}
virtual bool init() override;
};

#endif
#endif
2 changes: 2 additions & 0 deletions tests/cpp-tests/Classes/BugsTest/Bug-Child.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class BugChild : public BugsTestBase
CREATE_FUNC(BugChild);

virtual bool init() override;
virtual std::string title() const override { return "BugChild";}

void switchChild(cocos2d::Ref* sender);

Expand All @@ -61,6 +62,7 @@ class BugCameraMask : public BugsTestBase

virtual bool init() override;

virtual std::string title() const override { return "BugCameraMask";}
void switchSpriteFlag(cocos2d::Ref* sender);
void updateSpriteMaskLabel();
Node* _sprite;
Expand Down
2 changes: 1 addition & 1 deletion tests/cpp-tests/Classes/BugsTest/BugsTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
class BugsTestBase : public TestCase
{
public:

virtual std::string title() const override {return "No Test Title set";}
};

DEFINE_TEST_SUITE(BugsTests);
Expand Down
4 changes: 2 additions & 2 deletions tests/lua-tests/src/BugsTest/BugsTest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ local function BugTest1174()

print("Test1 - Start")
local i = 0
for i = 0, 9999 do
for i = 0, 999 do
--[[
A|b
-----
Expand Down Expand Up @@ -513,7 +513,7 @@ local function BugTest1174()

ok=0
err=0
for i = 0 , 9999 do
for i = 0 , 999 do
-- A | b
-- -----
-- c | d
Expand Down