From ad3e3380e215d160408ac6b005d088b256a2f99f Mon Sep 17 00:00:00 2001 From: rh101 Date: Thu, 19 Aug 2021 15:43:18 +1000 Subject: [PATCH] Fixes for crashes in sprite and sprite cache tests --- cocos/2d/CCDrawNode.cpp | 26 ----- cocos/2d/CCDrawNode.h | 14 --- .../physics-nodes/CCPhysicsDebugNodeBox2D.cpp | 107 ++++++++++++++---- .../physics-nodes/CCPhysicsDebugNodeBox2D.h | 40 +++++-- .../lua-bindings/auto/lua_cocos2dx_auto.cpp | 62 +++------- tests/cpp-tests/Classes/Box2DTest/Box2dTest.h | 2 +- .../Classes/Box2DTestBed/Box2DTestBed.cpp | 90 +++++---------- .../Classes/Box2DTestBed/Box2DTestBed.h | 13 +-- tests/cpp-tests/Classes/Box2DTestBed/Test.cpp | 94 ++++----------- .../cpp-tests/Classes/Box2DTestBed/settings.h | 83 ++++++++++++++ .../Box2DTestBed/tests/apply_force.cpp | 4 +- .../Classes/Box2DTestBed/tests/body_types.cpp | 4 +- .../Classes/Box2DTestBed/tests/box_stack.cpp | 6 +- .../Box2DTestBed/tests/bullet_test.cpp | 12 +- .../Classes/Box2DTestBed/tests/car.cpp | 4 +- .../tests/character_collision.cpp | 12 +- .../Classes/Box2DTestBed/tests/confined.cpp | 4 +- .../Box2DTestBed/tests/continuous_test.cpp | 16 +-- .../Box2DTestBed/tests/convex_hull.cpp | 6 +- .../Box2DTestBed/tests/distance_test.cpp | 8 +- .../Box2DTestBed/tests/dump_loader.cpp | 4 +- .../Box2DTestBed/tests/dynamic_tree.cpp | 8 +- .../Box2DTestBed/tests/edge_shapes.cpp | 4 +- .../Classes/Box2DTestBed/tests/gear_joint.cpp | 8 +- .../Box2DTestBed/tests/motor_joint.cpp | 2 +- .../Classes/Box2DTestBed/tests/pinball.cpp | 4 +- .../Classes/Box2DTestBed/tests/platformer.cpp | 4 +- .../Box2DTestBed/tests/polygon_collision.cpp | 4 +- .../Box2DTestBed/tests/polygon_shapes.cpp | 12 +- .../Box2DTestBed/tests/prismatic_joint.cpp | 4 +- .../Box2DTestBed/tests/pulley_joint.cpp | 4 +- .../Classes/Box2DTestBed/tests/ray_cast.cpp | 12 +- .../Box2DTestBed/tests/revolute_joint.cpp | 8 +- .../Classes/Box2DTestBed/tests/rope.cpp | 4 +- .../Classes/Box2DTestBed/tests/settings.h | 7 +- .../Classes/Box2DTestBed/tests/shape_cast.cpp | 4 +- .../Box2DTestBed/tests/shape_editing.cpp | 8 +- .../Classes/Box2DTestBed/tests/skier.cpp | 4 +- .../Box2DTestBed/tests/slider_crank_2.cpp | 8 +- .../Classes/Box2DTestBed/tests/test.h | 12 +- .../Box2DTestBed/tests/theo_jansen.cpp | 4 +- .../Classes/Box2DTestBed/tests/tiles.cpp | 8 +- .../Box2DTestBed/tests/time_of_impact.cpp | 8 +- .../Classes/Box2DTestBed/tests/web.cpp | 4 +- .../Box2DTestBed/tests/wheel_joint.cpp | 8 +- .../Box2DTestBed/tests/wrecking_ball.cpp | 6 +- .../SpriteFrameCacheTest.cpp | 11 +- .../SpritePolygonTest/SpritePolygonTest.cpp | 8 +- .../Classes/SpriteTest/SpriteTest.cpp | 10 +- .../UIButtonTest/UIButtonTest.cpp | 2 +- .../UIImageViewTest/UIImageViewTest.cpp | 4 +- .../CocoStudioGUITest/UIScale9SpriteTest.cpp | 12 +- 52 files changed, 404 insertions(+), 413 deletions(-) create mode 100644 tests/cpp-tests/Classes/Box2DTestBed/settings.h diff --git a/cocos/2d/CCDrawNode.cpp b/cocos/2d/CCDrawNode.cpp index 43915b6804..f82f71f155 100644 --- a/cocos/2d/CCDrawNode.cpp +++ b/cocos/2d/CCDrawNode.cpp @@ -677,29 +677,6 @@ void DrawNode::drawSolidPoly(const Vec2 *poli, unsigned int numberOfPoints, cons drawPolygon(poli, numberOfPoints, color, 0.0, Color4F()); } -void DrawNode::drawSolidCircle(const Vec2& center, float radius, float angle, unsigned int segments, float scaleX, float scaleY, const Color4F& fillColor, float borderWidth, const Color4F& borderColor) -{ - const float coef = 2.0f * (float)M_PI / segments; - - Vec2* vertices = new (std::nothrow) Vec2[segments]; - if (!vertices) - return; - - for (unsigned int i = 0; i < segments; i++) - { - float rads = i * coef; - float j = radius * cosf(rads + angle) * scaleX + center.x; - float k = radius * sinf(rads + angle) * scaleY + center.y; - - vertices[i].x = j; - vertices[i].y = k; - } - - drawPolygon(vertices, segments, fillColor, borderWidth, borderColor); - - CC_SAFE_DELETE_ARRAY(vertices); -} - void DrawNode::drawSolidCircle(const Vec2& center, float radius, float angle, unsigned int segments, float scaleX, float scaleY, const Color4F &color) { const float coef = 2.0f * (float)M_PI/segments; @@ -723,9 +700,6 @@ void DrawNode::drawSolidCircle(const Vec2& center, float radius, float angle, un CC_SAFE_DELETE_ARRAY(vertices); } - - - void DrawNode::drawSolidCircle( const Vec2& center, float radius, float angle, unsigned int segments, const Color4F& color) { drawSolidCircle(center, radius, angle, segments, 1.0f, 1.0f, color); diff --git a/cocos/2d/CCDrawNode.h b/cocos/2d/CCDrawNode.h index 528683c8a5..352714b07c 100644 --- a/cocos/2d/CCDrawNode.h +++ b/cocos/2d/CCDrawNode.h @@ -215,20 +215,6 @@ public: * @js NA */ void drawSolidPoly(const Vec2 *poli, unsigned int numberOfPoints, const Color4F &color); - - /** Draws a solid circle given the center, radius and number of segments. - * @param center The circle center point. - * @param radius The circle rotate of radius. - * @param angle The circle angle. - * @param segments The number of segments. - * @param scaleX The scale value in x. - * @param scaleY The scale value in y. - * @param fillColor The color will fill in polygon. - * @param borderWidth The border of line width. - * @param borderColor The border of line color. - * @js NA - */ - void drawSolidCircle(const Vec2& center, float radius, float angle, unsigned int segments, float scaleX, float scaleY, const Color4F& fillColor, float borderWidth, const Color4F& borderColor); /** Draws a solid circle given the center, radius and number of segments. * @param center The circle center point. diff --git a/extensions/physics-nodes/CCPhysicsDebugNodeBox2D.cpp b/extensions/physics-nodes/CCPhysicsDebugNodeBox2D.cpp index 3a1a6873a9..7ad273b1a7 100644 --- a/extensions/physics-nodes/CCPhysicsDebugNodeBox2D.cpp +++ b/extensions/physics-nodes/CCPhysicsDebugNodeBox2D.cpp @@ -16,64 +16,90 @@ * 3. This notice may not be removed or altered from any source distribution. */ +#include +#include +#include +#include +#include + #include "CCPhysicsDebugNodeBox2D.h" -NS_CC_EXT_BEGIN -PhysicsDebugNodeBox2D::PhysicsDebugNodeBox2D() + + +USING_NS_CC; + + +#if defined(CC_PLATFORM_PC) +extern cocos2d::Label* labelDebugDraw; +#endif + +#define BUFFER_OFFSET(x) ((const void*) (x)) + + +DebugDraw::DebugDraw() { drawBP = DrawNode::create(); - debugNodeOffset = { 40.0f, 0.0f }; - mRatio = 1.0f; + debugNodeOffset = { 40, 0 }; } -PhysicsDebugNodeBox2D::~PhysicsDebugNodeBox2D() +DebugDraw::~DebugDraw() { } -cocos2d::DrawNode* PhysicsDebugNodeBox2D::GetDrawNode() +void DebugDraw::initShader(void) +{ + // initShader is unsupported +} + +cocos2d::DrawNode* DebugDraw::GetDrawNode() { return drawBP; } -void PhysicsDebugNodeBox2D::SetDrawNode(cocos2d::DrawNode* drawNode) +void DebugDraw::SetDrawNode(cocos2d::DrawNode* drawNode) { + CCASSERT(!drawBP, "drawBP is not NULL"); drawBP = drawNode; } -cocos2d::Vec2& PhysicsDebugNodeBox2D::GetDebugNodeOffset() +cocos2d::Vec2& DebugDraw::GetDebugNodeOffset() { return debugNodeOffset; } -void PhysicsDebugNodeBox2D::DrawPolygon(const b2Vec2* verts, int vertexCount, const b2Color& color) +void DebugDraw::DrawPolygon(const b2Vec2* verts, int vertexCount, const b2Color& color) { Vec2* vec = new (std::nothrow) Vec2[vertexCount]; for (size_t i = 0; i < vertexCount; i++) { vec[i] = Vec2(verts[i].x * mRatio, verts[i].y * mRatio) + debugNodeOffset; } + // drawBP->drawPolygon(vec, vertexCount, Color4F(color.r, color.g, color.b, color.a), 1, Color4F(color.r, color.g, color.b, color.a)); drawBP->drawPolygon(vec, vertexCount, Color4F::BLACK, 0.4f, Color4F(color.r, color.g, color.b, color.a)); } -void PhysicsDebugNodeBox2D::DrawSolidPolygon(const b2Vec2* verts, int vertexCount, const b2Color& color) +void DebugDraw::DrawSolidPolygon(const b2Vec2* verts, int vertexCount, const b2Color& color) { Vec2* vec = new (std::nothrow) Vec2[vertexCount]; for (size_t i = 0; i < vertexCount; i++) { vec[i] = Vec2(verts[i].x * mRatio, verts[i].y * mRatio) + debugNodeOffset; } drawBP->drawPolygon(vec, vertexCount, Color4F(color.r / 2, color.g / 2, color.b / 2, color.a), 0.4f, Color4F(color.r, color.g, color.b, color.a)); + //drawBP->drawSolidPoly(vec, vertexCount, Color4F(color.r, color.g, color.b, color.a)); } -void PhysicsDebugNodeBox2D::DrawCircle(const b2Vec2& center, float radius, const b2Color& color) +void DebugDraw::DrawCircle(const b2Vec2& center, float radius, const b2Color& color) { - drawBP->drawCircle(Vec2(center.x * mRatio, center.y * mRatio) + debugNodeOffset, radius * mRatio, CC_DEGREES_TO_RADIANS(0), 30, true, 1.0f, 1.0f, Color4F(color.r, color.g, color.b, color.a)); + drawBP->drawCircle(Vec2(center.x * mRatio, center.y * mRatio) + debugNodeOffset, radius * mRatio, CC_DEGREES_TO_RADIANS(0), 30, true, 1.0f, + 1.0f, Color4F(color.r, color.g, color.b, color.a)); } -void PhysicsDebugNodeBox2D::DrawSolidCircle(const b2Vec2& center, float radius, const b2Vec2& axis, const b2Color& color) +void DebugDraw::DrawSolidCircle(const b2Vec2& center, float radius, const b2Vec2& axis, const b2Color& color) { + // DrawSolidCircle Maybe have to fix later Vec2 c = { Vec2(center.x * mRatio, center.y * mRatio) + debugNodeOffset }; - drawBP->drawSolidCircle(c, radius * mRatio, CC_DEGREES_TO_RADIANS(0), 20, 1.0f, 1.0f, Color4F(color.r / 2, color.g / 2, color.b / 2, color.a), 0.4f, Color4F(color.r, color.g, color.b, color.a)); + drawBP->drawCircle(c, radius * mRatio, CC_DEGREES_TO_RADIANS(0), 20, false, 1.0f, 1.0f, Color4F(color.r, color.g, color.b, color.a)); // Draw a line fixed in the circle to animate rotation. b2Vec2 pp = { (center + radius * axis) }; @@ -81,25 +107,66 @@ void PhysicsDebugNodeBox2D::DrawSolidCircle(const b2Vec2& center, float radius, drawBP->drawLine(c, cp, Color4F(color.r, color.g, color.b, color.a)); } -void PhysicsDebugNodeBox2D::DrawSegment(const b2Vec2& p1, const b2Vec2& p2, const b2Color& color) +void DebugDraw::DrawSegment(const b2Vec2& p1, const b2Vec2& p2, const b2Color& color) { drawBP->drawLine(Vec2(p1.x * mRatio, p1.y * mRatio) + debugNodeOffset, Vec2(p2.x * mRatio, p2.y * mRatio) + debugNodeOffset, Color4F(color.r, color.g, color.b, color.a)); } -void PhysicsDebugNodeBox2D::DrawTransform(const b2Transform& xf) +void DebugDraw::DrawTransform(const b2Transform& xf) { b2Vec2 p1 = xf.p, p2; const float k_axisScale = 0.4f; p2 = p1 + k_axisScale * xf.q.GetXAxis(); - DrawSegment(p1, p2, b2Color(1.0f, 0.0f, 0.0f)); + DrawSegment(p1, p2, b2Color(1, 0, 0)); p2 = p1 + k_axisScale * xf.q.GetYAxis(); - DrawSegment(p1, p2, b2Color(0.0f, 1.0f, 0.0f)); + DrawSegment(p1, p2, b2Color(0, 1, 0)); } -void PhysicsDebugNodeBox2D::DrawPoint(const b2Vec2& p, float size, const b2Color& color) +void DebugDraw::DrawPoint(const b2Vec2& p, float size, const b2Color& color) { drawBP->drawPoint(Vec2(p.x * mRatio, p.y * mRatio) + debugNodeOffset, size, Color4F(color.r, color.g, color.b, color.a)); } -NS_CC_EXT_END \ No newline at end of file +void DebugDraw::DrawString(int x, int y, const char* fmt, ...) +{ +#if defined(CC_PLATFORM_PC) + debugString.append(std::string(fmt)); + debugString.append("\n"); + labelDebugDraw->setString(debugString); +// labelDebugDraw->setPosition(x, y); +#endif +} + +void DebugDraw::DrawString(const b2Vec2& pw, const char* fmt, ...) +{ +#if defined(CC_PLATFORM_PC) + debugString.append(std::string(fmt)); + debugString.append("\n"); + labelDebugDraw->setString(debugString); +// labelDebugDraw->setPosition(pw.x, pw.y); +#endif +} + + + +void DebugDraw::DrawAABB(b2AABB* aabb, const b2Color& color) +{ + b2Vec2 p1 = aabb->lowerBound; + b2Vec2 p2 = b2Vec2(aabb->upperBound.x, aabb->lowerBound.y); + b2Vec2 p3 = aabb->upperBound; + b2Vec2 p4 = b2Vec2(aabb->lowerBound.x, aabb->upperBound.y); + + Vec2 verts[] = { + Vec2(p1.x * mRatio, p1.y * mRatio) + debugNodeOffset , + Vec2(p2.x * mRatio, p2.y * mRatio) + debugNodeOffset , + Vec2(p3.x * mRatio, p3.y * mRatio) + debugNodeOffset , + Vec2(p4.x * mRatio, p4.y * mRatio) + debugNodeOffset , + }; + drawBP->drawPolygon(verts, sizeof(verts) / sizeof(verts[0]), Color4F(color.r / 2, color.g / 2, color.b / 2, 0), 0.4f, Color4F(color.r, color.g, color.b, color.a)); +} + +void DebugDraw::Flush() +{ + // Flush is unsupported +} \ No newline at end of file diff --git a/extensions/physics-nodes/CCPhysicsDebugNodeBox2D.h b/extensions/physics-nodes/CCPhysicsDebugNodeBox2D.h index 4111592fe8..16151a7c23 100644 --- a/extensions/physics-nodes/CCPhysicsDebugNodeBox2D.h +++ b/extensions/physics-nodes/CCPhysicsDebugNodeBox2D.h @@ -20,21 +20,28 @@ #ifndef __PHYSICSNODES_DEBUGNODE_BOX2D_H__ #define __PHYSICSNODES_DEBUGNODE_BOX2D_H__ + +#define GLFW_INCLUDE_NONE + + #include "extensions/ExtensionMacros.h" -#include "extensions/ExtensionExport.h" #include "2d/CCDrawNode.h" +#include "extensions/ExtensionExport.h" #include "box2d/box2d.h" #include "cocos2d.h" -NS_CC_EXT_BEGIN -// This class implements debug drawing callbacks that are invoked inside b2World::Step. -class CC_EX_DLL PhysicsDebugNodeBox2D : public b2Draw +// This class implements debug drawing callbacks that are invoked +// inside b2World::Step. + +//PhysicsDebugNode : public DrawNode +class CC_EX_DLL DebugDraw : public b2Draw { public: + void initShader( void ); - PhysicsDebugNodeBox2D(); - ~PhysicsDebugNodeBox2D(); + DebugDraw(); + ~DebugDraw(); void Create(); void Destroy(); @@ -53,19 +60,28 @@ public: void DrawPoint(const b2Vec2& p, float size, const b2Color& color) override; - // adxe stuffs + void DrawString(int x, int y, const char* fmt, ...); + + void DrawString(const b2Vec2& p, const char* fmt, ...); + + void DrawAABB(b2AABB* aabb, const b2Color& color); + + void Flush(); + cocos2d::DrawNode* GetDrawNode(); void SetDrawNode(cocos2d::DrawNode* drawNode); cocos2d::Vec2& GetDebugNodeOffset(); - cocos2d::DrawNode* drawBP = NULL; // adxe "interface"! - cocos2d::Vec2 debugNodeOffset; float mRatio; + cocos2d::DrawNode* drawBP = NULL; + std::string debugString = ""; + cocos2d::Vec2 debugNodeOffset; private: + + + }; -NS_CC_EXT_END - -#endif //__PHYSICSNODES_DEBUGNODE_BOX2D_H__ \ No newline at end of file +#endif //__PHYSICSNODES_DEBUGNODE_BOX2D_H__ diff --git a/extensions/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp b/extensions/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp index ef1786bf6b..32754b3caa 100644 --- a/extensions/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp +++ b/extensions/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp @@ -98092,9 +98092,9 @@ int lua_cocos2dx_SpriteFrameCache_getSpriteSheetLoader(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - unsigned int arg0; + std::string arg0; - ok &= luaval_to_uint32(tolua_S, 2,&arg0, "cc.SpriteFrameCache:getSpriteSheetLoader"); + ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.SpriteFrameCache:getSpriteSheetLoader"); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_SpriteFrameCache_getSpriteSheetLoader'", nullptr); @@ -98244,8 +98244,8 @@ int lua_cocos2dx_SpriteFrameCache_addSpriteFramesWithFile(lua_State* tolua_S) ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.SpriteFrameCache:addSpriteFramesWithFile"); if (!ok) { break; } - std::string arg1; - ok &= luaval_to_std_string(tolua_S, 3,&arg1, "cc.SpriteFrameCache:addSpriteFramesWithFile"); + cocos2d::Texture2D* arg1; + ok &= luaval_to_object(tolua_S, 3, "cc.Texture2D",&arg1, "cc.SpriteFrameCache:addSpriteFramesWithFile"); if (!ok) { break; } cobj->addSpriteFramesWithFile(arg0, arg1); @@ -98260,12 +98260,12 @@ int lua_cocos2dx_SpriteFrameCache_addSpriteFramesWithFile(lua_State* tolua_S) ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.SpriteFrameCache:addSpriteFramesWithFile"); if (!ok) { break; } - std::string arg1; - ok &= luaval_to_std_string(tolua_S, 3,&arg1, "cc.SpriteFrameCache:addSpriteFramesWithFile"); + cocos2d::Texture2D* arg1; + ok &= luaval_to_object(tolua_S, 3, "cc.Texture2D",&arg1, "cc.SpriteFrameCache:addSpriteFramesWithFile"); if (!ok) { break; } - unsigned int arg2; - ok &= luaval_to_uint32(tolua_S, 4,&arg2, "cc.SpriteFrameCache:addSpriteFramesWithFile"); + std::string arg2; + ok &= luaval_to_std_string(tolua_S, 4,&arg2, "cc.SpriteFrameCache:addSpriteFramesWithFile"); if (!ok) { break; } cobj->addSpriteFramesWithFile(arg0, arg1, arg2); @@ -98292,8 +98292,8 @@ int lua_cocos2dx_SpriteFrameCache_addSpriteFramesWithFile(lua_State* tolua_S) ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.SpriteFrameCache:addSpriteFramesWithFile"); if (!ok) { break; } - unsigned int arg1; - ok &= luaval_to_uint32(tolua_S, 3,&arg1, "cc.SpriteFrameCache:addSpriteFramesWithFile"); + std::string arg1; + ok &= luaval_to_std_string(tolua_S, 3,&arg1, "cc.SpriteFrameCache:addSpriteFramesWithFile"); if (!ok) { break; } cobj->addSpriteFramesWithFile(arg0, arg1); @@ -98302,43 +98302,7 @@ int lua_cocos2dx_SpriteFrameCache_addSpriteFramesWithFile(lua_State* tolua_S) } }while(0); ok = true; - do{ - if (argc == 2) { - std::string arg0; - ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.SpriteFrameCache:addSpriteFramesWithFile"); - - if (!ok) { break; } - cocos2d::Texture2D* arg1; - ok &= luaval_to_object(tolua_S, 3, "cc.Texture2D",&arg1, "cc.SpriteFrameCache:addSpriteFramesWithFile"); - - if (!ok) { break; } - cobj->addSpriteFramesWithFile(arg0, arg1); - lua_settop(tolua_S, 1); - return 1; - } - }while(0); - ok = true; - do{ - if (argc == 3) { - std::string arg0; - ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.SpriteFrameCache:addSpriteFramesWithFile"); - - if (!ok) { break; } - cocos2d::Texture2D* arg1; - ok &= luaval_to_object(tolua_S, 3, "cc.Texture2D",&arg1, "cc.SpriteFrameCache:addSpriteFramesWithFile"); - - if (!ok) { break; } - unsigned int arg2; - ok &= luaval_to_uint32(tolua_S, 4,&arg2, "cc.SpriteFrameCache:addSpriteFramesWithFile"); - - if (!ok) { break; } - cobj->addSpriteFramesWithFile(arg0, arg1, arg2); - lua_settop(tolua_S, 1); - return 1; - } - }while(0); - ok = true; - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.SpriteFrameCache:addSpriteFramesWithFile",argc, 2); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.SpriteFrameCache:addSpriteFramesWithFile",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 @@ -98626,9 +98590,9 @@ int lua_cocos2dx_SpriteFrameCache_deregisterSpriteSheetLoader(lua_State* tolua_S argc = lua_gettop(tolua_S)-1; if (argc == 1) { - unsigned int arg0; + std::string arg0; - ok &= luaval_to_uint32(tolua_S, 2,&arg0, "cc.SpriteFrameCache:deregisterSpriteSheetLoader"); + ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.SpriteFrameCache:deregisterSpriteSheetLoader"); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_SpriteFrameCache_deregisterSpriteSheetLoader'", nullptr); diff --git a/tests/cpp-tests/Classes/Box2DTest/Box2dTest.h b/tests/cpp-tests/Classes/Box2DTest/Box2dTest.h index d98406d746..61cf7a33fb 100644 --- a/tests/cpp-tests/Classes/Box2DTest/Box2dTest.h +++ b/tests/cpp-tests/Classes/Box2DTest/Box2dTest.h @@ -59,7 +59,7 @@ private: cocos2d::Texture2D* _spriteTexture; cocos2d::DrawNode* drawBox2D; - cocos2d::extension::PhysicsDebugNodeBox2D g_debugDraw; + DebugDraw g_debugDraw; bool showDebugDraw = true; } ; diff --git a/tests/cpp-tests/Classes/Box2DTestBed/Box2DTestBed.cpp b/tests/cpp-tests/Classes/Box2DTestBed/Box2DTestBed.cpp index e5550fb128..ee5aaa666f 100644 --- a/tests/cpp-tests/Classes/Box2DTestBed/Box2DTestBed.cpp +++ b/tests/cpp-tests/Classes/Box2DTestBed/Box2DTestBed.cpp @@ -23,13 +23,11 @@ ****************************************************************************/ #include "platform/CCPlatformConfig.h" -#include "extensions/cocos-ext.h" -#include "ImGuiEXT/CCImGuiEXT.h" -#include "cocos2d.h" - #include "Box2DTestBed.h" +#include "extensions/cocos-ext.h" #include "tests/test.h" #include "tests/settings.h" +#include "ImGuiEXT/CCImGuiEXT.h" USING_NS_CC; USING_NS_CC_EXT; @@ -38,7 +36,16 @@ enum { kTagParentNode = 1, }; + + +#define kAccelerometerFrequency 30 +#define FRAMES_BETWEEN_PRESSES_FOR_DOUBLE_CLICK 10 + + +#define PTM_RATIO 32 + Settings settings; + cocos2d::Label* labelDebugDraw; enum @@ -116,11 +123,15 @@ bool Box2DTestBed::initWithEntryID(int entryId) m_test->debugDrawNode = debugDrawNode; m_test->g_debugDraw = g_debugDraw; + + + TestCase::addChild(debugDrawNode, 100); // init physics this->initPhysics(); + auto label = Label::createWithTTF(m_entry->name, "fonts/arial.ttf", 28); TestCase::addChild(label, 1); label->setPosition(visibleOrigin.x + visibleSize.width / 2, visibleOrigin.y + visibleSize.height - 50); @@ -131,20 +142,14 @@ bool Box2DTestBed::initWithEntryID(int entryId) _touchListener->onTouchBegan = CC_CALLBACK_2(Box2DTestBed::onTouchBegan, this); _touchListener->onTouchMoved = CC_CALLBACK_2(Box2DTestBed::onTouchMoved, this); _touchListener->onTouchEnded = CC_CALLBACK_2(Box2DTestBed::onTouchEnded, this); - TestCase::_eventDispatcher->addEventListenerWithFixedPriority(_touchListener,10); + TestCase::_eventDispatcher->addEventListenerWithFixedPriority(_touchListener,1); // Adds Keyboard event listener _keyboardListener = EventListenerKeyboard::create(); _keyboardListener->onKeyPressed = CC_CALLBACK_2(Box2DTestBed::onKeyPressed, this); _keyboardListener->onKeyReleased = CC_CALLBACK_2(Box2DTestBed::onKeyReleased, this); - TestCase::_eventDispatcher->addEventListenerWithFixedPriority(_keyboardListener,11); + TestCase::_eventDispatcher->addEventListenerWithFixedPriority(_keyboardListener,1); - auto _mouseListener = EventListenerMouse::create(); - _mouseListener->onMouseMove = CC_CALLBACK_1(Box2DTestBed::onMouseMove, this); - _mouseListener->onMouseUp = CC_CALLBACK_1(Box2DTestBed::onMouseUp, this); - _mouseListener->onMouseDown = CC_CALLBACK_1(Box2DTestBed::onMouseDown, this); - _mouseListener->onMouseScroll = CC_CALLBACK_1(Box2DTestBed::onMouseScroll, this); - TestCase::_eventDispatcher->addEventListenerWithFixedPriority(_mouseListener, 12); // Demo messageString labelDebugDraw = Label::createWithTTF("TEST", "fonts/arial.ttf", 8.0f); @@ -160,6 +165,7 @@ bool Box2DTestBed::initWithEntryID(int entryId) bool Box2DTestBed::onTouchBegan(Touch* touch, Event* event) { + CCLOG("onTouchBegan"); auto location = touch->getLocation() - g_debugDraw.debugNodeOffset; b2Vec2 pos = { location.x / g_debugDraw.mRatio, location.y / g_debugDraw.mRatio }; return m_test->MouseDown(pos); @@ -167,77 +173,36 @@ bool Box2DTestBed::onTouchBegan(Touch* touch, Event* event) void Box2DTestBed::onTouchMoved(Touch* touch, Event* event) { + CCLOG("onTouchMoved"); auto location = touch->getLocation() - g_debugDraw.debugNodeOffset; b2Vec2 pos = { location.x / g_debugDraw.mRatio, location.y / g_debugDraw.mRatio }; + m_test->MouseMove(pos); } void Box2DTestBed::onTouchEnded(Touch* touch, Event* event) { + CCLOG("onTouchEnded"); auto location = touch->getLocation() - g_debugDraw.debugNodeOffset; b2Vec2 pos = { location.x / g_debugDraw.mRatio, location.y / g_debugDraw.mRatio }; + m_test->MouseUp(pos); } void Box2DTestBed::onKeyPressed(EventKeyboard::KeyCode code, Event* event) { CCLOG("onKeyPressed, keycode: %d", static_cast(code)); - m_test->Keyboard((static_cast(code) - 59)); // its a bad hack! + m_test->Keyboard((static_cast(code) - 59)); + } void Box2DTestBed::onKeyReleased(EventKeyboard::KeyCode code, Event* event) { CCLOG("onKeyPressed, keycode: %d", static_cast(code)); - m_test->KeyboardUp((static_cast(code) - 59)); // its a bad hack! + m_test->KeyboardUp((static_cast(code) - 59)); } -void Box2DTestBed::onMouseDown(Event* event) -{ - EventMouse* e = (EventMouse*)event; - switch (e->getMouseButton()) - { - button[(int)EventMouse::MouseButton::BUTTON_LEFT] = false; - button[(int)EventMouse::MouseButton::BUTTON_RIGHT] = false; - button[(int)EventMouse::MouseButton::BUTTON_MIDDLE] = false; - case EventMouse::MouseButton::BUTTON_LEFT: - button[(int)EventMouse::MouseButton::BUTTON_LEFT] = true; - break; - case EventMouse::MouseButton::BUTTON_RIGHT: - button[(int)EventMouse::MouseButton::BUTTON_RIGHT] = true; - break; - case EventMouse::MouseButton::BUTTON_MIDDLE: - button[(int)EventMouse::MouseButton::BUTTON_MIDDLE] = true; - break; - } -} - -void Box2DTestBed::onMouseUp(Event* event) -{ - button[(int)EventMouse::MouseButton::BUTTON_LEFT] = false; - button[(int)EventMouse::MouseButton::BUTTON_RIGHT] = false; - button[(int)EventMouse::MouseButton::BUTTON_MIDDLE] = false; -} - -void Box2DTestBed::onMouseMove(Event* event) -{ - EventMouse* e = (EventMouse*)event; - pos = { e->getCursorX() / g_debugDraw.mRatio , e->getCursorY() / g_debugDraw.mRatio }; - - if (button[(int)EventMouse::MouseButton::BUTTON_RIGHT]) - { - (pos.x > oldPos.x) ? g_debugDraw.debugNodeOffset.x += 4 : g_debugDraw.debugNodeOffset.x -= 4; - (pos.y < oldPos.y) ? g_debugDraw.debugNodeOffset.y -= 2 : g_debugDraw.debugNodeOffset.y += 2; - } - oldPos = pos; -} - -void Box2DTestBed::onMouseScroll(Event* event) -{ - EventMouse* e = (EventMouse*)event; - g_debugDraw.mRatio += e->getScrollY(); -} - void Box2DTestBed::onEnter() { Scene::onEnter(); @@ -248,12 +213,13 @@ void Box2DTestBed::onExit() { Scene::onExit(); ImGuiEXT::getInstance()->removeRenderLoop("#im01"); + } void Box2DTestBed::update(float dt) { // Debug draw - m_test->debugString = ""; + m_test->g_debugDraw.debugString = ""; labelDebugDraw->setString(""); debugDrawNode->clear(); m_test->Step(settings); @@ -268,7 +234,7 @@ void Box2DTestBed::initPhysics() flags += 0 * b2Draw::e_aabbBit; flags += 0 * b2Draw::e_centerOfMassBit; g_debugDraw.SetFlags(flags); - g_debugDraw.mRatio = 8; + g_debugDraw.mRatio = PTM_RATIO / 4; m_test->m_world->SetDebugDraw(&g_debugDraw); m_test->g_debugDraw = g_debugDraw; g_debugDraw.debugNodeOffset = { 250, 70 }; diff --git a/tests/cpp-tests/Classes/Box2DTestBed/Box2DTestBed.h b/tests/cpp-tests/Classes/Box2DTestBed/Box2DTestBed.h index 92b4b7e6ff..c304afb0b0 100644 --- a/tests/cpp-tests/Classes/Box2DTestBed/Box2DTestBed.h +++ b/tests/cpp-tests/Classes/Box2DTestBed/Box2DTestBed.h @@ -28,6 +28,8 @@ #include "cocos2d.h" #include "box2d/box2d.h" #include "../BaseTest.h" +#include "renderer/CCCustomCommand.h" + DEFINE_TEST_SUITE(Box2DTestBedTests); @@ -74,11 +76,6 @@ public: void onKeyPressed(cocos2d::EventKeyboard::KeyCode code, cocos2d::Event* event) override; void onKeyReleased(cocos2d::EventKeyboard::KeyCode code, cocos2d::Event* event) override; - void onMouseDown(cocos2d::Event* event); - void onMouseUp(cocos2d::Event* event); - void onMouseMove(cocos2d::Event* event); - void onMouseScroll(cocos2d::Event* event); - cocos2d::EventListenerTouchOneByOne* _touchListener; cocos2d::EventListenerKeyboard* _keyboardListener; @@ -91,13 +88,9 @@ private: b2World* world; cocos2d::Texture2D* _spriteTexture; - b2Vec2 pos; - b2Vec2 oldPos; - bool button[2]; - // Debug stuff cocos2d::DrawNode* debugDrawNode; - cocos2d::extension::PhysicsDebugNodeBox2D g_debugDraw; + DebugDraw g_debugDraw; }; diff --git a/tests/cpp-tests/Classes/Box2DTestBed/Test.cpp b/tests/cpp-tests/Classes/Box2DTestBed/Test.cpp index 5d88954b27..a6be6b0e45 100644 --- a/tests/cpp-tests/Classes/Box2DTestBed/Test.cpp +++ b/tests/cpp-tests/Classes/Box2DTestBed/Test.cpp @@ -18,18 +18,10 @@ #include "tests/test.h" #include "tests/settings.h" - #include "extensions/cocos-ext.h" -#include "cocos2d.h" #include -USING_NS_CC; -USING_NS_CC_EXT; - -#if defined(CC_PLATFORM_PC) -extern cocos2d::Label* labelDebugDraw; -#endif void DestructionListener::SayGoodbye(b2Joint * joint) { @@ -112,7 +104,7 @@ void Test::PreSolve(b2Contact * contact, const b2Manifold * oldManifold) void Test::DrawTitle(const char* string) { - DrawString(5, 5, string); + g_debugDraw.DrawString(5, 5, string); m_textLine = int32(26.0f); } @@ -299,8 +291,8 @@ void Test::Step(Settings& settings) timeStep = 0.0f; } - DrawString(5, m_textLine, "****PAUSED****"); - + g_debugDraw.DrawString(5, m_textLine, "****PAUSED****"); + m_textLine += m_textIncrement; } uint32 flags = 0; @@ -331,15 +323,15 @@ void Test::Step(Settings& settings) int32 bodyCount = m_world->GetBodyCount(); int32 contactCount = m_world->GetContactCount(); int32 jointCount = m_world->GetJointCount(); - DrawString(5, m_textLine, "bodies/contacts/joints = %d/%d/%d", bodyCount, contactCount, jointCount); - + g_debugDraw.DrawString(5, m_textLine, "bodies/contacts/joints = %d/%d/%d", bodyCount, contactCount, jointCount); + m_textLine += m_textIncrement; int32 proxyCount = m_world->GetProxyCount(); int32 height = m_world->GetTreeHeight(); int32 balance = m_world->GetTreeBalance(); float quality = m_world->GetTreeQuality(); - DrawString(5, m_textLine, "proxies/height/balance/quality = %d/%d/%d/%g", proxyCount, height, balance, quality); - + g_debugDraw.DrawString(5, m_textLine, "proxies/height/balance/quality = %d/%d/%d/%g", proxyCount, height, balance, quality); + m_textLine += m_textIncrement; } // Track maximum profile times @@ -383,14 +375,22 @@ void Test::Step(Settings& settings) aveProfile.broadphase = scale * m_totalProfile.broadphase; } - DrawString(5, m_textLine, "step [ave] (max) = %5.2f [%6.2f] (%6.2f)", p.step, aveProfile.step, m_maxProfile.step); - DrawString(5, m_textLine, "collide [ave] (max) = %5.2f [%6.2f] (%6.2f)", p.collide, aveProfile.collide, m_maxProfile.collide); - DrawString(5, m_textLine, "solve [ave] (max) = %5.2f [%6.2f] (%6.2f)", p.solve, aveProfile.solve, m_maxProfile.solve); - DrawString(5, m_textLine, "solve init [ave] (max) = %5.2f [%6.2f] (%6.2f)", p.solveInit, aveProfile.solveInit, m_maxProfile.solveInit); - DrawString(5, m_textLine, "solve velocity [ave] (max) = %5.2f [%6.2f] (%6.2f)", p.solveVelocity, aveProfile.solveVelocity, m_maxProfile.solveVelocity); - DrawString(5, m_textLine, "solve position [ave] (max) = %5.2f [%6.2f] (%6.2f)", p.solvePosition, aveProfile.solvePosition, m_maxProfile.solvePosition); - DrawString(5, m_textLine, "solveTOI [ave] (max) = %5.2f [%6.2f] (%6.2f)", p.solveTOI, aveProfile.solveTOI, m_maxProfile.solveTOI); - DrawString(5, m_textLine, "broad-phase [ave] (max) = %5.2f [%6.2f] (%6.2f)", p.broadphase, aveProfile.broadphase, m_maxProfile.broadphase); + g_debugDraw.DrawString(5, m_textLine, "step [ave] (max) = %5.2f [%6.2f] (%6.2f)", p.step, aveProfile.step, m_maxProfile.step); + m_textLine += m_textIncrement; + g_debugDraw.DrawString(5, m_textLine, "collide [ave] (max) = %5.2f [%6.2f] (%6.2f)", p.collide, aveProfile.collide, m_maxProfile.collide); + m_textLine += m_textIncrement; + g_debugDraw.DrawString(5, m_textLine, "solve [ave] (max) = %5.2f [%6.2f] (%6.2f)", p.solve, aveProfile.solve, m_maxProfile.solve); + m_textLine += m_textIncrement; + g_debugDraw.DrawString(5, m_textLine, "solve init [ave] (max) = %5.2f [%6.2f] (%6.2f)", p.solveInit, aveProfile.solveInit, m_maxProfile.solveInit); + m_textLine += m_textIncrement; + g_debugDraw.DrawString(5, m_textLine, "solve velocity [ave] (max) = %5.2f [%6.2f] (%6.2f)", p.solveVelocity, aveProfile.solveVelocity, m_maxProfile.solveVelocity); + m_textLine += m_textIncrement; + g_debugDraw.DrawString(5, m_textLine, "solve position [ave] (max) = %5.2f [%6.2f] (%6.2f)", p.solvePosition, aveProfile.solvePosition, m_maxProfile.solvePosition); + m_textLine += m_textIncrement; + g_debugDraw.DrawString(5, m_textLine, "solveTOI [ave] (max) = %5.2f [%6.2f] (%6.2f)", p.solveTOI, aveProfile.solveTOI, m_maxProfile.solveTOI); + m_textLine += m_textIncrement; + g_debugDraw.DrawString(5, m_textLine, "broad-phase [ave] (max) = %5.2f [%6.2f] (%6.2f)", p.broadphase, aveProfile.broadphase, m_maxProfile.broadphase); + m_textLine += m_textIncrement; } if (m_bombSpawning) @@ -450,52 +450,4 @@ void Test::Step(Settings& settings) void Test::ShiftOrigin(const b2Vec2 & newOrigin) { m_world->ShiftOrigin(newOrigin); -} - -void Test::initShader(void) -{ - // initShader is unsupported -} - -void Test::DrawString(int x, int y, const char* fmt, ...) -{ -#if defined(CC_PLATFORM_PC) - debugString.append(std::string(fmt)); - debugString.append("\n"); - labelDebugDraw->setString(debugString); - // labelDebugDraw->setPosition(x, y); -#endif -} - -void Test::DrawString(const b2Vec2& pw, const char* fmt, ...) -{ -#if defined(CC_PLATFORM_PC) - debugString.append(std::string(fmt)); - debugString.append("\n"); - labelDebugDraw->setString(debugString); - // labelDebugDraw->setPosition(pw.x, pw.y); -#endif -} - - - -void Test::DrawAABB(b2AABB* aabb, const b2Color& color) -{ - b2Vec2 p1 = aabb->lowerBound; - b2Vec2 p2 = b2Vec2(aabb->upperBound.x, aabb->lowerBound.y); - b2Vec2 p3 = aabb->upperBound; - b2Vec2 p4 = b2Vec2(aabb->lowerBound.x, aabb->upperBound.y); - - Vec2 verts[] = { - Vec2(p1.x * g_debugDraw.mRatio, p1.y * g_debugDraw.mRatio) + g_debugDraw.debugNodeOffset , - Vec2(p2.x * g_debugDraw.mRatio, p2.y * g_debugDraw.mRatio) + g_debugDraw.debugNodeOffset , - Vec2(p3.x * g_debugDraw.mRatio, p3.y * g_debugDraw.mRatio) + g_debugDraw.debugNodeOffset , - Vec2(p4.x * g_debugDraw.mRatio, p4.y * g_debugDraw.mRatio) + g_debugDraw.debugNodeOffset , - }; - debugDrawNode->drawPolygon(verts, sizeof(verts) / sizeof(verts[0]), Color4F(color.r / 2, color.g / 2, color.b / 2, 0), 0.4f, Color4F(color.r, color.g, color.b, color.a)); -} - -void Test::Flush() -{ - // Flush is unsupported } \ No newline at end of file diff --git a/tests/cpp-tests/Classes/Box2DTestBed/settings.h b/tests/cpp-tests/Classes/Box2DTestBed/settings.h new file mode 100644 index 0000000000..65045da447 --- /dev/null +++ b/tests/cpp-tests/Classes/Box2DTestBed/settings.h @@ -0,0 +1,83 @@ +// MIT License + +// Copyright (c) 2019 Erin Catto + +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: + +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. + +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +#pragma once + +struct Settings +{ + Settings() + { + Reset(); + } + + void Reset() + { + m_testIndex = 0; + m_windowWidth = 1600; + m_windowHeight = 900; + m_hertz = 60.0f; + m_velocityIterations = 8; + m_positionIterations = 1; + m_drawShapes = true; + m_drawJoints = true; + m_drawAABBs = false; + m_drawContactPoints = false; + m_drawContactNormals = false; + m_drawContactImpulse = false; + m_drawFrictionImpulse = false; + m_drawCOMs = false; + m_drawStats = false; + m_drawProfile = false; + m_enableWarmStarting = true; + m_enableContinuous = true; + m_enableSubStepping = false; + m_enableSleep = true; + m_pause = false; + m_singleStep = false; + } + + void Save(); + void Load(); + + int m_testIndex; + int m_windowWidth; + int m_windowHeight; + float m_hertz; + int m_velocityIterations; + int m_positionIterations; + bool m_drawShapes; + bool m_drawJoints; + bool m_drawAABBs; + bool m_drawContactPoints; + bool m_drawContactNormals; + bool m_drawContactImpulse; + bool m_drawFrictionImpulse; + bool m_drawCOMs; + bool m_drawStats; + bool m_drawProfile; + bool m_enableWarmStarting; + bool m_enableContinuous; + bool m_enableSubStepping; + bool m_enableSleep; + bool m_pause; + bool m_singleStep; +}; \ No newline at end of file diff --git a/tests/cpp-tests/Classes/Box2DTestBed/tests/apply_force.cpp b/tests/cpp-tests/Classes/Box2DTestBed/tests/apply_force.cpp index 40fc7e1dec..335b58a745 100644 --- a/tests/cpp-tests/Classes/Box2DTestBed/tests/apply_force.cpp +++ b/tests/cpp-tests/Classes/Box2DTestBed/tests/apply_force.cpp @@ -169,8 +169,8 @@ public: void Step(Settings& settings) override { - DrawString(5, m_textLine, "Forward (W), Turn (A) and (D)"); - + g_debugDraw.DrawString(5, m_textLine, "Forward (W), Turn (A) and (D)"); + m_textLine += m_textIncrement; //if (glfwGetKey(g_mainWindow, GLFW_KEY_W) == GLFW_PRESS) //{ diff --git a/tests/cpp-tests/Classes/Box2DTestBed/tests/body_types.cpp b/tests/cpp-tests/Classes/Box2DTestBed/tests/body_types.cpp index 055d279578..279ae39bf7 100644 --- a/tests/cpp-tests/Classes/Box2DTestBed/tests/body_types.cpp +++ b/tests/cpp-tests/Classes/Box2DTestBed/tests/body_types.cpp @@ -146,8 +146,8 @@ public: Test::Step(settings); - DrawString(5, m_textLine, "Keys: (d) dynamic, (s) static, (k) kinematic"); - + g_debugDraw.DrawString(5, m_textLine, "Keys: (d) dynamic, (s) static, (k) kinematic"); + m_textLine += m_textIncrement; } static Test* Create() diff --git a/tests/cpp-tests/Classes/Box2DTestBed/tests/box_stack.cpp b/tests/cpp-tests/Classes/Box2DTestBed/tests/box_stack.cpp index 10da577cbc..90dc04460d 100644 --- a/tests/cpp-tests/Classes/Box2DTestBed/tests/box_stack.cpp +++ b/tests/cpp-tests/Classes/Box2DTestBed/tests/box_stack.cpp @@ -128,9 +128,9 @@ public: void Step(Settings& settings) override { Test::Step(settings); - DrawString(5, m_textLine, "Press: (,) to launch a bullet."); - - DrawString(5, m_textLine, "Blocksolve = %d", g_blockSolve); + g_debugDraw.DrawString(5, m_textLine, "Press: (,) to launch a bullet."); + m_textLine += m_textIncrement; + g_debugDraw.DrawString(5, m_textLine, "Blocksolve = %d", g_blockSolve); if (m_stepCount == 300) { if (m_bullet != NULL) diff --git a/tests/cpp-tests/Classes/Box2DTestBed/tests/bullet_test.cpp b/tests/cpp-tests/Classes/Box2DTestBed/tests/bullet_test.cpp index 0ff1800f28..9ddd733a4a 100644 --- a/tests/cpp-tests/Classes/Box2DTestBed/tests/bullet_test.cpp +++ b/tests/cpp-tests/Classes/Box2DTestBed/tests/bullet_test.cpp @@ -104,20 +104,20 @@ public: if (b2_gjkCalls > 0) { - DrawString(5, m_textLine, "gjk calls = %d, ave gjk iters = %3.1f, max gjk iters = %d", + g_debugDraw.DrawString(5, m_textLine, "gjk calls = %d, ave gjk iters = %3.1f, max gjk iters = %d", b2_gjkCalls, b2_gjkIters / float(b2_gjkCalls), b2_gjkMaxIters); - + m_textLine += m_textIncrement; } if (b2_toiCalls > 0) { - DrawString(5, m_textLine, "toi calls = %d, ave toi iters = %3.1f, max toi iters = %d", + g_debugDraw.DrawString(5, m_textLine, "toi calls = %d, ave toi iters = %3.1f, max toi iters = %d", b2_toiCalls, b2_toiIters / float(b2_toiCalls), b2_toiMaxRootIters); - + m_textLine += m_textIncrement; - DrawString(5, m_textLine, "ave toi root iters = %3.1f, max toi root iters = %d", + g_debugDraw.DrawString(5, m_textLine, "ave toi root iters = %3.1f, max toi root iters = %d", b2_toiRootIters / float(b2_toiCalls), b2_toiMaxRootIters); - + m_textLine += m_textIncrement; } if (m_stepCount % 60 == 0) diff --git a/tests/cpp-tests/Classes/Box2DTestBed/tests/car.cpp b/tests/cpp-tests/Classes/Box2DTestBed/tests/car.cpp index 63179b0526..58fa288100 100644 --- a/tests/cpp-tests/Classes/Box2DTestBed/tests/car.cpp +++ b/tests/cpp-tests/Classes/Box2DTestBed/tests/car.cpp @@ -264,8 +264,8 @@ public: void Step(Settings& settings) override { - DrawString(5, m_textLine, "Keys: left = a, brake = s, right = d, hz down = q, hz up = e"); - + g_debugDraw.DrawString(5, m_textLine, "Keys: left = a, brake = s, right = d, hz down = q, hz up = e"); + m_textLine += m_textIncrement; //g_camera.m_center.x = m_car->GetPosition().x; g_debugDraw.debugNodeOffset.x += m_car->GetPosition().x; diff --git a/tests/cpp-tests/Classes/Box2DTestBed/tests/character_collision.cpp b/tests/cpp-tests/Classes/Box2DTestBed/tests/character_collision.cpp index 42af87aec7..3eab4a744d 100644 --- a/tests/cpp-tests/Classes/Box2DTestBed/tests/character_collision.cpp +++ b/tests/cpp-tests/Classes/Box2DTestBed/tests/character_collision.cpp @@ -237,12 +237,12 @@ public: m_character->SetLinearVelocity(v); Test::Step(settings); - DrawString(5, m_textLine, "This tests various character collision shapes."); - - DrawString(5, m_textLine, "Limitation: square and hexagon can snag on aligned boxes."); - - DrawString(5, m_textLine, "Feature: edge chains have smooth collision inside and out."); - + g_debugDraw.DrawString(5, m_textLine, "This tests various character collision shapes."); + m_textLine += m_textIncrement; + g_debugDraw.DrawString(5, m_textLine, "Limitation: square and hexagon can snag on aligned boxes."); + m_textLine += m_textIncrement; + g_debugDraw.DrawString(5, m_textLine, "Feature: edge chains have smooth collision inside and out."); + m_textLine += m_textIncrement; } static Test* Create() diff --git a/tests/cpp-tests/Classes/Box2DTestBed/tests/confined.cpp b/tests/cpp-tests/Classes/Box2DTestBed/tests/confined.cpp index dc0e7cf122..3ac9bd6b87 100644 --- a/tests/cpp-tests/Classes/Box2DTestBed/tests/confined.cpp +++ b/tests/cpp-tests/Classes/Box2DTestBed/tests/confined.cpp @@ -157,8 +157,8 @@ public: } } - DrawString(5, m_textLine, "Press 'c' to create a circle."); - + g_debugDraw.DrawString(5, m_textLine, "Press 'c' to create a circle."); + m_textLine += m_textIncrement; } static Test* Create() diff --git a/tests/cpp-tests/Classes/Box2DTestBed/tests/continuous_test.cpp b/tests/cpp-tests/Classes/Box2DTestBed/tests/continuous_test.cpp index d8da4e99c1..78cc223d88 100644 --- a/tests/cpp-tests/Classes/Box2DTestBed/tests/continuous_test.cpp +++ b/tests/cpp-tests/Classes/Box2DTestBed/tests/continuous_test.cpp @@ -118,9 +118,9 @@ public: if (b2_gjkCalls > 0) { - DrawString(5, m_textLine, "gjk calls = %d, ave gjk iters = %3.1f, max gjk iters = %d", + g_debugDraw.DrawString(5, m_textLine, "gjk calls = %d, ave gjk iters = %3.1f, max gjk iters = %d", b2_gjkCalls, b2_gjkIters / float(b2_gjkCalls), b2_gjkMaxIters); - + m_textLine += m_textIncrement; } extern B2_API int32 b2_toiCalls, b2_toiIters; @@ -129,17 +129,17 @@ public: if (b2_toiCalls > 0) { - DrawString(5, m_textLine, "toi calls = %d, ave [max] toi iters = %3.1f [%d]", + g_debugDraw.DrawString(5, m_textLine, "toi calls = %d, ave [max] toi iters = %3.1f [%d]", b2_toiCalls, b2_toiIters / float(b2_toiCalls), b2_toiMaxRootIters); + m_textLine += m_textIncrement; - - DrawString(5, m_textLine, "ave [max] toi root iters = %3.1f [%d]", + g_debugDraw.DrawString(5, m_textLine, "ave [max] toi root iters = %3.1f [%d]", b2_toiRootIters / float(b2_toiCalls), b2_toiMaxRootIters); - + m_textLine += m_textIncrement; - DrawString(5, m_textLine, "ave [max] toi time = %.1f [%.1f] (microseconds)", + g_debugDraw.DrawString(5, m_textLine, "ave [max] toi time = %.1f [%.1f] (microseconds)", 1000.0f * b2_toiTime / float(b2_toiCalls), 1000.0f * b2_toiMaxTime); - + m_textLine += m_textIncrement; } if (m_stepCount % 60 == 0) diff --git a/tests/cpp-tests/Classes/Box2DTestBed/tests/convex_hull.cpp b/tests/cpp-tests/Classes/Box2DTestBed/tests/convex_hull.cpp index ac047b235e..ab56e91154 100644 --- a/tests/cpp-tests/Classes/Box2DTestBed/tests/convex_hull.cpp +++ b/tests/cpp-tests/Classes/Box2DTestBed/tests/convex_hull.cpp @@ -77,15 +77,15 @@ public: b2PolygonShape shape; shape.Set(m_points, m_count); - DrawString(5, m_textLine, "Press g to generate a new random convex hull"); - + g_debugDraw.DrawString(5, m_textLine, "Press g to generate a new random convex hull"); + m_textLine += m_textIncrement; g_debugDraw.DrawPolygon(shape.m_vertices, shape.m_count, b2Color(0.9f, 0.9f, 0.9f)); for (int32 i = 0; i < m_count; ++i) { g_debugDraw.DrawPoint(m_points[i], 3.0f, b2Color(0.3f, 0.9f, 0.3f)); - DrawString(m_points[i] + b2Vec2(0.05f, 0.05f), "%d", i); + g_debugDraw.DrawString(m_points[i] + b2Vec2(0.05f, 0.05f), "%d", i); } if (shape.Validate() == false) diff --git a/tests/cpp-tests/Classes/Box2DTestBed/tests/distance_test.cpp b/tests/cpp-tests/Classes/Box2DTestBed/tests/distance_test.cpp index 0f970de658..90496adfd7 100644 --- a/tests/cpp-tests/Classes/Box2DTestBed/tests/distance_test.cpp +++ b/tests/cpp-tests/Classes/Box2DTestBed/tests/distance_test.cpp @@ -63,11 +63,11 @@ public: b2DistanceOutput output; b2Distance(&output, &cache, &input); - DrawString(5, m_textLine, "distance = %g", output.distance); - + g_debugDraw.DrawString(5, m_textLine, "distance = %g", output.distance); + m_textLine += m_textIncrement; - DrawString(5, m_textLine, "iterations = %d", output.iterations); - + g_debugDraw.DrawString(5, m_textLine, "iterations = %d", output.iterations); + m_textLine += m_textIncrement; { b2Color color(0.9f, 0.9f, 0.9f); diff --git a/tests/cpp-tests/Classes/Box2DTestBed/tests/dump_loader.cpp b/tests/cpp-tests/Classes/Box2DTestBed/tests/dump_loader.cpp index 3225113b51..882f59b67c 100644 --- a/tests/cpp-tests/Classes/Box2DTestBed/tests/dump_loader.cpp +++ b/tests/cpp-tests/Classes/Box2DTestBed/tests/dump_loader.cpp @@ -71,8 +71,8 @@ public: float ke = 0.5f * massData.mass * b2Dot(v, v) + 0.5f * massData.I * omega * omega; - DrawString(5, m_textLine, "kinetic energy = %.6f", ke); - + g_debugDraw.DrawString(5, m_textLine, "kinetic energy = %.6f", ke); + m_textLine += m_textIncrement; Test::Step(settings); } diff --git a/tests/cpp-tests/Classes/Box2DTestBed/tests/dynamic_tree.cpp b/tests/cpp-tests/Classes/Box2DTestBed/tests/dynamic_tree.cpp index 4efcf56903..7772d5ce57 100644 --- a/tests/cpp-tests/Classes/Box2DTestBed/tests/dynamic_tree.cpp +++ b/tests/cpp-tests/Classes/Box2DTestBed/tests/dynamic_tree.cpp @@ -109,11 +109,11 @@ public: c.Set(0.6f, 0.6f, 0.9f); } - DrawAABB(&actor->aabb, c); + g_debugDraw.DrawAABB(&actor->aabb, c); } b2Color c(0.7f, 0.7f, 0.7f); - DrawAABB(&m_queryAABB, c); + g_debugDraw.DrawAABB(&m_queryAABB, c); g_debugDraw.DrawSegment(m_rayCastInput.p1, m_rayCastInput.p2, c); @@ -131,8 +131,8 @@ public: { int32 height = m_tree.GetHeight(); - DrawString(5, m_textLine, "dynamic tree height = %d", height); - + g_debugDraw.DrawString(5, m_textLine, "dynamic tree height = %d", height); + m_textLine += m_textIncrement; } ++m_stepCount; diff --git a/tests/cpp-tests/Classes/Box2DTestBed/tests/edge_shapes.cpp b/tests/cpp-tests/Classes/Box2DTestBed/tests/edge_shapes.cpp index 3792354969..6648c3c5c3 100644 --- a/tests/cpp-tests/Classes/Box2DTestBed/tests/edge_shapes.cpp +++ b/tests/cpp-tests/Classes/Box2DTestBed/tests/edge_shapes.cpp @@ -205,8 +205,8 @@ public: bool advanceRay = settings.m_pause == 0 || settings.m_singleStep; Test::Step(settings); - DrawString(5, m_textLine, "Press 1-5 to drop stuff"); - + g_debugDraw.DrawString(5, m_textLine, "Press 1-5 to drop stuff"); + m_textLine += m_textIncrement; float L = 25.0f; b2Vec2 point1(0.0f, 10.0f); diff --git a/tests/cpp-tests/Classes/Box2DTestBed/tests/gear_joint.cpp b/tests/cpp-tests/Classes/Box2DTestBed/tests/gear_joint.cpp index ddde2cfb8d..6f312837eb 100644 --- a/tests/cpp-tests/Classes/Box2DTestBed/tests/gear_joint.cpp +++ b/tests/cpp-tests/Classes/Box2DTestBed/tests/gear_joint.cpp @@ -156,13 +156,13 @@ public: ratio = m_joint4->GetRatio(); value = m_joint1->GetJointAngle() + ratio * m_joint2->GetJointAngle(); - DrawString(5, m_textLine, "theta1 + %4.2f * theta2 = %4.2f", (float) ratio, (float) value); - + g_debugDraw.DrawString(5, m_textLine, "theta1 + %4.2f * theta2 = %4.2f", (float) ratio, (float) value); + m_textLine += m_textIncrement; ratio = m_joint5->GetRatio(); value = m_joint2->GetJointAngle() + ratio * m_joint3->GetJointTranslation(); - DrawString(5, m_textLine, "theta2 + %4.2f * delta = %4.2f", (float) ratio, (float) value); - + g_debugDraw.DrawString(5, m_textLine, "theta2 + %4.2f * delta = %4.2f", (float) ratio, (float) value); + m_textLine += m_textIncrement; } static Test* Create() diff --git a/tests/cpp-tests/Classes/Box2DTestBed/tests/motor_joint.cpp b/tests/cpp-tests/Classes/Box2DTestBed/tests/motor_joint.cpp index a7b0156e9b..dcda76fa85 100644 --- a/tests/cpp-tests/Classes/Box2DTestBed/tests/motor_joint.cpp +++ b/tests/cpp-tests/Classes/Box2DTestBed/tests/motor_joint.cpp @@ -101,7 +101,7 @@ public: g_debugDraw.DrawPoint(linearOffset, 4.0f, b2Color(0.9f, 0.9f, 0.9f)); Test::Step(settings); - DrawString(5, m_textLine, "Keys: (s) pause"); + g_debugDraw.DrawString(5, m_textLine, "Keys: (s) pause"); m_textLine += 15; } diff --git a/tests/cpp-tests/Classes/Box2DTestBed/tests/pinball.cpp b/tests/cpp-tests/Classes/Box2DTestBed/tests/pinball.cpp index c7dca48db4..9a9826d79e 100644 --- a/tests/cpp-tests/Classes/Box2DTestBed/tests/pinball.cpp +++ b/tests/cpp-tests/Classes/Box2DTestBed/tests/pinball.cpp @@ -131,8 +131,8 @@ public: Test::Step(settings); - DrawString(5, m_textLine, "Press 'a' to control the flippers"); - + g_debugDraw.DrawString(5, m_textLine, "Press 'a' to control the flippers"); + m_textLine += m_textIncrement; } diff --git a/tests/cpp-tests/Classes/Box2DTestBed/tests/platformer.cpp b/tests/cpp-tests/Classes/Box2DTestBed/tests/platformer.cpp index 18b39b8a7e..388892ff53 100644 --- a/tests/cpp-tests/Classes/Box2DTestBed/tests/platformer.cpp +++ b/tests/cpp-tests/Classes/Box2DTestBed/tests/platformer.cpp @@ -115,8 +115,8 @@ public: Test::Step(settings); b2Vec2 v = m_character->GetBody()->GetLinearVelocity(); - DrawString(5, m_textLine, "Character Linear Velocity: %f", v.y); - + g_debugDraw.DrawString(5, m_textLine, "Character Linear Velocity: %f", v.y); + m_textLine += m_textIncrement; } static Test* Create() diff --git a/tests/cpp-tests/Classes/Box2DTestBed/tests/polygon_collision.cpp b/tests/cpp-tests/Classes/Box2DTestBed/tests/polygon_collision.cpp index 558ad59c27..e55f1336ff 100644 --- a/tests/cpp-tests/Classes/Box2DTestBed/tests/polygon_collision.cpp +++ b/tests/cpp-tests/Classes/Box2DTestBed/tests/polygon_collision.cpp @@ -55,8 +55,8 @@ public: b2WorldManifold worldManifold; worldManifold.Initialize(&manifold, m_transformA, m_polygonA.m_radius, m_transformB, m_polygonB.m_radius); - DrawString(5, m_textLine, "point count = %d", manifold.pointCount); - + g_debugDraw.DrawString(5, m_textLine, "point count = %d", manifold.pointCount); + m_textLine += m_textIncrement; { b2Color color(0.9f, 0.9f, 0.9f); diff --git a/tests/cpp-tests/Classes/Box2DTestBed/tests/polygon_shapes.cpp b/tests/cpp-tests/Classes/Box2DTestBed/tests/polygon_shapes.cpp index 2fa4c1cbc6..e12875b8c0 100644 --- a/tests/cpp-tests/Classes/Box2DTestBed/tests/polygon_shapes.cpp +++ b/tests/cpp-tests/Classes/Box2DTestBed/tests/polygon_shapes.cpp @@ -243,12 +243,12 @@ public: b2Color color(0.4f, 0.7f, 0.8f); g_debugDraw.DrawCircle(callback.m_circle.m_p, callback.m_circle.m_radius, color); - DrawString(5, m_textLine, "Press 1-5 to drop stuff, maximum of %d overlaps detected", PolygonShapesCallback::e_maxCount); - - DrawString(5, m_textLine, "Press 'a' to enable/disable some bodies"); - - DrawString(5, m_textLine, "Press 'd' to destroy a body"); - + g_debugDraw.DrawString(5, m_textLine, "Press 1-5 to drop stuff, maximum of %d overlaps detected", PolygonShapesCallback::e_maxCount); + m_textLine += m_textIncrement; + g_debugDraw.DrawString(5, m_textLine, "Press 'a' to enable/disable some bodies"); + m_textLine += m_textIncrement; + g_debugDraw.DrawString(5, m_textLine, "Press 'd' to destroy a body"); + m_textLine += m_textIncrement; } static Test* Create() diff --git a/tests/cpp-tests/Classes/Box2DTestBed/tests/prismatic_joint.cpp b/tests/cpp-tests/Classes/Box2DTestBed/tests/prismatic_joint.cpp index b63d6c5f92..6ffb5bda96 100644 --- a/tests/cpp-tests/Classes/Box2DTestBed/tests/prismatic_joint.cpp +++ b/tests/cpp-tests/Classes/Box2DTestBed/tests/prismatic_joint.cpp @@ -100,8 +100,8 @@ public: { Test::Step(settings); float force = m_joint->GetMotorForce(settings.m_hertz); - DrawString(5, m_textLine, "Motor Force = %4.0f", force); - + g_debugDraw.DrawString(5, m_textLine, "Motor Force = %4.0f", force); + m_textLine += m_textIncrement; } static Test* Create() diff --git a/tests/cpp-tests/Classes/Box2DTestBed/tests/pulley_joint.cpp b/tests/cpp-tests/Classes/Box2DTestBed/tests/pulley_joint.cpp index 83dcd6e283..c2ff6839c6 100644 --- a/tests/cpp-tests/Classes/Box2DTestBed/tests/pulley_joint.cpp +++ b/tests/cpp-tests/Classes/Box2DTestBed/tests/pulley_joint.cpp @@ -81,8 +81,8 @@ public: float ratio = m_joint1->GetRatio(); float L = m_joint1->GetCurrentLengthA() + ratio * m_joint1->GetCurrentLengthB(); - DrawString(5, m_textLine, "L1 + %4.2f * L2 = %4.2f", (float) ratio, (float) L); - + g_debugDraw.DrawString(5, m_textLine, "L1 + %4.2f * L2 = %4.2f", (float) ratio, (float) L); + m_textLine += m_textIncrement; } static Test* Create() diff --git a/tests/cpp-tests/Classes/Box2DTestBed/tests/ray_cast.cpp b/tests/cpp-tests/Classes/Box2DTestBed/tests/ray_cast.cpp index 4dba339838..d5041aaa4f 100644 --- a/tests/cpp-tests/Classes/Box2DTestBed/tests/ray_cast.cpp +++ b/tests/cpp-tests/Classes/Box2DTestBed/tests/ray_cast.cpp @@ -345,24 +345,24 @@ public: { Test::Step(settings); - DrawString(5, m_textLine, "Shape 1 is intentionally ignored by the ray"); - + g_debugDraw.DrawString(5, m_textLine, "Shape 1 is intentionally ignored by the ray"); + m_textLine += m_textIncrement; switch (m_mode) { case e_closest: - DrawString(5, m_textLine, "Ray-cast mode: closest - find closest fixture along the ray"); + g_debugDraw.DrawString(5, m_textLine, "Ray-cast mode: closest - find closest fixture along the ray"); break; case e_any: - DrawString(5, m_textLine, "Ray-cast mode: any - check for obstruction"); + g_debugDraw.DrawString(5, m_textLine, "Ray-cast mode: any - check for obstruction"); break; case e_multiple: - DrawString(5, m_textLine, "Ray-cast mode: multiple - gather multiple fixtures"); + g_debugDraw.DrawString(5, m_textLine, "Ray-cast mode: multiple - gather multiple fixtures"); break; } - + m_textLine += m_textIncrement; float angle = b2_pi * m_degrees / 180.0f; float L = 11.0f; diff --git a/tests/cpp-tests/Classes/Box2DTestBed/tests/revolute_joint.cpp b/tests/cpp-tests/Classes/Box2DTestBed/tests/revolute_joint.cpp index e793d86bf2..2ea31072ee 100644 --- a/tests/cpp-tests/Classes/Box2DTestBed/tests/revolute_joint.cpp +++ b/tests/cpp-tests/Classes/Box2DTestBed/tests/revolute_joint.cpp @@ -138,12 +138,12 @@ public: Test::Step(settings); float torque1 = m_joint1->GetMotorTorque(settings.m_hertz); - DrawString(5, m_textLine, "Motor Torque 1= %4.0f", torque1); - + g_debugDraw.DrawString(5, m_textLine, "Motor Torque 1= %4.0f", torque1); + m_textLine += m_textIncrement; float torque2 = m_joint2->GetMotorTorque(settings.m_hertz); - DrawString(5, m_textLine, "Motor Torque 2= %4.0f", torque2); - + g_debugDraw.DrawString(5, m_textLine, "Motor Torque 2= %4.0f", torque2); + m_textLine += m_textIncrement; } static Test* Create() diff --git a/tests/cpp-tests/Classes/Box2DTestBed/tests/rope.cpp b/tests/cpp-tests/Classes/Box2DTestBed/tests/rope.cpp index 846cfaaee6..a2815951ba 100644 --- a/tests/cpp-tests/Classes/Box2DTestBed/tests/rope.cpp +++ b/tests/cpp-tests/Classes/Box2DTestBed/tests/rope.cpp @@ -263,8 +263,8 @@ public: m_rope1.Draw(&g_debugDraw); m_rope2.Draw(&g_debugDraw); - DrawString(5, m_textLine, "Press comma and period to move left and right"); - + g_debugDraw.DrawString(5, m_textLine, "Press comma and period to move left and right"); + m_textLine += m_textIncrement; } static Test* Create() diff --git a/tests/cpp-tests/Classes/Box2DTestBed/tests/settings.h b/tests/cpp-tests/Classes/Box2DTestBed/tests/settings.h index a34f6fda0c..e4725e3d77 100644 --- a/tests/cpp-tests/Classes/Box2DTestBed/tests/settings.h +++ b/tests/cpp-tests/Classes/Box2DTestBed/tests/settings.h @@ -20,8 +20,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -#ifndef SETTINGS_H -#define SETTINGS_H +#pragma once struct Settings { @@ -81,6 +80,4 @@ struct Settings bool m_enableSleep; bool m_pause; bool m_singleStep; -}; - -#endif \ No newline at end of file +}; \ No newline at end of file diff --git a/tests/cpp-tests/Classes/Box2DTestBed/tests/shape_cast.cpp b/tests/cpp-tests/Classes/Box2DTestBed/tests/shape_cast.cpp index 2c942add28..85ce422741 100644 --- a/tests/cpp-tests/Classes/Box2DTestBed/tests/shape_cast.cpp +++ b/tests/cpp-tests/Classes/Box2DTestBed/tests/shape_cast.cpp @@ -120,9 +120,9 @@ public: b2Distance(&distanceOutput, &simplexCache, &distanceInput); - DrawString(5, m_textLine, "hit = %s, iters = %d, lambda = %g, distance = %g", + g_debugDraw.DrawString(5, m_textLine, "hit = %s, iters = %d, lambda = %g, distance = %g", hit ? "true" : "false", output.iterations, output.lambda, distanceOutput.distance); - + m_textLine += m_textIncrement; b2Vec2 vertices[b2_maxPolygonVertices]; diff --git a/tests/cpp-tests/Classes/Box2DTestBed/tests/shape_editing.cpp b/tests/cpp-tests/Classes/Box2DTestBed/tests/shape_editing.cpp index 357ed8fa28..307f295b83 100644 --- a/tests/cpp-tests/Classes/Box2DTestBed/tests/shape_editing.cpp +++ b/tests/cpp-tests/Classes/Box2DTestBed/tests/shape_editing.cpp @@ -88,10 +88,10 @@ public: void Step(Settings& settings) override { Test::Step(settings); - DrawString(5, m_textLine, "Press: (c) create a shape, (d) destroy a shape."); - - DrawString(5, m_textLine, "sensor = %d", m_sensor); - + g_debugDraw.DrawString(5, m_textLine, "Press: (c) create a shape, (d) destroy a shape."); + m_textLine += m_textIncrement; + g_debugDraw.DrawString(5, m_textLine, "sensor = %d", m_sensor); + m_textLine += m_textIncrement; } static Test* Create() diff --git a/tests/cpp-tests/Classes/Box2DTestBed/tests/skier.cpp b/tests/cpp-tests/Classes/Box2DTestBed/tests/skier.cpp index c5ff525340..94845fc1d8 100644 --- a/tests/cpp-tests/Classes/Box2DTestBed/tests/skier.cpp +++ b/tests/cpp-tests/Classes/Box2DTestBed/tests/skier.cpp @@ -126,8 +126,8 @@ public: void Step(Settings& settings) override { - DrawString(5, m_textLine, "Keys: c = Camera fixed/tracking"); - + g_debugDraw.DrawString(5, m_textLine, "Keys: c = Camera fixed/tracking"); + m_textLine += m_textIncrement; if(!m_fixed_camera) { diff --git a/tests/cpp-tests/Classes/Box2DTestBed/tests/slider_crank_2.cpp b/tests/cpp-tests/Classes/Box2DTestBed/tests/slider_crank_2.cpp index 22119e803a..546d6a1d4c 100644 --- a/tests/cpp-tests/Classes/Box2DTestBed/tests/slider_crank_2.cpp +++ b/tests/cpp-tests/Classes/Box2DTestBed/tests/slider_crank_2.cpp @@ -141,11 +141,11 @@ public: void Step(Settings& settings) override { Test::Step(settings); - DrawString(5, m_textLine, "Keys: (f) toggle friction, (m) toggle motor"); - + g_debugDraw.DrawString(5, m_textLine, "Keys: (f) toggle friction, (m) toggle motor"); + m_textLine += m_textIncrement; float torque = m_joint1->GetMotorTorque(settings.m_hertz); - DrawString(5, m_textLine, "Motor Torque = %5.0f", (float) torque); - + g_debugDraw.DrawString(5, m_textLine, "Motor Torque = %5.0f", (float) torque); + m_textLine += m_textIncrement; } static Test* Create() diff --git a/tests/cpp-tests/Classes/Box2DTestBed/tests/test.h b/tests/cpp-tests/Classes/Box2DTestBed/tests/test.h index 0d81acaa72..6c02e438d0 100644 --- a/tests/cpp-tests/Classes/Box2DTestBed/tests/test.h +++ b/tests/cpp-tests/Classes/Box2DTestBed/tests/test.h @@ -27,6 +27,8 @@ class Test; struct Settings; + + #define RAND_LIMIT 32767 #define DRAW_STRING_NEW_LINE 25 @@ -111,15 +113,9 @@ public: void ShiftOrigin(const b2Vec2& newOrigin); - void initShader(void); - void DrawString(int x, int y, const char* fmt, ...); - void DrawString(const b2Vec2& p, const char* fmt, ...); - void DrawAABB(b2AABB* aabb, const b2Color& color); - void Flush(); - - cocos2d::extension::PhysicsDebugNodeBox2D g_debugDraw; + DebugDraw g_debugDraw; cocos2d::DrawNode* debugDrawNode; - std::string debugString = ""; + b2World* m_world; diff --git a/tests/cpp-tests/Classes/Box2DTestBed/tests/theo_jansen.cpp b/tests/cpp-tests/Classes/Box2DTestBed/tests/theo_jansen.cpp index 4ff62c7a5d..a3155acf9c 100644 --- a/tests/cpp-tests/Classes/Box2DTestBed/tests/theo_jansen.cpp +++ b/tests/cpp-tests/Classes/Box2DTestBed/tests/theo_jansen.cpp @@ -222,8 +222,8 @@ public: void Step(Settings& settings) override { - DrawString(5, m_textLine, "Keys: left = a, brake = s, right = d, toggle motor = m"); - + g_debugDraw.DrawString(5, m_textLine, "Keys: left = a, brake = s, right = d, toggle motor = m"); + m_textLine += m_textIncrement; Test::Step(settings); } diff --git a/tests/cpp-tests/Classes/Box2DTestBed/tests/tiles.cpp b/tests/cpp-tests/Classes/Box2DTestBed/tests/tiles.cpp index 9457862196..e6a4e56143 100644 --- a/tests/cpp-tests/Classes/Box2DTestBed/tests/tiles.cpp +++ b/tests/cpp-tests/Classes/Box2DTestBed/tests/tiles.cpp @@ -130,14 +130,14 @@ public: int32 leafCount = cm.m_broadPhase.GetProxyCount(); int32 minimumNodeCount = 2 * leafCount - 1; float minimumHeight = ceilf(logf(float(minimumNodeCount)) / logf(2.0f)); - DrawString(5, m_textLine, "dynamic tree height = %d, min = %d", height, int32(minimumHeight)); - + g_debugDraw.DrawString(5, m_textLine, "dynamic tree height = %d, min = %d", height, int32(minimumHeight)); + m_textLine += m_textIncrement; Test::Step(settings); - DrawString(5, m_textLine, "create time = %6.2f ms, fixture count = %d", + g_debugDraw.DrawString(5, m_textLine, "create time = %6.2f ms, fixture count = %d", m_createTime, m_fixtureCount); - + m_textLine += m_textIncrement; //b2DynamicTree* tree = &m_world->m_contactManager.m_broadPhase.m_tree; diff --git a/tests/cpp-tests/Classes/Box2DTestBed/tests/time_of_impact.cpp b/tests/cpp-tests/Classes/Box2DTestBed/tests/time_of_impact.cpp index 3face36e22..25362bf23c 100644 --- a/tests/cpp-tests/Classes/Box2DTestBed/tests/time_of_impact.cpp +++ b/tests/cpp-tests/Classes/Box2DTestBed/tests/time_of_impact.cpp @@ -69,12 +69,12 @@ public: b2TimeOfImpact(&output, &input); - DrawString(5, m_textLine, "toi = %g", output.t); - + g_debugDraw.DrawString(5, m_textLine, "toi = %g", output.t); + m_textLine += m_textIncrement; extern B2_API int32 b2_toiMaxIters, b2_toiMaxRootIters; - DrawString(5, m_textLine, "max toi iters = %d, max root iters = %d", b2_toiMaxIters, b2_toiMaxRootIters); - + g_debugDraw.DrawString(5, m_textLine, "max toi iters = %d, max root iters = %d", b2_toiMaxIters, b2_toiMaxRootIters); + m_textLine += m_textIncrement; b2Vec2 vertices[b2_maxPolygonVertices]; diff --git a/tests/cpp-tests/Classes/Box2DTestBed/tests/web.cpp b/tests/cpp-tests/Classes/Box2DTestBed/tests/web.cpp index fdacf8aa80..aefa46ac97 100644 --- a/tests/cpp-tests/Classes/Box2DTestBed/tests/web.cpp +++ b/tests/cpp-tests/Classes/Box2DTestBed/tests/web.cpp @@ -190,8 +190,8 @@ public: void Step(Settings& settings) override { Test::Step(settings); - DrawString(5, m_textLine, "Press: (b) to delete a body, (j) to delete a joint"); - + g_debugDraw.DrawString(5, m_textLine, "Press: (b) to delete a body, (j) to delete a joint"); + m_textLine += m_textIncrement; } void JointDestroyed(b2Joint* joint) override diff --git a/tests/cpp-tests/Classes/Box2DTestBed/tests/wheel_joint.cpp b/tests/cpp-tests/Classes/Box2DTestBed/tests/wheel_joint.cpp index 6be76ff262..4c5d6e7cd7 100644 --- a/tests/cpp-tests/Classes/Box2DTestBed/tests/wheel_joint.cpp +++ b/tests/cpp-tests/Classes/Box2DTestBed/tests/wheel_joint.cpp @@ -80,12 +80,12 @@ public: Test::Step(settings); float torque = m_joint->GetMotorTorque(settings.m_hertz); - DrawString(5, m_textLine, "Motor Torque = %4.0f", torque); - + g_debugDraw.DrawString(5, m_textLine, "Motor Torque = %4.0f", torque); + m_textLine += m_textIncrement; b2Vec2 F = m_joint->GetReactionForce(settings.m_hertz); - DrawString(5, m_textLine, "Reaction Force = (%4.1f, %4.1f)", F.x, F.y); - + g_debugDraw.DrawString(5, m_textLine, "Reaction Force = (%4.1f, %4.1f)", F.x, F.y); + m_textLine += m_textIncrement; } void UpdateUI() override diff --git a/tests/cpp-tests/Classes/Box2DTestBed/tests/wrecking_ball.cpp b/tests/cpp-tests/Classes/Box2DTestBed/tests/wrecking_ball.cpp index c1722a61cb..b84511f48f 100644 --- a/tests/cpp-tests/Classes/Box2DTestBed/tests/wrecking_ball.cpp +++ b/tests/cpp-tests/Classes/Box2DTestBed/tests/wrecking_ball.cpp @@ -143,13 +143,13 @@ public: if (m_distanceJoint) { - DrawString(5, m_textLine, "Distance Joint ON"); + g_debugDraw.DrawString(5, m_textLine, "Distance Joint ON"); } else { - DrawString(5, m_textLine, "Distance Joint OFF"); + g_debugDraw.DrawString(5, m_textLine, "Distance Joint OFF"); } - + m_textLine += m_textIncrement; } static Test* Create() diff --git a/tests/cpp-tests/Classes/SpriteFrameCacheTest/SpriteFrameCacheTest.cpp b/tests/cpp-tests/Classes/SpriteFrameCacheTest/SpriteFrameCacheTest.cpp index 650aca986b..283f12b2b4 100644 --- a/tests/cpp-tests/Classes/SpriteFrameCacheTest/SpriteFrameCacheTest.cpp +++ b/tests/cpp-tests/Classes/SpriteFrameCacheTest/SpriteFrameCacheTest.cpp @@ -57,12 +57,11 @@ SpriteFrameCachePixelFormatTest::SpriteFrameCachePixelFormatTest() loadSpriteFrames("Images/sprite_frames_test/test_A8.plist", backend::PixelFormat::A8); loadSpriteFrames("Images/sprite_frames_test/test_RGBA8888.plist", backend::PixelFormat::RGBA8); loadSpriteFrames("Images/sprite_frames_test/test_AI88.plist", backend::PixelFormat::LA8); - loadSpriteFrames("Images/sprite_frames_test/test_RGBA8888.plist", backend::PixelFormat::RGBA8); loadSpriteFrames("Images/sprite_frames_test/test_RGB565.plist", backend::PixelFormat::RGB565); loadSpriteFrames("Images/sprite_frames_test/test_RGB888.plist", backend::PixelFormat::RGB8); loadSpriteFrames("Images/sprite_frames_test/test_RGBA4444.plist", backend::PixelFormat::RGBA4); loadSpriteFrames("Images/sprite_frames_test/test_RGBA5551.plist", backend::PixelFormat::RGB5A1); - + if (Configuration::getInstance()->supportsPVRTC()) { loadSpriteFrames("Images/sprite_frames_test/test_PVRTC2.plist", backend::PixelFormat::PVRTC2A); loadSpriteFrames("Images/sprite_frames_test/test_PVRTC4.plist", backend::PixelFormat::PVRTC4A); @@ -80,7 +79,7 @@ SpriteFrameCachePixelFormatTest::SpriteFrameCachePixelFormatTest() void SpriteFrameCachePixelFormatTest::loadSpriteFrames(const std::string &file, cocos2d::backend::PixelFormat expectedFormat) { SpriteFrameCache::getInstance()->addSpriteFramesWithFile(file); - SpriteFrame *spriteFrame = SpriteFrameCache::getInstance()->getSpriteFrameByName("grossini.png"); + SpriteFrame *spriteFrame = SpriteFrameCache::getInstance()->getSpriteFrameByName("sprite_frames_test/grossini.png"); Texture2D *texture = spriteFrame->getTexture(); const ssize_t bitsPerKB = 8 * 1024; const double memorySize = 1.0 * texture->getBitsPerPixelForFormat() * texture->getContentSizeInPixels().width * texture->getContentSizeInPixels().height / bitsPerKB; @@ -110,11 +109,11 @@ SpriteFrameCacheLoadMultipleTimes::SpriteFrameCacheLoadMultipleTimes() void SpriteFrameCacheLoadMultipleTimes::loadSpriteFrames(const std::string &file, cocos2d::backend::PixelFormat expectedFormat) { SpriteFrameCache::getInstance()->addSpriteFramesWithFile(file); - SpriteFrame *spriteFrame = SpriteFrameCache::getInstance()->getSpriteFrameByName("grossini.png"); + SpriteFrame *spriteFrame = SpriteFrameCache::getInstance()->getSpriteFrameByName("sprite_frames_test/grossini.png"); Texture2D *texture = spriteFrame->getTexture(); CC_ASSERT(texture->getPixelFormat() == expectedFormat); - SpriteFrameCache::getInstance()->removeSpriteFrameByName("grossini.png"); + SpriteFrameCache::getInstance()->removeSpriteFrameByName("sprite_frames_test/grossini.png"); Director::getInstance()->getTextureCache()->removeTexture(texture); } @@ -491,7 +490,7 @@ SpriteFrameCacheJsonAtlasTest::~SpriteFrameCacheJsonAtlasTest() void SpriteFrameCacheJsonAtlasTest::loadSpriteFrames(const std::string& file, cocos2d::backend::PixelFormat expectedFormat) { SpriteFrameCache::getInstance()->addSpriteFramesWithFile(file, GenericJsonArraySpriteSheetLoader::FORMAT); - SpriteFrame* spriteFrame = SpriteFrameCache::getInstance()->getSpriteFrameByName("grossini.png"); + SpriteFrame* spriteFrame = SpriteFrameCache::getInstance()->getSpriteFrameByName("sprite_frames_test/grossini.png"); Texture2D* texture = spriteFrame->getTexture(); const ssize_t bitsPerKB = 8 * 1024; const double memorySize = 1.0 * texture->getBitsPerPixelForFormat() * texture->getContentSizeInPixels().width * texture->getContentSizeInPixels().height / bitsPerKB; diff --git a/tests/cpp-tests/Classes/SpritePolygonTest/SpritePolygonTest.cpp b/tests/cpp-tests/Classes/SpritePolygonTest/SpritePolygonTest.cpp index 3bc3c9413f..5596a281d3 100644 --- a/tests/cpp-tests/Classes/SpritePolygonTest/SpritePolygonTest.cpp +++ b/tests/cpp-tests/Classes/SpritePolygonTest/SpritePolygonTest.cpp @@ -123,7 +123,7 @@ void SpritePolygonTestCase::updateDrawNode() //draw 3 lines Vec3 from = verts[indices[i*3]].vertices; Vec3 to = verts[indices[i*3+1]].vertices; - drawnode->drawLine(Vec2(from.x, from.y), Vec2(to.x,to.y), Color4F::BLUE); + drawnode->drawLine(Vec2(from.x, from.y), Vec2(to.x,to.y), Color4F::GREEN); from = verts[indices[i*3+1]].vertices; to = verts[indices[i*3+2]].vertices; @@ -131,7 +131,7 @@ void SpritePolygonTestCase::updateDrawNode() from = verts[indices[i*3+2]].vertices; to = verts[indices[i*3]].vertices; - drawnode->drawLine(Vec2(from.x, from.y), Vec2(to.x,to.y), Color4F::RED); + drawnode->drawLine(Vec2(from.x, from.y), Vec2(to.x,to.y), Color4F::GREEN); } } } @@ -791,7 +791,7 @@ void SpritePolygonTestFrameAnim::initSprites() _drawNodes.pushBack(spDrawNode); } - + updateDrawNode(); Vector animFrames(5); @@ -803,8 +803,6 @@ void SpritePolygonTestFrameAnim::initSprites() auto animation = Animation::createWithSpriteFrames(animFrames, 0.3f); sprite->runAction(RepeatForever::create(Animate::create(animation))); - - updateDrawNode(); } // diff --git a/tests/cpp-tests/Classes/SpriteTest/SpriteTest.cpp b/tests/cpp-tests/Classes/SpriteTest/SpriteTest.cpp index 66e7ea6e26..6a0eb5f2dc 100644 --- a/tests/cpp-tests/Classes/SpriteTest/SpriteTest.cpp +++ b/tests/cpp-tests/Classes/SpriteTest/SpriteTest.cpp @@ -5627,7 +5627,7 @@ SpriteSlice9Test10::SpriteSlice9Test10() SpriteFrameCache::getInstance()->addSpriteFramesWithFile("Images/blocks9ss.plist"); - auto s1 = Sprite::createWithSpriteFrameName("blocks9r.png"); + auto s1 = Sprite::createWithSpriteFrameName("blocks9ss/blocks9r.png"); addChild(s1); s1->setPosition(s.width/2-s.width/3, s.height/2); s1->setAnchorPoint(Vec2::ANCHOR_MIDDLE); @@ -5635,7 +5635,7 @@ SpriteSlice9Test10::SpriteSlice9Test10() s1->setContentSize(s1->getContentSize()*1.5); s1->setFlippedX(true); - auto s2 = Sprite::createWithSpriteFrameName("blocks9r.png"); + auto s2 = Sprite::createWithSpriteFrameName("blocks9ss/blocks9r.png"); addChild(s2); s2->setPosition(s.width*2/4, s.height/2); s2->setAnchorPoint(Vec2::ANCHOR_MIDDLE); @@ -5643,7 +5643,7 @@ SpriteSlice9Test10::SpriteSlice9Test10() s2->setContentSize(s2->getContentSize()*1.5); //Create reference sprite that's rotating based on there anchor point - auto s3 = Sprite::createWithSpriteFrameName("blocks9r.png"); + auto s3 = Sprite::createWithSpriteFrameName("blocks9ss/blocks9r.png"); addChild(s3); s3->setPosition(s.width/2+s.width/3, s.height/2); s3->setAnchorPoint(Vec2::ANCHOR_MIDDLE); @@ -5666,7 +5666,7 @@ Issue17119::Issue17119() SpriteFrameCache::getInstance()->addSpriteFramesWithFile("Images/blocks9ss.plist"); - auto s1 = Sprite::createWithSpriteFrameName("firstPic.png"); + auto s1 = Sprite::createWithSpriteFrameName("issue_17119/firstPic.png"); addChild(s1); s1->setPosition(s.width/2-s.width/3, s.height/2); s1->setScale(0.25f); @@ -5675,7 +5675,7 @@ Issue17119::Issue17119() p1->setPosition(s1->getPosition()); addChild(p1, 10); - auto s2 = Sprite::createWithSpriteFrameName("blocks9r.png"); + auto s2 = Sprite::createWithSpriteFrameName("blocks9ss/blocks9r.png"); addChild(s2); s2->setPosition(s.width/2, s.height/2); s2->setCenterRectNormalized(Rect(1/3.f, 1/3.f, 1/3.f, 1/3.f)); diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest.cpp index 66c6a762ff..d1fc43e221 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest.cpp @@ -1230,7 +1230,7 @@ bool Issue17116::init() SpriteFrameCache::getInstance()->addSpriteFramesWithFile("Images/issue_17116.plist"); auto button = ui::Button::create(); - button->loadTextureNormal("buttons/play-big", ui::Widget::TextureResType::PLIST); + button->loadTextureNormal("issue_17116/buttons/play-big", ui::Widget::TextureResType::PLIST); button->setPosition(Vec2(visibleSize.width/2, visibleSize.height/2)); button->setOpacity(100); addChild(button); diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIImageViewTest/UIImageViewTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIImageViewTest/UIImageViewTest.cpp index c58ec5c895..1eb2851be7 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIImageViewTest/UIImageViewTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIImageViewTest/UIImageViewTest.cpp @@ -244,7 +244,7 @@ bool UIImageViewFlipTest::init() _uiLayer->addChild(alert); // Create the imageview - ImageView* imageView = ImageView::create("blocks9r.png", Widget::TextureResType::PLIST); + ImageView* imageView = ImageView::create("blocks9ss/blocks9r.png", Widget::TextureResType::PLIST); imageView->setScale9Enabled(true); imageView->setContentSize(Size(250, 115)); imageView->setFlippedX(true); @@ -296,7 +296,7 @@ bool UIImageViewIssue12249Test::init() _uiLayer->addChild(alert); // Create the imageview - ImageView* imageView = ImageView::create("blocks9r.png", Widget::TextureResType::PLIST); + ImageView* imageView = ImageView::create("blocks9ss/blocks9r.png", Widget::TextureResType::PLIST); imageView->setScale9Enabled(true); imageView->setContentSize(Size(250, imageView->getContentSize().height * 2)); imageView->setFlippedX(true); diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScale9SpriteTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScale9SpriteTest.cpp index 6f770269d8..f54a102376 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScale9SpriteTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScale9SpriteTest.cpp @@ -305,7 +305,7 @@ bool UIS9FrameNameSpriteSheet::init() SpriteFrameCache::getInstance()->addSpriteFramesWithFile(s_s9s_blocks9_plist); - auto blocks = ui::Scale9Sprite::createWithSpriteFrameName("blocks9.png"); + auto blocks = ui::Scale9Sprite::createWithSpriteFrameName("blocks9ss/blocks9.png"); blocks->setInsetLeft(0); blocks->setInsetRight(0); blocks->setInsetTop(0); @@ -480,7 +480,7 @@ bool UIS9FrameNameSpriteSheetScaledNoInsets::init() float y = 0 + (winSize.height / 2); SpriteFrameCache::getInstance()->addSpriteFramesWithFile(s_s9s_blocks9_plist); - auto blocks_scaled = ui::Scale9Sprite::createWithSpriteFrameName("blocks9.png"); + auto blocks_scaled = ui::Scale9Sprite::createWithSpriteFrameName("blocks9ss/blocks9.png"); blocks_scaled->setPosition(Vec2(x, y)); @@ -551,7 +551,7 @@ bool UIS9FrameNameSpriteSheetInsets::init() float y = 0 + (winSize.height / 2); - auto blocks_with_insets = ui::Scale9Sprite::createWithSpriteFrameName("blocks9.png", Rect(32, 32, 32, 32)); + auto blocks_with_insets = ui::Scale9Sprite::createWithSpriteFrameName("blocks9ss/blocks9.png", Rect(32, 32, 32, 32)); blocks_with_insets->setPosition(Vec2(x, y)); @@ -570,7 +570,7 @@ bool UIS9FrameNameSpriteSheetInsetsScaled::init() float x = winSize.width / 2; float y = 0 + (winSize.height / 2); - auto blocks_scaled_with_insets = ui::Scale9Sprite::createWithSpriteFrameName("blocks9.png", Rect(32, 32, 32, 32)); + auto blocks_scaled_with_insets = ui::Scale9Sprite::createWithSpriteFrameName("blocks9ss/blocks9.png", Rect(32, 32, 32, 32)); blocks_scaled_with_insets->setContentSize(Size(96 * 4.5, 96 * 2.5)); @@ -642,7 +642,7 @@ bool UIS9FrameNameSpriteSheetRotatedInsetsScaled::init() float x = winSize.width / 2; float y = 0 + (winSize.height / 2); - auto blocks_scaled_with_insets = ui::Scale9Sprite::createWithSpriteFrameName("blocks9.png", Rect(32, 32, 32, 32)); + auto blocks_scaled_with_insets = ui::Scale9Sprite::createWithSpriteFrameName("blocks9ss/blocks9.png", Rect(32, 32, 32, 32)); blocks_scaled_with_insets->setContentSize(Size(96 * 4.5, 96 * 2.5)); @@ -988,7 +988,7 @@ bool UIS9BatchTest::init() this->addChild(label); auto preferedSize = Size(150.0f,99.0f); - std::vector spriteFrameNameArray = {"blocks9.png", "blocks9r.png"}; + std::vector spriteFrameNameArray = {"blocks9ss/blocks9.png", "blocks9ss/blocks9r.png"}; auto addSpriteButton = ui::Button::create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png"); addSpriteButton->setPosition(Vec2(winSize.width/2 - 50,winSize.height - 100)); addSpriteButton->setTitleText("Add Normal Sprite");