diff --git a/.travis.yml b/.travis.yml index 1739a0557d..1bccfbf9d6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -37,4 +37,4 @@ before_install: # whitelist branches: only: - - v3.8 + - v3 diff --git a/AUTHORS b/AUTHORS index 696cef8b7a..331a7f56a7 100644 --- a/AUTHORS +++ b/AUTHORS @@ -412,6 +412,7 @@ Developers: UI: Added ScrollViewBar for displaying a scroll bar at the side of ScrollView UI: Added RadioButton widget UI: Refined scroll event dispatching for ScrollView + platform: Fixed Android app occasionally freeze issue caused by Cocos2dxRenderer.nativeOnResume() is not called when the activity is resumed Sam Clegg (sbc100) Author of Native Client port. diff --git a/CHANGELOG b/CHANGELOG index 1eb672ca75..e6c0c7f48e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,4 @@ +cocos2d-x-3.8 final September.6 2015 cocos2d-x-3.8 rc0 August.26 2015 cocos2d-x-3.8 beta0 August.14 2015 @@ -7,7 +8,7 @@ cocos2d-x-3.8 beta0 August.14 2015 [HIGHLIGHT] FileUtils: Added a set of file writing APIs: writeStringToFile, writeDataToFile, writeValueMapToFile, writeValueVectorToFile [HIGHLIGHT] UI: Refined UI system [HIGHLIGHT] UI: Added RadioButton widget (JSB/Lua ready) - [HIGHLIGHT] UI: Reimplemented and enhanced EditBox on Android + [HIGHLIGHT] UI: Reimplemented and enhanced EditBox on Android: display cursor; support copy, cut, paste and select actions; support multi-line input; pretty adjustment when virtual keyboard shown [HIGHLIGHT] JS: Bound new AudioEngine in JSB [HIGHLIGHT] JS: Merged JSB test project into cocos2d test project [HIGHLIGHT] network: Upgrade SocketIO support to v1.x @@ -27,6 +28,7 @@ cocos2d-x-3.8 beta0 August.14 2015 [NEW] audio: AudioEngine supported audio preloading [NEW] UserDefault: Supported removing key pairs from UserDefault [NEW] spine: Supported Spine runtime 2.3 (Both native and web engine) + [NEW] JS: Added auto binding for BlendFuncFrame [NEW] console: Supported new portrait projects from templates [NEW] console: Moved the framework-compile tools into cocos2d-console [NEW] framework: Support generate prebuilt libs of engine with debug mode @@ -35,6 +37,10 @@ cocos2d-x-3.8 beta0 August.14 2015 [REFINE] 3D: Supported composite 2D/3D scene by moving UI and camera far away [REFINE] 3D: Improved Particle3D performance [REFINE] 3D: Made SkyBox not transparent + [REFINE] 3D: Enable depth write for SkyBox + [REFINE] 3D: Enable depth write for transparent object + [REFINE] 3D: Set depth test function of Skybox brush to always + [REFINE] renderer: Enabled blending all the time for 2D render queue [REFINE] Director: Made types to handle time consistent by modifing setAnimationInterval argument from double to float [REFINE] Sprite: Made Sprite::setTexture accept nullptr as parameter [REFINE] TextureCache: Made addImageAsync function thread safe @@ -52,6 +58,7 @@ cocos2d-x-3.8 beta0 August.14 2015 [REFINE] studio: Avoid CSLoader from openning csb file multiple times with fopen [REFINE] studio: Added BlendFrame support to Skeleton Animation [REFINE] studio: Enabled blendfunc cascade to the skin of BoneNode + [REFINE] studio: Update reader with parse logic for valid attribute of SkyBox [REFINE] FileUtils: Remove old path while adding existing search path [REFINE] Device: Implemented Device::getDPI for Mac [REFINE] network: Refine NSLog in HttpAsynConnection in release mode @@ -92,6 +99,7 @@ cocos2d-x-3.8 beta0 August.14 2015 [FIX] renderer: Fixed shader issue by reloading shader when light number changed [FIX] Scheduler: Fixed timer's delta time is error when interval equals to zero [FIX] Scheduler: Fixed Pause/Resume act incorrectly + [FIX] Scheduler: Fixed the callback will be executed multiple times if the value of delay parameter equal zero [FIX] Node: Fixed issue that euler angle is NaN when update Euler angle from quaternion and asin value is not between -1 and 1 by accident [FIX] Scene: Fixed bug that can't add custom member to Scene subclass [FIX] Sprite: Fixed some warnings and a related bug in CCSprite @@ -131,6 +139,9 @@ cocos2d-x-3.8 beta0 August.14 2015 [FIX] UI: Fixed EditBox input maxLength for Chinese character issue on iOS [FIX] UI: Fixed EditBox turning black when soft keyboard hiding [FIX] UI: Fixed scrollview innerContainer initial position error + [FIX] UI: Fixed issue that Slider create function is not taking account of res type (TextureResType) + [FIX] Scale9Sprite: Fixed Scale9Sprite default capInset bug + [FIX] Scale9Sprite: Fixed issue that Scale9Sprite draw extra 1 pixel when creating from spritesheet [FIX] studio: Removed "using namespace cocos2d" from CCFrame.h [FIX] studio: Fixed the SkyBox display error while parsed from editor files [FIX] studio: Fixed userCamera flag error while parsing old version exported files @@ -138,6 +149,8 @@ cocos2d-x-3.8 beta0 August.14 2015 [FIX] studio: Fixed crash when loading cocostudio json files with null or empty fontName [FIX] studio: Fixed bug that setColor works on a whole armature, but not on an individual bone [FIX] studio: Fixed object size error while data is error + [FIX] studio: Fixed issue that bone's color and opacity cannot cascade to bone + [FIX] studio: Fixed issue that bone can be see by other cameras [FIX] ClippingNode: Removed CCClippingRectangleNode transform error support [FIX] spine: Fixed the position of debug draw of bones is incorrect [FIX] spine: Fixed memory leak caused by SkeletonRenderer::initialize @@ -174,6 +187,7 @@ cocos2d-x-3.8 beta0 August.14 2015 [FIX] platform: Removed unneeded protocol for AppController on iOS [FIX] platform: Fixed link errors in release mode on win32 [FIX] platform: Fixed Windows 10 UWP and WP8.1 app certification issue + [FIX] platform: Fixed Android app occasionally freeze issue caused by Cocos2dxRenderer.nativeOnResume() is not called when the activity is resumed [FIX] web: Fixed a bug that VideoPlayer remove event throw error [FIX] web: Fixed Armature position error in studio JSON parser [FIX] web: Fixed default clearColor error in director @@ -187,6 +201,9 @@ cocos2d-x-3.8 beta0 August.14 2015 [FIX] web: Fixed logic issue in Menu's _onTouchCancelled function [FIX] web: Fixed MenuItem crash when normal image is null [FIX] web: Fixed CCTouch's startPoint unset issue + [FIX] web: Fixed incomplete fadeout effects + [FIX] web: Fixed issue that return value of cc.screen.fullScreen is not boolean + [FIX] web: Fixed a bug that SkeletonNode is not drawing children [TEST] 3D: Avoid to trigger touch event multiple times in Physics3D Test and Physics3D Constraint Test [TEST] 3D: Fixed Sprite3D test background to foreground bug diff --git a/build/cocos2d_libs.xcodeproj/project.pbxproj b/build/cocos2d_libs.xcodeproj/project.pbxproj index 6f97b84ffa..3f1361a1e8 100644 --- a/build/cocos2d_libs.xcodeproj/project.pbxproj +++ b/build/cocos2d_libs.xcodeproj/project.pbxproj @@ -1224,6 +1224,8 @@ 299754F5193EC95400A54AC3 /* ObjectFactory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 299754F2193EC95400A54AC3 /* ObjectFactory.cpp */; }; 299754F6193EC95400A54AC3 /* ObjectFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = 299754F3193EC95400A54AC3 /* ObjectFactory.h */; }; 299754F7193EC95400A54AC3 /* ObjectFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = 299754F3193EC95400A54AC3 /* ObjectFactory.h */; }; + 299B15AC1B93FC530008E196 /* UIEditBoxImpl-common.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 299B15AA1B93FC530008E196 /* UIEditBoxImpl-common.cpp */; }; + 299B15AD1B93FC530008E196 /* UIEditBoxImpl-common.h in Headers */ = {isa = PBXBuildFile; fileRef = 299B15AB1B93FC530008E196 /* UIEditBoxImpl-common.h */; }; 299CF1FB19A434BC00C378C1 /* ccRandom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 299CF1F919A434BC00C378C1 /* ccRandom.cpp */; }; 299CF1FC19A434BC00C378C1 /* ccRandom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 299CF1F919A434BC00C378C1 /* ccRandom.cpp */; }; 299CF1FD19A434BC00C378C1 /* ccRandom.h in Headers */ = {isa = PBXBuildFile; fileRef = 299CF1FA19A434BC00C378C1 /* ccRandom.h */; }; @@ -1361,6 +1363,14 @@ 46C02E0818E91123004B7456 /* xxhash.c in Sources */ = {isa = PBXBuildFile; fileRef = 46C02E0518E91123004B7456 /* xxhash.c */; }; 46C02E0918E91123004B7456 /* xxhash.h in Headers */ = {isa = PBXBuildFile; fileRef = 46C02E0618E91123004B7456 /* xxhash.h */; }; 46C02E0A18E91123004B7456 /* xxhash.h in Headers */ = {isa = PBXBuildFile; fileRef = 46C02E0618E91123004B7456 /* xxhash.h */; }; + 46EE47511B817EFD00100730 /* CCComponentPhysics2d.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46EE474D1B817EFD00100730 /* CCComponentPhysics2d.cpp */; }; + 46EE47521B817EFD00100730 /* CCComponentPhysics2d.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46EE474D1B817EFD00100730 /* CCComponentPhysics2d.cpp */; }; + 46EE47531B817EFD00100730 /* CCComponentPhysics2d.h in Headers */ = {isa = PBXBuildFile; fileRef = 46EE474E1B817EFD00100730 /* CCComponentPhysics2d.h */; }; + 46EE47541B817EFD00100730 /* CCComponentPhysics2d.h in Headers */ = {isa = PBXBuildFile; fileRef = 46EE474E1B817EFD00100730 /* CCComponentPhysics2d.h */; }; + 46EE47551B817EFD00100730 /* CCPhysicsManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46EE474F1B817EFD00100730 /* CCPhysicsManager.cpp */; }; + 46EE47561B817EFD00100730 /* CCPhysicsManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46EE474F1B817EFD00100730 /* CCPhysicsManager.cpp */; }; + 46EE47571B817EFD00100730 /* CCPhysicsManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 46EE47501B817EFD00100730 /* CCPhysicsManager.h */; }; + 46EE47581B817EFD00100730 /* CCPhysicsManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 46EE47501B817EFD00100730 /* CCPhysicsManager.h */; }; 4D76BE3A1A4AAF0A00102962 /* CCActionTimelineNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D76BE381A4AAF0A00102962 /* CCActionTimelineNode.cpp */; }; 4D76BE3B1A4AAF0A00102962 /* CCActionTimelineNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D76BE381A4AAF0A00102962 /* CCActionTimelineNode.cpp */; }; 4D76BE3C1A4AAF0A00102962 /* CCActionTimelineNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 4D76BE391A4AAF0A00102962 /* CCActionTimelineNode.h */; }; @@ -4108,6 +4118,8 @@ 2986667918B1B079000E39CA /* CCTweenFunction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCTweenFunction.h; sourceTree = ""; }; 299754F2193EC95400A54AC3 /* ObjectFactory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ObjectFactory.cpp; path = ../base/ObjectFactory.cpp; sourceTree = ""; }; 299754F3193EC95400A54AC3 /* ObjectFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ObjectFactory.h; path = ../base/ObjectFactory.h; sourceTree = ""; }; + 299B15AA1B93FC530008E196 /* UIEditBoxImpl-common.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = "UIEditBoxImpl-common.cpp"; sourceTree = ""; }; + 299B15AB1B93FC530008E196 /* UIEditBoxImpl-common.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIEditBoxImpl-common.h"; sourceTree = ""; }; 299CF1F919A434BC00C378C1 /* ccRandom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ccRandom.cpp; path = ../base/ccRandom.cpp; sourceTree = ""; }; 299CF1FA19A434BC00C378C1 /* ccRandom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ccRandom.h; path = ../base/ccRandom.h; sourceTree = ""; }; 29BDBA52195D597A003225C9 /* UIDeprecated.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UIDeprecated.cpp; sourceTree = ""; }; @@ -4350,6 +4362,10 @@ 46A170781807CE7A005B8026 /* CCPhysicsWorld.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCPhysicsWorld.h; sourceTree = ""; }; 46C02E0518E91123004B7456 /* xxhash.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = xxhash.c; sourceTree = ""; }; 46C02E0618E91123004B7456 /* xxhash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = xxhash.h; sourceTree = ""; }; + 46EE474D1B817EFD00100730 /* CCComponentPhysics2d.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCComponentPhysics2d.cpp; sourceTree = ""; }; + 46EE474E1B817EFD00100730 /* CCComponentPhysics2d.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCComponentPhysics2d.h; sourceTree = ""; }; + 46EE474F1B817EFD00100730 /* CCPhysicsManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCPhysicsManager.cpp; sourceTree = ""; }; + 46EE47501B817EFD00100730 /* CCPhysicsManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCPhysicsManager.h; sourceTree = ""; }; 4D76BE381A4AAF0A00102962 /* CCActionTimelineNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCActionTimelineNode.cpp; sourceTree = ""; }; 4D76BE391A4AAF0A00102962 /* CCActionTimelineNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCActionTimelineNode.h; sourceTree = ""; }; 5012168C1AC47380009A4BEA /* CCRenderState.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCRenderState.cpp; sourceTree = ""; }; @@ -6816,6 +6832,8 @@ 292DB12E19B4574100A80320 /* UIEditBox */ = { isa = PBXGroup; children = ( + 299B15AA1B93FC530008E196 /* UIEditBoxImpl-common.cpp */, + 299B15AB1B93FC530008E196 /* UIEditBoxImpl-common.h */, 50ED2BDC19BEAF7900A0AB90 /* UIEditBoxImpl-win32.h */, 50ED2BDE19BEAF7900A0AB90 /* UIEditBoxImpl-win32.cpp */, 292DB12F19B4574100A80320 /* UIEditBox.cpp */, @@ -7362,6 +7380,10 @@ 46A170611807CE7A005B8026 /* physics */ = { isa = PBXGroup; children = ( + 46EE474D1B817EFD00100730 /* CCComponentPhysics2d.cpp */, + 46EE474E1B817EFD00100730 /* CCComponentPhysics2d.h */, + 46EE474F1B817EFD00100730 /* CCPhysicsManager.cpp */, + 46EE47501B817EFD00100730 /* CCPhysicsManager.h */, ED74D7681A5B8A2600157FD4 /* CCPhysicsHelper.h */, 46A1706E1807CE7A005B8026 /* CCPhysicsBody.cpp */, 46A1706F1807CE7A005B8026 /* CCPhysicsBody.h */, @@ -9656,6 +9678,7 @@ B6CAB3351AF9AA1A00B9B856 /* btGImpactShape.h in Headers */, 15AE1A6F19AAD40300C27E9E /* b2CircleContact.h in Headers */, B6CAB3431AF9AA1A00B9B856 /* gim_box_collision.h in Headers */, + 46EE47531B817EFD00100730 /* CCComponentPhysics2d.h in Headers */, B6CAB39B1AF9AA1A00B9B856 /* btVoronoiSimplexSolver.h in Headers */, B6CAB1EB1AF9AA1A00B9B856 /* btBroadphaseInterface.h in Headers */, B665E3E81AA80A6600DDB1C5 /* CCPUSineForceAffectorTranslator.h in Headers */, @@ -9727,6 +9750,7 @@ 5034CA35191D591100CE6051 /* ccShader_PositionTexture.frag in Headers */, 15AE1BB219AADFEF00C27E9E /* HttpClient.h in Headers */, B6CAB3FD1AF9AA1A00B9B856 /* btMultiBodyConstraint.h in Headers */, + 46EE47571B817EFD00100730 /* CCPhysicsManager.h in Headers */, B6DD2FF31B04825B00E47F5F /* DetourTileCacheBuilder.h in Headers */, 15AE197619AAD35700C27E9E /* CCTimelineMacro.h in Headers */, 50ABBE6F1925AB6F00A911A9 /* CCEventListenerKeyboard.h in Headers */, @@ -10173,6 +10197,7 @@ 1A570084180BC5A10088DEC7 /* CCActionManager.h in Headers */, B665E3151AA80A6500DDB1C5 /* CCPUObserverManager.h in Headers */, 15AE18C619AAD33D00C27E9E /* CCLayerLoader.h in Headers */, + 46EE47541B817EFD00100730 /* CCComponentPhysics2d.h in Headers */, B6CAB4A41AF9AA1A00B9B856 /* PpuAddressSpace.h in Headers */, B6CAB2041AF9AA1A00B9B856 /* btMultiSapBroadphase.h in Headers */, B665E2C51AA80A6500DDB1C5 /* CCPUGeometryRotatorTranslator.h in Headers */, @@ -10540,6 +10565,7 @@ 15AE1BEB19AAE01E00C27E9E /* CCControlButton.h in Headers */, B6CAB1F81AF9AA1A00B9B856 /* btDbvt.h in Headers */, B665E35D1AA80A6500DDB1C5 /* CCPUOnRandomObserver.h in Headers */, + 299B15AD1B93FC530008E196 /* UIEditBoxImpl-common.h in Headers */, 1A570281180BCC900088DEC7 /* CCSprite.h in Headers */, B6DD2FD21B04825B00E47F5F /* DetourNode.h in Headers */, 1A570285180BCC900088DEC7 /* CCSpriteBatchNode.h in Headers */, @@ -10945,6 +10971,7 @@ B6CAB3E01AF9AA1A00B9B856 /* btTypedConstraint.h in Headers */, 50ABBDAA1925AB4100A911A9 /* CCRenderCommand.h in Headers */, B29A7DF019EE1B7700872B35 /* SkeletonBounds.h in Headers */, + 46EE47581B817EFD00100730 /* CCPhysicsManager.h in Headers */, B6CAB3361AF9AA1A00B9B856 /* btGImpactShape.h in Headers */, 15AE1BE919AAE01E00C27E9E /* CCControl.h in Headers */, 15AE193719AAD35100C27E9E /* CCArmature.h in Headers */, @@ -11285,6 +11312,7 @@ 38B8E2E119E671D2002D7CE7 /* UILayoutComponent.cpp in Sources */, B665E3F61AA80A6600DDB1C5 /* CCPUSlaveEmitterTranslator.cpp in Sources */, 1A57019D180BCB590088DEC7 /* CCFont.cpp in Sources */, + 46EE47551B817EFD00100730 /* CCPhysicsManager.cpp in Sources */, B6CAB2D51AF9AA1A00B9B856 /* btOptimizedBvh.cpp in Sources */, 50CB247B19D9C5A100687767 /* AudioEngine-inl.mm in Sources */, 1A5701A1180BCB590088DEC7 /* CCFontAtlas.cpp in Sources */, @@ -11507,6 +11535,7 @@ B6CAB3631AF9AA1A00B9B856 /* btContinuousConvexCollision.cpp in Sources */, B665E3021AA80A6500DDB1C5 /* CCPUMeshSurfaceEmitter.cpp in Sources */, B665E3721AA80A6500DDB1C5 /* CCPUParticleFollower.cpp in Sources */, + 46EE47511B817EFD00100730 /* CCComponentPhysics2d.cpp in Sources */, B6CAB22B1AF9AA1A00B9B856 /* btCollisionObject.cpp in Sources */, 1A5702C8180BCE370088DEC7 /* CCTextFieldTTF.cpp in Sources */, B665E2861AA80A6500DDB1C5 /* CCPUDoStopSystemEventHandlerTranslator.cpp in Sources */, @@ -11970,6 +11999,7 @@ 1A57006E180BC5A10088DEC7 /* CCActionEase.cpp in Sources */, 50ABBD8C1925AB4100A911A9 /* CCGLProgram.cpp in Sources */, B665E2671AA80A6500DDB1C5 /* CCPUDoExpireEventHandlerTranslator.cpp in Sources */, + 46EE47561B817EFD00100730 /* CCPhysicsManager.cpp in Sources */, B6CAB4AA1AF9AA1A00B9B856 /* SpuCollisionObjectWrapper.cpp in Sources */, B6CAAFFF1AF9A9E100B9B856 /* CCPhysicsSprite3D.cpp in Sources */, 15AE196119AAD35100C27E9E /* CCSSceneReader.cpp in Sources */, @@ -12152,6 +12182,7 @@ B6CAB2201AF9AA1A00B9B856 /* btBoxBoxDetector.cpp in Sources */, 5E9F612B1A3FFE3D0038DE01 /* CCPlane.cpp in Sources */, 1A57019E180BCB590088DEC7 /* CCFont.cpp in Sources */, + 46EE47521B817EFD00100730 /* CCComponentPhysics2d.cpp in Sources */, 15AE1ACC19AAD40300C27E9E /* b2PrismaticJoint.cpp in Sources */, 15AE195F19AAD35100C27E9E /* CCSpriteFrameCacheHelper.cpp in Sources */, 15AE193019AAD35100C27E9E /* CCActionManagerEx.cpp in Sources */, @@ -12226,6 +12257,7 @@ B6DD2FC41B04825B00E47F5F /* DetourNavMesh.cpp in Sources */, B6CAAFFB1AF9A9E100B9B856 /* CCPhysics3DWorld.cpp in Sources */, B665E3471AA80A6500DDB1C5 /* CCPUOnExpireObserverTranslator.cpp in Sources */, + 299B15AC1B93FC530008E196 /* UIEditBoxImpl-common.cpp in Sources */, B6CAB2A41AF9AA1A00B9B856 /* btConvexHullShape.cpp in Sources */, 15AE1AA519AAD40300C27E9E /* b2Fixture.cpp in Sources */, B29A7DE219EE1B7700872B35 /* MeshAttachment.c in Sources */, diff --git a/cocos/2d/CCAction.cpp b/cocos/2d/CCAction.cpp index 589f3884eb..9c6d6a51a3 100644 --- a/cocos/2d/CCAction.cpp +++ b/cocos/2d/CCAction.cpp @@ -42,6 +42,10 @@ Action::Action() ,_tag(Action::INVALID_TAG) ,_flags(0) { +#if CC_ENABLE_SCRIPT_BINDING + ScriptEngineProtocol* engine = ScriptEngineManager::getInstance()->getScriptEngine(); + _scriptType = engine != nullptr ? engine->getScriptType() : kScriptTypeNone; +#endif } Action::~Action() diff --git a/cocos/2d/CCAction.h b/cocos/2d/CCAction.h index 68c9e9e19a..89733af0b8 100644 --- a/cocos/2d/CCAction.h +++ b/cocos/2d/CCAction.h @@ -30,10 +30,16 @@ THE SOFTWARE. #include "base/CCRef.h" #include "math/CCGeometry.h" +#include "base/CCScriptSupport.h" NS_CC_BEGIN class Node; + +enum { + kActionUpdate +}; + /** * @addtogroup actions * @{ @@ -172,6 +178,9 @@ protected: /** The action flag field. To categorize action into certain groups.*/ unsigned int _flags; +#if CC_ENABLE_SCRIPT_BINDING + ccScriptType _scriptType; ///< type of script binding, lua or javascript +#endif private: CC_DISALLOW_COPY_AND_ASSIGN(Action); }; @@ -221,7 +230,6 @@ CC_CONSTRUCTOR_ACCESS: protected: //! Duration in seconds. float _duration; - private: CC_DISALLOW_COPY_AND_ASSIGN(FiniteTimeAction); }; diff --git a/cocos/2d/CCActionCamera.cpp b/cocos/2d/CCActionCamera.cpp index 5bc37224e7..926644477f 100644 --- a/cocos/2d/CCActionCamera.cpp +++ b/cocos/2d/CCActionCamera.cpp @@ -116,7 +116,7 @@ void ActionCamera::updateTransform() } // FIXME: Using the AdditionalTransform is a complete hack. - // This should be done by multipliying the lookup-Matrix with the Node's MV matrix + // This should be done by multiplying the lookup-Matrix with the Node's MV matrix // And then setting the result as the new MV matrix // But that operation needs to be done after all the 'updates'. // So the Director should emit an 'director_after_update' event. diff --git a/cocos/2d/CCActionInstant.cpp b/cocos/2d/CCActionInstant.cpp index 7bcc16dc22..b81b7055ab 100644 --- a/cocos/2d/CCActionInstant.cpp +++ b/cocos/2d/CCActionInstant.cpp @@ -47,7 +47,15 @@ bool ActionInstant::isDone() const void ActionInstant::step(float dt) { CC_UNUSED_PARAM(dt); - update(1); + float updateDt = 1; +#if CC_ENABLE_SCRIPT_BINDING + if (_scriptType == kScriptTypeJavascript) + { + if (ScriptEngineManager::sendActionEventToJS(this, kActionUpdate, (void *)&updateDt)) + return; + } +#endif + update(updateDt); } void ActionInstant::update(float time) { diff --git a/cocos/2d/CCActionInterval.cpp b/cocos/2d/CCActionInterval.cpp index 9c9eec5bc8..7aeef85468 100644 --- a/cocos/2d/CCActionInterval.cpp +++ b/cocos/2d/CCActionInterval.cpp @@ -37,6 +37,7 @@ THE SOFTWARE. #include "base/CCEventCustom.h" #include "base/CCEventDispatcher.h" #include "platform/CCStdC.h" +#include "base/CCScriptSupport.h" NS_CC_BEGIN @@ -105,6 +106,18 @@ bool ActionInterval::initWithDuration(float d) return true; } +bool ActionInterval::sendUpdateEventToScript(float dt, Action *actionObject) +{ +#if CC_ENABLE_SCRIPT_BINDING + if (_scriptType == kScriptTypeJavascript) + { + if (ScriptEngineManager::sendActionEventToJS(actionObject, kActionUpdate, (void *)&dt)) + return true; + } +#endif + return false; +} + bool ActionInterval::isDone() const { return _elapsed >= _duration; @@ -122,12 +135,16 @@ void ActionInterval::step(float dt) _elapsed += dt; } - this->update(MAX (0, // needed for rewind. elapsed could be negative - MIN(1, _elapsed / - MAX(_duration, FLT_EPSILON) // division by 0 - ) - ) - ); + + float updateDt = MAX (0, // needed for rewind. elapsed could be negative + MIN(1, _elapsed / + MAX(_duration, FLT_EPSILON) // division by 0 + ) + ); + + if (sendUpdateEventToScript(updateDt, this)) return; + + this->update(updateDt); } void ActionInterval::setAmplitudeRate(float amp) @@ -323,13 +340,15 @@ void Sequence::update(float t) if( _last == -1 ) { // action[0] was skipped, execute it. _actions[0]->startWithTarget(_target); - _actions[0]->update(1.0f); + if (!(sendUpdateEventToScript(1.0f, _actions[0]))) + _actions[0]->update(1.0f); _actions[0]->stop(); } else if( _last == 0 ) { // switching to action 1. stop action 0. - _actions[0]->update(1.0f); + if (!(sendUpdateEventToScript(1.0f, _actions[0]))) + _actions[0]->update(1.0f); _actions[0]->stop(); } } @@ -339,7 +358,8 @@ void Sequence::update(float t) // FIXME: Bug. this case doesn't contemplate when _last==-1, found=0 and in "reverse mode" // since it will require a hack to know if an action is on reverse mode or not. // "step" should be overriden, and the "reverseMode" value propagated to inner Sequences. - _actions[1]->update(0); + if (!(sendUpdateEventToScript(0, _actions[1]))) + _actions[1]->update(0); _actions[1]->stop(); } // Last action found and it is done. @@ -353,8 +373,8 @@ void Sequence::update(float t) { _actions[found]->startWithTarget(_target); } - - _actions[found]->update(new_t); + if (!(sendUpdateEventToScript(new_t, _actions[found]))) + _actions[found]->update(new_t); _last = found; } @@ -436,8 +456,8 @@ void Repeat::update(float dt) { while (dt > _nextDt && _total < _times) { - - _innerAction->update(1.0f); + if (!(sendUpdateEventToScript(1.0f, _innerAction))) + _innerAction->update(1.0f); _total++; _innerAction->stop(); @@ -456,19 +476,22 @@ void Repeat::update(float dt) { if (_total == _times) { - _innerAction->update(1); + if (!(sendUpdateEventToScript(1, _innerAction))) + _innerAction->update(1); _innerAction->stop(); } else { // issue #390 prevent jerk, use right update - _innerAction->update(dt - (_nextDt - _innerAction->getDuration()/_duration)); + if (!(sendUpdateEventToScript(dt - (_nextDt - _innerAction->getDuration()/_duration), _innerAction))) + _innerAction->update(dt - (_nextDt - _innerAction->getDuration()/_duration)); } } } else { - _innerAction->update(fmodf(dt * _times,1.0f)); + if (!(sendUpdateEventToScript(fmodf(dt * _times,1.0f), _innerAction))) + _innerAction->update(fmodf(dt * _times,1.0f)); } } @@ -710,11 +733,13 @@ void Spawn::update(float time) { if (_one) { - _one->update(time); + if (!(sendUpdateEventToScript(time, _one))) + _one->update(time); } if (_two) { - _two->update(time); + if (!(sendUpdateEventToScript(time, _two))) + _two->update(time); } } @@ -2241,7 +2266,8 @@ void ReverseTime::update(float time) { if (_other) { - _other->update(1 - time); + if (!(sendUpdateEventToScript(1 - time, _other))) + _other->update(1 - time); } } @@ -2502,7 +2528,8 @@ void TargetedAction::stop() void TargetedAction::update(float time) { - _action->update(time); + if (!(sendUpdateEventToScript(time, _action))) + _action->update(time); } bool TargetedAction::isDone(void) const diff --git a/cocos/2d/CCActionInterval.h b/cocos/2d/CCActionInterval.h index b424c6be36..816ef56bd8 100644 --- a/cocos/2d/CCActionInterval.h +++ b/cocos/2d/CCActionInterval.h @@ -112,6 +112,9 @@ CC_CONSTRUCTOR_ACCESS: protected: float _elapsed; bool _firstTick; + +protected: + bool sendUpdateEventToScript(float dt, Action *actionObject); }; /** @class Sequence diff --git a/cocos/2d/CCComponentContainer.h b/cocos/2d/CCComponentContainer.h index 357e082eb3..44939fbb82 100644 --- a/cocos/2d/CCComponentContainer.h +++ b/cocos/2d/CCComponentContainer.h @@ -49,6 +49,22 @@ public: * @lua NA */ virtual ~ComponentContainer(void); + + template + T* getComponent() const + { + if (_components) + { + for (const auto &iter : *_components) + { + if (dynamic_cast(iter.second) != nullptr) + return static_cast(iter.second); + } + } + + return nullptr; + } + /** * @js getComponent */ diff --git a/cocos/2d/CCGrid.h b/cocos/2d/CCGrid.h index de3fcf5540..f0a2eb345d 100644 --- a/cocos/2d/CCGrid.h +++ b/cocos/2d/CCGrid.h @@ -63,7 +63,7 @@ public: @param gridSize the size of the grid. @param texture The texture used for grab. @param flipped whether or not the grab texture should be flip by Y or not. - @param rect The effct grid rect. + @param rect The effective grid rect. */ bool initWithSize(const Size& gridSize); bool initWithSize(const Size& gridSize, const Rect& rect); @@ -155,7 +155,7 @@ class CC_DLL Grid3D : public GridBase public: /** create one Grid. */ static Grid3D* create(const Size& gridSize); - /** craete one Grid. */ + /** create one Grid. */ static Grid3D* create(const Size& gridSize, const Rect& rect); /** create one Grid. */ static Grid3D* create(const Size& gridSize, Texture2D *texture, bool flipped); @@ -197,7 +197,7 @@ public: */ void setVertex(const Vec2& pos, const Vec3& vertex); /**@{ - Implementations for interfaces in base calss. + Implementations for interfaces in base class. */ virtual void beforeBlit() override; virtual void afterBlit() override; @@ -275,7 +275,7 @@ public: void setTile(const Vec2& pos, const Quad3& coords); /**@{ - Implementations for interfaces in base calss. + Implementations for interfaces in base class. */ virtual void blit() override; virtual void reuse() override; diff --git a/cocos/2d/CCLayer.cpp b/cocos/2d/CCLayer.cpp index 8eaf23c10c..ca839dbb9c 100644 --- a/cocos/2d/CCLayer.cpp +++ b/cocos/2d/CCLayer.cpp @@ -44,10 +44,6 @@ THE SOFTWARE. #include "deprecated/CCString.h" -#if CC_USE_PHYSICS -#include "physics/CCPhysicsBody.h" -#endif - NS_CC_BEGIN // Layer diff --git a/cocos/2d/CCLayer.h b/cocos/2d/CCLayer.h index d437853543..9dd0034980 100644 --- a/cocos/2d/CCLayer.h +++ b/cocos/2d/CCLayer.h @@ -84,7 +84,7 @@ public: */ /** Callback function for touch began. * - * @param touch Touch infomation. + * @param touch Touch information. * @param unused_event Event information. * @return if return false, onTouchMoved, onTouchEnded, onTouchCancelled will never called. * @js NA @@ -92,21 +92,21 @@ public: virtual bool onTouchBegan(Touch *touch, Event *unused_event); /** Callback function for touch moved. * - * @param touch Touch infomation. + * @param touch Touch information. * @param unused_event Event information. * @js NA */ virtual void onTouchMoved(Touch *touch, Event *unused_event); /** Callback function for touch ended. * - * @param touch Touch infomation. + * @param touch Touch information. * @param unused_event Event information. * @js NA */ virtual void onTouchEnded(Touch *touch, Event *unused_event); /** Callback function for touch cancelled. * - * @param touch Touch infomation. + * @param touch Touch information. * @param unused_event Event information. * @js NA */ @@ -149,7 +149,7 @@ public: /* Callback function should not be deprecated, it will generate lots of warnings. Since 'setAccelerometerEnabled' was deprecated, it will make warnings if developer overrides onAcceleration and invokes setAccelerometerEnabled(true) instead of using EventDispatcher::addEventListenerWithXXX. */ - /** Callback funtion for acceleration. + /** Callback function for acceleration. * @param acc Acceleration information. * @param unused_event Event information. * @js NA @@ -297,19 +297,19 @@ public: // virtual GLubyte getOpacity() const override { return Layer::getOpacity(); } virtual GLubyte getDisplayedOpacity() const override { return Layer::getDisplayedOpacity(); } - virtual void setOpacity(GLubyte opacity) override { return Layer::setOpacity(opacity); } - virtual void updateDisplayedOpacity(GLubyte parentOpacity) override { return Layer::updateDisplayedOpacity(parentOpacity); } + virtual void setOpacity(GLubyte opacity) override { Layer::setOpacity(opacity); } + virtual void updateDisplayedOpacity(GLubyte parentOpacity) override { Layer::updateDisplayedOpacity(parentOpacity); } virtual bool isCascadeOpacityEnabled() const override { return Layer::isCascadeOpacityEnabled(); } - virtual void setCascadeOpacityEnabled(bool cascadeOpacityEnabled) override { return Layer::setCascadeOpacityEnabled(cascadeOpacityEnabled); } + virtual void setCascadeOpacityEnabled(bool cascadeOpacityEnabled) override { Layer::setCascadeOpacityEnabled(cascadeOpacityEnabled); } virtual const Color3B& getColor() const override { return Layer::getColor(); } virtual const Color3B& getDisplayedColor() const override { return Layer::getDisplayedColor(); } - virtual void setColor(const Color3B& color) override { return Layer::setColor(color); } - virtual void updateDisplayedColor(const Color3B& parentColor) override { return Layer::updateDisplayedColor(parentColor); } + virtual void setColor(const Color3B& color) override { Layer::setColor(color); } + virtual void updateDisplayedColor(const Color3B& parentColor) override { Layer::updateDisplayedColor(parentColor); } virtual bool isCascadeColorEnabled() const override { return Layer::isCascadeOpacityEnabled(); } - virtual void setCascadeColorEnabled(bool cascadeColorEnabled) override { return Layer::setCascadeColorEnabled(cascadeColorEnabled); } + virtual void setCascadeColorEnabled(bool cascadeColorEnabled) override { Layer::setCascadeColorEnabled(cascadeColorEnabled); } - virtual void setOpacityModifyRGB(bool bValue) override { return Layer::setOpacityModifyRGB(bValue); } + virtual void setOpacityModifyRGB(bool bValue) override { Layer::setOpacityModifyRGB(bValue); } virtual bool isOpacityModifyRGB() const override { return Layer::isOpacityModifyRGB(); } CC_CONSTRUCTOR_ACCESS: diff --git a/cocos/2d/CCNode.cpp b/cocos/2d/CCNode.cpp index 6f6a8b45f8..161713d5c5 100644 --- a/cocos/2d/CCNode.cpp +++ b/cocos/2d/CCNode.cpp @@ -41,19 +41,12 @@ THE SOFTWARE. #include "2d/CCActionManager.h" #include "2d/CCScene.h" #include "2d/CCComponent.h" -#include "2d/CCComponentContainer.h" #include "renderer/CCGLProgram.h" #include "renderer/CCGLProgramState.h" #include "renderer/CCMaterial.h" #include "math/TransformUtils.h" - #include "deprecated/CCString.h" -#if CC_USE_PHYSICS -#include "physics/CCPhysicsBody.h" -#include "physics/CCPhysicsWorld.h" -#endif - #if CC_NODE_RENDER_SUBPIXEL #define RENDER_IN_SUBPIXEL @@ -118,17 +111,6 @@ Node::Node(void) , _updateScriptHandler(0) #endif , _componentContainer(nullptr) -#if CC_USE_PHYSICS -, _physicsBody(nullptr) -, _physicsScaleStartX(1.0f) -, _physicsScaleStartY(1.0f) -, _physicsRotation(0.0f) -, _physicsTransformDirty(true) -, _updateTransformFromPhysics(true) -, _physicsWorld(nullptr) -, _physicsBodyAssociatedWith(0) -, _physicsRotationOffset(0.0f) -#endif , _displayedOpacity(255) , _realOpacity(255) , _displayedColor(Color3B::WHITE) @@ -194,11 +176,6 @@ Node::~Node() CC_SAFE_DELETE(_componentContainer); -#if CC_USE_PHYSICS - setPhysicsBody(nullptr); - -#endif - stopAllActions(); unscheduleAllCallbacks(); CC_SAFE_RELEASE_NULL(_actionManager); @@ -259,13 +236,6 @@ void Node::setSkewX(float skewX) if (_skewX == skewX) return; -#if CC_USE_PHYSICS - if (_physicsBody != nullptr) - { - CCLOG("Node WARNING: PhysicsBody doesn't support setSkewX"); - } -#endif - _skewX = skewX; _transformUpdated = _transformDirty = _inverseDirty = true; } @@ -280,13 +250,6 @@ void Node::setSkewY(float skewY) if (_skewY == skewY) return; -#if CC_USE_PHYSICS - if (_physicsBody != nullptr) - { - CCLOG("Node WARNING: PhysicsBody doesn't support setSkewY"); - } -#endif - _skewY = skewY; _transformUpdated = _transformDirty = _inverseDirty = true; } @@ -336,12 +299,6 @@ void Node::setRotation(float rotation) _rotationZ_X = _rotationZ_Y = rotation; _transformUpdated = _transformDirty = _inverseDirty = true; -#if CC_USE_PHYSICS - if (_physicsWorld && _physicsBodyAssociatedWith > 0) - { - _physicsWorld->_updateBodyTransform = true; - } -#endif updateRotationQuat(); } @@ -367,13 +324,6 @@ void Node::setRotation3D(const Vec3& rotation) _rotationZ_Y = _rotationZ_X = rotation.z; updateRotationQuat(); - -#if CC_USE_PHYSICS - if (_physicsBody != nullptr) - { - CCLOG("Node WARNING: PhysicsBody doesn't support setRotation3D"); - } -#endif } Vec3 Node::getRotation3D() const @@ -429,13 +379,6 @@ void Node::setRotationSkewX(float rotationX) if (_rotationZ_X == rotationX) return; -#if CC_USE_PHYSICS - if (_physicsBody != nullptr) - { - CCLOG("Node WARNING: PhysicsBody doesn't support setRotationSkewX"); - } -#endif - _rotationZ_X = rotationX; _transformUpdated = _transformDirty = _inverseDirty = true; @@ -452,13 +395,6 @@ void Node::setRotationSkewY(float rotationY) if (_rotationZ_Y == rotationY) return; -#if CC_USE_PHYSICS - if (_physicsBody != nullptr) - { - CCLOG("Node WARNING: PhysicsBody doesn't support setRotationSkewY"); - } -#endif - _rotationZ_Y = rotationY; _transformUpdated = _transformDirty = _inverseDirty = true; @@ -480,12 +416,6 @@ void Node::setScale(float scale) _scaleX = _scaleY = _scaleZ = scale; _transformUpdated = _transformDirty = _inverseDirty = true; -#if CC_USE_PHYSICS - if (_physicsWorld && _physicsBodyAssociatedWith > 0) - { - _physicsWorld->_updateBodyTransform = true; - } -#endif } /// scaleX getter @@ -503,12 +433,6 @@ void Node::setScale(float scaleX,float scaleY) _scaleX = scaleX; _scaleY = scaleY; _transformUpdated = _transformDirty = _inverseDirty = true; -#if CC_USE_PHYSICS - if (_physicsWorld && _physicsBodyAssociatedWith > 0) - { - _physicsWorld->_updateBodyTransform = true; - } -#endif } /// scaleX setter @@ -519,12 +443,6 @@ void Node::setScaleX(float scaleX) _scaleX = scaleX; _transformUpdated = _transformDirty = _inverseDirty = true; -#if CC_USE_PHYSICS - if (_physicsWorld && _physicsBodyAssociatedWith > 0) - { - _physicsWorld->_updateBodyTransform = true; - } -#endif } /// scaleY getter @@ -539,13 +457,6 @@ void Node::setScaleZ(float scaleZ) if (_scaleZ == scaleZ) return; -#if CC_USE_PHYSICS - if (_physicsBody != nullptr) - { - CCLOG("Node WARNING: PhysicsBody doesn't support setScaleZ"); - } -#endif - _scaleZ = scaleZ; _transformUpdated = _transformDirty = _inverseDirty = true; } @@ -564,12 +475,6 @@ void Node::setScaleY(float scaleY) _scaleY = scaleY; _transformUpdated = _transformDirty = _inverseDirty = true; -#if CC_USE_PHYSICS - if (_physicsWorld && _physicsBodyAssociatedWith > 0) - { - _physicsWorld->_updateBodyTransform = true; - } -#endif } @@ -601,12 +506,6 @@ void Node::setPosition(float x, float y) _transformUpdated = _transformDirty = _inverseDirty = true; _usingNormalizedPosition = false; -#if CC_USE_PHYSICS - if (_physicsWorld && _physicsBodyAssociatedWith > 0) - { - _physicsWorld->_updateBodyTransform = true; - } -#endif } void Node::setPosition3D(const Vec3& position) @@ -671,12 +570,6 @@ void Node::setNormalizedPosition(const Vec2& position) _usingNormalizedPosition = true; _normalizedPositionDirty = true; _transformUpdated = _transformDirty = _inverseDirty = true; -#if CC_USE_PHYSICS - if (_physicsWorld && _physicsBodyAssociatedWith > 0) - { - _physicsWorld->_updateBodyTransform = true; - } -#endif } ssize_t Node::getChildrenCount() const @@ -1059,24 +952,6 @@ void Node::addChildHelper(Node* child, int localZOrder, int tag, const std::stri child->setParent(this); child->setOrderOfArrival(s_globalOrderOfArrival++); -#if CC_USE_PHYSICS - _physicsBodyAssociatedWith += child->_physicsBodyAssociatedWith; - auto parentNode = this; - while (parentNode->_parent) - { - parentNode = parentNode->_parent; - parentNode->_physicsBodyAssociatedWith += child->_physicsBodyAssociatedWith; - } - - auto scene = dynamic_cast(parentNode); - - // Recursive add children with which have physics body. - if (scene && scene->getPhysicsWorld()) - { - scene->addChildToPhysicsWorld(child); - } -#endif - if( _running ) { child->onEnter(); @@ -1177,21 +1052,6 @@ void Node::removeAllChildren() this->removeAllChildrenWithCleanup(true); } -#if CC_USE_PHYSICS -void Node::removeFromPhysicsWorld() -{ - if (_physicsBody != nullptr) - { - _physicsBody->removeFromWorld(); - } - - for (auto child : _children) - { - child->removeFromPhysicsWorld(); - } -} -#endif - void Node::removeAllChildrenWithCleanup(bool cleanup) { // not using detachChild improves speed here @@ -1206,10 +1066,6 @@ void Node::removeAllChildrenWithCleanup(bool cleanup) child->onExit(); } -#if CC_USE_PHYSICS - child->removeFromPhysicsWorld(); -#endif - if (cleanup) { child->cleanup(); @@ -1231,10 +1087,6 @@ void Node::detachChild(Node *child, ssize_t childIndex, bool doCleanup) child->onExitTransitionDidStart(); child->onExit(); } - -#if CC_USE_PHYSICS - child->removeFromPhysicsWorld(); -#endif // If you don't do cleanup, the child's actions will not get removed and the // its scheduledSelectors_ dict will not get released! @@ -1297,12 +1149,6 @@ void Node::visit() uint32_t Node::processParentFlags(const Mat4& parentTransform, uint32_t parentFlags) { -#if CC_USE_PHYSICS - if (_physicsBody && _updateTransformFromPhysics) - { - updateTransformFromPhysics(parentTransform, parentFlags); - } -#endif if(_usingNormalizedPosition) { CCASSERT(_parent, "setNormalizedPosition() doesn't work with orphan nodes"); @@ -1330,15 +1176,8 @@ uint32_t Node::processParentFlags(const Mat4& parentTransform, uint32_t parentFl if(flags & FLAGS_DIRTY_MASK) _modelViewTransform = this->transform(parentTransform); -#if CC_USE_PHYSICS - if (_updateTransformFromPhysics) { - _transformUpdated = false; - _contentSizeDirty = false; - } -#else _transformUpdated = false; _contentSizeDirty = false; -#endif return flags; } @@ -1813,7 +1652,7 @@ const Mat4& Node::getNodeToParentTransform() const Vec2 anchorPoint(_anchorPointInPoints.x * _scaleX, _anchorPointInPoints.y * _scaleY); - // caculate real position + // calculate real position if (! needsSkewMatrix && !_anchorPointInPoints.isZero()) { x += -anchorPoint.x; @@ -2065,120 +1904,6 @@ void Node::removeAllComponents() _componentContainer->removeAll(); } -#if CC_USE_PHYSICS - -// MARK: Physics - -void Node::setPhysicsBody(PhysicsBody* body) -{ - if (_physicsBody == body) - { - return; - } - - if (_physicsBody) - { - _physicsBody->removeFromWorld(); - _physicsBody->_node = nullptr; - _physicsBody->release(); - _physicsBody = nullptr; - - _physicsBodyAssociatedWith--; - auto parentNode = this; - while (parentNode->_parent) - { - parentNode = parentNode->_parent; - parentNode->_physicsBodyAssociatedWith--; - } - } - - if (body) - { - if (body->getNode()) - { - body->getNode()->setPhysicsBody(nullptr); - } - - body->_node = this; - body->retain(); - - _physicsBody = body; - _physicsScaleStartX = _scaleX; - _physicsScaleStartY = _scaleY; - _physicsRotationOffset = _rotationZ_X; - - _physicsBodyAssociatedWith++; - auto parentNode = this; - while (parentNode->_parent) - { - parentNode = parentNode->_parent; - parentNode->_physicsBodyAssociatedWith++; - } - - auto scene = dynamic_cast(parentNode); - if (scene && scene->getPhysicsWorld()) - { - _physicsTransformDirty = true; - scene->getPhysicsWorld()->addBody(body); - } - } -} - -void Node::updatePhysicsBodyTransform(const Mat4& parentTransform, uint32_t parentFlags, float parentScaleX, float parentScaleY) -{ - _updateTransformFromPhysics = false; - auto flags = processParentFlags(parentTransform, parentFlags); - _updateTransformFromPhysics = true; - auto scaleX = parentScaleX * _scaleX; - auto scaleY = parentScaleY * _scaleY; - - if (_parent) - { - _physicsRotation = _parent->_physicsRotation + _rotationZ_X; - } - if (_physicsBody && ((flags & FLAGS_DIRTY_MASK) || _physicsTransformDirty)) - { - _physicsTransformDirty = false; - - Vec3 vec3(_contentSize.width * 0.5f, _contentSize.height * 0.5f, 0); - Vec3 ret; - _modelViewTransform.transformPoint(vec3, &ret); - _physicsBody->setPosition(Vec2(ret.x, ret.y)); - - parentTransform.getInversed().transformPoint(&ret); - _offsetX = ret.x - _position.x; - _offsetY = ret.y - _position.y; - - _physicsBody->setScale(scaleX / _physicsScaleStartX, scaleY / _physicsScaleStartY); - _physicsBody->setRotation(_physicsRotation - _physicsRotationOffset); - } - - for (auto node : _children) - { - node->updatePhysicsBodyTransform(_modelViewTransform, flags, scaleX, scaleY); - } -} - -void Node::updateTransformFromPhysics(const Mat4& parentTransform, uint32_t parentFlags) -{ - auto& newPosition = _physicsBody->getPosition(); - auto& recordedPosition = _physicsBody->_recordedPosition; - auto updateBodyTransform = _physicsWorld->_updateBodyTransform; - if (parentFlags || recordedPosition.x != newPosition.x || recordedPosition.y != newPosition.y) - { - recordedPosition = newPosition; - Vec3 vec3(newPosition.x, newPosition.y, 0); - Vec3 ret; - parentTransform.getInversed().transformPoint(vec3, &ret); - setPosition(ret.x - _offsetX, ret.y - _offsetY); - } - _physicsRotation = _physicsBody->getRotation(); - setRotation(_physicsRotation - _parent->_physicsRotation + _physicsRotationOffset); - _physicsWorld->_updateBodyTransform = updateBodyTransform; -} - -#endif //CC_USE_PHYSICS - // MARK: Opacity and Color GLubyte Node::getOpacity(void) const diff --git a/cocos/2d/CCNode.h b/cocos/2d/CCNode.h index 2240eed040..2ce7811d91 100644 --- a/cocos/2d/CCNode.h +++ b/cocos/2d/CCNode.h @@ -35,6 +35,7 @@ #include "base/CCScriptSupport.h" #include "math/CCAffineTransform.h" #include "math/CCMath.h" +#include "2d/CCComponentContainer.h" NS_CC_BEGIN @@ -53,10 +54,6 @@ class Director; class GLProgram; class GLProgramState; class Material; -#if CC_USE_PHYSICS -class PhysicsBody; -class PhysicsWorld; -#endif class Camera; /** @@ -1560,7 +1557,6 @@ public: virtual Mat4 getWorldToNodeTransform() const; virtual AffineTransform getWorldToNodeAffineTransform() const; - /** @deprecated Use getWorldToNodeTransform() instead */ CC_DEPRECATED_ATTRIBUTE inline virtual AffineTransform worldToNodeTransform() const { return getWorldToNodeAffineTransform(); } @@ -1644,6 +1640,22 @@ public: * @return The Component by name. */ Component* getComponent(const std::string& name); + + /** + * Get a component by the type T. + * @lua NA + * @js NA + * + * @return The component that match the type T. + */ + template + T* getComponent() const + { + if (_componentContainer) + return _componentContainer->getComponent(); + else + return nullptr; + } /** * Adds a component. @@ -1673,39 +1685,6 @@ public: */ virtual void removeAllComponents(); /// @} end of component functions - - -#if CC_USE_PHYSICS - /** - * Set the PhysicsBody that let the sprite effect with physics. - * @note This method will set anchor point to Vec2::ANCHOR_MIDDLE if body not null, and you cann't change anchor point if node has a physics body. - * - * @param body A given physics body. - */ - void setPhysicsBody(PhysicsBody* body); - - /** - * Get the PhysicsBody the sprite have. - * - * @return The PhysicsBody the sprite have. - */ - PhysicsBody* getPhysicsBody() const { return _physicsBody; } - - /** - * Remove this node from physics world. it will remove all the physics bodies in it's children too. - */ - void removeFromPhysicsWorld(); - - /** - * Update the transform matrix from physics. - */ - void updateTransformFromPhysics(const Mat4& parentTransform, uint32_t parentFlags); - - /** - * Update physics body transform matrix. - */ - virtual void updatePhysicsBodyTransform(const Mat4& parentTransform, uint32_t parentFlags, float parentScaleX, float parentScaleY); -#endif // overrides virtual GLubyte getOpacity() const; @@ -1863,22 +1842,6 @@ protected: #endif ComponentContainer *_componentContainer; ///< Dictionary of components - -#if CC_USE_PHYSICS - PhysicsBody* _physicsBody; ///< the physicsBody the node have - float _physicsScaleStartX; ///< the scale x value when setPhysicsBody - float _physicsScaleStartY; ///< the scale y value when setPhysicsBody - float _physicsRotation; - bool _physicsTransformDirty; - bool _updateTransformFromPhysics; - - PhysicsWorld* _physicsWorld; /** The PhysicsWorld associated with the node.*/ - int _physicsBodyAssociatedWith; /** The count of PhysicsBody associated with the node and children.*/ - float _physicsRotationOffset; /** Record the rotation value when invoke Node::setPhysicsBody.*/ - - float _offsetX; - float _offsetY; -#endif // opacity controls GLubyte _displayedOpacity; @@ -1900,10 +1863,6 @@ protected: private: CC_DISALLOW_COPY_AND_ASSIGN(Node); - -#if CC_USE_PHYSICS - friend class Scene; -#endif //CC_USTPS }; diff --git a/cocos/2d/CCProtectedNode.cpp b/cocos/2d/CCProtectedNode.cpp index 1b831bd9f5..c248846047 100644 --- a/cocos/2d/CCProtectedNode.cpp +++ b/cocos/2d/CCProtectedNode.cpp @@ -29,10 +29,6 @@ #include "CCProtectedNode.h" #include "base/CCDirector.h" - -#if CC_USE_PHYSICS -#include "physics/CCPhysicsBody.h" -#endif #include "2d/CCScene.h" NS_CC_BEGIN @@ -108,19 +104,6 @@ void ProtectedNode::addProtectedChild(Node *child, int zOrder, int tag) child->setParent(this); child->setOrderOfArrival(s_globalOrderOfArrival++); -#if CC_USE_PHYSICS - // Recursive add children with which have physics body. - for (Node* node = this; node != nullptr; node = node->getParent()) - { - Scene* scene = dynamic_cast(node); - if (scene != nullptr && scene->getPhysicsWorld() != nullptr) - { - scene->addChildToPhysicsWorld(child); - break; - } - } -#endif - if( _running ) { child->onEnter(); @@ -178,13 +161,6 @@ void ProtectedNode::removeProtectedChild(cocos2d::Node *child, bool cleanup) child->onExit(); } -#if CC_USE_PHYSICS - if (child->getPhysicsBody() != nullptr) - { - child->getPhysicsBody()->removeFromWorld(); - } - -#endif // If you don't do cleanup, the child's actions will not get removed and the // its scheduledSelectors_ dict will not get released! if (cleanup) @@ -218,13 +194,6 @@ void ProtectedNode::removeAllProtectedChildrenWithCleanup(bool cleanup) child->onExit(); } -#if CC_USE_PHYSICS - if (child->getPhysicsBody() != nullptr) - { - child->getPhysicsBody()->removeFromWorld(); - } -#endif - if (cleanup) { child->cleanup(); diff --git a/cocos/2d/CCScene.cpp b/cocos/2d/CCScene.cpp index 9dc81e8a2a..a2dee0aa9f 100644 --- a/cocos/2d/CCScene.cpp +++ b/cocos/2d/CCScene.cpp @@ -35,7 +35,7 @@ THE SOFTWARE. #include "deprecated/CCString.h" #if CC_USE_PHYSICS -#include "physics/CCPhysicsWorld.h" +#include "physics/CCPhysicsManager.h" #endif #if CC_USE_3D_PHYSICS && CC_ENABLE_BULLET_INTEGRATION @@ -50,9 +50,6 @@ THE SOFTWARE. NS_CC_BEGIN Scene::Scene() -#if CC_USE_PHYSICS -: _physicsWorld(nullptr) -#endif { #if CC_USE_3D_PHYSICS && CC_ENABLE_BULLET_INTEGRATION _physics3DWorld = nullptr; @@ -61,6 +58,9 @@ Scene::Scene() #if CC_USE_NAVMESH _navMesh = nullptr; _navMeshDebugCamera = nullptr; +#endif +#if CC_USE_PHYSICS + _physicsManager = nullptr; #endif _ignoreAnchorPointForPosition = true; setAnchorPoint(Vec2(0.5f, 0.5f)); @@ -79,9 +79,6 @@ Scene::Scene() Scene::~Scene() { -#if CC_USE_PHYSICS - CC_SAFE_DELETE(_physicsWorld); -#endif #if CC_USE_3D_PHYSICS && CC_ENABLE_BULLET_INTEGRATION CC_SAFE_RELEASE(_physics3DWorld); CC_SAFE_RELEASE(_physics3dDebugCamera); @@ -91,6 +88,10 @@ Scene::~Scene() #endif Director::getInstance()->getEventDispatcher()->removeEventListener(_event); CC_SAFE_RELEASE(_event); + +#if CC_USE_PHYSICS + delete _physicsManager; +#endif } #if CC_USE_NAVMESH @@ -260,21 +261,6 @@ void Scene::setNavMeshDebugCamera(Camera *camera) #endif #if (CC_USE_PHYSICS || (CC_USE_3D_PHYSICS && CC_ENABLE_BULLET_INTEGRATION)) -void Scene::addChild(Node* child, int zOrder, int tag) -{ - Node::addChild(child, zOrder, tag); -#if CC_USE_PHYSICS - addChildToPhysicsWorld(child); -#endif -} - -void Scene::addChild(Node* child, int zOrder, const std::string &name) -{ - Node::addChild(child, zOrder, name); -#if CC_USE_PHYSICS - addChildToPhysicsWorld(child); -#endif -} Scene* Scene::createWithPhysics() { @@ -293,6 +279,9 @@ Scene* Scene::createWithPhysics() bool Scene::initWithPhysics() { + _physicsManager = new (std::nothrow) PhysicsManager(this); + _physicsWorld = _physicsManager->getPhysicsWorld(); + bool ret = false; do { @@ -300,9 +289,6 @@ bool Scene::initWithPhysics() CC_BREAK_IF( ! (director = Director::getInstance()) ); this->setContentSize(director->getWinSize()); -#if CC_USE_PHYSICS - CC_BREAK_IF(! (_physicsWorld = PhysicsWorld::construct(*this))); -#endif #if CC_USE_3D_PHYSICS && CC_ENABLE_BULLET_INTEGRATION Physics3DWorldDes info; @@ -316,43 +302,16 @@ bool Scene::initWithPhysics() return ret; } -void Scene::addChildToPhysicsWorld(Node* child) -{ -#if CC_USE_PHYSICS - if (_physicsWorld) - { - std::function addToPhysicsWorldFunc = nullptr; - addToPhysicsWorldFunc = [this, &addToPhysicsWorldFunc](Node* node) -> void - { - node->_physicsWorld = _physicsWorld; - - if (node->getPhysicsBody()) - { - _physicsWorld->addBody(node->getPhysicsBody()); - } - - auto& children = node->getChildren(); - for( const auto &n : children) { - addToPhysicsWorldFunc(n); - } - }; - - addToPhysicsWorldFunc(child); - } -#endif -} - #endif #if (CC_USE_PHYSICS || (CC_USE_3D_PHYSICS && CC_ENABLE_BULLET_INTEGRATION) || CC_USE_NAVMESH) void Scene::stepPhysicsAndNavigation(float deltaTime) { #if CC_USE_PHYSICS - if (_physicsWorld && _physicsWorld->isAutoStep()) - { - _physicsWorld->update(deltaTime, false); - } + if (_physicsManager) + _physicsManager->update(deltaTime); #endif + #if CC_USE_3D_PHYSICS && CC_ENABLE_BULLET_INTEGRATION if (_physics3DWorld) { diff --git a/cocos/2d/CCScene.h b/cocos/2d/CCScene.h index ae154083e4..6047977074 100644 --- a/cocos/2d/CCScene.h +++ b/cocos/2d/CCScene.h @@ -40,6 +40,7 @@ class EventListenerCustom; class EventCustom; #if CC_USE_PHYSICS class PhysicsWorld; +class PhysicsManager; #endif #if CC_USE_3D_PHYSICS && CC_ENABLE_BULLET_INTEGRATION class Physics3DWorld; @@ -145,15 +146,21 @@ private: #if (CC_USE_PHYSICS || (CC_USE_3D_PHYSICS && CC_ENABLE_BULLET_INTEGRATION)) public: - virtual void addChild(Node* child, int zOrder, int tag) override; - virtual void addChild(Node* child, int zOrder, const std::string &name) override; #if CC_USE_PHYSICS /** Get the physics world of the scene. * @return The physics world of the scene. * @js NA */ - inline PhysicsWorld* getPhysicsWorld() { return _physicsWorld; } + inline PhysicsWorld* getPhysicsWorld() const { return _physicsWorld; } + + /** + * Get the `PhysicsManager` belongs to this `Scene`. + * + * @return PhysicsManager of the scene. + * @js NA + */ + PhysicsManager* getPhysicsManager() const { return _physicsManager; } #endif #if CC_USE_3D_PHYSICS && CC_ENABLE_BULLET_INTEGRATION @@ -183,6 +190,7 @@ protected: #if CC_USE_PHYSICS PhysicsWorld* _physicsWorld; + PhysicsManager* _physicsManager; #endif #if CC_USE_3D_PHYSICS && CC_ENABLE_BULLET_INTEGRATION @@ -203,8 +211,8 @@ public: void setNavMeshDebugCamera(Camera *camera); protected: - NavMesh* _navMesh; - Camera * _navMeshDebugCamera; + NavMesh* _navMesh; + Camera * _navMeshDebugCamera; #endif #if (CC_USE_PHYSICS || (CC_USE_3D_PHYSICS && CC_ENABLE_BULLET_INTEGRATION) || CC_USE_NAVMESH) diff --git a/cocos/2d/CCSprite.cpp b/cocos/2d/CCSprite.cpp index 08836f66c8..826cb382b6 100644 --- a/cocos/2d/CCSprite.cpp +++ b/cocos/2d/CCSprite.cpp @@ -1129,7 +1129,7 @@ void Sprite::updateBlendFunc(void) { CCASSERT(! _batchNode, "CCSprite: updateBlendFunc doesn't work when the sprite is rendered using a SpriteBatchNode"); - // it is possible to have an untextured spritec + // it is possible to have an untextured sprite if (! _texture || ! _texture->hasPremultipliedAlpha()) { _blendFunc = BlendFunc::ALPHA_NON_PREMULTIPLIED; diff --git a/cocos/2d/CCSpriteBatchNode.cpp b/cocos/2d/CCSpriteBatchNode.cpp index fc927aa342..96a78e6d83 100644 --- a/cocos/2d/CCSpriteBatchNode.cpp +++ b/cocos/2d/CCSpriteBatchNode.cpp @@ -367,13 +367,6 @@ void SpriteBatchNode::draw(Renderer *renderer, const Mat4 &transform, uint32_t f for (const auto &child : _children) { -#if CC_USE_PHYSICS - auto physicsBody = child->getPhysicsBody(); - if (physicsBody) - { - child->updateTransformFromPhysics(transform, flags); - } -#endif child->updateTransform(); } diff --git a/cocos/2d/CCSpriteFrameCache.cpp b/cocos/2d/CCSpriteFrameCache.cpp index c9d918aa43..3588ad2b7c 100644 --- a/cocos/2d/CCSpriteFrameCache.cpp +++ b/cocos/2d/CCSpriteFrameCache.cpp @@ -131,7 +131,7 @@ void SpriteFrameCache::addSpriteFramesWithDictionary(ValueMap& dictionary, Textu // check ow/oh if(!ow || !oh) { - CCLOGWARN("cocos2d: WARNING: originalWidth/Height not found on the SpriteFrame. AnchorPoint won't work as expected. Regenrate the .plist"); + CCLOGWARN("cocos2d: WARNING: originalWidth/Height not found on the SpriteFrame. AnchorPoint won't work as expected. Regenerate the .plist"); } // abs ow/oh ow = abs(ow); diff --git a/cocos/2d/libcocos2d.vcxproj b/cocos/2d/libcocos2d.vcxproj index f62d0aeb5a..eec068403b 100644 --- a/cocos/2d/libcocos2d.vcxproj +++ b/cocos/2d/libcocos2d.vcxproj @@ -587,9 +587,11 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.* + + @@ -1195,10 +1197,12 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.* + + diff --git a/cocos/2d/libcocos2d.vcxproj.filters b/cocos/2d/libcocos2d.vcxproj.filters index eb2707d8f7..72850a6776 100644 --- a/cocos/2d/libcocos2d.vcxproj.filters +++ b/cocos/2d/libcocos2d.vcxproj.filters @@ -285,6 +285,9 @@ + + physics + physics @@ -294,6 +297,9 @@ physics + + physics + physics @@ -1936,6 +1942,9 @@ + + physics + physics @@ -1945,6 +1954,9 @@ physics + + physics + physics diff --git a/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems b/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems index 0933df8075..b3595dd31a 100644 --- a/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems +++ b/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems @@ -468,10 +468,12 @@ + + @@ -1071,9 +1073,11 @@ + + diff --git a/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems.filters b/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems.filters index f9759f3410..27e9f827b9 100644 --- a/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems.filters +++ b/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems.filters @@ -210,6 +210,12 @@ physics + + physics + + + physics + cocostudio @@ -2054,6 +2060,12 @@ physics + + physics + + + physics + cocostudio\action diff --git a/cocos/2d/libcocos2d_win10/libcocos2d.vcxproj b/cocos/2d/libcocos2d_win10/libcocos2d.vcxproj index 547868ac0c..ad54fe8425 100644 --- a/cocos/2d/libcocos2d_win10/libcocos2d.vcxproj +++ b/cocos/2d/libcocos2d_win10/libcocos2d.vcxproj @@ -565,9 +565,11 @@ + + @@ -1179,10 +1181,12 @@ + + diff --git a/cocos/2d/libcocos2d_win10/libcocos2d.vcxproj.filters b/cocos/2d/libcocos2d_win10/libcocos2d.vcxproj.filters index ecf6c1b2d4..d2e1c62e5a 100644 --- a/cocos/2d/libcocos2d_win10/libcocos2d.vcxproj.filters +++ b/cocos/2d/libcocos2d_win10/libcocos2d.vcxproj.filters @@ -1578,6 +1578,9 @@ network + + physics + physics @@ -1587,6 +1590,9 @@ physics + + physics + physics @@ -3389,6 +3395,9 @@ network + + physics + physics @@ -3401,6 +3410,9 @@ physics + + physics + physics diff --git a/cocos/3d/CCAABB.h b/cocos/3d/CCAABB.h index a06da15bb4..6faaeb4ecb 100644 --- a/cocos/3d/CCAABB.h +++ b/cocos/3d/CCAABB.h @@ -36,7 +36,7 @@ NS_CC_BEGIN */ /** - * Axis Aligned Bounding Box (AABB), usually caculate some rough but fast collision detection. + * Axis Aligned Bounding Box (AABB), usually calculate some rough but fast collision detection. */ class CC_DLL AABB { diff --git a/cocos/3d/CCAnimate3D.cpp b/cocos/3d/CCAnimate3D.cpp index 25656c6a43..325c9437a7 100644 --- a/cocos/3d/CCAnimate3D.cpp +++ b/cocos/3d/CCAnimate3D.cpp @@ -224,7 +224,7 @@ void Animate3D::startWithTarget(Node *target) if (!hasCurve) { - CCLOG("warning: no animation finde for the skeleton"); + CCLOG("warning: no animation found for the skeleton"); } } diff --git a/cocos/3d/CCAnimate3D.h b/cocos/3d/CCAnimate3D.h index 87cab15ea6..80be79f74c 100644 --- a/cocos/3d/CCAnimate3D.h +++ b/cocos/3d/CCAnimate3D.h @@ -41,7 +41,7 @@ class EventCustom; enum class Animate3DQuality { - QUALITY_NONE = 0, // it'll be ignore the curve-evaluating(the animation looks like stop), just acculate transition time. + QUALITY_NONE = 0, // it'll be ignore the curve-evaluating(the animation looks like stop), just accumulate transition time. QUALITY_LOW, // low animation quality, it'll be more efficient. QUALITY_HIGH, // high animation quality. }; @@ -161,7 +161,7 @@ protected: float _last; //last time 0 - 1, used to generate sub Animate3D bool _playReverse; // is playing reverse static float _transTime; //transition time from one animate3d to another - float _accTransTime; // acculate transition time + float _accTransTime; // accumulate transition time float _lastTime; // last t (0 - 1) float _originInterval;// save origin interval time float _frameRate; diff --git a/cocos/3d/CCAnimationCurve.h b/cocos/3d/CCAnimationCurve.h index c6af3a2fb6..78aa46bd5a 100644 --- a/cocos/3d/CCAnimationCurve.h +++ b/cocos/3d/CCAnimationCurve.h @@ -66,7 +66,7 @@ public: static AnimationCurve* create(float* keytime, float* value, int count); /** - * evalute value of time + * evaluate value of time * @param time Time to be estimated * @param dst Estimated value of that time * @param type EvaluateType diff --git a/cocos/3d/CCBillBoard.h b/cocos/3d/CCBillBoard.h index a10a37ed1a..45d3cdcf75 100644 --- a/cocos/3d/CCBillBoard.h +++ b/cocos/3d/CCBillBoard.h @@ -111,7 +111,7 @@ CC_CONSTRUCTOR_ACCESS: protected: /** - * calculate a model matrix which keep orignal translate & scaling but always face to the camera + * calculate a model matrix which keep original translate & scaling but always face to the camera */ bool calculateBillbaordTransform(); diff --git a/cocos/3d/CCBundle3D.cpp b/cocos/3d/CCBundle3D.cpp index d8fcada512..8be4e25243 100644 --- a/cocos/3d/CCBundle3D.cpp +++ b/cocos/3d/CCBundle3D.cpp @@ -1261,7 +1261,7 @@ bool Bundle3D::loadSkinDataJson(SkinData* skindata) skindata->inverseBindPoseMatrices.push_back(mat_bind_pos); } - // set root bone infomation + // set root bone information const rapidjson::Value& skin_data_1 = skin_data_array[1]; // parent and child relationship map @@ -1815,7 +1815,7 @@ NodeData* Bundle3D::parseNodesRecursivelyBinary(bool& skeleton, bool singleSprit bool skeleton_; if (_binaryReader.read(&skeleton_, 1, 1) != 1) { - CCLOG("warning: Failed to read is sleleton"); + CCLOG("warning: Failed to read is skeleton"); return nullptr; } if (skeleton_) diff --git a/cocos/3d/CCBundleReader.h b/cocos/3d/CCBundleReader.h index a4c80071a8..cade992888 100644 --- a/cocos/3d/CCBundleReader.h +++ b/cocos/3d/CCBundleReader.h @@ -48,12 +48,12 @@ class BundleReader: public cocos2d::Ref { public: /** - * Structor + * Constructor */ BundleReader(); /** - * inicial + * Destructor */ ~BundleReader(); @@ -163,7 +163,7 @@ inline bool BundleReader::readArray(unsigned int *length, std::vector *values } /** -* specalization for char +* specialization for char */ template<> inline bool BundleReader::read(char *ptr) @@ -180,7 +180,7 @@ inline bool BundleReader::read(char *ptr) } /** -* specalization for std::string +* specialization for std::string */ template<> inline bool BundleReader::read(std::string *ptr) diff --git a/cocos/3d/CCMesh.cpp b/cocos/3d/CCMesh.cpp index ad4aa2811e..98072c2aee 100644 --- a/cocos/3d/CCMesh.cpp +++ b/cocos/3d/CCMesh.cpp @@ -358,9 +358,9 @@ void Mesh::draw(Renderer* renderer, float globalZOrder, const Mat4& transform, u flags); - if (isTransparent && !forceDepthWrite) - _material->getStateBlock()->setDepthWrite(false); - else +// if (isTransparent && !forceDepthWrite) +// _material->getStateBlock()->setDepthWrite(false); +// else _material->getStateBlock()->setDepthWrite(true); diff --git a/cocos/3d/CCMesh.h b/cocos/3d/CCMesh.h index 5df31d3776..bb2714eb7c 100644 --- a/cocos/3d/CCMesh.h +++ b/cocos/3d/CCMesh.h @@ -59,7 +59,7 @@ class CC_DLL Mesh : public Ref friend class Sprite3D; public: typedef std::vector IndexArray; - /**create mesh from positions, normals, and so on, sigle SubMesh*/ + /**create mesh from positions, normals, and so on, single SubMesh*/ static Mesh* create(const std::vector& positions, const std::vector& normals, const std::vector& texs, const IndexArray& indices); /**create mesh with vertex attributes*/ CC_DEPRECATED_ATTRIBUTE static Mesh* create(const std::vector& vertices, int perVertexSizeInFloat, const IndexArray& indices, int numIndex, const std::vector& attribs, int attribCount){ return create(vertices, perVertexSizeInFloat, indices, attribs); } diff --git a/cocos/3d/CCMeshSkin.h b/cocos/3d/CCMeshSkin.h index 1339ca17dc..640f894890 100644 --- a/cocos/3d/CCMeshSkin.h +++ b/cocos/3d/CCMeshSkin.h @@ -97,7 +97,7 @@ protected: std::vector _invBindPoses; //inverse bind pose of bone Bone3D* _rootBone; - Skeleton3D* _skeleton; //skeleton the skin refered + Skeleton3D* _skeleton; //skeleton the skin referred // Pointer to the array of palette matrices. // This array is passed to the vertex shader as a uniform. diff --git a/cocos/3d/CCOBB.h b/cocos/3d/CCOBB.h index 5c83ab6460..7ea82fd2a3 100644 --- a/cocos/3d/CCOBB.h +++ b/cocos/3d/CCOBB.h @@ -35,8 +35,8 @@ NS_CC_BEGIN */ /** - * Oritened Bounding Box(OBB) - * @brief the OBB is similar to the AABB but the bounding box has the same direction as Sprite3D. so it's collistion detection more precise than AABB + * Oriented Bounding Box(OBB) + * @brief the OBB is similar to the AABB but the bounding box has the same direction as Sprite3D. so it's collision detection more precise than AABB * @js NA */ class CC_DLL OBB @@ -119,7 +119,7 @@ protected: void getInterval(const OBB& box, const Vec3& axis, float &min, float &max) const; /* - * Get the edege of x y z axis direction + * Get the edge of x y z axis direction */ Vec3 getEdgeDirection(int index) const; @@ -131,7 +131,7 @@ protected: public: Vec3 _center; // obb center Vec3 _xAxis; // x axis of obb, unit vector - Vec3 _yAxis; // y axis of obb, unit vecotr + Vec3 _yAxis; // y axis of obb, unit vector Vec3 _zAxis; // z axis of obb, unit vector Vec3 _extentX; // _xAxis * _extents.x Vec3 _extentY; // _yAxis * _extents.y diff --git a/cocos/3d/CCSkeleton3D.h b/cocos/3d/CCSkeleton3D.h index c7aab26e44..93bdcb6983 100644 --- a/cocos/3d/CCSkeleton3D.h +++ b/cocos/3d/CCSkeleton3D.h @@ -38,7 +38,7 @@ NS_CC_BEGIN */ /** - * @brief Defines a basic hierachial structure of transformation spaces. + * @brief Defines a basic hierarchical structure of transformation spaces. * @lua NA */ class CC_DLL Bone3D : public Ref @@ -57,7 +57,7 @@ public: /**update own world matrix and children's*/ void updateWorldMat(); - /**get wrod matrix*/ + /**get world matrix*/ const Mat4& getWorldMat(); /**get bone name*/ diff --git a/cocos/3d/CCSkybox.h b/cocos/3d/CCSkybox.h index c26a65f778..d3b02d1bc1 100644 --- a/cocos/3d/CCSkybox.h +++ b/cocos/3d/CCSkybox.h @@ -40,7 +40,7 @@ NS_CC_BEGIN class TextureCube; /** -* Sky box technology usually used to simulate infinity sky, mountains and other phenomena. +* Sky box technology is usually used to simulate infinity sky, mountains and other phenomena. */ class CC_DLL Skybox : public Node { @@ -49,7 +49,7 @@ public: /** create skybox from 6 textures. @param positive_x texture for the right side of the texture cube face. - @param negative_x texture for the up side of the texture cube face. + @param negative_x texture for the left side of the texture cube face. @param positive_y texture for the top side of the texture cube face @param negative_y texture for the bottom side of the texture cube face @param positive_z texture for the forward side of the texture cube face. diff --git a/cocos/3d/CCSprite3D.h b/cocos/3d/CCSprite3D.h index e51cb37540..8464be430f 100644 --- a/cocos/3d/CCSprite3D.h +++ b/cocos/3d/CCSprite3D.h @@ -51,7 +51,7 @@ class Texture2D; class MeshSkin; class AttachNode; struct NodeData; -/** @brief Sprite3D: A sprite can be loaded from 3D model files, .obj, .c3t, .c3b, then can be drawed as sprite */ +/** @brief Sprite3D: A sprite can be loaded from 3D model files, .obj, .c3t, .c3b, then can be drawn as sprite */ class CC_DLL Sprite3D : public Node, public BlendProtocol { public: @@ -70,7 +70,7 @@ public: /** create 3d sprite asynchronously * If the 3d model was previously loaded, it will create a new 3d sprite and the callback will be called at once. - * Otherwise it will load the model file in a new thread, and when the 3d sprite is loaded, the callback will be called with the created Sprite3D and a userdefined parameter. + * Otherwise it will load the model file in a new thread, and when the 3d sprite is loaded, the callback will be called with the created Sprite3D and a user-defined parameter. * The callback will be called from the main thread, so it is safe to create any cocos2d object from the callback. * @param modelPath model to be loaded * @param callback callback after loading @@ -124,12 +124,12 @@ public: // overrides /** set GLProgramState, you should bind attributes by yourself */ virtual void setGLProgramState(GLProgramState *glProgramState) override; - /** just rember bind attributes */ + /** just remember bind attributes */ virtual void setGLProgram(GLProgram *glprogram) override; /* * Get AABB - * If the sprite has animation, it can't be calculated accuratly, + * If the sprite has animation, it can't be calculated accurately, * because bone can drive the vertices, we just use the origin vertices * to calculate the AABB. */ @@ -161,7 +161,7 @@ public: /** * Returns 2d bounding-box - * Note: the bouding-box is just get from the AABB which as Z=0, so that is not very accurate. + * Note: the bounding-box is just get from the AABB which as Z=0, so that is not very accurate. */ virtual Rect getBoundingBox() const override; @@ -332,7 +332,7 @@ protected: static Sprite3DCache* _cacheInstance; - std::unordered_map _spriteDatas; //cached sprite datas + std::unordered_map _spriteDatas; //cached sprite data }; // end of 3d group diff --git a/cocos/3d/CCTerrain.cpp b/cocos/3d/CCTerrain.cpp index 461a3eb5ba..fdf4a43240 100644 --- a/cocos/3d/CCTerrain.cpp +++ b/cocos/3d/CCTerrain.cpp @@ -924,7 +924,7 @@ void Terrain::reload() void Terrain::Chunk::finish() { - //genearate two VBO ,the first for vertices, we just setup datas once ,won't changed at all + //generate two VBO ,the first for vertices, we just setup datas once ,won't changed at all //the second vbo for the indices, because we use level of detail technique to each chunk, so we will modified frequently glGenBuffers(1,&_vbo); @@ -939,7 +939,7 @@ void Terrain::Chunk::finish() for(int i =0;i<4;i++) { int step = 1<<_currentLod; - //reserve the indices size, the first part is the core part of the chunk, the second part & thid part is for fix crack + //reserve the indices size, the first part is the core part of the chunk, the second part & third part is for fix crack int indicesAmount =(_terrain->_chunkSize.width/step+1)*(_terrain->_chunkSize.height/step+1)*6+(_terrain->_chunkSize.height/step)*6 +(_terrain->_chunkSize.width/step)*6; _lod[i]._indices.reserve(indicesAmount); diff --git a/cocos/3d/CCTerrain.h b/cocos/3d/CCTerrain.h index d681090687..2220fecbd5 100644 --- a/cocos/3d/CCTerrain.h +++ b/cocos/3d/CCTerrain.h @@ -44,7 +44,7 @@ NS_CC_BEGIN */ /** - * the maximum amount of the chunkes + * the maximum amount of the chunks **/ #define MAX_CHUNKES 256 @@ -70,12 +70,12 @@ NS_CC_BEGIN * via the chunkSize property in TerrainData. * * Chunks are managed under the QuadTree.As DE FACTO terminal Node of the QuadTree; - * let us cull chunks efficientlly to reduce drawCall amount And reduce the VBOs'Size that pass to the GPU. + * let us cull chunks efficiently to reduce drawCall amount And reduce the VBOs'Size that pass to the GPU. * * Level of detail (LOD) is supported using a technique that is similar to texture mipmapping -- called GeoMapping. * A distance-to-camera based test used to decide * the appropriate LOD for a terrain chunk. The number of LOD levels is 0 by default (which - * means only the base level is used),the maxium number of LOD levels is 4. Of course ,you can hack the value individually. + * means only the base level is used),the maximum number of LOD levels is 4. Of course ,you can hack the value individually. * * Finally, when LOD is enabled, cracks can begin to appear between terrain Chunks of * different LOD levels. An acceptable solution might be to simply reduce the lower LOD(high detail,smooth) chunks border, @@ -136,7 +136,7 @@ public: /**constructor, this constructor construct a terrain which have 3 detailmaps, 1 alpha map*/ TerrainData(const char* heightMapsrc, const char * alphamap, const DetailMap& detail1,const DetailMap& detail2, const DetailMap& detail3, const Size & chunksize = Size(32,32), float mapHeight = 2, float mapScale = 0.1); /** - *deterimine the chunk size,chunk is the minimal subdivision of the Terrain + *determine the chunk size,chunk is the minimal subdivision of the Terrain */ Size _chunkSize; /**height Map source path*/ @@ -285,7 +285,7 @@ private: QuadTree * _tr; QuadTree * _bl; QuadTree * _br; - /**A flag present current quadTree node whether a terminal node,the terminal node is de facto the chunck*/ + /**A flag present current quadTree node whether a terminal node,the terminal node is de facto the chunk*/ bool _isTerminal; Chunk * _chunk; int _posX; @@ -336,7 +336,7 @@ public: **/ float getHeight(Vec2 pos, Vec3*Normal = nullptr) const; - /**get the normal of the specified pistion in terrain + /**get the normal of the specified position in terrain * @return the normal vector of the specified position of the terrain. * @note the fast normal calculation may not get precise normal vector. **/ @@ -348,7 +348,7 @@ public: **/ void setDrawWire(bool boolValue); /** - * Set threshold distance of each LOD level,must equal or gereater than the chunk size + * Set threshold distance of each LOD level,must equal or greater than the chunk size * @Note when invoke initHeightMap, the LOD distance will be automatic calculated. */ void setLODDistance(float lod1, float lod2, float lod3); @@ -374,7 +374,7 @@ public: /** * Ray-Terrain intersection. * @param ray to hit the terrain - * @param intersectionPoint hit point if hitted + * @param intersectionPoint hit point if hit * @return true if hit, false otherwise */ bool getIntersectionPoint(const Ray & ray, Vec3 & intersectionPoint) const; @@ -395,12 +395,12 @@ public: void resetHeightMap(const char * heightMap); /** - * get the terrain's mininal height. + * get the terrain's minimal height. */ float getMinHeight(); /** - * get the terrain's maximum height. + * get the terrain's maximal height. */ float getMaxHeight(); @@ -440,7 +440,7 @@ protected: /** * recursively set each chunk's LOD - * @param cameraPos the camera postion in world space + * @param cameraPos the camera position in world space **/ void setChunksLOD(Vec3 cameraPos); @@ -458,7 +458,7 @@ protected: virtual void onEnter() override; /** - * cache all unifrom loactions in GLSL. + * cache all uniform locations in GLSL. **/ void cacheUniformAttribLocation(); diff --git a/cocos/Android.mk b/cocos/Android.mk index d2049c1e68..7a5dad7ec7 100644 --- a/cocos/Android.mk +++ b/cocos/Android.mk @@ -200,6 +200,8 @@ physics/CCPhysicsContact.cpp \ physics/CCPhysicsJoint.cpp \ physics/CCPhysicsShape.cpp \ physics/CCPhysicsWorld.cpp \ +physics/CCComponentPhysics2d.cpp \ +physics/CCPhysicsManager.cpp \ physics3d/CCPhysics3D.cpp \ physics3d/CCPhysics3DWorld.cpp \ physics3d/CCPhysics3DComponent.cpp \ diff --git a/cocos/audio/apple/AudioEngine-inl.mm b/cocos/audio/apple/AudioEngine-inl.mm index 6829fb98cc..5515e7119e 100644 --- a/cocos/audio/apple/AudioEngine-inl.mm +++ b/cocos/audio/apple/AudioEngine-inl.mm @@ -75,7 +75,7 @@ void AudioEngineInterruptionListenerCallback(void* user_data, UInt32 interruptio { if ([[[UIDevice currentDevice] systemVersion] intValue] > 5) { [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleInterruption:) name:AVAudioSessionInterruptionNotification object:[AVAudioSession sharedInstance]]; - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleInterruption:) name:UIApplicationDidBecomeActiveNotification object:[AVAudioSession sharedInstance]]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleInterruption:) name:UIApplicationDidBecomeActiveNotification object:nil]; } else { AudioSessionInitialize(NULL, NULL, AudioEngineInterruptionListenerCallback, self); diff --git a/cocos/base/CCDirector.cpp b/cocos/base/CCDirector.cpp index 5494c67408..86a4498fd2 100644 --- a/cocos/base/CCDirector.cpp +++ b/cocos/base/CCDirector.cpp @@ -61,7 +61,6 @@ THE SOFTWARE. #include "base/CCConfiguration.h" #include "base/CCAsyncTaskPool.h" #include "platform/CCApplication.h" -//#include "platform/CCGLViewImpl.h" #if CC_ENABLE_SCRIPT_BINDING #include "CCScriptSupport.h" diff --git a/cocos/base/CCDirector.h b/cocos/base/CCDirector.h index 8085bc4157..14f35e2fa3 100644 --- a/cocos/base/CCDirector.h +++ b/cocos/base/CCDirector.h @@ -154,12 +154,12 @@ public: /** Gets the FPS value. */ inline float getAnimationInterval() { return _animationInterval; } - /** Sets the FPS value. FPS = 1/internal. */ + /** Sets the FPS value. FPS = 1/interval. */ virtual void setAnimationInterval(float interval) = 0; - /** Whether or not to display the FPS on the bottom-left corner. */ + /** Whether or not displaying the FPS on the bottom-left corner of the screen. */ inline bool isDisplayStats() { return _displayStats; } - /** Display the FPS on the bottom-left corner. */ + /** Display the FPS on the bottom-left corner of the screen. */ inline void setDisplayStats(bool displayStats) { _displayStats = displayStats; } /** Get seconds per frame. */ @@ -260,8 +260,8 @@ public: Vec2 convertToUI(const Vec2& point); /** - * Gets the distance between camera and near clipping frane. - * It is correct for default camera that near clipping frane is the same as screen. + * Gets the distance between camera and near clipping frame. + * It is correct for default camera that near clipping frame is same as the screen. */ float getZEye() const; diff --git a/cocos/base/CCEventListenerMouse.cpp b/cocos/base/CCEventListenerMouse.cpp index de25349faf..c0b139907a 100644 --- a/cocos/base/CCEventListenerMouse.cpp +++ b/cocos/base/CCEventListenerMouse.cpp @@ -82,19 +82,19 @@ bool EventListenerMouse::init() { case EventMouse::MouseEventType::MOUSE_DOWN: if(onMouseDown != nullptr) - onMouseDown(event); + onMouseDown(mouseEvent); break; case EventMouse::MouseEventType::MOUSE_UP: if(onMouseUp != nullptr) - onMouseUp(event); + onMouseUp(mouseEvent); break; case EventMouse::MouseEventType::MOUSE_MOVE: if(onMouseMove != nullptr) - onMouseMove(event); + onMouseMove(mouseEvent); break; case EventMouse::MouseEventType::MOUSE_SCROLL: if(onMouseScroll != nullptr) - onMouseScroll(event); + onMouseScroll(mouseEvent); break; default: break; diff --git a/cocos/base/CCEventListenerMouse.h b/cocos/base/CCEventListenerMouse.h index 49a185d719..90985804f9 100644 --- a/cocos/base/CCEventListenerMouse.h +++ b/cocos/base/CCEventListenerMouse.h @@ -57,10 +57,10 @@ public: virtual EventListenerMouse* clone() override; virtual bool checkAvailable() override; - std::function onMouseDown; - std::function onMouseUp; - std::function onMouseMove; - std::function onMouseScroll; + std::function onMouseDown; + std::function onMouseUp; + std::function onMouseMove; + std::function onMouseScroll; CC_CONSTRUCTOR_ACCESS: EventListenerMouse(); diff --git a/cocos/base/CCScriptSupport.cpp b/cocos/base/CCScriptSupport.cpp index 6de27bb537..048676e536 100644 --- a/cocos/base/CCScriptSupport.cpp +++ b/cocos/base/CCScriptSupport.cpp @@ -163,6 +163,18 @@ void ScriptEngineManager::destroyInstance() } } +bool ScriptEngineManager::sendActionEventToJS(Action* actionObject, int eventType, void* param) +{ + auto scriptEngine = getInstance()->getScriptEngine(); + + ActionObjectScriptData data(actionObject,(int*)&eventType, param); + ScriptEvent scriptEvent(kScriptActionEvent,(void*)&data); + if (scriptEngine->sendEvent(&scriptEvent)) + return true; + + return false; +} + bool ScriptEngineManager::sendNodeEventToJS(Node* node, int action) { auto scriptEngine = getInstance()->getScriptEngine(); diff --git a/cocos/base/CCScriptSupport.h b/cocos/base/CCScriptSupport.h index 203060c50b..ca0ad7a75e 100644 --- a/cocos/base/CCScriptSupport.h +++ b/cocos/base/CCScriptSupport.h @@ -51,6 +51,7 @@ class Layer; class MenuItem; class CallFunc; class Acceleration; +class Action; enum ccScriptType { kScriptTypeNone = 0, @@ -259,7 +260,8 @@ enum ScriptEventType kControlEvent, kCommonEvent, kComponentEvent, - kRestartGame + kRestartGame, + kScriptActionEvent }; /** @@ -296,6 +298,48 @@ struct BasicScriptData } }; +/** + * For Lua, Wrapper the script data that should be used to find the handler corresponding to the Lua function by the nativeobject pointer and store the value pointer which would be converted concretely by the different events,then the converted data would be passed into the Lua stack. + * @js NA + */ +struct ActionObjectScriptData +{ + /** + * For Lua, nativeobject is used to get handler corresponding to the Lua function. + * + * @js NA + * @lua NA + */ + void* nativeObject; + + /** + * A pointer point to the value data which event action + * + * @js NA + * @lua NA + */ + int* eventType; + + /** + * A pointer point to the value data which would be converted by different events. + * + * @js NA + * @lua NA + */ + void* param; + + /** + * Constructor of BasicScriptData. + * + * @js NA + * @lua NA + */ + ActionObjectScriptData(void* inObject,int* inValue = nullptr, void* inParam = nullptr) + : nativeObject(inObject),eventType(inValue), param(inParam) + { + } +}; + /** * For Lua, the SchedulerScriptData is used to find the Lua function pointer by the handler, then call the Lua function by push the elapse into the Lua stack as a parameter when scheduler update event is triggered. * @js NA @@ -770,6 +814,13 @@ public: * @js NA */ static void destroyInstance(); + /** + * + * + * @lua NA + * @js NA + */ + static bool sendActionEventToJS(Action* actionObject, int eventType, void* param); /** * * diff --git a/cocos/cocos2d.h b/cocos/cocos2d.h index fb205c046b..34070a9a70 100644 --- a/cocos/cocos2d.h +++ b/cocos/cocos2d.h @@ -29,8 +29,8 @@ THE SOFTWARE. #define __COCOS2D_H__ // 0x00 HI ME LO -// 00 03 07 00 -#define COCOS2D_VERSION 0x00030700 +// 00 03 08 00 +#define COCOS2D_VERSION 0x00030800 // // all cocos2d include files @@ -186,6 +186,8 @@ THE SOFTWARE. #include "physics/CCPhysicsJoint.h" #include "physics/CCPhysicsShape.h" #include "physics/CCPhysicsWorld.h" +#include "physics/CCComponentPhysics2d.h" +#include "physics/CCPhysicsManager.h" // platform #include "platform/CCCommon.h" diff --git a/cocos/editor-support/cocostudio/WidgetReader/TextReader/TextReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/TextReader/TextReader.cpp index 173aeac4f9..962ad2b66f 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/TextReader/TextReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/TextReader/TextReader.cpp @@ -400,54 +400,33 @@ namespace cocostudio bool touchScaleEnabled = options->touchScaleEnable() != 0; label->setTouchScaleChangeEnabled(touchScaleEnabled); - std::string text = options->text()->c_str(); - label->setString(text); - int fontSize = options->fontSize(); label->setFontSize(fontSize); - - std::string fontName = options->fontName()->c_str(); - label->setFontName(fontName); - + Size areaSize = Size(options->areaWidth(), options->areaHeight()); if (!areaSize.equals(Size::ZERO)) { label->setTextAreaSize(areaSize); } + + auto resourceData = options->fontResource(); + std::string path = resourceData->path()->c_str(); + if (!path.empty() && FileUtils::getInstance()->isFileExist(path)) + { + label->setFontName(path); + } + else + { + std::string fontName = options->fontName()->c_str(); + label->setFontName(fontName); + } TextHAlignment h_alignment = (TextHAlignment)options->hAlignment(); label->setTextHorizontalAlignment(h_alignment); - + TextVAlignment v_alignment = (TextVAlignment)options->vAlignment(); label->setTextVerticalAlignment((TextVAlignment)v_alignment); - - bool fileExist = false; - std::string errorFilePath = ""; - auto resourceData = options->fontResource(); - std::string path = resourceData->path()->c_str(); - if (path != "") - { - if (FileUtils::getInstance()->isFileExist(path)) - { - fileExist = true; - } - else - { - errorFilePath = path; - fileExist = false; - } - if (fileExist) - { - label->setFontName(path); - } - //else - //{ - // auto alert = Label::create(); - // alert->setString(__String::createWithFormat("%s missed", errorFilePath.c_str())->getCString()); - // label->addChild(alert); - //} - } - + bool outlineEnabled = options->outlineEnabled() != 0; if (outlineEnabled) { @@ -470,6 +449,9 @@ namespace cocostudio } } + std::string text = options->text()->c_str(); + label->setString(text); + // Save node color before set widget properties auto oldColor = node->getColor(); @@ -494,7 +476,6 @@ namespace cocostudio Size contentSize(widgetOptions->size()->width(), widgetOptions->size()->height()); label->setContentSize(contentSize); } - } Node* TextReader::createNodeWithFlatBuffers(const flatbuffers::Table *textOptions) diff --git a/cocos/network/SocketIO.cpp b/cocos/network/SocketIO.cpp index 58dd0de8ec..083b2071d8 100644 --- a/cocos/network/SocketIO.cpp +++ b/cocos/network/SocketIO.cpp @@ -1096,6 +1096,11 @@ void SIOClient::fireEvent(const std::string& eventName, const std::string& data) CCLOGINFO("SIOClient::fireEvent no native event with name %s found", eventName.c_str()); } + +void SIOClient::setTag(const char* tag) +{ + _tag = tag; +} //begin SocketIO methods SocketIO *SocketIO::_inst = nullptr; diff --git a/cocos/network/SocketIO.h b/cocos/network/SocketIO.h index 3456320cc6..5ad10d0f35 100644 --- a/cocos/network/SocketIO.h +++ b/cocos/network/SocketIO.h @@ -262,10 +262,8 @@ public: * The tag is used to distinguish the various SIOClient objects. * @param tag string object. */ - inline void setTag(const char* tag) - { - _tag = tag; - }; + void setTag(const char* tag); + /** * Get tag of SIOClient. * @return const char* the pointer point to the _tag. diff --git a/cocos/physics/CCComponentPhysics2d.cpp b/cocos/physics/CCComponentPhysics2d.cpp new file mode 100644 index 0000000000..08c4c9c3b8 --- /dev/null +++ b/cocos/physics/CCComponentPhysics2d.cpp @@ -0,0 +1,263 @@ +/**************************************************************************** + Copyright (c) 2015 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + 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. + ****************************************************************************/ + +#include "base/ccConfig.h" // to include defination of CC_USE_PHYSICS +#if CC_USE_PHYSICS + +#include "physics/CCComponentPhysics2d.h" +#include "physics/CCPhysicsBody.h" +#include "physics/CCPhysicsManager.h" +#include "2d/CCNode.h" +#include "base/CCDirector.h" + +NS_CC_BEGIN + +const std::string ComponentPhysics2d::COMPONENT_NAME = "physics2d"; + +ComponentPhysics2d* ComponentPhysics2d::create() +{ + return create(nullptr); +} + +ComponentPhysics2d* ComponentPhysics2d::create(PhysicsBody *physicsBody) +{ + auto ret = new (std::nothrow) ComponentPhysics2d(physicsBody); + if (ret) + ret->autorelease(); + + return ret; +} + +ComponentPhysics2d::ComponentPhysics2d() +: _physicsBody(nullptr) +, _physicsRotation(0.0f) +, _ownerOriginRotation(0.0f) +{ + _name = COMPONENT_NAME; +} + +ComponentPhysics2d::ComponentPhysics2d(PhysicsBody* physicsBody) +: _physicsRotation(0.0f) +, _ownerOriginRotation(0.0f) +, _physicsBody(nullptr) // should set to null to invoke setPhysicsBody() +{ + _name = COMPONENT_NAME; + setPhysicsBody(physicsBody); +} + +ComponentPhysics2d::~ComponentPhysics2d() +{ + removePhysicsBody(); +} + +// true if two Vec3 equals, false else +bool ComponentPhysics2d::isVec3Equal(const cocos2d::Vec3 &v1, const cocos2d::Vec3 &v2) const +{ + return fabs(v1.x - v2.x) < FLT_EPSILON && + fabs(v1.x - v2.y) < FLT_EPSILON; +} + +void ComponentPhysics2d::beforeSimulation() +{ + if (nullptr == _physicsBody) + return; + + _nodeToWorldTransform = _owner->getNodeToWorldTransform(); + + // set scale + _nodeToWorldTransform.getScale(&_scale); + if (! isVec3Equal(_scale, _recordScale)) + { + _physicsBody->setScale(_scale.x, _scale.y); + _recordScale = _scale; + } + + // set rotation + if (_owner->getParent()) + { + _physicsRotation = getPhysicsRotation(_owner->getParent()) + _owner->getRotation(); + } + _physicsBody->setRotation(_physicsRotation - _ownerOriginRotation); + + // set position + auto worldPosition = _ownerCenterOffset; + _nodeToWorldTransform.transformPoint(&worldPosition); + _physicsBody->setPosition(Vec2(worldPosition.x, worldPosition.y)); + + getParentToWorldTransform().getInversed().transformPoint(&worldPosition); + _offset.x = worldPosition.x - _owner->getPosition().x; + _offset.y = worldPosition.y - _owner->getPosition().y; +} + +void ComponentPhysics2d::afterSimulation() +{ + if (nullptr == _physicsBody) + return; + + // set Node position + auto worldPosition = _physicsBody->getPosition(); + Vec3 positionInParent(worldPosition.x, worldPosition.y, 0); + getParentToWorldTransform().getInversed().transformPoint(&positionInParent); + _owner->setPosition(positionInParent.x - _offset.x, positionInParent.y - _offset.y); + + // set Node rotation + _physicsRotation = _physicsBody->getRotation(); + _owner->setRotation(_physicsRotation - getPhysicsRotation(_owner->getParent()) + _ownerOriginRotation); +} + +void ComponentPhysics2d::setPhysicsBody(PhysicsBody *physicsBody) +{ + removeFromPhysicsManager(); + + if (physicsBody != _physicsBody) + { + if (nullptr != _physicsBody) + { + _physicsBody->release(); + _physicsBody->_componentBelongsTo = nullptr; + } + + // two components should not share the same physics body + if (physicsBody && physicsBody->_componentBelongsTo != nullptr) + physicsBody->_componentBelongsTo->_physicsBody = nullptr; + + _physicsBody = physicsBody; + + if (nullptr != _physicsBody) + { + _physicsBody->retain(); + _physicsBody->_componentBelongsTo = this; + } + } + + addToPhysicsManager(); +} + +PhysicsBody* ComponentPhysics2d::getPhysicsBody() const +{ + return _physicsBody; +} + +void ComponentPhysics2d::setEnabled(bool value) +{ + Component::setEnabled(value); + + if (value) + addToPhysicsManager(); + else + removeFromPhysicsManager(); +} + +void ComponentPhysics2d::onEnter() +{ + addToPhysicsManager(); +} + +void ComponentPhysics2d::onExit() +{ + removeFromPhysicsManager(); +} + +void ComponentPhysics2d::onAdd() +{ + auto contentSize = _owner->getContentSize(); + _ownerCenterOffset.x = 0.5 * contentSize.width; + _ownerCenterOffset.y = 0.5 * contentSize.height; + + _ownerOriginRotation = _owner->getRotation(); + + // component may be added after onEnter() has been invoked, so we should add + // this line to make sure physics body is added to physics world + addToPhysicsManager(); +} + +void ComponentPhysics2d::onRemove() +{ + removePhysicsBody(); +} + +void ComponentPhysics2d::removePhysicsBody() +{ + removeFromPhysicsManager(); + + if (_physicsBody) + { + _physicsBody->_componentBelongsTo = nullptr; + _physicsBody->release(); + _physicsBody = nullptr; + } +} + +void ComponentPhysics2d::addToPhysicsManager() +{ + if (_owner) + { + auto scene = _owner->getScene(); + if (scene) + scene->getPhysicsManager()->addPhysicsComponent(this); + } + +} + +void ComponentPhysics2d::removeFromPhysicsManager() +{ + if (_owner) + { + auto scene = _owner->getScene(); + if (scene) + scene->getPhysicsManager()->removePhysicsComponent(this); + } +} + +Mat4 ComponentPhysics2d::getParentToWorldTransform() const +{ + if (_owner->getParent()) + return _owner->getParent()->getNodeToWorldTransform(); + else + return _owner->getNodeToWorldTransform(); +} + +float ComponentPhysics2d::getPhysicsRotation(Node *node) const +{ + if (!node) + return 0.0f; + + auto physicsComponent = node->getComponent(); + if (physicsComponent) + { + return physicsComponent->_physicsRotation; + } + else + { + auto parent = node->getParent(); + if (parent) + return getPhysicsRotation(parent) + node->getRotation(); + else + return 0.0f; + } +} + +NS_CC_END + +#endif // CC_USE_PHYSICS diff --git a/cocos/physics/CCComponentPhysics2d.h b/cocos/physics/CCComponentPhysics2d.h new file mode 100644 index 0000000000..6814b883ef --- /dev/null +++ b/cocos/physics/CCComponentPhysics2d.h @@ -0,0 +1,140 @@ +/**************************************************************************** + Copyright (c) 2015 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + 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 + +#include "base/ccConfig.h" // to include defination of CC_USE_PHYSICS +#if CC_USE_PHYSICS + +#include "platform/CCPlatformMacros.h" +#include "2d/CCComponent.h" + +NS_CC_BEGIN + +/** + * @addtogroup physics + * @{ + * @addtogroup physics_2d + * @{ + */ + +class PhysicsBody; + +class CC_DLL ComponentPhysics2d : public Component +{ +public: + /** + * Create a physics component without physics body. Can set phyiscs body later with setPhysicsBody(). + * I am not sure if we need this function, because i think physics body is needed when creating a + * physics component. But i think it is needed by editor, so i keep this function. + * + * @return A pointer of `ComponentPhysics2d` that is autoreleased. + */ + static ComponentPhysics2d* create(); + /** + * Create a physics component with physics body. + * + * @param physicsBody The physics body that belongs to this component. + * @return A pointer of `ComponentPhysics2d` that is autoreleased. + */ + static ComponentPhysics2d* create(PhysicsBody *physicsBody); + + virtual ~ComponentPhysics2d(); + + /// @cond DO_NOT_SHOW + + /** + * Synchronize Node's status(position, rotation, scale) to phyiscs body. + * It is invoked before physics simulation. + * + * @warning Don't invoke this funciton by yourself. + */ + void beforeSimulation(); + /** + * Synchronize physics body's status(position, rotation) to phyiscs body. + * It is invoked after physics simulation. + * + * @warning Don't invoke this funciton by yourself. + */ + void afterSimulation(); + + /// @endcond DO_NOT_SHOW + + /** + * Set physics body of this physics component. If the physics body is set to + * another physics component before, will set another physics component's physics + * body to null. + * + * @param physicsBody The physics body belongs to this component. + */ + void setPhysicsBody(PhysicsBody *physicsBody); + /** + * Get the physics body of this component. + * + * @return The physics body of this component. + */ + PhysicsBody* getPhysicsBody() const; + + virtual void setEnabled(bool value) override; + virtual void onEnter() override; + virtual void onExit() override; + virtual void onAdd() override; + virtual void onRemove() override; + +public: + const static std::string COMPONENT_NAME; + +CC_CONSTRUCTOR_ACCESS: + ComponentPhysics2d(); + ComponentPhysics2d(PhysicsBody *phsicsBody); + +private: + void removePhysicsBody(); + void addToPhysicsManager(); + void removeFromPhysicsManager(); + Mat4 getParentToWorldTransform() const; + float getPhysicsRotation(Node *node) const; + bool isVec3Equal(const Vec3 &v1, const Vec3 &v2) const; + +private: + // this physic body of this component + PhysicsBody *_physicsBody; + // offset between owner's center point and down left point + Vec3 _ownerCenterOffset; + Mat4 _nodeToWorldTransform; + // offset of owner's center point and anchor point in parent coordinate + Vec2 _offset; + float _physicsRotation; + // the rotation of owner when the component is added to, the value will not change + float _ownerOriginRotation; + Vec3 _recordScale; + Vec3 _scale; +}; + +/** @} */ +/** @} */ + +NS_CC_END + +#endif // CC_USE_PHYSICS diff --git a/cocos/physics/CCPhysicsBody.cpp b/cocos/physics/CCPhysicsBody.cpp index 188a16e00b..563bb9973f 100644 --- a/cocos/physics/CCPhysicsBody.cpp +++ b/cocos/physics/CCPhysicsBody.cpp @@ -31,10 +31,11 @@ #include "chipmunk.h" #include "2d/CCScene.h" -#include "CCPhysicsShape.h" -#include "CCPhysicsJoint.h" -#include "CCPhysicsWorld.h" -#include "CCPhysicsHelper.h" +#include "physics/CCPhysicsShape.h" +#include "physics/CCPhysicsJoint.h" +#include "physics/CCPhysicsWorld.h" +#include "physics/CCPhysicsHelper.h" +#include "physics/CCComponentPhysics2d.h" static inline void cpBodyUpdateVelocityWithoutGravity(cpBody *body, cpVect gravity, cpFloat damping, cpFloat dt) { @@ -51,8 +52,7 @@ namespace } PhysicsBody::PhysicsBody() -: _node(nullptr) -, _world(nullptr) +: _world(nullptr) , _cpBody(nullptr) , _dynamic(true) , _enabled(true) @@ -68,10 +68,12 @@ PhysicsBody::PhysicsBody() , _linearDamping(0.0f) , _angularDamping(0.0f) , _tag(0) -, _positionInitDirty(true) , _rotationOffset(0) , _recordedRotation(0.0f) , _recordedAngle(0.0) +, _componentBelongsTo(nullptr) +, _massSetByUser(false) +, _momentSetByUser(false) { } @@ -334,8 +336,6 @@ void PhysicsBody::setGravityEnable(bool enable) void PhysicsBody::setPosition(const Vec2& position) { - _positionInitDirty = false; - _recordedPosition = position; cpBodySetPos(_cpBody, PhysicsHelper::point2cpv(position + _positionOffset)); } @@ -350,25 +350,25 @@ void PhysicsBody::setScale(float scaleX, float scaleY) { for (auto shape : _shapes) { + _area -= shape->getArea(); + if (!_massSetByUser) + addMass(-shape->getMass()); + if (!_momentSetByUser) + addMoment(-shape->getMoment()); + shape->setScale(scaleX, scaleY); + + _area += shape->getArea(); + if (!_massSetByUser) + addMass(shape->getMass()); + if (!_momentSetByUser) + addMoment(shape->getMoment()); } } -const Vec2& PhysicsBody::getPosition() +Vec2 PhysicsBody::getPosition() const { - if (_positionInitDirty) { - if (_node) { - if (_node->getParent()) { - _latestPosition = _node->getParent()->convertToWorldSpace(_node->getPosition()); - } else { - _latestPosition = _node->getPosition(); - } - } - } else { - _latestPosition.x = _cpBody->p.x - _positionOffset.x; - _latestPosition.y = _cpBody->p.y - _positionOffset.y; - } - return _latestPosition; + return Vec2(_cpBody->p.x - _positionOffset.x, _cpBody->p.y - _positionOffset.y); } float PhysicsBody::getRotation() @@ -450,6 +450,7 @@ void PhysicsBody::setMass(float mass) } _mass = mass; _massDefault = false; + _massSetByUser = true; // update density if (_mass == PHYSICS_INFINITY) @@ -628,6 +629,7 @@ void PhysicsBody::setMoment(float moment) { _moment = moment; _momentDefault = false; + _momentSetByUser = true; // the static body's mass and moment is always infinity if (_rotationEnabled && _dynamic) @@ -723,6 +725,14 @@ void PhysicsBody::removeFromWorld() } } +Node* PhysicsBody::getNode() const +{ + if (_componentBelongsTo) + return _componentBelongsTo->getOwner(); + else + return nullptr; +} + void PhysicsBody::setEnable(bool enable) { if (_enabled != enable) @@ -760,15 +770,12 @@ void PhysicsBody::setResting(bool rest) const void PhysicsBody::update(float delta) { - if (_node) + // damping compute + if (_isDamping && _dynamic && !isResting()) { - // damping compute - if (_isDamping && _dynamic && !isResting()) - { - _cpBody->v.x *= cpfclamp(1.0f - delta * _linearDamping, 0.0f, 1.0f); - _cpBody->v.y *= cpfclamp(1.0f - delta * _linearDamping, 0.0f, 1.0f); - _cpBody->w *= cpfclamp(1.0f - delta * _angularDamping, 0.0f, 1.0f); - } + _cpBody->v.x *= cpfclamp(1.0f - delta * _linearDamping, 0.0f, 1.0f); + _cpBody->v.y *= cpfclamp(1.0f - delta * _linearDamping, 0.0f, 1.0f); + _cpBody->w *= cpfclamp(1.0f - delta * _angularDamping, 0.0f, 1.0f); } } diff --git a/cocos/physics/CCPhysicsBody.h b/cocos/physics/CCPhysicsBody.h index a47fd564a8..ad0db3d1a5 100644 --- a/cocos/physics/CCPhysicsBody.h +++ b/cocos/physics/CCPhysicsBody.h @@ -41,6 +41,7 @@ class Node; class Sprite; class PhysicsWorld; class PhysicsJoint; +class ComponentPhysics2d; typedef Vec2 Vect; @@ -305,7 +306,7 @@ public: inline const std::vector& getJoints() const { return _joints; } /** get the sprite the body set to. */ - inline Node* getNode() const { return _node; } + Node* getNode() const; /** * A mask that defines which categories this physics body belongs to. @@ -368,7 +369,7 @@ public: int getGroup() const; /** get the body position. */ - const Vec2& getPosition(); + Vec2 getPosition() const; /** get the body rotation. */ float getRotation(); @@ -505,7 +506,7 @@ public: Vec2 local2World(const Vec2& point); /** Get the rigid body of chipmunk. */ - cpBody* getCPBody() { return _cpBody; } + cpBody* getCPBody() const { return _cpBody; } protected: @@ -525,10 +526,11 @@ protected: virtual ~PhysicsBody(); protected: - Node* _node; std::vector _joints; Vector _shapes; PhysicsWorld* _world; + // weak reference + ComponentPhysics2d *_componentBelongsTo; cpBody* _cpBody; bool _dynamic; bool _enabled; @@ -545,9 +547,11 @@ protected: float _angularDamping; int _tag; - bool _positionInitDirty; - Vec2 _recordedPosition; - Vec2 _latestPosition; + // when setMass() is invoked, it means body's mass is not calculated by shapes + bool _massSetByUser; + // when setMoment() is invoked, it means body's moment is not calculated by shapes + bool _momentSetByUser; + Vec2 _positionOffset; float _rotationOffset; float _recordedRotation; @@ -559,6 +563,7 @@ protected: friend class Node; friend class Layer; friend class ProtectedNode; + friend class ComponentPhysics2d; }; /** @} */ diff --git a/cocos/physics/CCPhysicsManager.cpp b/cocos/physics/CCPhysicsManager.cpp new file mode 100644 index 0000000000..15a4d40583 --- /dev/null +++ b/cocos/physics/CCPhysicsManager.cpp @@ -0,0 +1,133 @@ +/**************************************************************************** + Copyright (c) 2015 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + 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. + ****************************************************************************/ + +#include "base/ccConfig.h" // to include defination of CC_USE_PHYSICS +#if CC_USE_PHYSICS + +#include "physics/CCPhysicsManager.h" +#include "physics/CCComponentPhysics2d.h" +#include "physics/CCPhysicsWorld.h" +#include "2d/CCScene.h" + +NS_CC_BEGIN + +PhysicsManager::PhysicsManager(Scene *scene) +: _scene(scene) +{ + _physicsWorld = PhysicsWorld::construct(); +} + +PhysicsManager::~PhysicsManager() +{ + delete _physicsWorld; +} + +void PhysicsManager::update(float dt) +{ + // Update physics position, should loop as the same sequence as node tree. + // ComponentPhysics2d::beforeSimulation() will depend on the sequence. + beforeSimulation(_scene); + + // do simulation + _physicsWorld->update(dt, false); + + // Update physics position, should loop as the same sequence as node tree. + // ComponentPhysics2d::afterSimulation() will depend on the sequence. + afterSimulation(_scene); +} + +void PhysicsManager::beforeSimulation(Node *node) +{ + auto iter = _owners.find(node); + if (iter != _owners.end()) + { + auto component = iter->second; + component->beforeSimulation(); + } + + for (auto child : node->getChildren()) + beforeSimulation(child); +} + +void PhysicsManager::afterSimulation(Node *node) +{ + auto iter = _owners.find(node); + if (iter != _owners.end()) + { + auto component = iter->second; + component->afterSimulation(); + } + + for (auto child : node->getChildren()) + afterSimulation(child); +} + +void PhysicsManager::addPhysicsComponent(ComponentPhysics2d* componentPhsics2d) +{ + // don't add component again + if (std::find(_components.begin(), _components.end(), componentPhsics2d) != _components.end()) + return; + + _components.push_back(componentPhsics2d); + // Node::getComponent<>() is a time comsuming operation, so record data to avoid invoking it. + std::pair element(componentPhsics2d->getOwner(), componentPhsics2d); + _owners.insert(element); + + if (nullptr != componentPhsics2d->getPhysicsBody()) + _physicsWorld->addBody(componentPhsics2d->getPhysicsBody()); +} + +void PhysicsManager::removePhysicsComponent(ComponentPhysics2d* componentPhsics2d) +{ + auto iter = std::find(_components.begin(), _components.end(), componentPhsics2d); + if (iter != _components.end()) + { + removeElementFromMap(*iter); + + _components.erase(iter); + if (componentPhsics2d->getPhysicsBody()) + _physicsWorld->removeBody(componentPhsics2d->getPhysicsBody()); + } +} + +void PhysicsManager::removeElementFromMap(ComponentPhysics2d* component) +{ + for (auto element : _owners) + { + if (element.second == component) + { + _owners.erase(element.first); + break; + } + } +} + +PhysicsWorld* PhysicsManager::getPhysicsWorld() const +{ + return _physicsWorld; +} + +NS_CC_END + +#endif // CC_USE_PHYSICS diff --git a/cocos/physics/CCPhysicsManager.h b/cocos/physics/CCPhysicsManager.h new file mode 100644 index 0000000000..5c1ecc0931 --- /dev/null +++ b/cocos/physics/CCPhysicsManager.h @@ -0,0 +1,124 @@ +/**************************************************************************** + Copyright (c) 2015 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + 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 + +#include "base/ccConfig.h" // to include defination of CC_USE_PHYSICS +#if CC_USE_PHYSICS + +#include +#include + +#include "platform/CCPlatformMacros.h" + +NS_CC_BEGIN + +class ComponentPhysics2d; +class PhysicsWorld; +class Scene; +class Node; + +/** + * @addtogroup physics + * @{ + * @addtogroup physics_2d + * @{ + */ + +/** + * Now `PhysicsManager` belongs to a `Scene`. `Scene` will create `PhysicsManager` automatically. + * The reason to design like this are: + * - PhysicsManager keeps physics world, it is reasonale that a scene has its own physics world. + * It is useful that when a scene is active again, you don't have to create physics world and + * do all related things again. + * - Keep compatibility + */ +class CC_DLL PhysicsManager +{ +public: + + /// @cond DO_NOT_SHOW + + /** + * Create a PhysicsManager with `Scene`. `Scene` will create it automatically, + * so don't create it yourself. + * + * @scene The scene this `PhysicsManager` belongs to. + */ + PhysicsManager(Scene *scene); + /** + * Destructor. + */ + ~PhysicsManager(); + + /** + * Do physics simulation. It will do the following things: + * - synchronize Node's status(position, rotation, scale) to corresponding physics body + * - do physics simulation + * - synchronize physics body's status(position, rotation) to correspondind Node + * + * It is invoked by `Scene`, don't invoke it yourself. + */ + void update(float dt); + + /// @endcond DO_NOT_SHOW + + /** + * Get the physics world. + * + * @return Physics world managed by this `PhysicsManager`. + */ + PhysicsWorld* getPhysicsWorld() const; + + /** + * Add a physics component to be managed by the `PhysicsManager`. Will register physics + * component's physics body to physics world managed by this `PhysicsManager`. + * + * @param componentPhsics2d The physics component to be managed by this `PhysicsManager`. + */ + void addPhysicsComponent(ComponentPhysics2d* componentPhsics2d); + /** + * Remove a physics component from `PhysiscsManager`. Will remove physics component's physics + * body from the physics world managed by this `PhysicsManager`. + */ + void removePhysicsComponent(ComponentPhysics2d* componentPhsics2d); + +private: + void beforeSimulation(Node *node); + void afterSimulation(Node* node); + void removeElementFromMap(ComponentPhysics2d* component); +private: + std::vector _components; + // record the owners of components for performance + std::unordered_map _owners; + PhysicsWorld *_physicsWorld; + Scene *_scene; +}; + +/** @} */ +/** @} */ + +NS_CC_END + +#endif // CC_USE_PHYSICS diff --git a/cocos/physics/CCPhysicsShape.cpp b/cocos/physics/CCPhysicsShape.cpp index 538778e7d1..9f5116305e 100644 --- a/cocos/physics/CCPhysicsShape.cpp +++ b/cocos/physics/CCPhysicsShape.cpp @@ -114,7 +114,7 @@ void PhysicsShape::setMaterial(const PhysicsMaterial& material) void PhysicsShape::setScale(float scaleX, float scaleY) { - if (_scaleX != scaleX || _scaleY != scaleY) + if (fabs(_scaleX - scaleX) > FLT_EPSILON || fabs(_scaleY - scaleY) > FLT_EPSILON) { if (_type == Type::CIRCLE && scaleX != scaleY) { @@ -123,7 +123,13 @@ void PhysicsShape::setScale(float scaleX, float scaleY) } _newScaleX = scaleX; _newScaleY = scaleY; + updateScale(); + + // re-calculate area and mass + _area = calculateArea(); + _mass = _material.density * _area; + _moment = calculateDefaultMoment(); } } @@ -649,10 +655,14 @@ void PhysicsShapePolygon::updateScale() for (int i = 0; i < count; ++i) { - cpVect n = cpvnormalize(cpvperp(cpvsub(vects[i], vects[(i + 1) % count]))); - - planes[i].n = n; - planes[i].d = cpvdot(n, vects[i]); +// cpVect n = cpvnormalize(cpvperp(cpvsub(vects[i], vects[(i + 1) % count]))); +// +// planes[i].n = n; +// planes[i].d = cpvdot(n, vects[i]); + + // FIXED ME: if update 'planes[i]' as the above codes, then can not query polygon shape by PhysicsWorld::getShapes(). + // But modified like this, then ray test can not work correctly on some cases. + planes[i].d = cpvdot(planes[i].n, vects[i]); } PhysicsShape::updateScale(); diff --git a/cocos/physics/CCPhysicsWorld.cpp b/cocos/physics/CCPhysicsWorld.cpp index 117d4627c1..1ceb0824f4 100644 --- a/cocos/physics/CCPhysicsWorld.cpp +++ b/cocos/physics/CCPhysicsWorld.cpp @@ -281,7 +281,7 @@ int PhysicsWorld::collisionBeginCallback(PhysicsContact& contact) { contact.setEventCode(PhysicsContact::EventCode::BEGIN); contact.setWorld(this); - _scene->getEventDispatcher()->dispatchEvent(&contact); + Director::getInstance()->getEventDispatcher()->dispatchEvent(&contact); } return ret ? contact.resetResult() : false; @@ -296,7 +296,7 @@ int PhysicsWorld::collisionPreSolveCallback(PhysicsContact& contact) contact.setEventCode(PhysicsContact::EventCode::PRESOLVE); contact.setWorld(this); - _scene->getEventDispatcher()->dispatchEvent(&contact); + Director::getInstance()->getEventDispatcher()->dispatchEvent(&contact); return contact.resetResult(); } @@ -310,7 +310,7 @@ void PhysicsWorld::collisionPostSolveCallback(PhysicsContact& contact) contact.setEventCode(PhysicsContact::EventCode::POSTSOLVE); contact.setWorld(this); - _scene->getEventDispatcher()->dispatchEvent(&contact); + Director::getInstance()->getEventDispatcher()->dispatchEvent(&contact); } void PhysicsWorld::collisionSeparateCallback(PhysicsContact& contact) @@ -322,7 +322,7 @@ void PhysicsWorld::collisionSeparateCallback(PhysicsContact& contact) contact.setEventCode(PhysicsContact::EventCode::SEPARATE); contact.setWorld(this); - _scene->getEventDispatcher()->dispatchEvent(&contact); + Director::getInstance()->getEventDispatcher()->dispatchEvent(&contact); } void PhysicsWorld::rayCast(PhysicsRayCastCallbackFunc func, const Vec2& point1, const Vec2& point2, void* data) @@ -333,7 +333,6 @@ void PhysicsWorld::rayCast(PhysicsRayCastCallbackFunc func, const Vec2& point1, { if (!_delayAddBodies.empty() || !_delayRemoveBodies.empty()) { - _scene->updatePhysicsBodyTransform(_scene->getNodeToParentTransform(), 0, 1.0f, 1.0f); updateBodies(); } RayCastCallbackInfo info = { this, func, point1, point2, data }; @@ -357,7 +356,6 @@ void PhysicsWorld::queryRect(PhysicsQueryRectCallbackFunc func, const Rect& rect { if (!_delayAddBodies.empty() || !_delayRemoveBodies.empty()) { - _scene->updatePhysicsBodyTransform(_scene->getNodeToParentTransform(), 0, 1.0f, 1.0f); updateBodies(); } RectQueryCallbackInfo info = {this, func, data}; @@ -380,7 +378,6 @@ void PhysicsWorld::queryPoint(PhysicsQueryPointCallbackFunc func, const Vec2& po { if (!_delayAddBodies.empty() || !_delayRemoveBodies.empty()) { - _scene->updatePhysicsBodyTransform(_scene->getNodeToParentTransform(), 0, 1.0f, 1.0f); updateBodies(); } PointQueryCallbackInfo info = {this, func, data}; @@ -422,10 +419,10 @@ PhysicsShape* PhysicsWorld::getShape(const Vec2& point) const return shape == nullptr ? nullptr : s_physicsShapeMap.find(shape)->second; } -PhysicsWorld* PhysicsWorld::construct(Scene& scene) +PhysicsWorld* PhysicsWorld::construct() { PhysicsWorld * world = new (std::nothrow) PhysicsWorld(); - if(world && world->init(scene)) + if(world && world->init()) { return world; } @@ -434,15 +431,13 @@ PhysicsWorld* PhysicsWorld::construct(Scene& scene) return nullptr; } -bool PhysicsWorld::init(Scene& scene) +bool PhysicsWorld::init() { do { _cpSpace = cpSpaceNew(); CC_BREAK_IF(_cpSpace == nullptr); - _scene = &scene; - cpSpaceSetGravity(_cpSpace, PhysicsHelper::point2cpv(_gravity)); cpSpaceSetDefaultCollisionHandler(_cpSpace, @@ -817,11 +812,9 @@ void PhysicsWorld::step(float delta) void PhysicsWorld::update(float delta, bool userCall/* = false*/) { - if(_updateBodyTransform || !_delayAddBodies.empty()) + if(!_delayAddBodies.empty()) { - _scene->updatePhysicsBodyTransform(_scene->getNodeToParentTransform(), 0, 1.0f, 1.0f); updateBodies(); - _updateBodyTransform = false; } else if (!_delayRemoveBodies.empty()) { @@ -904,7 +897,7 @@ PhysicsDebugDraw::PhysicsDebugDraw(PhysicsWorld& world) , _world(world) { _drawNode = DrawNode::create(); - _world.getScene().addChild(_drawNode); + Director::getInstance()->getRunningScene()->addChild(_drawNode); } PhysicsDebugDraw::~PhysicsDebugDraw() diff --git a/cocos/physics/CCPhysicsWorld.h b/cocos/physics/CCPhysicsWorld.h index 4f45d6554e..107dcac932 100644 --- a/cocos/physics/CCPhysicsWorld.h +++ b/cocos/physics/CCPhysicsWorld.h @@ -329,8 +329,9 @@ public: void step(float delta); protected: - static PhysicsWorld* construct(Scene& scene); - bool init(Scene& scene); + static PhysicsWorld* construct(); + bool init(); + virtual void addBody(PhysicsBody* body); virtual void addShape(PhysicsShape* shape); @@ -389,6 +390,7 @@ protected: friend class PhysicsJoint; friend class PhysicsWorldCallback; friend class PhysicsDebugDraw; + friend class PhysicsManager; }; /** A physics helper class. Draw physics shape, joint in debug mode. diff --git a/cocos/physics/CMakeLists.txt b/cocos/physics/CMakeLists.txt index 22d5349bdf..4a2b9447d6 100644 --- a/cocos/physics/CMakeLists.txt +++ b/cocos/physics/CMakeLists.txt @@ -6,5 +6,6 @@ set(COCOS_PHYSICS_SRC physics/CCPhysicsJoint.cpp physics/CCPhysicsShape.cpp physics/CCPhysicsWorld.cpp - + physics/CCComponentPhysics2d.cpp + physics/CCPhysicsManager.cpp ) diff --git a/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxEditBox.java b/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxEditBox.java index a02daf0c10..4228b97c74 100644 --- a/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxEditBox.java +++ b/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxEditBox.java @@ -26,8 +26,11 @@ package org.cocos2dx.lib; import android.content.Context; import android.graphics.Color; +import android.graphics.Typeface; import android.text.InputFilter; import android.text.InputType; +import android.text.method.PasswordTransformationMethod; +import android.util.Log; import android.view.Gravity; import android.view.KeyEvent; import android.view.View; @@ -106,6 +109,12 @@ public class Cocos2dxEditBox extends EditText { private int mInputModeContraints; private int mMaxLength; + //OpenGL view scaleX + private float mScaleX; + + + + public Cocos2dxEditBox(Context context){ super(context); } @@ -121,6 +130,15 @@ public class Cocos2dxEditBox extends EditText { this.setLayoutParams(layoutParams); } + public float getOpenGLViewScaleX() { + return mScaleX; + } + + public void setOpenGLViewScaleX(float mScaleX) { + this.mScaleX = mScaleX; + } + + public void setMaxLength(int maxLength){ this.mMaxLength = maxLength; @@ -210,6 +228,8 @@ public class Cocos2dxEditBox extends EditText { switch (inputFlag) { case kEditBoxInputFlagPassword: this.mInputFlagConstraints = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD; + this.setTypeface(Typeface.DEFAULT); + this.setTransformationMethod(new PasswordTransformationMethod()); break; case kEditBoxInputFlagSensitive: this.mInputFlagConstraints = InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS; diff --git a/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxEditBoxHelper.java b/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxEditBoxHelper.java index 14a8c46920..1651aa27c5 100644 --- a/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxEditBoxHelper.java +++ b/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxEditBoxHelper.java @@ -75,8 +75,17 @@ public class Cocos2dxEditBoxHelper { Cocos2dxEditBoxHelper.mEditBoxArray = new SparseArray(); } + public static int convertToSP(float point){ + Resources r = mCocos2dxActivity.getResources(); - public static int createEditBox(final int left, final int top, final int width, final int height) { + int convertedValue = (int)TypedValue.applyDimension( + TypedValue.COMPLEX_UNIT_SP, point, r.getDisplayMetrics()); + + return convertedValue; + + } + + public static int createEditBox(final int left, final int top, final int width, final int height, final float scaleX) { final int index = mViewTag; mCocos2dxActivity.runOnUiThread(new Runnable() { @Override @@ -92,6 +101,17 @@ public class Cocos2dxEditBoxHelper { editBox.setBackgroundColor(Color.TRANSPARENT); editBox.setTextColor(Color.WHITE); editBox.setSingleLine(); + editBox.setOpenGLViewScaleX(scaleX); + Resources r = mCocos2dxActivity.getResources(); + float density = r.getDisplayMetrics().density; + int paddingBottom = (int)(height * 0.33f / density); + paddingBottom = convertToSP(paddingBottom - 5 * scaleX / density); + paddingBottom = paddingBottom / 2; + int paddingTop = paddingBottom; + int paddingLeft = (int)(5 * scaleX / density); + paddingLeft = convertToSP(paddingLeft); + + editBox.setPadding(paddingLeft,paddingTop, 0, paddingBottom); FrameLayout.LayoutParams lParams = new FrameLayout.LayoutParams( @@ -101,7 +121,7 @@ public class Cocos2dxEditBoxHelper { lParams.leftMargin = left; lParams.topMargin = top; lParams.width = width; - lParams.height = height+20; + lParams.height = height; lParams.gravity = Gravity.TOP | Gravity.LEFT; mFrameLayout.addView(editBox, lParams); @@ -222,7 +242,10 @@ public class Cocos2dxEditBoxHelper { } //TODO: The font size is not the same across all the anroid devices... if (fontSize >= 0){ - editBox.setTextSize(TypedValue.COMPLEX_UNIT_SP, fontSize); + float density = mCocos2dxActivity.getResources().getDisplayMetrics().density; +// Log.e("XXX", "density is " + density); + editBox.setTextSize(TypedValue.COMPLEX_UNIT_SP, + fontSize / density ); } editBox.setTypeface(tf); } diff --git a/cocos/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.cpp b/cocos/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.cpp index 0ca899fd15..cbd1285e05 100644 --- a/cocos/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.cpp +++ b/cocos/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.cpp @@ -390,12 +390,12 @@ void deleteValueForKeyJNI(const char* key) } } -int addEditBoxJNI(int left, int top, int width, int height){ +int addEditBoxJNI(int left, int top, int width, int height, float scaleX){ JniMethodInfo t; int ret = -1; - if (JniHelper::getStaticMethodInfo(t, EDITBOX_CLASS_NAME, "createEditBox", "(IIII)I")) { - ret = t.env->CallStaticIntMethod(t.classID, t.methodID, left, top, width, height); + if (JniHelper::getStaticMethodInfo(t, EDITBOX_CLASS_NAME, "createEditBox", "(IIIIF)I")) { + ret = t.env->CallStaticIntMethod(t.classID, t.methodID, left, top, width, height, scaleX); t.env->DeleteLocalRef(t.classID); } return ret; diff --git a/cocos/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.h b/cocos/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.h index 0536c40991..534a35669c 100644 --- a/cocos/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.h +++ b/cocos/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.h @@ -55,7 +55,7 @@ extern void setStringForKeyJNI(const char* key, const char* value); extern void deleteValueForKeyJNI(const char* key); extern void conversionEncodingJNI(const char* src, int byteSize, const char* fromCharset, char* dst, const char* newCharset); //Added for new Android EditBox -extern int addEditBoxJNI(int left, int top, int width, int height); +extern int addEditBoxJNI(int left, int top, int width, int height, float scaleX); extern void removeEditBoxJNI(int index); extern void setEditBoxViewRectJNI(int index, int left, int top, int width, int height); extern void setMaxLengthJNI(int index, int maxLength); diff --git a/cocos/renderer/CCFrameBuffer.cpp b/cocos/renderer/CCFrameBuffer.cpp index d26016967b..7d679261bd 100644 --- a/cocos/renderer/CCFrameBuffer.cpp +++ b/cocos/renderer/CCFrameBuffer.cpp @@ -456,7 +456,7 @@ void FrameBuffer::applyFBO() CHECK_GL_ERROR_DEBUG(); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, nullptr == _rtDepthStencil ? 0 : _rtDepthStencil->getBuffer()); CHECK_GL_ERROR_DEBUG(); - CCLOG("FBO is %d _fbo %d color, %d ds", _fbo, RenderTargetBase::Type::Texture2D == _rt->getType() ? _rt->getTexture()->getName() : _rt->getBuffer(), _rtDepthStencil->getBuffer()); + CCLOG("FBO is %d _fbo %d color, %d ds", _fbo, RenderTargetBase::Type::Texture2D == _rt->getType() ? _rt->getTexture()->getName() : _rt->getBuffer(), nullptr == _rtDepthStencil ? 0 : _rtDepthStencil->getBuffer()); _fboBindingDirty = false; } if(GL_FRAMEBUFFER_COMPLETE != glCheckFramebufferStatus(GL_FRAMEBUFFER)) diff --git a/cocos/renderer/CCMaterial.cpp b/cocos/renderer/CCMaterial.cpp index 2bd87a6a36..dfd60b66e4 100644 --- a/cocos/renderer/CCMaterial.cpp +++ b/cocos/renderer/CCMaterial.cpp @@ -501,6 +501,7 @@ ssize_t Material::getTechniqueCount() const return _techniques.size(); } + // Helpers implementation static bool isValidUniform(const char* name) { diff --git a/cocos/renderer/CCMaterial.h b/cocos/renderer/CCMaterial.h index 4bde1f6af1..120400e554 100644 --- a/cocos/renderer/CCMaterial.h +++ b/cocos/renderer/CCMaterial.h @@ -62,7 +62,6 @@ class CC_DLL Material : public RenderState friend class Mesh; public: - /** * Creates a Material using the data from the Properties object defined at the specified URL, * where the URL is of the format ".#//.../" @@ -139,6 +138,7 @@ protected: bool parseUniform(GLProgramState* programState, Properties* properties, const char* uniformName); bool parseRenderState(RenderState* renderState, Properties* properties); + // material name std::string _name; @@ -150,7 +150,6 @@ protected: // weak reference Node* _target; - }; NS_CC_END diff --git a/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_auto_api.js b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_auto_api.js index 7969665b23..ba2818540d 100644 --- a/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_auto_api.js +++ b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_auto_api.js @@ -521,6 +521,77 @@ EventTouch : function ( }; +/** + * @class ComponentContainer + */ +cc.ComponentContainer = { + +/** + * @method visit + * @param {float} arg0 + */ +visit : function ( +float +) +{ +}, + +/** + * @method remove +* @param {cc.Component|String} component +* @return {bool|bool} +*/ +remove : function( +str +) +{ + return false; +}, + +/** + * @method removeAll + */ +removeAll : function ( +) +{ +}, + +/** + * @method add + * @param {cc.Component} arg0 + * @return {bool} + */ +add : function ( +component +) +{ + return false; +}, + +/** + * @method isEmpty + * @return {bool} + */ +isEmpty : function ( +) +{ + return false; +}, + +/** + * @method get + * @param {String} arg0 + * @return {cc.Component} + */ +get : function ( +str +) +{ + return cc.Component; +}, + +}; + /** * @class Node */ @@ -552,16 +623,6 @@ str return false; }, -/** - * @method setPhysicsBody - * @param {cc.PhysicsBody} arg0 - */ -setPhysicsBody : function ( -physicsbody -) -{ -}, - /** * @method getGLProgram * @return {cc.GLProgram} @@ -572,18 +633,6 @@ getGLProgram : function ( return cc.GLProgram; }, -/** - * @method updateTransformFromPhysics - * @param {mat4_object} arg0 - * @param {unsigned int} arg1 - */ -updateTransformFromPhysics : function ( -mat4, -int -) -{ -}, - /** * @method getDescription * @return {String} @@ -746,14 +795,6 @@ func { }, -/** - * @method removeFromPhysicsWorld - */ -removeFromPhysicsWorld : function ( -) -{ -}, - /** * @method removeAllComponents */ @@ -804,16 +845,6 @@ getonEnterTransitionDidFinishCallback : function ( return std::function; }, -/** - * @method isOpacityModifyRGB - * @return {bool} - */ -isOpacityModifyRGB : function ( -) -{ - return false; -}, - /** * @method getNodeToWorldAffineTransform * @return {cc.AffineTransform} @@ -1053,13 +1084,13 @@ getOnEnterCallback : function ( }, /** - * @method getPhysicsBody - * @return {cc.PhysicsBody} + * @method isOpacityModifyRGB + * @return {bool} */ -getPhysicsBody : function ( +isOpacityModifyRGB : function ( ) { - return cc.PhysicsBody; + return false; }, /** @@ -1418,22 +1449,6 @@ str { }, -/** - * @method updatePhysicsBodyTransform - * @param {mat4_object} arg0 - * @param {unsigned int} arg1 - * @param {float} arg2 - * @param {float} arg3 - */ -updatePhysicsBodyTransform : function ( -mat4, -int, -float, -float -) -{ -}, - /** * @method getDisplayedOpacity * @return {unsigned char} @@ -2051,6 +2066,16 @@ eventcustom { }, +/** + * @method getPhysicsManager + * @return {cc.PhysicsManager} + */ +getPhysicsManager : function ( +) +{ + return cc.PhysicsManager; +}, + /** * @method initWithSize * @param {size_object} arg0 @@ -20670,6 +20695,102 @@ TextureCache : function ( }; +/** + * @class Component + */ +cc.Component = { + +/** + * @method setEnabled + * @param {bool} arg0 + */ +setEnabled : function ( +bool +) +{ +}, + +/** + * @method setName + * @param {String} arg0 + */ +setName : function ( +str +) +{ +}, + +/** + * @method isEnabled + * @return {bool} + */ +isEnabled : function ( +) +{ + return false; +}, + +/** + * @method getOwner + * @return {cc.Node} + */ +getOwner : function ( +) +{ + return cc.Node; +}, + +/** + * @method init + * @return {bool} + */ +init : function ( +) +{ + return false; +}, + +/** + * @method getName + * @return {String} + */ +getName : function ( +) +{ + return ; +}, + +/** + * @method setOwner + * @param {cc.Node} arg0 + */ +setOwner : function ( +node +) +{ +}, + +/** + * @method create + * @return {cc.Component} + */ +create : function ( +) +{ + return cc.Component; +}, + +/** + * @method Component + * @constructor + */ +Component : function ( +) +{ +}, + +}; + /** * @class Device */ @@ -22672,173 +22793,6 @@ TileMapAtlas : function ( }; -/** - * @class Component - */ -cc.Component = { - -/** - * @method setEnabled - * @param {bool} arg0 - */ -setEnabled : function ( -bool -) -{ -}, - -/** - * @method setName - * @param {String} arg0 - */ -setName : function ( -str -) -{ -}, - -/** - * @method isEnabled - * @return {bool} - */ -isEnabled : function ( -) -{ - return false; -}, - -/** - * @method getOwner - * @return {cc.Node} - */ -getOwner : function ( -) -{ - return cc.Node; -}, - -/** - * @method init - * @return {bool} - */ -init : function ( -) -{ - return false; -}, - -/** - * @method getName - * @return {String} - */ -getName : function ( -) -{ - return ; -}, - -/** - * @method setOwner - * @param {cc.Node} arg0 - */ -setOwner : function ( -node -) -{ -}, - -/** - * @method create - * @return {cc.Component} - */ -create : function ( -) -{ - return cc.Component; -}, - -/** - * @method Component - * @constructor - */ -Component : function ( -) -{ -}, - -}; - -/** - * @class ComponentContainer - */ -cc.ComponentContainer = { - -/** - * @method visit - * @param {float} arg0 - */ -visit : function ( -float -) -{ -}, - -/** - * @method remove -* @param {cc.Component|String} component -* @return {bool|bool} -*/ -remove : function( -str -) -{ - return false; -}, - -/** - * @method removeAll - */ -removeAll : function ( -) -{ -}, - -/** - * @method add - * @param {cc.Component} arg0 - * @return {bool} - */ -add : function ( -component -) -{ - return false; -}, - -/** - * @method isEmpty - * @return {bool} - */ -isEmpty : function ( -) -{ - return false; -}, - -/** - * @method get - * @param {String} arg0 - * @return {cc.Component} - */ -get : function ( -str -) -{ - return cc.Component; -}, - -}; - /** * @class SimpleAudioEngine */ diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.cpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.cpp index 5d9cd334d6..e701ed0155 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.cpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.cpp @@ -1419,6 +1419,232 @@ void js_register_cocos2dx_EventTouch(JSContext *cx, JS::HandleObject global) { } } +JSClass *jsb_cocos2d_ComponentContainer_class; +JSObject *jsb_cocos2d_ComponentContainer_prototype; + +bool js_cocos2dx_ComponentContainer_visit(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ComponentContainer* cobj = (cocos2d::ComponentContainer *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ComponentContainer_visit : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ComponentContainer_visit : Error processing arguments"); + cobj->visit(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ComponentContainer_visit : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ComponentContainer_remove(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::ComponentContainer* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::ComponentContainer *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ComponentContainer_remove : Invalid Native Object"); + do { + if (argc == 1) { + cocos2d::Component* arg0; + do { + if (args.get(0).isNull()) { arg0 = nullptr; break; } + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Component*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + bool ret = cobj->remove(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + bool ret = cobj->remove(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_ComponentContainer_remove : wrong number of arguments"); + return false; +} +bool js_cocos2dx_ComponentContainer_removeAll(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ComponentContainer* cobj = (cocos2d::ComponentContainer *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ComponentContainer_removeAll : Invalid Native Object"); + if (argc == 0) { + cobj->removeAll(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ComponentContainer_removeAll : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ComponentContainer_add(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ComponentContainer* cobj = (cocos2d::ComponentContainer *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ComponentContainer_add : Invalid Native Object"); + if (argc == 1) { + cocos2d::Component* arg0; + do { + if (args.get(0).isNull()) { arg0 = nullptr; break; } + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Component*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ComponentContainer_add : Error processing arguments"); + bool ret = cobj->add(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ComponentContainer_add : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ComponentContainer_isEmpty(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ComponentContainer* cobj = (cocos2d::ComponentContainer *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ComponentContainer_isEmpty : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isEmpty(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ComponentContainer_isEmpty : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ComponentContainer_get(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ComponentContainer* cobj = (cocos2d::ComponentContainer *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ComponentContainer_get : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ComponentContainer_get : Error processing arguments"); + cocos2d::Component* ret = cobj->get(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Component*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ComponentContainer_get : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} + +void js_cocos2d_ComponentContainer_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (ComponentContainer)", obj); +} +void js_register_cocos2dx_ComponentContainer(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_ComponentContainer_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_ComponentContainer_class->name = "ComponentContainer"; + jsb_cocos2d_ComponentContainer_class->addProperty = JS_PropertyStub; + jsb_cocos2d_ComponentContainer_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_ComponentContainer_class->getProperty = JS_PropertyStub; + jsb_cocos2d_ComponentContainer_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_ComponentContainer_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_ComponentContainer_class->resolve = JS_ResolveStub; + jsb_cocos2d_ComponentContainer_class->convert = JS_ConvertStub; + jsb_cocos2d_ComponentContainer_class->finalize = js_cocos2d_ComponentContainer_finalize; + jsb_cocos2d_ComponentContainer_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("visit", js_cocos2dx_ComponentContainer_visit, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("remove", js_cocos2dx_ComponentContainer_remove, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removeAll", js_cocos2dx_ComponentContainer_removeAll, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("add", js_cocos2dx_ComponentContainer_add, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isEmpty", js_cocos2dx_ComponentContainer_isEmpty, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getComponent", js_cocos2dx_ComponentContainer_get, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + JSFunctionSpec *st_funcs = NULL; + + jsb_cocos2d_ComponentContainer_prototype = JS_InitClass( + cx, global, + JS::NullPtr(), // parent proto + jsb_cocos2d_ComponentContainer_class, + empty_constructor, 0, + properties, + funcs, + NULL, // no static properties + st_funcs); + // make the class enumerable in the registered namespace +// bool found; +//FIXME: Removed in Firefox v27 +// JS_SetPropertyAttributes(cx, global, "ComponentContainer", JSPROP_ENUMERATE | JSPROP_READONLY, &found); + + // add the proto and JSClass to the type->js info hash table + TypeTest t; + js_type_class_t *p; + std::string typeName = t.s_name(); + if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) + { + p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); + p->jsclass = jsb_cocos2d_ComponentContainer_class; + p->proto = jsb_cocos2d_ComponentContainer_prototype; + p->parentProto = NULL; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + JSClass *jsb_cocos2d_Node_class; JSObject *jsb_cocos2d_Node_prototype; @@ -1575,34 +1801,6 @@ bool js_cocos2dx_Node_removeComponent(JSContext *cx, uint32_t argc, jsval *vp) JS_ReportError(cx, "js_cocos2dx_Node_removeComponent : wrong number of arguments"); return false; } -bool js_cocos2dx_Node_setPhysicsBody(JSContext *cx, uint32_t argc, jsval *vp) -{ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - bool ok = true; - JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Node_setPhysicsBody : Invalid Native Object"); - if (argc == 1) { - cocos2d::PhysicsBody* arg0; - do { - if (args.get(0).isNull()) { arg0 = nullptr; break; } - if (!args.get(0).isObject()) { ok = false; break; } - js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); - jsProxy = jsb_get_js_proxy(tmpObj); - arg0 = (cocos2d::PhysicsBody*)(jsProxy ? jsProxy->ptr : NULL); - JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); - } while (0); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Node_setPhysicsBody : Error processing arguments"); - cobj->setPhysicsBody(arg0); - args.rval().setUndefined(); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_Node_setPhysicsBody : wrong number of arguments: %d, was expecting %d", argc, 1); - return false; -} bool js_cocos2dx_Node_getGLProgram(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -1628,28 +1826,6 @@ bool js_cocos2dx_Node_getGLProgram(JSContext *cx, uint32_t argc, jsval *vp) JS_ReportError(cx, "js_cocos2dx_Node_getGLProgram : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } -bool js_cocos2dx_Node_updateTransformFromPhysics(JSContext *cx, uint32_t argc, jsval *vp) -{ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - bool ok = true; - JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Node_updateTransformFromPhysics : Invalid Native Object"); - if (argc == 2) { - cocos2d::Mat4 arg0; - unsigned int arg1; - ok &= jsval_to_matrix(cx, args.get(0), &arg0); - ok &= jsval_to_uint32(cx, args.get(1), &arg1); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Node_updateTransformFromPhysics : Error processing arguments"); - cobj->updateTransformFromPhysics(arg0, arg1); - args.rval().setUndefined(); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_Node_updateTransformFromPhysics : wrong number of arguments: %d, was expecting %d", argc, 2); - return false; -} bool js_cocos2dx_Node_getDescription(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -2021,22 +2197,6 @@ bool js_cocos2dx_Node_setonEnterTransitionDidFinishCallback(JSContext *cx, uint3 JS_ReportError(cx, "js_cocos2dx_Node_setonEnterTransitionDidFinishCallback : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } -bool js_cocos2dx_Node_removeFromPhysicsWorld(JSContext *cx, uint32_t argc, jsval *vp) -{ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Node_removeFromPhysicsWorld : Invalid Native Object"); - if (argc == 0) { - cobj->removeFromPhysicsWorld(); - args.rval().setUndefined(); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_Node_removeFromPhysicsWorld : wrong number of arguments: %d, was expecting %d", argc, 0); - return false; -} bool js_cocos2dx_Node_removeAllComponents(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -2137,24 +2297,6 @@ bool js_cocos2dx_Node_getonEnterTransitionDidFinishCallback(JSContext *cx, uint3 JS_ReportError(cx, "js_cocos2dx_Node_getonEnterTransitionDidFinishCallback : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } -bool js_cocos2dx_Node_isOpacityModifyRGB(JSContext *cx, uint32_t argc, jsval *vp) -{ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Node_isOpacityModifyRGB : Invalid Native Object"); - if (argc == 0) { - bool ret = cobj->isOpacityModifyRGB(); - jsval jsret = JSVAL_NULL; - jsret = BOOLEAN_TO_JSVAL(ret); - args.rval().set(jsret); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_Node_isOpacityModifyRGB : wrong number of arguments: %d, was expecting %d", argc, 0); - return false; -} bool js_cocos2dx_Node_getNodeToWorldAffineTransform(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -2744,29 +2886,22 @@ bool js_cocos2dx_Node_getOnEnterCallback(JSContext *cx, uint32_t argc, jsval *vp JS_ReportError(cx, "js_cocos2dx_Node_getOnEnterCallback : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } -bool js_cocos2dx_Node_getPhysicsBody(JSContext *cx, uint32_t argc, jsval *vp) +bool js_cocos2dx_Node_isOpacityModifyRGB(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Node_getPhysicsBody : Invalid Native Object"); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Node_isOpacityModifyRGB : Invalid Native Object"); if (argc == 0) { - cocos2d::PhysicsBody* ret = cobj->getPhysicsBody(); + bool ret = cobj->isOpacityModifyRGB(); jsval jsret = JSVAL_NULL; - do { - if (ret) { - js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::PhysicsBody*)ret); - jsret = OBJECT_TO_JSVAL(jsProxy->obj); - } else { - jsret = JSVAL_NULL; - } - } while (0); + jsret = BOOLEAN_TO_JSVAL(ret); args.rval().set(jsret); return true; } - JS_ReportError(cx, "js_cocos2dx_Node_getPhysicsBody : wrong number of arguments: %d, was expecting %d", argc, 0); + JS_ReportError(cx, "js_cocos2dx_Node_isOpacityModifyRGB : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } bool js_cocos2dx_Node_stopActionByTag(JSContext *cx, uint32_t argc, jsval *vp) @@ -3554,32 +3689,6 @@ bool js_cocos2dx_Node_setName(JSContext *cx, uint32_t argc, jsval *vp) JS_ReportError(cx, "js_cocos2dx_Node_setName : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } -bool js_cocos2dx_Node_updatePhysicsBodyTransform(JSContext *cx, uint32_t argc, jsval *vp) -{ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - bool ok = true; - JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Node_updatePhysicsBodyTransform : Invalid Native Object"); - if (argc == 4) { - cocos2d::Mat4 arg0; - unsigned int arg1; - double arg2; - double arg3; - ok &= jsval_to_matrix(cx, args.get(0), &arg0); - ok &= jsval_to_uint32(cx, args.get(1), &arg1); - ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); - ok &= JS::ToNumber( cx, args.get(3), &arg3) && !isnan(arg3); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Node_updatePhysicsBodyTransform : Error processing arguments"); - cobj->updatePhysicsBodyTransform(arg0, arg1, arg2, arg3); - args.rval().setUndefined(); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_Node_updatePhysicsBodyTransform : wrong number of arguments: %d, was expecting %d", argc, 4); - return false; -} bool js_cocos2dx_Node_getDisplayedOpacity(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -4919,9 +5028,7 @@ void js_register_cocos2dx_Node(JSContext *cx, JS::HandleObject global) { static JSFunctionSpec funcs[] = { JS_FN("addChild", js_cocos2dx_Node_addChild, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("removeComponent", js_cocos2dx_Node_removeComponent, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("setPhysicsBody", js_cocos2dx_Node_setPhysicsBody, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getShaderProgram", js_cocos2dx_Node_getGLProgram, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("updateTransformFromPhysics", js_cocos2dx_Node_updateTransformFromPhysics, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getDescription", js_cocos2dx_Node_getDescription, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setOpacityModifyRGB", js_cocos2dx_Node_setOpacityModifyRGB, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setCascadeOpacityEnabled", js_cocos2dx_Node_setCascadeOpacityEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), @@ -4938,13 +5045,11 @@ void js_register_cocos2dx_Node(JSContext *cx, JS::HandleObject global) { JS_FN("setScaleX", js_cocos2dx_Node_setScaleX, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getColor", js_cocos2dx_Node_getColor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setonEnterTransitionDidFinishCallback", js_cocos2dx_Node_setonEnterTransitionDidFinishCallback, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("removeFromPhysicsWorld", js_cocos2dx_Node_removeFromPhysicsWorld, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("removeAllComponents", js_cocos2dx_Node_removeAllComponents, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getOpacity", js_cocos2dx_Node_getOpacity, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setCameraMask", js_cocos2dx_Node_setCameraMask, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTag", js_cocos2dx_Node_getTag, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getonEnterTransitionDidFinishCallback", js_cocos2dx_Node_getonEnterTransitionDidFinishCallback, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("isOpacityModifyRGB", js_cocos2dx_Node_isOpacityModifyRGB, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getNodeToWorldTransform", js_cocos2dx_Node_getNodeToWorldAffineTransform, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getPosition3D", js_cocos2dx_Node_getPosition3D, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("removeChild", js_cocos2dx_Node_removeChild, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), @@ -4968,7 +5073,7 @@ void js_register_cocos2dx_Node(JSContext *cx, JS::HandleObject global) { JS_FN("getNodeToParentTransform", js_cocos2dx_Node_getNodeToParentAffineTransform, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("convertTouchToNodeSpaceAR", js_cocos2dx_Node_convertTouchToNodeSpaceAR, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getOnEnterCallback", js_cocos2dx_Node_getOnEnterCallback, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("getPhysicsBody", js_cocos2dx_Node_getPhysicsBody, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isOpacityModifyRGB", js_cocos2dx_Node_isOpacityModifyRGB, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("stopActionByTag", js_cocos2dx_Node_stopActionByTag, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("reorderChild", js_cocos2dx_Node_reorderChild, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("ignoreAnchorPointForPosition", js_cocos2dx_Node_ignoreAnchorPointForPosition, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), @@ -5003,7 +5108,6 @@ void js_register_cocos2dx_Node(JSContext *cx, JS::HandleObject global) { JS_FN("setRotationX", js_cocos2dx_Node_setRotationSkewX, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setRotationY", js_cocos2dx_Node_setRotationSkewY, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setName", js_cocos2dx_Node_setName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("updatePhysicsBodyTransform", js_cocos2dx_Node_updatePhysicsBodyTransform, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getDisplayedOpacity", js_cocos2dx_Node_getDisplayedOpacity, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getLocalZOrder", js_cocos2dx_Node_getLocalZOrder, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getScheduler", js_cocos2dx_Node_getScheduler, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), @@ -5296,6 +5400,31 @@ bool js_cocos2dx_Scene_onProjectionChanged(JSContext *cx, uint32_t argc, jsval * JS_ReportError(cx, "js_cocos2dx_Scene_onProjectionChanged : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } +bool js_cocos2dx_Scene_getPhysicsManager(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Scene* cobj = (cocos2d::Scene *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Scene_getPhysicsManager : Invalid Native Object"); + if (argc == 0) { + cocos2d::PhysicsManager* ret = cobj->getPhysicsManager(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::PhysicsManager*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Scene_getPhysicsManager : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} bool js_cocos2dx_Scene_initWithSize(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -5462,6 +5591,7 @@ void js_register_cocos2dx_Scene(JSContext *cx, JS::HandleObject global) { JS_FN("render", js_cocos2dx_Scene_render, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("stepPhysicsAndNavigation", js_cocos2dx_Scene_stepPhysicsAndNavigation, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("onProjectionChanged", js_cocos2dx_Scene_onProjectionChanged, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getPhysicsManager", js_cocos2dx_Scene_getPhysicsManager, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("initWithSize", js_cocos2dx_Scene_initWithSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getDefaultCamera", js_cocos2dx_Scene_getDefaultCamera, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("ctor", js_cocos2dx_Scene_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), @@ -8894,6 +9024,21 @@ bool js_cocos2dx_Follow_constructor(JSContext *cx, uint32_t argc, jsval *vp) if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_Follow_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::Follow *nobj = new (std::nothrow) cocos2d::Follow(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::Follow"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_Action_prototype; @@ -8901,6 +9046,7 @@ extern JSObject *jsb_cocos2d_Action_prototype; void js_cocos2d_Follow_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (Follow)", obj); } + void js_register_cocos2dx_Follow(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_Follow_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_Follow_class->name = "Follow"; @@ -8923,6 +9069,7 @@ void js_register_cocos2dx_Follow(JSContext *cx, JS::HandleObject global) { JS_FN("setBoundarySet", js_cocos2dx_Follow_setBoundarySet, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("initWithTarget", js_cocos2dx_Follow_initWithTarget, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isBoundarySet", js_cocos2dx_Follow_isBoundarySet, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2dx_Follow_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -8957,6 +9104,7 @@ void js_register_cocos2dx_Follow(JSContext *cx, JS::HandleObject global) { p->parentProto = jsb_cocos2d_Action_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.Follow.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_SpriteFrame_class; @@ -9966,11 +10114,27 @@ bool js_cocos2dx_AnimationFrame_constructor(JSContext *cx, uint32_t argc, jsval if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_AnimationFrame_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::AnimationFrame *nobj = new (std::nothrow) cocos2d::AnimationFrame(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::AnimationFrame"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } void js_cocos2d_AnimationFrame_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (AnimationFrame)", obj); } + void js_register_cocos2dx_AnimationFrame(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_AnimationFrame_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_AnimationFrame_class->name = "AnimationFrame"; @@ -9998,6 +10162,7 @@ void js_register_cocos2dx_AnimationFrame(JSContext *cx, JS::HandleObject global) JS_FN("getDelayUnits", js_cocos2dx_AnimationFrame_getDelayUnits, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setUserInfo", js_cocos2dx_AnimationFrame_setUserInfo, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("initWithSpriteFrame", js_cocos2dx_AnimationFrame_initWithSpriteFrame, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2dx_AnimationFrame_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -10032,6 +10197,7 @@ void js_register_cocos2dx_AnimationFrame(JSContext *cx, JS::HandleObject global) p->parentProto = NULL; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.AnimationFrame.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_Animation_class; @@ -10584,11 +10750,27 @@ bool js_cocos2dx_Animation_constructor(JSContext *cx, uint32_t argc, jsval *vp) if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_Animation_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::Animation *nobj = new (std::nothrow) cocos2d::Animation(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::Animation"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } void js_cocos2d_Animation_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (Animation)", obj); } + void js_register_cocos2dx_Animation(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_Animation_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_Animation_class->name = "Animation"; @@ -10625,6 +10807,7 @@ void js_register_cocos2dx_Animation(JSContext *cx, JS::HandleObject global) { JS_FN("initWithSpriteFrames", js_cocos2dx_Animation_initWithSpriteFrames, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getRestoreOriginalFrame", js_cocos2dx_Animation_getRestoreOriginalFrame, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("addSpriteFrameWithTexture", js_cocos2dx_Animation_addSpriteFrameWithTexture, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2dx_Animation_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -10660,6 +10843,7 @@ void js_register_cocos2dx_Animation(JSContext *cx, JS::HandleObject global) { p->parentProto = NULL; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.Animation.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_ActionInterval_class; @@ -10875,6 +11059,21 @@ bool js_cocos2dx_Sequence_constructor(JSContext *cx, uint32_t argc, jsval *vp) if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_Sequence_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::Sequence *nobj = new (std::nothrow) cocos2d::Sequence(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::Sequence"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_ActionInterval_prototype; @@ -10882,6 +11081,7 @@ extern JSObject *jsb_cocos2d_ActionInterval_prototype; void js_cocos2d_Sequence_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (Sequence)", obj); } + void js_register_cocos2dx_Sequence(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_Sequence_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_Sequence_class->name = "Sequence"; @@ -10902,6 +11102,7 @@ void js_register_cocos2dx_Sequence(JSContext *cx, JS::HandleObject global) { static JSFunctionSpec funcs[] = { JS_FN("initWithTwoActions", js_cocos2dx_Sequence_initWithTwoActions, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2dx_Sequence_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -10933,6 +11134,7 @@ void js_register_cocos2dx_Sequence(JSContext *cx, JS::HandleObject global) { p->parentProto = jsb_cocos2d_ActionInterval_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.Sequence.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_Repeat_class; @@ -11085,6 +11287,21 @@ bool js_cocos2dx_Repeat_constructor(JSContext *cx, uint32_t argc, jsval *vp) if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_Repeat_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::Repeat *nobj = new (std::nothrow) cocos2d::Repeat(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::Repeat"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_ActionInterval_prototype; @@ -11092,6 +11309,7 @@ extern JSObject *jsb_cocos2d_ActionInterval_prototype; void js_cocos2d_Repeat_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (Repeat)", obj); } + void js_register_cocos2dx_Repeat(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_Repeat_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_Repeat_class->name = "Repeat"; @@ -11114,6 +11332,7 @@ void js_register_cocos2dx_Repeat(JSContext *cx, JS::HandleObject global) { JS_FN("setInnerAction", js_cocos2dx_Repeat_setInnerAction, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("initWithAction", js_cocos2dx_Repeat_initWithAction, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getInnerAction", js_cocos2dx_Repeat_getInnerAction, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2dx_Repeat_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -11148,6 +11367,7 @@ void js_register_cocos2dx_Repeat(JSContext *cx, JS::HandleObject global) { p->parentProto = jsb_cocos2d_ActionInterval_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.Repeat.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_RepeatForever_class; @@ -11296,6 +11516,21 @@ bool js_cocos2dx_RepeatForever_constructor(JSContext *cx, uint32_t argc, jsval * if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_RepeatForever_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::RepeatForever *nobj = new (std::nothrow) cocos2d::RepeatForever(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::RepeatForever"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_ActionInterval_prototype; @@ -11303,6 +11538,7 @@ extern JSObject *jsb_cocos2d_ActionInterval_prototype; void js_cocos2d_RepeatForever_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (RepeatForever)", obj); } + void js_register_cocos2dx_RepeatForever(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_RepeatForever_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_RepeatForever_class->name = "RepeatForever"; @@ -11325,6 +11561,7 @@ void js_register_cocos2dx_RepeatForever(JSContext *cx, JS::HandleObject global) JS_FN("setInnerAction", js_cocos2dx_RepeatForever_setInnerAction, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("initWithAction", js_cocos2dx_RepeatForever_initWithAction, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getInnerAction", js_cocos2dx_RepeatForever_getInnerAction, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2dx_RepeatForever_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -11359,6 +11596,7 @@ void js_register_cocos2dx_RepeatForever(JSContext *cx, JS::HandleObject global) p->parentProto = jsb_cocos2d_ActionInterval_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.RepeatForever.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_Spawn_class; @@ -11431,6 +11669,21 @@ bool js_cocos2dx_Spawn_constructor(JSContext *cx, uint32_t argc, jsval *vp) if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_Spawn_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::Spawn *nobj = new (std::nothrow) cocos2d::Spawn(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::Spawn"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_ActionInterval_prototype; @@ -11438,6 +11691,7 @@ extern JSObject *jsb_cocos2d_ActionInterval_prototype; void js_cocos2d_Spawn_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (Spawn)", obj); } + void js_register_cocos2dx_Spawn(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_Spawn_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_Spawn_class->name = "Spawn"; @@ -11458,6 +11712,7 @@ void js_register_cocos2dx_Spawn(JSContext *cx, JS::HandleObject global) { static JSFunctionSpec funcs[] = { JS_FN("initWithTwoActions", js_cocos2dx_Spawn_initWithTwoActions, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2dx_Spawn_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -11489,6 +11744,7 @@ void js_register_cocos2dx_Spawn(JSContext *cx, JS::HandleObject global) { p->parentProto = jsb_cocos2d_ActionInterval_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.Spawn.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_RotateTo_class; @@ -11649,6 +11905,21 @@ bool js_cocos2dx_RotateTo_constructor(JSContext *cx, uint32_t argc, jsval *vp) if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_RotateTo_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::RotateTo *nobj = new (std::nothrow) cocos2d::RotateTo(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::RotateTo"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_ActionInterval_prototype; @@ -11656,6 +11927,7 @@ extern JSObject *jsb_cocos2d_ActionInterval_prototype; void js_cocos2d_RotateTo_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (RotateTo)", obj); } + void js_register_cocos2dx_RotateTo(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_RotateTo_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_RotateTo_class->name = "RotateTo"; @@ -11676,6 +11948,7 @@ void js_register_cocos2dx_RotateTo(JSContext *cx, JS::HandleObject global) { static JSFunctionSpec funcs[] = { JS_FN("initWithDuration", js_cocos2dx_RotateTo_initWithDuration, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2dx_RotateTo_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -11710,6 +11983,7 @@ void js_register_cocos2dx_RotateTo(JSContext *cx, JS::HandleObject global) { p->parentProto = jsb_cocos2d_ActionInterval_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.RotateTo.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_RotateBy_class; @@ -11886,6 +12160,21 @@ bool js_cocos2dx_RotateBy_constructor(JSContext *cx, uint32_t argc, jsval *vp) if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_RotateBy_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::RotateBy *nobj = new (std::nothrow) cocos2d::RotateBy(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::RotateBy"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_ActionInterval_prototype; @@ -11893,6 +12182,7 @@ extern JSObject *jsb_cocos2d_ActionInterval_prototype; void js_cocos2d_RotateBy_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (RotateBy)", obj); } + void js_register_cocos2dx_RotateBy(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_RotateBy_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_RotateBy_class->name = "RotateBy"; @@ -11913,6 +12203,7 @@ void js_register_cocos2dx_RotateBy(JSContext *cx, JS::HandleObject global) { static JSFunctionSpec funcs[] = { JS_FN("initWithDuration", js_cocos2dx_RotateBy_initWithDuration, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2dx_RotateBy_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -11947,6 +12238,7 @@ void js_register_cocos2dx_RotateBy(JSContext *cx, JS::HandleObject global) { p->parentProto = jsb_cocos2d_ActionInterval_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.RotateBy.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_MoveBy_class; @@ -12078,6 +12370,21 @@ bool js_cocos2dx_MoveBy_constructor(JSContext *cx, uint32_t argc, jsval *vp) if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_MoveBy_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::MoveBy *nobj = new (std::nothrow) cocos2d::MoveBy(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::MoveBy"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_ActionInterval_prototype; @@ -12085,6 +12392,7 @@ extern JSObject *jsb_cocos2d_ActionInterval_prototype; void js_cocos2d_MoveBy_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (MoveBy)", obj); } + void js_register_cocos2dx_MoveBy(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_MoveBy_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_MoveBy_class->name = "MoveBy"; @@ -12105,6 +12413,7 @@ void js_register_cocos2dx_MoveBy(JSContext *cx, JS::HandleObject global) { static JSFunctionSpec funcs[] = { JS_FN("initWithDuration", js_cocos2dx_MoveBy_initWithDuration, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2dx_MoveBy_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -12139,6 +12448,7 @@ void js_register_cocos2dx_MoveBy(JSContext *cx, JS::HandleObject global) { p->parentProto = jsb_cocos2d_ActionInterval_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.MoveBy.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_MoveTo_class; @@ -12270,6 +12580,21 @@ bool js_cocos2dx_MoveTo_constructor(JSContext *cx, uint32_t argc, jsval *vp) if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_MoveTo_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::MoveTo *nobj = new (std::nothrow) cocos2d::MoveTo(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::MoveTo"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_MoveBy_prototype; @@ -12277,6 +12602,7 @@ extern JSObject *jsb_cocos2d_MoveBy_prototype; void js_cocos2d_MoveTo_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (MoveTo)", obj); } + void js_register_cocos2dx_MoveTo(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_MoveTo_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_MoveTo_class->name = "MoveTo"; @@ -12297,6 +12623,7 @@ void js_register_cocos2dx_MoveTo(JSContext *cx, JS::HandleObject global) { static JSFunctionSpec funcs[] = { JS_FN("initWithDuration", js_cocos2dx_MoveTo_initWithDuration, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2dx_MoveTo_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -12331,6 +12658,7 @@ void js_register_cocos2dx_MoveTo(JSContext *cx, JS::HandleObject global) { p->parentProto = jsb_cocos2d_MoveBy_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.MoveTo.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_SkewTo_class; @@ -12418,6 +12746,21 @@ bool js_cocos2dx_SkewTo_constructor(JSContext *cx, uint32_t argc, jsval *vp) if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_SkewTo_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::SkewTo *nobj = new (std::nothrow) cocos2d::SkewTo(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::SkewTo"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_ActionInterval_prototype; @@ -12425,6 +12768,7 @@ extern JSObject *jsb_cocos2d_ActionInterval_prototype; void js_cocos2d_SkewTo_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (SkewTo)", obj); } + void js_register_cocos2dx_SkewTo(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_SkewTo_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_SkewTo_class->name = "SkewTo"; @@ -12445,6 +12789,7 @@ void js_register_cocos2dx_SkewTo(JSContext *cx, JS::HandleObject global) { static JSFunctionSpec funcs[] = { JS_FN("initWithDuration", js_cocos2dx_SkewTo_initWithDuration, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2dx_SkewTo_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -12479,6 +12824,7 @@ void js_register_cocos2dx_SkewTo(JSContext *cx, JS::HandleObject global) { p->parentProto = jsb_cocos2d_ActionInterval_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.SkewTo.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_SkewBy_class; @@ -12566,6 +12912,21 @@ bool js_cocos2dx_SkewBy_constructor(JSContext *cx, uint32_t argc, jsval *vp) if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_SkewBy_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::SkewBy *nobj = new (std::nothrow) cocos2d::SkewBy(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::SkewBy"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_SkewTo_prototype; @@ -12573,6 +12934,7 @@ extern JSObject *jsb_cocos2d_SkewTo_prototype; void js_cocos2d_SkewBy_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (SkewBy)", obj); } + void js_register_cocos2dx_SkewBy(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_SkewBy_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_SkewBy_class->name = "SkewBy"; @@ -12593,6 +12955,7 @@ void js_register_cocos2dx_SkewBy(JSContext *cx, JS::HandleObject global) { static JSFunctionSpec funcs[] = { JS_FN("initWithDuration", js_cocos2dx_SkewBy_initWithDuration, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2dx_SkewBy_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -12627,6 +12990,7 @@ void js_register_cocos2dx_SkewBy(JSContext *cx, JS::HandleObject global) { p->parentProto = jsb_cocos2d_SkewTo_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.SkewBy.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_JumpBy_class; @@ -12718,6 +13082,21 @@ bool js_cocos2dx_JumpBy_constructor(JSContext *cx, uint32_t argc, jsval *vp) if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_JumpBy_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::JumpBy *nobj = new (std::nothrow) cocos2d::JumpBy(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::JumpBy"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_ActionInterval_prototype; @@ -12725,6 +13104,7 @@ extern JSObject *jsb_cocos2d_ActionInterval_prototype; void js_cocos2d_JumpBy_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (JumpBy)", obj); } + void js_register_cocos2dx_JumpBy(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_JumpBy_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_JumpBy_class->name = "JumpBy"; @@ -12745,6 +13125,7 @@ void js_register_cocos2dx_JumpBy(JSContext *cx, JS::HandleObject global) { static JSFunctionSpec funcs[] = { JS_FN("initWithDuration", js_cocos2dx_JumpBy_initWithDuration, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2dx_JumpBy_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -12779,6 +13160,7 @@ void js_register_cocos2dx_JumpBy(JSContext *cx, JS::HandleObject global) { p->parentProto = jsb_cocos2d_ActionInterval_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.JumpBy.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_JumpTo_class; @@ -12870,6 +13252,21 @@ bool js_cocos2dx_JumpTo_constructor(JSContext *cx, uint32_t argc, jsval *vp) if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_JumpTo_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::JumpTo *nobj = new (std::nothrow) cocos2d::JumpTo(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::JumpTo"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_JumpBy_prototype; @@ -12877,6 +13274,7 @@ extern JSObject *jsb_cocos2d_JumpBy_prototype; void js_cocos2d_JumpTo_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (JumpTo)", obj); } + void js_register_cocos2dx_JumpTo(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_JumpTo_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_JumpTo_class->name = "JumpTo"; @@ -12897,6 +13295,7 @@ void js_register_cocos2dx_JumpTo(JSContext *cx, JS::HandleObject global) { static JSFunctionSpec funcs[] = { JS_FN("initWithDuration", js_cocos2dx_JumpTo_initWithDuration, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2dx_JumpTo_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -12931,6 +13330,7 @@ void js_register_cocos2dx_JumpTo(JSContext *cx, JS::HandleObject global) { p->parentProto = jsb_cocos2d_JumpBy_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.JumpTo.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_BezierBy_class; @@ -12963,6 +13363,21 @@ bool js_cocos2dx_BezierBy_constructor(JSContext *cx, uint32_t argc, jsval *vp) if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_BezierBy_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::BezierBy *nobj = new (std::nothrow) cocos2d::BezierBy(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::BezierBy"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_ActionInterval_prototype; @@ -12970,6 +13385,7 @@ extern JSObject *jsb_cocos2d_ActionInterval_prototype; void js_cocos2d_BezierBy_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (BezierBy)", obj); } + void js_register_cocos2dx_BezierBy(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_BezierBy_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_BezierBy_class->name = "BezierBy"; @@ -12989,6 +13405,7 @@ void js_register_cocos2dx_BezierBy(JSContext *cx, JS::HandleObject global) { }; static JSFunctionSpec funcs[] = { + JS_FN("ctor", js_cocos2dx_BezierBy_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -13020,6 +13437,7 @@ void js_register_cocos2dx_BezierBy(JSContext *cx, JS::HandleObject global) { p->parentProto = jsb_cocos2d_ActionInterval_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.BezierBy.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_BezierTo_class; @@ -13052,6 +13470,21 @@ bool js_cocos2dx_BezierTo_constructor(JSContext *cx, uint32_t argc, jsval *vp) if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_BezierTo_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::BezierTo *nobj = new (std::nothrow) cocos2d::BezierTo(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::BezierTo"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_BezierBy_prototype; @@ -13059,6 +13492,7 @@ extern JSObject *jsb_cocos2d_BezierBy_prototype; void js_cocos2d_BezierTo_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (BezierTo)", obj); } + void js_register_cocos2dx_BezierTo(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_BezierTo_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_BezierTo_class->name = "BezierTo"; @@ -13078,6 +13512,7 @@ void js_register_cocos2dx_BezierTo(JSContext *cx, JS::HandleObject global) { }; static JSFunctionSpec funcs[] = { + JS_FN("ctor", js_cocos2dx_BezierTo_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -13109,6 +13544,7 @@ void js_register_cocos2dx_BezierTo(JSContext *cx, JS::HandleObject global) { p->parentProto = jsb_cocos2d_BezierBy_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.BezierTo.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_ScaleTo_class; @@ -13297,6 +13733,21 @@ bool js_cocos2dx_ScaleTo_constructor(JSContext *cx, uint32_t argc, jsval *vp) if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_ScaleTo_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::ScaleTo *nobj = new (std::nothrow) cocos2d::ScaleTo(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ScaleTo"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_ActionInterval_prototype; @@ -13304,6 +13755,7 @@ extern JSObject *jsb_cocos2d_ActionInterval_prototype; void js_cocos2d_ScaleTo_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (ScaleTo)", obj); } + void js_register_cocos2dx_ScaleTo(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_ScaleTo_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_ScaleTo_class->name = "ScaleTo"; @@ -13324,6 +13776,7 @@ void js_register_cocos2dx_ScaleTo(JSContext *cx, JS::HandleObject global) { static JSFunctionSpec funcs[] = { JS_FN("initWithDuration", js_cocos2dx_ScaleTo_initWithDuration, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2dx_ScaleTo_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -13358,6 +13811,7 @@ void js_register_cocos2dx_ScaleTo(JSContext *cx, JS::HandleObject global) { p->parentProto = jsb_cocos2d_ActionInterval_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.ScaleTo.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_ScaleBy_class; @@ -13475,6 +13929,21 @@ bool js_cocos2dx_ScaleBy_constructor(JSContext *cx, uint32_t argc, jsval *vp) if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_ScaleBy_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::ScaleBy *nobj = new (std::nothrow) cocos2d::ScaleBy(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ScaleBy"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_ScaleTo_prototype; @@ -13482,6 +13951,7 @@ extern JSObject *jsb_cocos2d_ScaleTo_prototype; void js_cocos2d_ScaleBy_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (ScaleBy)", obj); } + void js_register_cocos2dx_ScaleBy(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_ScaleBy_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_ScaleBy_class->name = "ScaleBy"; @@ -13501,6 +13971,7 @@ void js_register_cocos2dx_ScaleBy(JSContext *cx, JS::HandleObject global) { }; static JSFunctionSpec funcs[] = { + JS_FN("ctor", js_cocos2dx_ScaleBy_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -13535,6 +14006,7 @@ void js_register_cocos2dx_ScaleBy(JSContext *cx, JS::HandleObject global) { p->parentProto = jsb_cocos2d_ScaleTo_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.ScaleBy.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_Blink_class; @@ -13618,6 +14090,21 @@ bool js_cocos2dx_Blink_constructor(JSContext *cx, uint32_t argc, jsval *vp) if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_Blink_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::Blink *nobj = new (std::nothrow) cocos2d::Blink(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::Blink"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_ActionInterval_prototype; @@ -13625,6 +14112,7 @@ extern JSObject *jsb_cocos2d_ActionInterval_prototype; void js_cocos2d_Blink_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (Blink)", obj); } + void js_register_cocos2dx_Blink(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_Blink_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_Blink_class->name = "Blink"; @@ -13645,6 +14133,7 @@ void js_register_cocos2dx_Blink(JSContext *cx, JS::HandleObject global) { static JSFunctionSpec funcs[] = { JS_FN("initWithDuration", js_cocos2dx_Blink_initWithDuration, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2dx_Blink_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -13679,6 +14168,7 @@ void js_register_cocos2dx_Blink(JSContext *cx, JS::HandleObject global) { p->parentProto = jsb_cocos2d_ActionInterval_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.Blink.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_FadeTo_class; @@ -13762,6 +14252,21 @@ bool js_cocos2dx_FadeTo_constructor(JSContext *cx, uint32_t argc, jsval *vp) if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_FadeTo_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::FadeTo *nobj = new (std::nothrow) cocos2d::FadeTo(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::FadeTo"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_ActionInterval_prototype; @@ -13769,6 +14274,7 @@ extern JSObject *jsb_cocos2d_ActionInterval_prototype; void js_cocos2d_FadeTo_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (FadeTo)", obj); } + void js_register_cocos2dx_FadeTo(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_FadeTo_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_FadeTo_class->name = "FadeTo"; @@ -13789,6 +14295,7 @@ void js_register_cocos2dx_FadeTo(JSContext *cx, JS::HandleObject global) { static JSFunctionSpec funcs[] = { JS_FN("initWithDuration", js_cocos2dx_FadeTo_initWithDuration, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2dx_FadeTo_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -13823,6 +14330,7 @@ void js_register_cocos2dx_FadeTo(JSContext *cx, JS::HandleObject global) { p->parentProto = jsb_cocos2d_ActionInterval_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.FadeTo.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_FadeIn_class; @@ -13908,6 +14416,21 @@ bool js_cocos2dx_FadeIn_constructor(JSContext *cx, uint32_t argc, jsval *vp) if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_FadeIn_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::FadeIn *nobj = new (std::nothrow) cocos2d::FadeIn(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::FadeIn"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_FadeTo_prototype; @@ -13915,6 +14438,7 @@ extern JSObject *jsb_cocos2d_FadeTo_prototype; void js_cocos2d_FadeIn_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (FadeIn)", obj); } + void js_register_cocos2dx_FadeIn(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_FadeIn_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_FadeIn_class->name = "FadeIn"; @@ -13935,6 +14459,7 @@ void js_register_cocos2dx_FadeIn(JSContext *cx, JS::HandleObject global) { static JSFunctionSpec funcs[] = { JS_FN("setReverseAction", js_cocos2dx_FadeIn_setReverseAction, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2dx_FadeIn_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -13969,6 +14494,7 @@ void js_register_cocos2dx_FadeIn(JSContext *cx, JS::HandleObject global) { p->parentProto = jsb_cocos2d_FadeTo_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.FadeIn.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_FadeOut_class; @@ -14054,6 +14580,21 @@ bool js_cocos2dx_FadeOut_constructor(JSContext *cx, uint32_t argc, jsval *vp) if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_FadeOut_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::FadeOut *nobj = new (std::nothrow) cocos2d::FadeOut(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::FadeOut"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_FadeTo_prototype; @@ -14061,6 +14602,7 @@ extern JSObject *jsb_cocos2d_FadeTo_prototype; void js_cocos2d_FadeOut_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (FadeOut)", obj); } + void js_register_cocos2dx_FadeOut(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_FadeOut_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_FadeOut_class->name = "FadeOut"; @@ -14081,6 +14623,7 @@ void js_register_cocos2dx_FadeOut(JSContext *cx, JS::HandleObject global) { static JSFunctionSpec funcs[] = { JS_FN("setReverseAction", js_cocos2dx_FadeOut_setReverseAction, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2dx_FadeOut_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -14115,6 +14658,7 @@ void js_register_cocos2dx_FadeOut(JSContext *cx, JS::HandleObject global) { p->parentProto = jsb_cocos2d_FadeTo_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.FadeOut.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_TintTo_class; @@ -14234,6 +14778,21 @@ bool js_cocos2dx_TintTo_constructor(JSContext *cx, uint32_t argc, jsval *vp) if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_TintTo_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::TintTo *nobj = new (std::nothrow) cocos2d::TintTo(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TintTo"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_ActionInterval_prototype; @@ -14241,6 +14800,7 @@ extern JSObject *jsb_cocos2d_ActionInterval_prototype; void js_cocos2d_TintTo_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TintTo)", obj); } + void js_register_cocos2dx_TintTo(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_TintTo_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TintTo_class->name = "TintTo"; @@ -14261,6 +14821,7 @@ void js_register_cocos2dx_TintTo(JSContext *cx, JS::HandleObject global) { static JSFunctionSpec funcs[] = { JS_FN("initWithDuration", js_cocos2dx_TintTo_initWithDuration, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2dx_TintTo_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -14295,6 +14856,7 @@ void js_register_cocos2dx_TintTo(JSContext *cx, JS::HandleObject global) { p->parentProto = jsb_cocos2d_ActionInterval_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.TintTo.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_TintBy_class; @@ -14386,6 +14948,21 @@ bool js_cocos2dx_TintBy_constructor(JSContext *cx, uint32_t argc, jsval *vp) if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_TintBy_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::TintBy *nobj = new (std::nothrow) cocos2d::TintBy(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TintBy"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_ActionInterval_prototype; @@ -14393,6 +14970,7 @@ extern JSObject *jsb_cocos2d_ActionInterval_prototype; void js_cocos2d_TintBy_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TintBy)", obj); } + void js_register_cocos2dx_TintBy(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_TintBy_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TintBy_class->name = "TintBy"; @@ -14413,6 +14991,7 @@ void js_register_cocos2dx_TintBy(JSContext *cx, JS::HandleObject global) { static JSFunctionSpec funcs[] = { JS_FN("initWithDuration", js_cocos2dx_TintBy_initWithDuration, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2dx_TintBy_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -14447,6 +15026,7 @@ void js_register_cocos2dx_TintBy(JSContext *cx, JS::HandleObject global) { p->parentProto = jsb_cocos2d_ActionInterval_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.TintBy.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_DelayTime_class; @@ -14504,6 +15084,21 @@ bool js_cocos2dx_DelayTime_constructor(JSContext *cx, uint32_t argc, jsval *vp) if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_DelayTime_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::DelayTime *nobj = new (std::nothrow) cocos2d::DelayTime(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::DelayTime"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_ActionInterval_prototype; @@ -14511,6 +15106,7 @@ extern JSObject *jsb_cocos2d_ActionInterval_prototype; void js_cocos2d_DelayTime_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (DelayTime)", obj); } + void js_register_cocos2dx_DelayTime(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_DelayTime_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_DelayTime_class->name = "DelayTime"; @@ -14530,6 +15126,7 @@ void js_register_cocos2dx_DelayTime(JSContext *cx, JS::HandleObject global) { }; static JSFunctionSpec funcs[] = { + JS_FN("ctor", js_cocos2dx_DelayTime_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -14564,6 +15161,7 @@ void js_register_cocos2dx_DelayTime(JSContext *cx, JS::HandleObject global) { p->parentProto = jsb_cocos2d_ActionInterval_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.DelayTime.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_ReverseTime_class; @@ -14659,6 +15257,21 @@ bool js_cocos2dx_ReverseTime_constructor(JSContext *cx, uint32_t argc, jsval *vp if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_ReverseTime_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::ReverseTime *nobj = new (std::nothrow) cocos2d::ReverseTime(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ReverseTime"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_ActionInterval_prototype; @@ -14666,6 +15279,7 @@ extern JSObject *jsb_cocos2d_ActionInterval_prototype; void js_cocos2d_ReverseTime_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (ReverseTime)", obj); } + void js_register_cocos2dx_ReverseTime(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_ReverseTime_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_ReverseTime_class->name = "ReverseTime"; @@ -14686,6 +15300,7 @@ void js_register_cocos2dx_ReverseTime(JSContext *cx, JS::HandleObject global) { static JSFunctionSpec funcs[] = { JS_FN("initWithAction", js_cocos2dx_ReverseTime_initWithAction, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2dx_ReverseTime_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -14720,6 +15335,7 @@ void js_register_cocos2dx_ReverseTime(JSContext *cx, JS::HandleObject global) { p->parentProto = jsb_cocos2d_ActionInterval_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.ReverseTime.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_Animate_class; @@ -14909,6 +15525,21 @@ bool js_cocos2dx_Animate_constructor(JSContext *cx, uint32_t argc, jsval *vp) if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_Animate_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::Animate *nobj = new (std::nothrow) cocos2d::Animate(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::Animate"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_ActionInterval_prototype; @@ -14916,6 +15547,7 @@ extern JSObject *jsb_cocos2d_ActionInterval_prototype; void js_cocos2d_Animate_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (Animate)", obj); } + void js_register_cocos2dx_Animate(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_Animate_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_Animate_class->name = "Animate"; @@ -14939,6 +15571,7 @@ void js_register_cocos2dx_Animate(JSContext *cx, JS::HandleObject global) { JS_FN("getAnimation", js_cocos2dx_Animate_getAnimation, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getCurrentFrameIndex", js_cocos2dx_Animate_getCurrentFrameIndex, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setAnimation", js_cocos2dx_Animate_setAnimation, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2dx_Animate_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -14973,6 +15606,7 @@ void js_register_cocos2dx_Animate(JSContext *cx, JS::HandleObject global) { p->parentProto = jsb_cocos2d_ActionInterval_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.Animate.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_TargetedAction_class; @@ -20570,6 +21204,21 @@ bool js_cocos2dx_OrbitCamera_constructor(JSContext *cx, uint32_t argc, jsval *vp if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_OrbitCamera_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::OrbitCamera *nobj = new (std::nothrow) cocos2d::OrbitCamera(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::OrbitCamera"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_ActionCamera_prototype; @@ -20577,6 +21226,7 @@ extern JSObject *jsb_cocos2d_ActionCamera_prototype; void js_cocos2d_OrbitCamera_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (OrbitCamera)", obj); } + void js_register_cocos2dx_OrbitCamera(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_OrbitCamera_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_OrbitCamera_class->name = "OrbitCamera"; @@ -20598,6 +21248,7 @@ void js_register_cocos2dx_OrbitCamera(JSContext *cx, JS::HandleObject global) { static JSFunctionSpec funcs[] = { JS_FN("sphericalRadius", js_cocos2dx_OrbitCamera_sphericalRadius, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("initWithDuration", js_cocos2dx_OrbitCamera_initWithDuration, 7, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2dx_OrbitCamera_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -20632,6 +21283,7 @@ void js_register_cocos2dx_OrbitCamera(JSContext *cx, JS::HandleObject global) { p->parentProto = jsb_cocos2d_ActionCamera_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.OrbitCamera.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_CardinalSplineTo_class; @@ -21336,6 +21988,21 @@ bool js_cocos2dx_EaseIn_constructor(JSContext *cx, uint32_t argc, jsval *vp) if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_EaseIn_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::EaseIn *nobj = new (std::nothrow) cocos2d::EaseIn(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EaseIn"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_EaseRateAction_prototype; @@ -21343,6 +22010,7 @@ extern JSObject *jsb_cocos2d_EaseRateAction_prototype; void js_cocos2d_EaseIn_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (EaseIn)", obj); } + void js_register_cocos2dx_EaseIn(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_EaseIn_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_EaseIn_class->name = "EaseIn"; @@ -21362,6 +22030,7 @@ void js_register_cocos2dx_EaseIn(JSContext *cx, JS::HandleObject global) { }; static JSFunctionSpec funcs[] = { + JS_FN("ctor", js_cocos2dx_EaseIn_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -21396,6 +22065,7 @@ void js_register_cocos2dx_EaseIn(JSContext *cx, JS::HandleObject global) { p->parentProto = jsb_cocos2d_EaseRateAction_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.EaseIn.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_EaseOut_class; @@ -21463,6 +22133,21 @@ bool js_cocos2dx_EaseOut_constructor(JSContext *cx, uint32_t argc, jsval *vp) if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_EaseOut_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::EaseOut *nobj = new (std::nothrow) cocos2d::EaseOut(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EaseOut"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_EaseRateAction_prototype; @@ -21470,6 +22155,7 @@ extern JSObject *jsb_cocos2d_EaseRateAction_prototype; void js_cocos2d_EaseOut_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (EaseOut)", obj); } + void js_register_cocos2dx_EaseOut(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_EaseOut_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_EaseOut_class->name = "EaseOut"; @@ -21489,6 +22175,7 @@ void js_register_cocos2dx_EaseOut(JSContext *cx, JS::HandleObject global) { }; static JSFunctionSpec funcs[] = { + JS_FN("ctor", js_cocos2dx_EaseOut_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -21523,6 +22210,7 @@ void js_register_cocos2dx_EaseOut(JSContext *cx, JS::HandleObject global) { p->parentProto = jsb_cocos2d_EaseRateAction_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.EaseOut.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_EaseInOut_class; @@ -21590,6 +22278,21 @@ bool js_cocos2dx_EaseInOut_constructor(JSContext *cx, uint32_t argc, jsval *vp) if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_EaseInOut_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::EaseInOut *nobj = new (std::nothrow) cocos2d::EaseInOut(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EaseInOut"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_EaseRateAction_prototype; @@ -21597,6 +22300,7 @@ extern JSObject *jsb_cocos2d_EaseRateAction_prototype; void js_cocos2d_EaseInOut_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (EaseInOut)", obj); } + void js_register_cocos2dx_EaseInOut(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_EaseInOut_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_EaseInOut_class->name = "EaseInOut"; @@ -21616,6 +22320,7 @@ void js_register_cocos2dx_EaseInOut(JSContext *cx, JS::HandleObject global) { }; static JSFunctionSpec funcs[] = { + JS_FN("ctor", js_cocos2dx_EaseInOut_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -21650,6 +22355,7 @@ void js_register_cocos2dx_EaseInOut(JSContext *cx, JS::HandleObject global) { p->parentProto = jsb_cocos2d_EaseRateAction_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.EaseInOut.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_EaseExponentialIn_class; @@ -21715,6 +22421,21 @@ bool js_cocos2dx_EaseExponentialIn_constructor(JSContext *cx, uint32_t argc, jsv if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_EaseExponentialIn_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::EaseExponentialIn *nobj = new (std::nothrow) cocos2d::EaseExponentialIn(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EaseExponentialIn"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_ActionEase_prototype; @@ -21722,6 +22443,7 @@ extern JSObject *jsb_cocos2d_ActionEase_prototype; void js_cocos2d_EaseExponentialIn_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (EaseExponentialIn)", obj); } + void js_register_cocos2dx_EaseExponentialIn(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_EaseExponentialIn_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_EaseExponentialIn_class->name = "EaseExponentialIn"; @@ -21741,6 +22463,7 @@ void js_register_cocos2dx_EaseExponentialIn(JSContext *cx, JS::HandleObject glob }; static JSFunctionSpec funcs[] = { + JS_FN("ctor", js_cocos2dx_EaseExponentialIn_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -21775,6 +22498,7 @@ void js_register_cocos2dx_EaseExponentialIn(JSContext *cx, JS::HandleObject glob p->parentProto = jsb_cocos2d_ActionEase_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.EaseExponentialIn.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_EaseExponentialOut_class; @@ -21840,6 +22564,21 @@ bool js_cocos2dx_EaseExponentialOut_constructor(JSContext *cx, uint32_t argc, js if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_EaseExponentialOut_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::EaseExponentialOut *nobj = new (std::nothrow) cocos2d::EaseExponentialOut(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EaseExponentialOut"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_ActionEase_prototype; @@ -21847,6 +22586,7 @@ extern JSObject *jsb_cocos2d_ActionEase_prototype; void js_cocos2d_EaseExponentialOut_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (EaseExponentialOut)", obj); } + void js_register_cocos2dx_EaseExponentialOut(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_EaseExponentialOut_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_EaseExponentialOut_class->name = "EaseExponentialOut"; @@ -21866,6 +22606,7 @@ void js_register_cocos2dx_EaseExponentialOut(JSContext *cx, JS::HandleObject glo }; static JSFunctionSpec funcs[] = { + JS_FN("ctor", js_cocos2dx_EaseExponentialOut_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -21900,6 +22641,7 @@ void js_register_cocos2dx_EaseExponentialOut(JSContext *cx, JS::HandleObject glo p->parentProto = jsb_cocos2d_ActionEase_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.EaseExponentialOut.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_EaseExponentialInOut_class; @@ -21965,6 +22707,21 @@ bool js_cocos2dx_EaseExponentialInOut_constructor(JSContext *cx, uint32_t argc, if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_EaseExponentialInOut_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::EaseExponentialInOut *nobj = new (std::nothrow) cocos2d::EaseExponentialInOut(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EaseExponentialInOut"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_ActionEase_prototype; @@ -21972,6 +22729,7 @@ extern JSObject *jsb_cocos2d_ActionEase_prototype; void js_cocos2d_EaseExponentialInOut_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (EaseExponentialInOut)", obj); } + void js_register_cocos2dx_EaseExponentialInOut(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_EaseExponentialInOut_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_EaseExponentialInOut_class->name = "EaseExponentialInOut"; @@ -21991,6 +22749,7 @@ void js_register_cocos2dx_EaseExponentialInOut(JSContext *cx, JS::HandleObject g }; static JSFunctionSpec funcs[] = { + JS_FN("ctor", js_cocos2dx_EaseExponentialInOut_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -22025,6 +22784,7 @@ void js_register_cocos2dx_EaseExponentialInOut(JSContext *cx, JS::HandleObject g p->parentProto = jsb_cocos2d_ActionEase_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.EaseExponentialInOut.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_EaseSineIn_class; @@ -22090,6 +22850,21 @@ bool js_cocos2dx_EaseSineIn_constructor(JSContext *cx, uint32_t argc, jsval *vp) if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_EaseSineIn_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::EaseSineIn *nobj = new (std::nothrow) cocos2d::EaseSineIn(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EaseSineIn"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_ActionEase_prototype; @@ -22097,6 +22872,7 @@ extern JSObject *jsb_cocos2d_ActionEase_prototype; void js_cocos2d_EaseSineIn_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (EaseSineIn)", obj); } + void js_register_cocos2dx_EaseSineIn(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_EaseSineIn_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_EaseSineIn_class->name = "EaseSineIn"; @@ -22116,6 +22892,7 @@ void js_register_cocos2dx_EaseSineIn(JSContext *cx, JS::HandleObject global) { }; static JSFunctionSpec funcs[] = { + JS_FN("ctor", js_cocos2dx_EaseSineIn_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -22150,6 +22927,7 @@ void js_register_cocos2dx_EaseSineIn(JSContext *cx, JS::HandleObject global) { p->parentProto = jsb_cocos2d_ActionEase_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.EaseSineIn.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_EaseSineOut_class; @@ -22215,6 +22993,21 @@ bool js_cocos2dx_EaseSineOut_constructor(JSContext *cx, uint32_t argc, jsval *vp if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_EaseSineOut_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::EaseSineOut *nobj = new (std::nothrow) cocos2d::EaseSineOut(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EaseSineOut"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_ActionEase_prototype; @@ -22222,6 +23015,7 @@ extern JSObject *jsb_cocos2d_ActionEase_prototype; void js_cocos2d_EaseSineOut_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (EaseSineOut)", obj); } + void js_register_cocos2dx_EaseSineOut(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_EaseSineOut_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_EaseSineOut_class->name = "EaseSineOut"; @@ -22241,6 +23035,7 @@ void js_register_cocos2dx_EaseSineOut(JSContext *cx, JS::HandleObject global) { }; static JSFunctionSpec funcs[] = { + JS_FN("ctor", js_cocos2dx_EaseSineOut_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -22275,6 +23070,7 @@ void js_register_cocos2dx_EaseSineOut(JSContext *cx, JS::HandleObject global) { p->parentProto = jsb_cocos2d_ActionEase_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.EaseSineOut.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_EaseSineInOut_class; @@ -22340,6 +23136,21 @@ bool js_cocos2dx_EaseSineInOut_constructor(JSContext *cx, uint32_t argc, jsval * if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_EaseSineInOut_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::EaseSineInOut *nobj = new (std::nothrow) cocos2d::EaseSineInOut(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EaseSineInOut"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_ActionEase_prototype; @@ -22347,6 +23158,7 @@ extern JSObject *jsb_cocos2d_ActionEase_prototype; void js_cocos2d_EaseSineInOut_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (EaseSineInOut)", obj); } + void js_register_cocos2dx_EaseSineInOut(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_EaseSineInOut_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_EaseSineInOut_class->name = "EaseSineInOut"; @@ -22366,6 +23178,7 @@ void js_register_cocos2dx_EaseSineInOut(JSContext *cx, JS::HandleObject global) }; static JSFunctionSpec funcs[] = { + JS_FN("ctor", js_cocos2dx_EaseSineInOut_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -22400,6 +23213,7 @@ void js_register_cocos2dx_EaseSineInOut(JSContext *cx, JS::HandleObject global) p->parentProto = jsb_cocos2d_ActionEase_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.EaseSineInOut.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_EaseElastic_class; @@ -22650,6 +23464,21 @@ bool js_cocos2dx_EaseElasticIn_constructor(JSContext *cx, uint32_t argc, jsval * if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_EaseElasticIn_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::EaseElasticIn *nobj = new (std::nothrow) cocos2d::EaseElasticIn(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EaseElasticIn"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_EaseElastic_prototype; @@ -22657,6 +23486,7 @@ extern JSObject *jsb_cocos2d_EaseElastic_prototype; void js_cocos2d_EaseElasticIn_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (EaseElasticIn)", obj); } + void js_register_cocos2dx_EaseElasticIn(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_EaseElasticIn_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_EaseElasticIn_class->name = "EaseElasticIn"; @@ -22676,6 +23506,7 @@ void js_register_cocos2dx_EaseElasticIn(JSContext *cx, JS::HandleObject global) }; static JSFunctionSpec funcs[] = { + JS_FN("ctor", js_cocos2dx_EaseElasticIn_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -22710,6 +23541,7 @@ void js_register_cocos2dx_EaseElasticIn(JSContext *cx, JS::HandleObject global) p->parentProto = jsb_cocos2d_EaseElastic_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.EaseElasticIn.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_EaseElasticOut_class; @@ -22808,6 +23640,21 @@ bool js_cocos2dx_EaseElasticOut_constructor(JSContext *cx, uint32_t argc, jsval if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_EaseElasticOut_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::EaseElasticOut *nobj = new (std::nothrow) cocos2d::EaseElasticOut(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EaseElasticOut"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_EaseElastic_prototype; @@ -22815,6 +23662,7 @@ extern JSObject *jsb_cocos2d_EaseElastic_prototype; void js_cocos2d_EaseElasticOut_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (EaseElasticOut)", obj); } + void js_register_cocos2dx_EaseElasticOut(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_EaseElasticOut_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_EaseElasticOut_class->name = "EaseElasticOut"; @@ -22834,6 +23682,7 @@ void js_register_cocos2dx_EaseElasticOut(JSContext *cx, JS::HandleObject global) }; static JSFunctionSpec funcs[] = { + JS_FN("ctor", js_cocos2dx_EaseElasticOut_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -22868,6 +23717,7 @@ void js_register_cocos2dx_EaseElasticOut(JSContext *cx, JS::HandleObject global) p->parentProto = jsb_cocos2d_EaseElastic_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.EaseElasticOut.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_EaseElasticInOut_class; @@ -22966,6 +23816,21 @@ bool js_cocos2dx_EaseElasticInOut_constructor(JSContext *cx, uint32_t argc, jsva if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_EaseElasticInOut_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::EaseElasticInOut *nobj = new (std::nothrow) cocos2d::EaseElasticInOut(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EaseElasticInOut"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_EaseElastic_prototype; @@ -22973,6 +23838,7 @@ extern JSObject *jsb_cocos2d_EaseElastic_prototype; void js_cocos2d_EaseElasticInOut_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (EaseElasticInOut)", obj); } + void js_register_cocos2dx_EaseElasticInOut(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_EaseElasticInOut_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_EaseElasticInOut_class->name = "EaseElasticInOut"; @@ -22992,6 +23858,7 @@ void js_register_cocos2dx_EaseElasticInOut(JSContext *cx, JS::HandleObject globa }; static JSFunctionSpec funcs[] = { + JS_FN("ctor", js_cocos2dx_EaseElasticInOut_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -23026,6 +23893,7 @@ void js_register_cocos2dx_EaseElasticInOut(JSContext *cx, JS::HandleObject globa p->parentProto = jsb_cocos2d_EaseElastic_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.EaseElasticInOut.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_EaseBounce_class; @@ -23152,6 +24020,21 @@ bool js_cocos2dx_EaseBounceIn_constructor(JSContext *cx, uint32_t argc, jsval *v if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_EaseBounceIn_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::EaseBounceIn *nobj = new (std::nothrow) cocos2d::EaseBounceIn(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EaseBounceIn"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_EaseBounce_prototype; @@ -23159,6 +24042,7 @@ extern JSObject *jsb_cocos2d_EaseBounce_prototype; void js_cocos2d_EaseBounceIn_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (EaseBounceIn)", obj); } + void js_register_cocos2dx_EaseBounceIn(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_EaseBounceIn_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_EaseBounceIn_class->name = "EaseBounceIn"; @@ -23178,6 +24062,7 @@ void js_register_cocos2dx_EaseBounceIn(JSContext *cx, JS::HandleObject global) { }; static JSFunctionSpec funcs[] = { + JS_FN("ctor", js_cocos2dx_EaseBounceIn_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -23212,6 +24097,7 @@ void js_register_cocos2dx_EaseBounceIn(JSContext *cx, JS::HandleObject global) { p->parentProto = jsb_cocos2d_EaseBounce_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.EaseBounceIn.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_EaseBounceOut_class; @@ -23277,6 +24163,21 @@ bool js_cocos2dx_EaseBounceOut_constructor(JSContext *cx, uint32_t argc, jsval * if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_EaseBounceOut_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::EaseBounceOut *nobj = new (std::nothrow) cocos2d::EaseBounceOut(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EaseBounceOut"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_EaseBounce_prototype; @@ -23284,6 +24185,7 @@ extern JSObject *jsb_cocos2d_EaseBounce_prototype; void js_cocos2d_EaseBounceOut_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (EaseBounceOut)", obj); } + void js_register_cocos2dx_EaseBounceOut(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_EaseBounceOut_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_EaseBounceOut_class->name = "EaseBounceOut"; @@ -23303,6 +24205,7 @@ void js_register_cocos2dx_EaseBounceOut(JSContext *cx, JS::HandleObject global) }; static JSFunctionSpec funcs[] = { + JS_FN("ctor", js_cocos2dx_EaseBounceOut_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -23337,6 +24240,7 @@ void js_register_cocos2dx_EaseBounceOut(JSContext *cx, JS::HandleObject global) p->parentProto = jsb_cocos2d_EaseBounce_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.EaseBounceOut.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_EaseBounceInOut_class; @@ -23402,6 +24306,21 @@ bool js_cocos2dx_EaseBounceInOut_constructor(JSContext *cx, uint32_t argc, jsval if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_EaseBounceInOut_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::EaseBounceInOut *nobj = new (std::nothrow) cocos2d::EaseBounceInOut(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EaseBounceInOut"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_EaseBounce_prototype; @@ -23409,6 +24328,7 @@ extern JSObject *jsb_cocos2d_EaseBounce_prototype; void js_cocos2d_EaseBounceInOut_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (EaseBounceInOut)", obj); } + void js_register_cocos2dx_EaseBounceInOut(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_EaseBounceInOut_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_EaseBounceInOut_class->name = "EaseBounceInOut"; @@ -23428,6 +24348,7 @@ void js_register_cocos2dx_EaseBounceInOut(JSContext *cx, JS::HandleObject global }; static JSFunctionSpec funcs[] = { + JS_FN("ctor", js_cocos2dx_EaseBounceInOut_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -23462,6 +24383,7 @@ void js_register_cocos2dx_EaseBounceInOut(JSContext *cx, JS::HandleObject global p->parentProto = jsb_cocos2d_EaseBounce_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.EaseBounceInOut.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_EaseBackIn_class; @@ -23527,6 +24449,21 @@ bool js_cocos2dx_EaseBackIn_constructor(JSContext *cx, uint32_t argc, jsval *vp) if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_EaseBackIn_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::EaseBackIn *nobj = new (std::nothrow) cocos2d::EaseBackIn(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EaseBackIn"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_ActionEase_prototype; @@ -23534,6 +24471,7 @@ extern JSObject *jsb_cocos2d_ActionEase_prototype; void js_cocos2d_EaseBackIn_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (EaseBackIn)", obj); } + void js_register_cocos2dx_EaseBackIn(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_EaseBackIn_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_EaseBackIn_class->name = "EaseBackIn"; @@ -23553,6 +24491,7 @@ void js_register_cocos2dx_EaseBackIn(JSContext *cx, JS::HandleObject global) { }; static JSFunctionSpec funcs[] = { + JS_FN("ctor", js_cocos2dx_EaseBackIn_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -23587,6 +24526,7 @@ void js_register_cocos2dx_EaseBackIn(JSContext *cx, JS::HandleObject global) { p->parentProto = jsb_cocos2d_ActionEase_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.EaseBackIn.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_EaseBackOut_class; @@ -23652,6 +24592,21 @@ bool js_cocos2dx_EaseBackOut_constructor(JSContext *cx, uint32_t argc, jsval *vp if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_EaseBackOut_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::EaseBackOut *nobj = new (std::nothrow) cocos2d::EaseBackOut(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EaseBackOut"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_ActionEase_prototype; @@ -23659,6 +24614,7 @@ extern JSObject *jsb_cocos2d_ActionEase_prototype; void js_cocos2d_EaseBackOut_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (EaseBackOut)", obj); } + void js_register_cocos2dx_EaseBackOut(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_EaseBackOut_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_EaseBackOut_class->name = "EaseBackOut"; @@ -23678,6 +24634,7 @@ void js_register_cocos2dx_EaseBackOut(JSContext *cx, JS::HandleObject global) { }; static JSFunctionSpec funcs[] = { + JS_FN("ctor", js_cocos2dx_EaseBackOut_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -23712,6 +24669,7 @@ void js_register_cocos2dx_EaseBackOut(JSContext *cx, JS::HandleObject global) { p->parentProto = jsb_cocos2d_ActionEase_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.EaseBackOut.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_EaseBackInOut_class; @@ -23777,6 +24735,21 @@ bool js_cocos2dx_EaseBackInOut_constructor(JSContext *cx, uint32_t argc, jsval * if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_EaseBackInOut_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::EaseBackInOut *nobj = new (std::nothrow) cocos2d::EaseBackInOut(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EaseBackInOut"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_ActionEase_prototype; @@ -23784,6 +24757,7 @@ extern JSObject *jsb_cocos2d_ActionEase_prototype; void js_cocos2d_EaseBackInOut_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (EaseBackInOut)", obj); } + void js_register_cocos2dx_EaseBackInOut(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_EaseBackInOut_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_EaseBackInOut_class->name = "EaseBackInOut"; @@ -23803,6 +24777,7 @@ void js_register_cocos2dx_EaseBackInOut(JSContext *cx, JS::HandleObject global) }; static JSFunctionSpec funcs[] = { + JS_FN("ctor", js_cocos2dx_EaseBackInOut_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -23837,6 +24812,7 @@ void js_register_cocos2dx_EaseBackInOut(JSContext *cx, JS::HandleObject global) p->parentProto = jsb_cocos2d_ActionEase_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.EaseBackInOut.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_EaseBezierAction_class; @@ -26266,6 +27242,21 @@ bool js_cocos2dx_Show_constructor(JSContext *cx, uint32_t argc, jsval *vp) if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_Show_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::Show *nobj = new (std::nothrow) cocos2d::Show(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::Show"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_ActionInstant_prototype; @@ -26273,6 +27264,7 @@ extern JSObject *jsb_cocos2d_ActionInstant_prototype; void js_cocos2d_Show_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (Show)", obj); } + void js_register_cocos2dx_Show(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_Show_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_Show_class->name = "Show"; @@ -26292,6 +27284,7 @@ void js_register_cocos2dx_Show(JSContext *cx, JS::HandleObject global) { }; static JSFunctionSpec funcs[] = { + JS_FN("ctor", js_cocos2dx_Show_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -26326,6 +27319,7 @@ void js_register_cocos2dx_Show(JSContext *cx, JS::HandleObject global) { p->parentProto = jsb_cocos2d_ActionInstant_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.Show.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_Hide_class; @@ -26379,6 +27373,21 @@ bool js_cocos2dx_Hide_constructor(JSContext *cx, uint32_t argc, jsval *vp) if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_Hide_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::Hide *nobj = new (std::nothrow) cocos2d::Hide(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::Hide"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_ActionInstant_prototype; @@ -26386,6 +27395,7 @@ extern JSObject *jsb_cocos2d_ActionInstant_prototype; void js_cocos2d_Hide_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (Hide)", obj); } + void js_register_cocos2dx_Hide(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_Hide_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_Hide_class->name = "Hide"; @@ -26405,6 +27415,7 @@ void js_register_cocos2dx_Hide(JSContext *cx, JS::HandleObject global) { }; static JSFunctionSpec funcs[] = { + JS_FN("ctor", js_cocos2dx_Hide_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -26439,6 +27450,7 @@ void js_register_cocos2dx_Hide(JSContext *cx, JS::HandleObject global) { p->parentProto = jsb_cocos2d_ActionInstant_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.Hide.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_ToggleVisibility_class; @@ -26785,6 +27797,21 @@ bool js_cocos2dx_FlipX_constructor(JSContext *cx, uint32_t argc, jsval *vp) if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_FlipX_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::FlipX *nobj = new (std::nothrow) cocos2d::FlipX(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::FlipX"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_ActionInstant_prototype; @@ -26792,6 +27819,7 @@ extern JSObject *jsb_cocos2d_ActionInstant_prototype; void js_cocos2d_FlipX_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (FlipX)", obj); } + void js_register_cocos2dx_FlipX(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_FlipX_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_FlipX_class->name = "FlipX"; @@ -26812,6 +27840,7 @@ void js_register_cocos2dx_FlipX(JSContext *cx, JS::HandleObject global) { static JSFunctionSpec funcs[] = { JS_FN("initWithFlipX", js_cocos2dx_FlipX_initWithFlipX, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2dx_FlipX_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -26846,6 +27875,7 @@ void js_register_cocos2dx_FlipX(JSContext *cx, JS::HandleObject global) { p->parentProto = jsb_cocos2d_ActionInstant_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.FlipX.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_FlipY_class; @@ -26925,6 +27955,21 @@ bool js_cocos2dx_FlipY_constructor(JSContext *cx, uint32_t argc, jsval *vp) if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_FlipY_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::FlipY *nobj = new (std::nothrow) cocos2d::FlipY(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::FlipY"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_ActionInstant_prototype; @@ -26932,6 +27977,7 @@ extern JSObject *jsb_cocos2d_ActionInstant_prototype; void js_cocos2d_FlipY_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (FlipY)", obj); } + void js_register_cocos2dx_FlipY(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_FlipY_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_FlipY_class->name = "FlipY"; @@ -26952,6 +27998,7 @@ void js_register_cocos2dx_FlipY(JSContext *cx, JS::HandleObject global) { static JSFunctionSpec funcs[] = { JS_FN("initWithFlipY", js_cocos2dx_FlipY_initWithFlipY, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2dx_FlipY_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -26986,6 +28033,7 @@ void js_register_cocos2dx_FlipY(JSContext *cx, JS::HandleObject global) { p->parentProto = jsb_cocos2d_ActionInstant_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.FlipY.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_Place_class; @@ -27065,6 +28113,21 @@ bool js_cocos2dx_Place_constructor(JSContext *cx, uint32_t argc, jsval *vp) if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_Place_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::Place *nobj = new (std::nothrow) cocos2d::Place(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::Place"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_ActionInstant_prototype; @@ -27072,6 +28135,7 @@ extern JSObject *jsb_cocos2d_ActionInstant_prototype; void js_cocos2d_Place_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (Place)", obj); } + void js_register_cocos2dx_Place(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_Place_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_Place_class->name = "Place"; @@ -27092,6 +28156,7 @@ void js_register_cocos2dx_Place(JSContext *cx, JS::HandleObject global) { static JSFunctionSpec funcs[] = { JS_FN("initWithPosition", js_cocos2dx_Place_initWithPosition, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2dx_Place_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -27126,6 +28191,7 @@ void js_register_cocos2dx_Place(JSContext *cx, JS::HandleObject global) { p->parentProto = jsb_cocos2d_ActionInstant_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.Place.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_CallFunc_class; @@ -27174,6 +28240,21 @@ bool js_cocos2dx_CallFunc_constructor(JSContext *cx, uint32_t argc, jsval *vp) if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_CallFunc_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::CallFunc *nobj = new (std::nothrow) cocos2d::CallFunc(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::CallFunc"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_ActionInstant_prototype; @@ -27181,6 +28262,7 @@ extern JSObject *jsb_cocos2d_ActionInstant_prototype; void js_cocos2d_CallFunc_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (CallFunc)", obj); } + void js_register_cocos2dx_CallFunc(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_CallFunc_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_CallFunc_class->name = "_CallFunc"; @@ -27201,6 +28283,7 @@ void js_register_cocos2dx_CallFunc(JSContext *cx, JS::HandleObject global) { static JSFunctionSpec funcs[] = { JS_FN("execute", js_cocos2dx_CallFunc_execute, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2dx_CallFunc_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -27232,6 +28315,7 @@ void js_register_cocos2dx_CallFunc(JSContext *cx, JS::HandleObject global) { p->parentProto = jsb_cocos2d_ActionInstant_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc._CallFunc.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_CallFuncN_class; @@ -27264,6 +28348,21 @@ bool js_cocos2dx_CallFuncN_constructor(JSContext *cx, uint32_t argc, jsval *vp) if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_CallFuncN_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::CallFuncN *nobj = new (std::nothrow) cocos2d::CallFuncN(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::CallFuncN"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_CallFunc_prototype; @@ -27271,6 +28370,7 @@ extern JSObject *jsb_cocos2d_CallFunc_prototype; void js_cocos2d_CallFuncN_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (CallFuncN)", obj); } + void js_register_cocos2dx_CallFuncN(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_CallFuncN_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_CallFuncN_class->name = "CallFunc"; @@ -27290,6 +28390,7 @@ void js_register_cocos2dx_CallFuncN(JSContext *cx, JS::HandleObject global) { }; static JSFunctionSpec funcs[] = { + JS_FN("ctor", js_cocos2dx_CallFuncN_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -27321,6 +28422,7 @@ void js_register_cocos2dx_CallFuncN(JSContext *cx, JS::HandleObject global) { p->parentProto = jsb_cocos2d_CallFunc_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.CallFunc.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_GridAction_class; @@ -28162,6 +29264,21 @@ bool js_cocos2dx_FlipX3D_constructor(JSContext *cx, uint32_t argc, jsval *vp) if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_FlipX3D_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::FlipX3D *nobj = new (std::nothrow) cocos2d::FlipX3D(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::FlipX3D"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_Grid3DAction_prototype; @@ -28169,6 +29286,7 @@ extern JSObject *jsb_cocos2d_Grid3DAction_prototype; void js_cocos2d_FlipX3D_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (FlipX3D)", obj); } + void js_register_cocos2dx_FlipX3D(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_FlipX3D_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_FlipX3D_class->name = "FlipX3D"; @@ -28190,6 +29308,7 @@ void js_register_cocos2dx_FlipX3D(JSContext *cx, JS::HandleObject global) { static JSFunctionSpec funcs[] = { JS_FN("initWithSize", js_cocos2dx_FlipX3D_initWithSize, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("initWithDuration", js_cocos2dx_FlipX3D_initWithDuration, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2dx_FlipX3D_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -28224,6 +29343,7 @@ void js_register_cocos2dx_FlipX3D(JSContext *cx, JS::HandleObject global) { p->parentProto = jsb_cocos2d_Grid3DAction_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.FlipX3D.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_FlipY3D_class; @@ -28281,6 +29401,21 @@ bool js_cocos2dx_FlipY3D_constructor(JSContext *cx, uint32_t argc, jsval *vp) if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_FlipY3D_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::FlipY3D *nobj = new (std::nothrow) cocos2d::FlipY3D(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::FlipY3D"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_FlipX3D_prototype; @@ -28288,6 +29423,7 @@ extern JSObject *jsb_cocos2d_FlipX3D_prototype; void js_cocos2d_FlipY3D_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (FlipY3D)", obj); } + void js_register_cocos2dx_FlipY3D(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_FlipY3D_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_FlipY3D_class->name = "FlipY3D"; @@ -28307,6 +29443,7 @@ void js_register_cocos2dx_FlipY3D(JSContext *cx, JS::HandleObject global) { }; static JSFunctionSpec funcs[] = { + JS_FN("ctor", js_cocos2dx_FlipY3D_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -28341,6 +29478,7 @@ void js_register_cocos2dx_FlipY3D(JSContext *cx, JS::HandleObject global) { p->parentProto = jsb_cocos2d_FlipX3D_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.FlipY3D.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_Lens3D_class; @@ -30452,6 +31590,21 @@ bool js_cocos2dx_ProgressTo_constructor(JSContext *cx, uint32_t argc, jsval *vp) if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_ProgressTo_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::ProgressTo *nobj = new (std::nothrow) cocos2d::ProgressTo(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ProgressTo"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_ActionInterval_prototype; @@ -30459,6 +31612,7 @@ extern JSObject *jsb_cocos2d_ActionInterval_prototype; void js_cocos2d_ProgressTo_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (ProgressTo)", obj); } + void js_register_cocos2dx_ProgressTo(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_ProgressTo_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_ProgressTo_class->name = "ProgressTo"; @@ -30479,6 +31633,7 @@ void js_register_cocos2dx_ProgressTo(JSContext *cx, JS::HandleObject global) { static JSFunctionSpec funcs[] = { JS_FN("initWithDuration", js_cocos2dx_ProgressTo_initWithDuration, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2dx_ProgressTo_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -30513,6 +31668,7 @@ void js_register_cocos2dx_ProgressTo(JSContext *cx, JS::HandleObject global) { p->parentProto = jsb_cocos2d_ActionInterval_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.ProgressTo.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_ProgressFromTo_class; @@ -30600,6 +31756,21 @@ bool js_cocos2dx_ProgressFromTo_constructor(JSContext *cx, uint32_t argc, jsval if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_ProgressFromTo_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::ProgressFromTo *nobj = new (std::nothrow) cocos2d::ProgressFromTo(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ProgressFromTo"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_ActionInterval_prototype; @@ -30607,6 +31778,7 @@ extern JSObject *jsb_cocos2d_ActionInterval_prototype; void js_cocos2d_ProgressFromTo_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (ProgressFromTo)", obj); } + void js_register_cocos2dx_ProgressFromTo(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_ProgressFromTo_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_ProgressFromTo_class->name = "ProgressFromTo"; @@ -30627,6 +31799,7 @@ void js_register_cocos2dx_ProgressFromTo(JSContext *cx, JS::HandleObject global) static JSFunctionSpec funcs[] = { JS_FN("initWithDuration", js_cocos2dx_ProgressFromTo_initWithDuration, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2dx_ProgressFromTo_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -30661,6 +31834,7 @@ void js_register_cocos2dx_ProgressFromTo(JSContext *cx, JS::HandleObject global) p->parentProto = jsb_cocos2d_ActionInterval_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.ProgressFromTo.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_ShakyTiles3D_class; @@ -31329,6 +32503,21 @@ bool js_cocos2dx_FadeOutTRTiles_constructor(JSContext *cx, uint32_t argc, jsval if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_FadeOutTRTiles_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::FadeOutTRTiles *nobj = new (std::nothrow) cocos2d::FadeOutTRTiles(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::FadeOutTRTiles"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_TiledGrid3DAction_prototype; @@ -31336,6 +32525,7 @@ extern JSObject *jsb_cocos2d_TiledGrid3DAction_prototype; void js_cocos2d_FadeOutTRTiles_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (FadeOutTRTiles)", obj); } + void js_register_cocos2dx_FadeOutTRTiles(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_FadeOutTRTiles_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_FadeOutTRTiles_class->name = "FadeOutTRTiles"; @@ -31359,6 +32549,7 @@ void js_register_cocos2dx_FadeOutTRTiles(JSContext *cx, JS::HandleObject global) JS_FN("turnOffTile", js_cocos2dx_FadeOutTRTiles_turnOffTile, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("transformTile", js_cocos2dx_FadeOutTRTiles_transformTile, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("testFunc", js_cocos2dx_FadeOutTRTiles_testFunc, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2dx_FadeOutTRTiles_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -31393,6 +32584,7 @@ void js_register_cocos2dx_FadeOutTRTiles(JSContext *cx, JS::HandleObject global) p->parentProto = jsb_cocos2d_TiledGrid3DAction_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.FadeOutTRTiles.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_FadeOutBLTiles_class; @@ -31452,6 +32644,21 @@ bool js_cocos2dx_FadeOutBLTiles_constructor(JSContext *cx, uint32_t argc, jsval if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_FadeOutBLTiles_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::FadeOutBLTiles *nobj = new (std::nothrow) cocos2d::FadeOutBLTiles(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::FadeOutBLTiles"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_FadeOutTRTiles_prototype; @@ -31459,6 +32666,7 @@ extern JSObject *jsb_cocos2d_FadeOutTRTiles_prototype; void js_cocos2d_FadeOutBLTiles_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (FadeOutBLTiles)", obj); } + void js_register_cocos2dx_FadeOutBLTiles(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_FadeOutBLTiles_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_FadeOutBLTiles_class->name = "FadeOutBLTiles"; @@ -31478,6 +32686,7 @@ void js_register_cocos2dx_FadeOutBLTiles(JSContext *cx, JS::HandleObject global) }; static JSFunctionSpec funcs[] = { + JS_FN("ctor", js_cocos2dx_FadeOutBLTiles_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -31512,6 +32721,7 @@ void js_register_cocos2dx_FadeOutBLTiles(JSContext *cx, JS::HandleObject global) p->parentProto = jsb_cocos2d_FadeOutTRTiles_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.FadeOutBLTiles.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_FadeOutUpTiles_class; @@ -31571,6 +32781,21 @@ bool js_cocos2dx_FadeOutUpTiles_constructor(JSContext *cx, uint32_t argc, jsval if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_FadeOutUpTiles_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::FadeOutUpTiles *nobj = new (std::nothrow) cocos2d::FadeOutUpTiles(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::FadeOutUpTiles"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_FadeOutTRTiles_prototype; @@ -31578,6 +32803,7 @@ extern JSObject *jsb_cocos2d_FadeOutTRTiles_prototype; void js_cocos2d_FadeOutUpTiles_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (FadeOutUpTiles)", obj); } + void js_register_cocos2dx_FadeOutUpTiles(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_FadeOutUpTiles_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_FadeOutUpTiles_class->name = "FadeOutUpTiles"; @@ -31597,6 +32823,7 @@ void js_register_cocos2dx_FadeOutUpTiles(JSContext *cx, JS::HandleObject global) }; static JSFunctionSpec funcs[] = { + JS_FN("ctor", js_cocos2dx_FadeOutUpTiles_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -31631,6 +32858,7 @@ void js_register_cocos2dx_FadeOutUpTiles(JSContext *cx, JS::HandleObject global) p->parentProto = jsb_cocos2d_FadeOutTRTiles_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.FadeOutUpTiles.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_FadeOutDownTiles_class; @@ -31690,6 +32918,21 @@ bool js_cocos2dx_FadeOutDownTiles_constructor(JSContext *cx, uint32_t argc, jsva if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_FadeOutDownTiles_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::FadeOutDownTiles *nobj = new (std::nothrow) cocos2d::FadeOutDownTiles(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::FadeOutDownTiles"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_FadeOutUpTiles_prototype; @@ -31697,6 +32940,7 @@ extern JSObject *jsb_cocos2d_FadeOutUpTiles_prototype; void js_cocos2d_FadeOutDownTiles_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (FadeOutDownTiles)", obj); } + void js_register_cocos2dx_FadeOutDownTiles(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_FadeOutDownTiles_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_FadeOutDownTiles_class->name = "FadeOutDownTiles"; @@ -31716,6 +32960,7 @@ void js_register_cocos2dx_FadeOutDownTiles(JSContext *cx, JS::HandleObject globa }; static JSFunctionSpec funcs[] = { + JS_FN("ctor", js_cocos2dx_FadeOutDownTiles_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -31750,6 +32995,7 @@ void js_register_cocos2dx_FadeOutDownTiles(JSContext *cx, JS::HandleObject globa p->parentProto = jsb_cocos2d_FadeOutUpTiles_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.FadeOutDownTiles.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_TurnOffTiles_class; @@ -32390,6 +33636,21 @@ bool js_cocos2dx_JumpTiles3D_constructor(JSContext *cx, uint32_t argc, jsval *vp if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_JumpTiles3D_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::JumpTiles3D *nobj = new (std::nothrow) cocos2d::JumpTiles3D(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::JumpTiles3D"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_TiledGrid3DAction_prototype; @@ -32397,6 +33658,7 @@ extern JSObject *jsb_cocos2d_TiledGrid3DAction_prototype; void js_cocos2d_JumpTiles3D_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (JumpTiles3D)", obj); } + void js_register_cocos2dx_JumpTiles3D(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_JumpTiles3D_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_JumpTiles3D_class->name = "JumpTiles3D"; @@ -32421,6 +33683,7 @@ void js_register_cocos2dx_JumpTiles3D(JSContext *cx, JS::HandleObject global) { JS_FN("getAmplitude", js_cocos2dx_JumpTiles3D_getAmplitude, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getAmplitudeRate", js_cocos2dx_JumpTiles3D_getAmplitudeRate, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setAmplitude", js_cocos2dx_JumpTiles3D_setAmplitude, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2dx_JumpTiles3D_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -32455,6 +33718,7 @@ void js_register_cocos2dx_JumpTiles3D(JSContext *cx, JS::HandleObject global) { p->parentProto = jsb_cocos2d_TiledGrid3DAction_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.JumpTiles3D.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_SplitRows_class; @@ -32905,14 +34169,7 @@ bool js_cocos2dx_GLProgramState_setUniformCallback(JSContext *cx, uint32_t argc, largv[0] = JSVAL_NULL; } } while (0); - do { - if (larg1) { - js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Uniform*)larg1); - largv[1] = OBJECT_TO_JSVAL(jsProxy->obj); - } else { - largv[1] = JSVAL_NULL; - } - } while (0); + largv[1] = uniform_to_jsval(cx, larg1); JS::RootedValue rval(cx); bool succeed = func->invoke(2, &largv[0], &rval); if (!succeed && JS_IsExceptionPending(cx)) { @@ -32955,14 +34212,7 @@ bool js_cocos2dx_GLProgramState_setUniformCallback(JSContext *cx, uint32_t argc, largv[0] = JSVAL_NULL; } } while (0); - do { - if (larg1) { - js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Uniform*)larg1); - largv[1] = OBJECT_TO_JSVAL(jsProxy->obj); - } else { - largv[1] = JSVAL_NULL; - } - } while (0); + largv[1] = uniform_to_jsval(cx, larg1); JS::RootedValue rval(cx); bool succeed = func->invoke(2, &largv[0], &rval); if (!succeed && JS_IsExceptionPending(cx)) { @@ -51568,6 +52818,21 @@ bool js_cocos2dx_TransitionSceneOriented_constructor(JSContext *cx, uint32_t arg if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_TransitionSceneOriented_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::TransitionSceneOriented *nobj = new (std::nothrow) cocos2d::TransitionSceneOriented(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TransitionSceneOriented"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_TransitionScene_prototype; @@ -51575,6 +52840,7 @@ extern JSObject *jsb_cocos2d_TransitionScene_prototype; void js_cocos2d_TransitionSceneOriented_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TransitionSceneOriented)", obj); } + void js_register_cocos2dx_TransitionSceneOriented(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_TransitionSceneOriented_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TransitionSceneOriented_class->name = "TransitionSceneOriented"; @@ -51595,6 +52861,7 @@ void js_register_cocos2dx_TransitionSceneOriented(JSContext *cx, JS::HandleObjec static JSFunctionSpec funcs[] = { JS_FN("initWithDuration", js_cocos2dx_TransitionSceneOriented_initWithDuration, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2dx_TransitionSceneOriented_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -51629,6 +52896,7 @@ void js_register_cocos2dx_TransitionSceneOriented(JSContext *cx, JS::HandleObjec p->parentProto = jsb_cocos2d_TransitionScene_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.TransitionSceneOriented.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_TransitionRotoZoom_class; @@ -51696,6 +52964,21 @@ bool js_cocos2dx_TransitionRotoZoom_constructor(JSContext *cx, uint32_t argc, js if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_TransitionRotoZoom_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::TransitionRotoZoom *nobj = new (std::nothrow) cocos2d::TransitionRotoZoom(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TransitionRotoZoom"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_TransitionScene_prototype; @@ -51703,6 +52986,7 @@ extern JSObject *jsb_cocos2d_TransitionScene_prototype; void js_cocos2d_TransitionRotoZoom_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TransitionRotoZoom)", obj); } + void js_register_cocos2dx_TransitionRotoZoom(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_TransitionRotoZoom_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TransitionRotoZoom_class->name = "TransitionRotoZoom"; @@ -51722,6 +53006,7 @@ void js_register_cocos2dx_TransitionRotoZoom(JSContext *cx, JS::HandleObject glo }; static JSFunctionSpec funcs[] = { + JS_FN("ctor", js_cocos2dx_TransitionRotoZoom_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -51756,6 +53041,7 @@ void js_register_cocos2dx_TransitionRotoZoom(JSContext *cx, JS::HandleObject glo p->parentProto = jsb_cocos2d_TransitionScene_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.TransitionRotoZoom.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_TransitionJumpZoom_class; @@ -51823,6 +53109,21 @@ bool js_cocos2dx_TransitionJumpZoom_constructor(JSContext *cx, uint32_t argc, js if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_TransitionJumpZoom_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::TransitionJumpZoom *nobj = new (std::nothrow) cocos2d::TransitionJumpZoom(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TransitionJumpZoom"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_TransitionScene_prototype; @@ -51830,6 +53131,7 @@ extern JSObject *jsb_cocos2d_TransitionScene_prototype; void js_cocos2d_TransitionJumpZoom_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TransitionJumpZoom)", obj); } + void js_register_cocos2dx_TransitionJumpZoom(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_TransitionJumpZoom_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TransitionJumpZoom_class->name = "TransitionJumpZoom"; @@ -51849,6 +53151,7 @@ void js_register_cocos2dx_TransitionJumpZoom(JSContext *cx, JS::HandleObject glo }; static JSFunctionSpec funcs[] = { + JS_FN("ctor", js_cocos2dx_TransitionJumpZoom_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -51883,6 +53186,7 @@ void js_register_cocos2dx_TransitionJumpZoom(JSContext *cx, JS::HandleObject glo p->parentProto = jsb_cocos2d_TransitionScene_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.TransitionJumpZoom.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_TransitionMoveInL_class; @@ -52012,6 +53316,21 @@ bool js_cocos2dx_TransitionMoveInL_constructor(JSContext *cx, uint32_t argc, jsv if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_TransitionMoveInL_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::TransitionMoveInL *nobj = new (std::nothrow) cocos2d::TransitionMoveInL(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TransitionMoveInL"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_TransitionScene_prototype; @@ -52019,6 +53338,7 @@ extern JSObject *jsb_cocos2d_TransitionScene_prototype; void js_cocos2d_TransitionMoveInL_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TransitionMoveInL)", obj); } + void js_register_cocos2dx_TransitionMoveInL(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_TransitionMoveInL_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TransitionMoveInL_class->name = "TransitionMoveInL"; @@ -52040,6 +53360,7 @@ void js_register_cocos2dx_TransitionMoveInL(JSContext *cx, JS::HandleObject glob static JSFunctionSpec funcs[] = { JS_FN("action", js_cocos2dx_TransitionMoveInL_action, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("easeActionWithAction", js_cocos2dx_TransitionMoveInL_easeActionWithAction, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2dx_TransitionMoveInL_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -52074,6 +53395,7 @@ void js_register_cocos2dx_TransitionMoveInL(JSContext *cx, JS::HandleObject glob p->parentProto = jsb_cocos2d_TransitionScene_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.TransitionMoveInL.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_TransitionMoveInR_class; @@ -52141,6 +53463,21 @@ bool js_cocos2dx_TransitionMoveInR_constructor(JSContext *cx, uint32_t argc, jsv if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_TransitionMoveInR_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::TransitionMoveInR *nobj = new (std::nothrow) cocos2d::TransitionMoveInR(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TransitionMoveInR"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_TransitionMoveInL_prototype; @@ -52148,6 +53485,7 @@ extern JSObject *jsb_cocos2d_TransitionMoveInL_prototype; void js_cocos2d_TransitionMoveInR_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TransitionMoveInR)", obj); } + void js_register_cocos2dx_TransitionMoveInR(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_TransitionMoveInR_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TransitionMoveInR_class->name = "TransitionMoveInR"; @@ -52167,6 +53505,7 @@ void js_register_cocos2dx_TransitionMoveInR(JSContext *cx, JS::HandleObject glob }; static JSFunctionSpec funcs[] = { + JS_FN("ctor", js_cocos2dx_TransitionMoveInR_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -52201,6 +53540,7 @@ void js_register_cocos2dx_TransitionMoveInR(JSContext *cx, JS::HandleObject glob p->parentProto = jsb_cocos2d_TransitionMoveInL_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.TransitionMoveInR.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_TransitionMoveInT_class; @@ -52268,6 +53608,21 @@ bool js_cocos2dx_TransitionMoveInT_constructor(JSContext *cx, uint32_t argc, jsv if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_TransitionMoveInT_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::TransitionMoveInT *nobj = new (std::nothrow) cocos2d::TransitionMoveInT(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TransitionMoveInT"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_TransitionMoveInL_prototype; @@ -52275,6 +53630,7 @@ extern JSObject *jsb_cocos2d_TransitionMoveInL_prototype; void js_cocos2d_TransitionMoveInT_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TransitionMoveInT)", obj); } + void js_register_cocos2dx_TransitionMoveInT(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_TransitionMoveInT_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TransitionMoveInT_class->name = "TransitionMoveInT"; @@ -52294,6 +53650,7 @@ void js_register_cocos2dx_TransitionMoveInT(JSContext *cx, JS::HandleObject glob }; static JSFunctionSpec funcs[] = { + JS_FN("ctor", js_cocos2dx_TransitionMoveInT_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -52328,6 +53685,7 @@ void js_register_cocos2dx_TransitionMoveInT(JSContext *cx, JS::HandleObject glob p->parentProto = jsb_cocos2d_TransitionMoveInL_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.TransitionMoveInT.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_TransitionMoveInB_class; @@ -52395,6 +53753,21 @@ bool js_cocos2dx_TransitionMoveInB_constructor(JSContext *cx, uint32_t argc, jsv if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_TransitionMoveInB_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::TransitionMoveInB *nobj = new (std::nothrow) cocos2d::TransitionMoveInB(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TransitionMoveInB"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_TransitionMoveInL_prototype; @@ -52402,6 +53775,7 @@ extern JSObject *jsb_cocos2d_TransitionMoveInL_prototype; void js_cocos2d_TransitionMoveInB_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TransitionMoveInB)", obj); } + void js_register_cocos2dx_TransitionMoveInB(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_TransitionMoveInB_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TransitionMoveInB_class->name = "TransitionMoveInB"; @@ -52421,6 +53795,7 @@ void js_register_cocos2dx_TransitionMoveInB(JSContext *cx, JS::HandleObject glob }; static JSFunctionSpec funcs[] = { + JS_FN("ctor", js_cocos2dx_TransitionMoveInB_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -52455,6 +53830,7 @@ void js_register_cocos2dx_TransitionMoveInB(JSContext *cx, JS::HandleObject glob p->parentProto = jsb_cocos2d_TransitionMoveInL_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.TransitionMoveInB.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_TransitionSlideInL_class; @@ -52584,6 +53960,21 @@ bool js_cocos2dx_TransitionSlideInL_constructor(JSContext *cx, uint32_t argc, js if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_TransitionSlideInL_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::TransitionSlideInL *nobj = new (std::nothrow) cocos2d::TransitionSlideInL(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TransitionSlideInL"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_TransitionScene_prototype; @@ -52591,6 +53982,7 @@ extern JSObject *jsb_cocos2d_TransitionScene_prototype; void js_cocos2d_TransitionSlideInL_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TransitionSlideInL)", obj); } + void js_register_cocos2dx_TransitionSlideInL(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_TransitionSlideInL_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TransitionSlideInL_class->name = "TransitionSlideInL"; @@ -52612,6 +54004,7 @@ void js_register_cocos2dx_TransitionSlideInL(JSContext *cx, JS::HandleObject glo static JSFunctionSpec funcs[] = { JS_FN("action", js_cocos2dx_TransitionSlideInL_action, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("easeActionWithAction", js_cocos2dx_TransitionSlideInL_easeActionWithAction, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2dx_TransitionSlideInL_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -52646,6 +54039,7 @@ void js_register_cocos2dx_TransitionSlideInL(JSContext *cx, JS::HandleObject glo p->parentProto = jsb_cocos2d_TransitionScene_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.TransitionSlideInL.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_TransitionSlideInR_class; @@ -52713,6 +54107,21 @@ bool js_cocos2dx_TransitionSlideInR_constructor(JSContext *cx, uint32_t argc, js if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_TransitionSlideInR_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::TransitionSlideInR *nobj = new (std::nothrow) cocos2d::TransitionSlideInR(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TransitionSlideInR"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_TransitionSlideInL_prototype; @@ -52720,6 +54129,7 @@ extern JSObject *jsb_cocos2d_TransitionSlideInL_prototype; void js_cocos2d_TransitionSlideInR_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TransitionSlideInR)", obj); } + void js_register_cocos2dx_TransitionSlideInR(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_TransitionSlideInR_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TransitionSlideInR_class->name = "TransitionSlideInR"; @@ -52739,6 +54149,7 @@ void js_register_cocos2dx_TransitionSlideInR(JSContext *cx, JS::HandleObject glo }; static JSFunctionSpec funcs[] = { + JS_FN("ctor", js_cocos2dx_TransitionSlideInR_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -52773,6 +54184,7 @@ void js_register_cocos2dx_TransitionSlideInR(JSContext *cx, JS::HandleObject glo p->parentProto = jsb_cocos2d_TransitionSlideInL_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.TransitionSlideInR.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_TransitionSlideInB_class; @@ -52840,6 +54252,21 @@ bool js_cocos2dx_TransitionSlideInB_constructor(JSContext *cx, uint32_t argc, js if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_TransitionSlideInB_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::TransitionSlideInB *nobj = new (std::nothrow) cocos2d::TransitionSlideInB(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TransitionSlideInB"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_TransitionSlideInL_prototype; @@ -52847,6 +54274,7 @@ extern JSObject *jsb_cocos2d_TransitionSlideInL_prototype; void js_cocos2d_TransitionSlideInB_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TransitionSlideInB)", obj); } + void js_register_cocos2dx_TransitionSlideInB(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_TransitionSlideInB_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TransitionSlideInB_class->name = "TransitionSlideInB"; @@ -52866,6 +54294,7 @@ void js_register_cocos2dx_TransitionSlideInB(JSContext *cx, JS::HandleObject glo }; static JSFunctionSpec funcs[] = { + JS_FN("ctor", js_cocos2dx_TransitionSlideInB_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -52900,6 +54329,7 @@ void js_register_cocos2dx_TransitionSlideInB(JSContext *cx, JS::HandleObject glo p->parentProto = jsb_cocos2d_TransitionSlideInL_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.TransitionSlideInB.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_TransitionSlideInT_class; @@ -52967,6 +54397,21 @@ bool js_cocos2dx_TransitionSlideInT_constructor(JSContext *cx, uint32_t argc, js if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_TransitionSlideInT_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::TransitionSlideInT *nobj = new (std::nothrow) cocos2d::TransitionSlideInT(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TransitionSlideInT"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_TransitionSlideInL_prototype; @@ -52974,6 +54419,7 @@ extern JSObject *jsb_cocos2d_TransitionSlideInL_prototype; void js_cocos2d_TransitionSlideInT_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TransitionSlideInT)", obj); } + void js_register_cocos2dx_TransitionSlideInT(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_TransitionSlideInT_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TransitionSlideInT_class->name = "TransitionSlideInT"; @@ -52993,6 +54439,7 @@ void js_register_cocos2dx_TransitionSlideInT(JSContext *cx, JS::HandleObject glo }; static JSFunctionSpec funcs[] = { + JS_FN("ctor", js_cocos2dx_TransitionSlideInT_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -53027,6 +54474,7 @@ void js_register_cocos2dx_TransitionSlideInT(JSContext *cx, JS::HandleObject glo p->parentProto = jsb_cocos2d_TransitionSlideInL_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.TransitionSlideInT.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_TransitionShrinkGrow_class; @@ -53131,6 +54579,21 @@ bool js_cocos2dx_TransitionShrinkGrow_constructor(JSContext *cx, uint32_t argc, if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_TransitionShrinkGrow_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::TransitionShrinkGrow *nobj = new (std::nothrow) cocos2d::TransitionShrinkGrow(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TransitionShrinkGrow"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_TransitionScene_prototype; @@ -53138,6 +54601,7 @@ extern JSObject *jsb_cocos2d_TransitionScene_prototype; void js_cocos2d_TransitionShrinkGrow_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TransitionShrinkGrow)", obj); } + void js_register_cocos2dx_TransitionShrinkGrow(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_TransitionShrinkGrow_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TransitionShrinkGrow_class->name = "TransitionShrinkGrow"; @@ -53158,6 +54622,7 @@ void js_register_cocos2dx_TransitionShrinkGrow(JSContext *cx, JS::HandleObject g static JSFunctionSpec funcs[] = { JS_FN("easeActionWithAction", js_cocos2dx_TransitionShrinkGrow_easeActionWithAction, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2dx_TransitionShrinkGrow_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -53192,6 +54657,7 @@ void js_register_cocos2dx_TransitionShrinkGrow(JSContext *cx, JS::HandleObject g p->parentProto = jsb_cocos2d_TransitionScene_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.TransitionShrinkGrow.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_TransitionFlipX_class; @@ -53296,6 +54762,21 @@ bool js_cocos2dx_TransitionFlipX_constructor(JSContext *cx, uint32_t argc, jsval if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_TransitionFlipX_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::TransitionFlipX *nobj = new (std::nothrow) cocos2d::TransitionFlipX(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TransitionFlipX"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_TransitionSceneOriented_prototype; @@ -53303,6 +54784,7 @@ extern JSObject *jsb_cocos2d_TransitionSceneOriented_prototype; void js_cocos2d_TransitionFlipX_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TransitionFlipX)", obj); } + void js_register_cocos2dx_TransitionFlipX(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_TransitionFlipX_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TransitionFlipX_class->name = "TransitionFlipX"; @@ -53322,6 +54804,7 @@ void js_register_cocos2dx_TransitionFlipX(JSContext *cx, JS::HandleObject global }; static JSFunctionSpec funcs[] = { + JS_FN("ctor", js_cocos2dx_TransitionFlipX_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -53356,6 +54839,7 @@ void js_register_cocos2dx_TransitionFlipX(JSContext *cx, JS::HandleObject global p->parentProto = jsb_cocos2d_TransitionSceneOriented_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.TransitionFlipX.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_TransitionFlipY_class; @@ -53460,6 +54944,21 @@ bool js_cocos2dx_TransitionFlipY_constructor(JSContext *cx, uint32_t argc, jsval if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_TransitionFlipY_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::TransitionFlipY *nobj = new (std::nothrow) cocos2d::TransitionFlipY(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TransitionFlipY"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_TransitionSceneOriented_prototype; @@ -53467,6 +54966,7 @@ extern JSObject *jsb_cocos2d_TransitionSceneOriented_prototype; void js_cocos2d_TransitionFlipY_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TransitionFlipY)", obj); } + void js_register_cocos2dx_TransitionFlipY(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_TransitionFlipY_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TransitionFlipY_class->name = "TransitionFlipY"; @@ -53486,6 +54986,7 @@ void js_register_cocos2dx_TransitionFlipY(JSContext *cx, JS::HandleObject global }; static JSFunctionSpec funcs[] = { + JS_FN("ctor", js_cocos2dx_TransitionFlipY_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -53520,6 +55021,7 @@ void js_register_cocos2dx_TransitionFlipY(JSContext *cx, JS::HandleObject global p->parentProto = jsb_cocos2d_TransitionSceneOriented_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.TransitionFlipY.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_TransitionFlipAngular_class; @@ -53624,6 +55126,21 @@ bool js_cocos2dx_TransitionFlipAngular_constructor(JSContext *cx, uint32_t argc, if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_TransitionFlipAngular_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::TransitionFlipAngular *nobj = new (std::nothrow) cocos2d::TransitionFlipAngular(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TransitionFlipAngular"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_TransitionSceneOriented_prototype; @@ -53631,6 +55148,7 @@ extern JSObject *jsb_cocos2d_TransitionSceneOriented_prototype; void js_cocos2d_TransitionFlipAngular_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TransitionFlipAngular)", obj); } + void js_register_cocos2dx_TransitionFlipAngular(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_TransitionFlipAngular_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TransitionFlipAngular_class->name = "TransitionFlipAngular"; @@ -53650,6 +55168,7 @@ void js_register_cocos2dx_TransitionFlipAngular(JSContext *cx, JS::HandleObject }; static JSFunctionSpec funcs[] = { + JS_FN("ctor", js_cocos2dx_TransitionFlipAngular_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -53684,6 +55203,7 @@ void js_register_cocos2dx_TransitionFlipAngular(JSContext *cx, JS::HandleObject p->parentProto = jsb_cocos2d_TransitionSceneOriented_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.TransitionFlipAngular.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_TransitionZoomFlipX_class; @@ -53788,6 +55308,21 @@ bool js_cocos2dx_TransitionZoomFlipX_constructor(JSContext *cx, uint32_t argc, j if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_TransitionZoomFlipX_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::TransitionZoomFlipX *nobj = new (std::nothrow) cocos2d::TransitionZoomFlipX(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TransitionZoomFlipX"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_TransitionSceneOriented_prototype; @@ -53795,6 +55330,7 @@ extern JSObject *jsb_cocos2d_TransitionSceneOriented_prototype; void js_cocos2d_TransitionZoomFlipX_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TransitionZoomFlipX)", obj); } + void js_register_cocos2dx_TransitionZoomFlipX(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_TransitionZoomFlipX_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TransitionZoomFlipX_class->name = "TransitionZoomFlipX"; @@ -53814,6 +55350,7 @@ void js_register_cocos2dx_TransitionZoomFlipX(JSContext *cx, JS::HandleObject gl }; static JSFunctionSpec funcs[] = { + JS_FN("ctor", js_cocos2dx_TransitionZoomFlipX_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -53848,6 +55385,7 @@ void js_register_cocos2dx_TransitionZoomFlipX(JSContext *cx, JS::HandleObject gl p->parentProto = jsb_cocos2d_TransitionSceneOriented_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.TransitionZoomFlipX.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_TransitionZoomFlipY_class; @@ -53952,6 +55490,21 @@ bool js_cocos2dx_TransitionZoomFlipY_constructor(JSContext *cx, uint32_t argc, j if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_TransitionZoomFlipY_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::TransitionZoomFlipY *nobj = new (std::nothrow) cocos2d::TransitionZoomFlipY(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TransitionZoomFlipY"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_TransitionSceneOriented_prototype; @@ -53959,6 +55512,7 @@ extern JSObject *jsb_cocos2d_TransitionSceneOriented_prototype; void js_cocos2d_TransitionZoomFlipY_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TransitionZoomFlipY)", obj); } + void js_register_cocos2dx_TransitionZoomFlipY(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_TransitionZoomFlipY_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TransitionZoomFlipY_class->name = "TransitionZoomFlipY"; @@ -53978,6 +55532,7 @@ void js_register_cocos2dx_TransitionZoomFlipY(JSContext *cx, JS::HandleObject gl }; static JSFunctionSpec funcs[] = { + JS_FN("ctor", js_cocos2dx_TransitionZoomFlipY_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -54012,6 +55567,7 @@ void js_register_cocos2dx_TransitionZoomFlipY(JSContext *cx, JS::HandleObject gl p->parentProto = jsb_cocos2d_TransitionSceneOriented_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.TransitionZoomFlipY.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_TransitionZoomFlipAngular_class; @@ -54116,6 +55672,21 @@ bool js_cocos2dx_TransitionZoomFlipAngular_constructor(JSContext *cx, uint32_t a if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_TransitionZoomFlipAngular_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::TransitionZoomFlipAngular *nobj = new (std::nothrow) cocos2d::TransitionZoomFlipAngular(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TransitionZoomFlipAngular"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_TransitionSceneOriented_prototype; @@ -54123,6 +55694,7 @@ extern JSObject *jsb_cocos2d_TransitionSceneOriented_prototype; void js_cocos2d_TransitionZoomFlipAngular_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TransitionZoomFlipAngular)", obj); } + void js_register_cocos2dx_TransitionZoomFlipAngular(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_TransitionZoomFlipAngular_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TransitionZoomFlipAngular_class->name = "TransitionZoomFlipAngular"; @@ -54142,6 +55714,7 @@ void js_register_cocos2dx_TransitionZoomFlipAngular(JSContext *cx, JS::HandleObj }; static JSFunctionSpec funcs[] = { + JS_FN("ctor", js_cocos2dx_TransitionZoomFlipAngular_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -54176,6 +55749,7 @@ void js_register_cocos2dx_TransitionZoomFlipAngular(JSContext *cx, JS::HandleObj p->parentProto = jsb_cocos2d_TransitionSceneOriented_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.TransitionZoomFlipAngular.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_TransitionFade_class; @@ -54345,6 +55919,21 @@ bool js_cocos2dx_TransitionFade_constructor(JSContext *cx, uint32_t argc, jsval if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_TransitionFade_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::TransitionFade *nobj = new (std::nothrow) cocos2d::TransitionFade(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TransitionFade"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_TransitionScene_prototype; @@ -54352,6 +55941,7 @@ extern JSObject *jsb_cocos2d_TransitionScene_prototype; void js_cocos2d_TransitionFade_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TransitionFade)", obj); } + void js_register_cocos2dx_TransitionFade(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_TransitionFade_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TransitionFade_class->name = "TransitionFade"; @@ -54372,6 +55962,7 @@ void js_register_cocos2dx_TransitionFade(JSContext *cx, JS::HandleObject global) static JSFunctionSpec funcs[] = { JS_FN("initWithDuration", js_cocos2dx_TransitionFade_initWithDuration, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2dx_TransitionFade_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -54406,6 +55997,7 @@ void js_register_cocos2dx_TransitionFade(JSContext *cx, JS::HandleObject global) p->parentProto = jsb_cocos2d_TransitionScene_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.TransitionFade.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_TransitionCrossFade_class; @@ -54473,6 +56065,21 @@ bool js_cocos2dx_TransitionCrossFade_constructor(JSContext *cx, uint32_t argc, j if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_TransitionCrossFade_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::TransitionCrossFade *nobj = new (std::nothrow) cocos2d::TransitionCrossFade(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TransitionCrossFade"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_TransitionScene_prototype; @@ -54480,6 +56087,7 @@ extern JSObject *jsb_cocos2d_TransitionScene_prototype; void js_cocos2d_TransitionCrossFade_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TransitionCrossFade)", obj); } + void js_register_cocos2dx_TransitionCrossFade(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_TransitionCrossFade_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TransitionCrossFade_class->name = "TransitionCrossFade"; @@ -54499,6 +56107,7 @@ void js_register_cocos2dx_TransitionCrossFade(JSContext *cx, JS::HandleObject gl }; static JSFunctionSpec funcs[] = { + JS_FN("ctor", js_cocos2dx_TransitionCrossFade_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -54533,6 +56142,7 @@ void js_register_cocos2dx_TransitionCrossFade(JSContext *cx, JS::HandleObject gl p->parentProto = jsb_cocos2d_TransitionScene_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.TransitionCrossFade.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_TransitionTurnOffTiles_class; @@ -54637,6 +56247,21 @@ bool js_cocos2dx_TransitionTurnOffTiles_constructor(JSContext *cx, uint32_t argc if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_TransitionTurnOffTiles_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::TransitionTurnOffTiles *nobj = new (std::nothrow) cocos2d::TransitionTurnOffTiles(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TransitionTurnOffTiles"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_TransitionScene_prototype; @@ -54644,6 +56269,7 @@ extern JSObject *jsb_cocos2d_TransitionScene_prototype; void js_cocos2d_TransitionTurnOffTiles_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TransitionTurnOffTiles)", obj); } + void js_register_cocos2dx_TransitionTurnOffTiles(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_TransitionTurnOffTiles_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TransitionTurnOffTiles_class->name = "TransitionTurnOffTiles"; @@ -54664,6 +56290,7 @@ void js_register_cocos2dx_TransitionTurnOffTiles(JSContext *cx, JS::HandleObject static JSFunctionSpec funcs[] = { JS_FN("easeActionWithAction", js_cocos2dx_TransitionTurnOffTiles_easeActionWithAction, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2dx_TransitionTurnOffTiles_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -54698,6 +56325,7 @@ void js_register_cocos2dx_TransitionTurnOffTiles(JSContext *cx, JS::HandleObject p->parentProto = jsb_cocos2d_TransitionScene_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.TransitionTurnOffTiles.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_TransitionSplitCols_class; @@ -54827,6 +56455,21 @@ bool js_cocos2dx_TransitionSplitCols_constructor(JSContext *cx, uint32_t argc, j if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_TransitionSplitCols_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::TransitionSplitCols *nobj = new (std::nothrow) cocos2d::TransitionSplitCols(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TransitionSplitCols"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_TransitionScene_prototype; @@ -54834,6 +56477,7 @@ extern JSObject *jsb_cocos2d_TransitionScene_prototype; void js_cocos2d_TransitionSplitCols_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TransitionSplitCols)", obj); } + void js_register_cocos2dx_TransitionSplitCols(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_TransitionSplitCols_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TransitionSplitCols_class->name = "TransitionSplitCols"; @@ -54855,6 +56499,7 @@ void js_register_cocos2dx_TransitionSplitCols(JSContext *cx, JS::HandleObject gl static JSFunctionSpec funcs[] = { JS_FN("action", js_cocos2dx_TransitionSplitCols_action, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("easeActionWithAction", js_cocos2dx_TransitionSplitCols_easeActionWithAction, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2dx_TransitionSplitCols_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -54889,6 +56534,7 @@ void js_register_cocos2dx_TransitionSplitCols(JSContext *cx, JS::HandleObject gl p->parentProto = jsb_cocos2d_TransitionScene_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.TransitionSplitCols.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_TransitionSplitRows_class; @@ -54956,6 +56602,21 @@ bool js_cocos2dx_TransitionSplitRows_constructor(JSContext *cx, uint32_t argc, j if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_TransitionSplitRows_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::TransitionSplitRows *nobj = new (std::nothrow) cocos2d::TransitionSplitRows(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TransitionSplitRows"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_TransitionSplitCols_prototype; @@ -54963,6 +56624,7 @@ extern JSObject *jsb_cocos2d_TransitionSplitCols_prototype; void js_cocos2d_TransitionSplitRows_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TransitionSplitRows)", obj); } + void js_register_cocos2dx_TransitionSplitRows(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_TransitionSplitRows_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TransitionSplitRows_class->name = "TransitionSplitRows"; @@ -54982,6 +56644,7 @@ void js_register_cocos2dx_TransitionSplitRows(JSContext *cx, JS::HandleObject gl }; static JSFunctionSpec funcs[] = { + JS_FN("ctor", js_cocos2dx_TransitionSplitRows_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -55016,6 +56679,7 @@ void js_register_cocos2dx_TransitionSplitRows(JSContext *cx, JS::HandleObject gl p->parentProto = jsb_cocos2d_TransitionSplitCols_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.TransitionSplitRows.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_TransitionFadeTR_class; @@ -55149,6 +56813,21 @@ bool js_cocos2dx_TransitionFadeTR_constructor(JSContext *cx, uint32_t argc, jsva if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_TransitionFadeTR_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::TransitionFadeTR *nobj = new (std::nothrow) cocos2d::TransitionFadeTR(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TransitionFadeTR"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_TransitionScene_prototype; @@ -55156,6 +56835,7 @@ extern JSObject *jsb_cocos2d_TransitionScene_prototype; void js_cocos2d_TransitionFadeTR_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TransitionFadeTR)", obj); } + void js_register_cocos2dx_TransitionFadeTR(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_TransitionFadeTR_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TransitionFadeTR_class->name = "TransitionFadeTR"; @@ -55177,6 +56857,7 @@ void js_register_cocos2dx_TransitionFadeTR(JSContext *cx, JS::HandleObject globa static JSFunctionSpec funcs[] = { JS_FN("easeActionWithAction", js_cocos2dx_TransitionFadeTR_easeActionWithAction, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("actionWithSize", js_cocos2dx_TransitionFadeTR_actionWithSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2dx_TransitionFadeTR_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -55211,6 +56892,7 @@ void js_register_cocos2dx_TransitionFadeTR(JSContext *cx, JS::HandleObject globa p->parentProto = jsb_cocos2d_TransitionScene_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.TransitionFadeTR.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_TransitionFadeBL_class; @@ -55278,6 +56960,21 @@ bool js_cocos2dx_TransitionFadeBL_constructor(JSContext *cx, uint32_t argc, jsva if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_TransitionFadeBL_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::TransitionFadeBL *nobj = new (std::nothrow) cocos2d::TransitionFadeBL(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TransitionFadeBL"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_TransitionFadeTR_prototype; @@ -55285,6 +56982,7 @@ extern JSObject *jsb_cocos2d_TransitionFadeTR_prototype; void js_cocos2d_TransitionFadeBL_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TransitionFadeBL)", obj); } + void js_register_cocos2dx_TransitionFadeBL(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_TransitionFadeBL_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TransitionFadeBL_class->name = "TransitionFadeBL"; @@ -55304,6 +57002,7 @@ void js_register_cocos2dx_TransitionFadeBL(JSContext *cx, JS::HandleObject globa }; static JSFunctionSpec funcs[] = { + JS_FN("ctor", js_cocos2dx_TransitionFadeBL_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -55338,6 +57037,7 @@ void js_register_cocos2dx_TransitionFadeBL(JSContext *cx, JS::HandleObject globa p->parentProto = jsb_cocos2d_TransitionFadeTR_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.TransitionFadeBL.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_TransitionFadeUp_class; @@ -55405,6 +57105,21 @@ bool js_cocos2dx_TransitionFadeUp_constructor(JSContext *cx, uint32_t argc, jsva if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_TransitionFadeUp_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::TransitionFadeUp *nobj = new (std::nothrow) cocos2d::TransitionFadeUp(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TransitionFadeUp"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_TransitionFadeTR_prototype; @@ -55412,6 +57127,7 @@ extern JSObject *jsb_cocos2d_TransitionFadeTR_prototype; void js_cocos2d_TransitionFadeUp_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TransitionFadeUp)", obj); } + void js_register_cocos2dx_TransitionFadeUp(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_TransitionFadeUp_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TransitionFadeUp_class->name = "TransitionFadeUp"; @@ -55431,6 +57147,7 @@ void js_register_cocos2dx_TransitionFadeUp(JSContext *cx, JS::HandleObject globa }; static JSFunctionSpec funcs[] = { + JS_FN("ctor", js_cocos2dx_TransitionFadeUp_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -55465,6 +57182,7 @@ void js_register_cocos2dx_TransitionFadeUp(JSContext *cx, JS::HandleObject globa p->parentProto = jsb_cocos2d_TransitionFadeTR_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.TransitionFadeUp.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_TransitionFadeDown_class; @@ -55532,6 +57250,21 @@ bool js_cocos2dx_TransitionFadeDown_constructor(JSContext *cx, uint32_t argc, js if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_TransitionFadeDown_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::TransitionFadeDown *nobj = new (std::nothrow) cocos2d::TransitionFadeDown(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TransitionFadeDown"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_TransitionFadeTR_prototype; @@ -55539,6 +57272,7 @@ extern JSObject *jsb_cocos2d_TransitionFadeTR_prototype; void js_cocos2d_TransitionFadeDown_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TransitionFadeDown)", obj); } + void js_register_cocos2dx_TransitionFadeDown(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_TransitionFadeDown_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TransitionFadeDown_class->name = "TransitionFadeDown"; @@ -55558,6 +57292,7 @@ void js_register_cocos2dx_TransitionFadeDown(JSContext *cx, JS::HandleObject glo }; static JSFunctionSpec funcs[] = { + JS_FN("ctor", js_cocos2dx_TransitionFadeDown_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -55592,6 +57327,7 @@ void js_register_cocos2dx_TransitionFadeDown(JSContext *cx, JS::HandleObject glo p->parentProto = jsb_cocos2d_TransitionFadeTR_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.TransitionFadeDown.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_TransitionPageTurn_class; @@ -55724,6 +57460,21 @@ bool js_cocos2dx_TransitionPageTurn_constructor(JSContext *cx, uint32_t argc, js if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_TransitionPageTurn_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::TransitionPageTurn *nobj = new (std::nothrow) cocos2d::TransitionPageTurn(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TransitionPageTurn"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_TransitionScene_prototype; @@ -55731,6 +57482,7 @@ extern JSObject *jsb_cocos2d_TransitionScene_prototype; void js_cocos2d_TransitionPageTurn_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TransitionPageTurn)", obj); } + void js_register_cocos2dx_TransitionPageTurn(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_TransitionPageTurn_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TransitionPageTurn_class->name = "TransitionPageTurn"; @@ -55752,6 +57504,7 @@ void js_register_cocos2dx_TransitionPageTurn(JSContext *cx, JS::HandleObject glo static JSFunctionSpec funcs[] = { JS_FN("actionWithSize", js_cocos2dx_TransitionPageTurn_actionWithSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("initWithDuration", js_cocos2dx_TransitionPageTurn_initWithDuration, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2dx_TransitionPageTurn_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -55786,6 +57539,7 @@ void js_register_cocos2dx_TransitionPageTurn(JSContext *cx, JS::HandleObject glo p->parentProto = jsb_cocos2d_TransitionScene_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.TransitionPageTurn.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_TransitionProgress_class; @@ -55853,6 +57607,21 @@ bool js_cocos2dx_TransitionProgress_constructor(JSContext *cx, uint32_t argc, js if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_TransitionProgress_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::TransitionProgress *nobj = new (std::nothrow) cocos2d::TransitionProgress(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TransitionProgress"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_TransitionScene_prototype; @@ -55860,6 +57629,7 @@ extern JSObject *jsb_cocos2d_TransitionScene_prototype; void js_cocos2d_TransitionProgress_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TransitionProgress)", obj); } + void js_register_cocos2dx_TransitionProgress(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_TransitionProgress_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TransitionProgress_class->name = "TransitionProgress"; @@ -55879,6 +57649,7 @@ void js_register_cocos2dx_TransitionProgress(JSContext *cx, JS::HandleObject glo }; static JSFunctionSpec funcs[] = { + JS_FN("ctor", js_cocos2dx_TransitionProgress_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -55913,6 +57684,7 @@ void js_register_cocos2dx_TransitionProgress(JSContext *cx, JS::HandleObject glo p->parentProto = jsb_cocos2d_TransitionScene_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.TransitionProgress.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_TransitionProgressRadialCCW_class; @@ -55980,6 +57752,21 @@ bool js_cocos2dx_TransitionProgressRadialCCW_constructor(JSContext *cx, uint32_t if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_TransitionProgressRadialCCW_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::TransitionProgressRadialCCW *nobj = new (std::nothrow) cocos2d::TransitionProgressRadialCCW(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TransitionProgressRadialCCW"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_TransitionProgress_prototype; @@ -55987,6 +57774,7 @@ extern JSObject *jsb_cocos2d_TransitionProgress_prototype; void js_cocos2d_TransitionProgressRadialCCW_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TransitionProgressRadialCCW)", obj); } + void js_register_cocos2dx_TransitionProgressRadialCCW(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_TransitionProgressRadialCCW_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TransitionProgressRadialCCW_class->name = "TransitionProgressRadialCCW"; @@ -56006,6 +57794,7 @@ void js_register_cocos2dx_TransitionProgressRadialCCW(JSContext *cx, JS::HandleO }; static JSFunctionSpec funcs[] = { + JS_FN("ctor", js_cocos2dx_TransitionProgressRadialCCW_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -56040,6 +57829,7 @@ void js_register_cocos2dx_TransitionProgressRadialCCW(JSContext *cx, JS::HandleO p->parentProto = jsb_cocos2d_TransitionProgress_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.TransitionProgressRadialCCW.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_TransitionProgressRadialCW_class; @@ -56107,6 +57897,21 @@ bool js_cocos2dx_TransitionProgressRadialCW_constructor(JSContext *cx, uint32_t if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_TransitionProgressRadialCW_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::TransitionProgressRadialCW *nobj = new (std::nothrow) cocos2d::TransitionProgressRadialCW(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TransitionProgressRadialCW"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_TransitionProgress_prototype; @@ -56114,6 +57919,7 @@ extern JSObject *jsb_cocos2d_TransitionProgress_prototype; void js_cocos2d_TransitionProgressRadialCW_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TransitionProgressRadialCW)", obj); } + void js_register_cocos2dx_TransitionProgressRadialCW(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_TransitionProgressRadialCW_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TransitionProgressRadialCW_class->name = "TransitionProgressRadialCW"; @@ -56133,6 +57939,7 @@ void js_register_cocos2dx_TransitionProgressRadialCW(JSContext *cx, JS::HandleOb }; static JSFunctionSpec funcs[] = { + JS_FN("ctor", js_cocos2dx_TransitionProgressRadialCW_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -56167,6 +57974,7 @@ void js_register_cocos2dx_TransitionProgressRadialCW(JSContext *cx, JS::HandleOb p->parentProto = jsb_cocos2d_TransitionProgress_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.TransitionProgressRadialCW.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_TransitionProgressHorizontal_class; @@ -56234,6 +58042,21 @@ bool js_cocos2dx_TransitionProgressHorizontal_constructor(JSContext *cx, uint32_ if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_TransitionProgressHorizontal_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::TransitionProgressHorizontal *nobj = new (std::nothrow) cocos2d::TransitionProgressHorizontal(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TransitionProgressHorizontal"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_TransitionProgress_prototype; @@ -56241,6 +58064,7 @@ extern JSObject *jsb_cocos2d_TransitionProgress_prototype; void js_cocos2d_TransitionProgressHorizontal_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TransitionProgressHorizontal)", obj); } + void js_register_cocos2dx_TransitionProgressHorizontal(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_TransitionProgressHorizontal_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TransitionProgressHorizontal_class->name = "TransitionProgressHorizontal"; @@ -56260,6 +58084,7 @@ void js_register_cocos2dx_TransitionProgressHorizontal(JSContext *cx, JS::Handle }; static JSFunctionSpec funcs[] = { + JS_FN("ctor", js_cocos2dx_TransitionProgressHorizontal_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -56294,6 +58119,7 @@ void js_register_cocos2dx_TransitionProgressHorizontal(JSContext *cx, JS::Handle p->parentProto = jsb_cocos2d_TransitionProgress_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.TransitionProgressHorizontal.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_TransitionProgressVertical_class; @@ -56361,6 +58187,21 @@ bool js_cocos2dx_TransitionProgressVertical_constructor(JSContext *cx, uint32_t if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_TransitionProgressVertical_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::TransitionProgressVertical *nobj = new (std::nothrow) cocos2d::TransitionProgressVertical(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TransitionProgressVertical"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_TransitionProgress_prototype; @@ -56368,6 +58209,7 @@ extern JSObject *jsb_cocos2d_TransitionProgress_prototype; void js_cocos2d_TransitionProgressVertical_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TransitionProgressVertical)", obj); } + void js_register_cocos2dx_TransitionProgressVertical(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_TransitionProgressVertical_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TransitionProgressVertical_class->name = "TransitionProgressVertical"; @@ -56387,6 +58229,7 @@ void js_register_cocos2dx_TransitionProgressVertical(JSContext *cx, JS::HandleOb }; static JSFunctionSpec funcs[] = { + JS_FN("ctor", js_cocos2dx_TransitionProgressVertical_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -56421,6 +58264,7 @@ void js_register_cocos2dx_TransitionProgressVertical(JSContext *cx, JS::HandleOb p->parentProto = jsb_cocos2d_TransitionProgress_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.TransitionProgressVertical.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_TransitionProgressInOut_class; @@ -56488,6 +58332,21 @@ bool js_cocos2dx_TransitionProgressInOut_constructor(JSContext *cx, uint32_t arg if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_TransitionProgressInOut_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::TransitionProgressInOut *nobj = new (std::nothrow) cocos2d::TransitionProgressInOut(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TransitionProgressInOut"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_TransitionProgress_prototype; @@ -56495,6 +58354,7 @@ extern JSObject *jsb_cocos2d_TransitionProgress_prototype; void js_cocos2d_TransitionProgressInOut_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TransitionProgressInOut)", obj); } + void js_register_cocos2dx_TransitionProgressInOut(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_TransitionProgressInOut_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TransitionProgressInOut_class->name = "TransitionProgressInOut"; @@ -56514,6 +58374,7 @@ void js_register_cocos2dx_TransitionProgressInOut(JSContext *cx, JS::HandleObjec }; static JSFunctionSpec funcs[] = { + JS_FN("ctor", js_cocos2dx_TransitionProgressInOut_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -56548,6 +58409,7 @@ void js_register_cocos2dx_TransitionProgressInOut(JSContext *cx, JS::HandleObjec p->parentProto = jsb_cocos2d_TransitionProgress_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.TransitionProgressInOut.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_TransitionProgressOutIn_class; @@ -56615,6 +58477,21 @@ bool js_cocos2dx_TransitionProgressOutIn_constructor(JSContext *cx, uint32_t arg if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_TransitionProgressOutIn_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::TransitionProgressOutIn *nobj = new (std::nothrow) cocos2d::TransitionProgressOutIn(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TransitionProgressOutIn"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } extern JSObject *jsb_cocos2d_TransitionProgress_prototype; @@ -56622,6 +58499,7 @@ extern JSObject *jsb_cocos2d_TransitionProgress_prototype; void js_cocos2d_TransitionProgressOutIn_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TransitionProgressOutIn)", obj); } + void js_register_cocos2dx_TransitionProgressOutIn(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_TransitionProgressOutIn_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TransitionProgressOutIn_class->name = "TransitionProgressOutIn"; @@ -56641,6 +58519,7 @@ void js_register_cocos2dx_TransitionProgressOutIn(JSContext *cx, JS::HandleObjec }; static JSFunctionSpec funcs[] = { + JS_FN("ctor", js_cocos2dx_TransitionProgressOutIn_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -56675,6 +58554,7 @@ void js_register_cocos2dx_TransitionProgressOutIn(JSContext *cx, JS::HandleObjec p->parentProto = jsb_cocos2d_TransitionProgress_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.TransitionProgressOutIn.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_Camera_class; @@ -60530,7 +62410,7 @@ bool js_cocos2dx_GLProgram_getUniform(JSContext *cx, uint32_t argc, jsval *vp) JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_GLProgram_getUniform : Error processing arguments"); cocos2d::Uniform* ret = cobj->getUniform(arg0); jsval jsret = JSVAL_NULL; - #pragma warning NO CONVERSION FROM NATIVE FOR Uniform*; + jsret = uniform_to_jsval(cx, ret); args.rval().set(jsret); return true; } @@ -63184,6 +65064,289 @@ void js_register_cocos2dx_TextureCache(JSContext *cx, JS::HandleObject global) { } } +JSClass *jsb_cocos2d_Component_class; +JSObject *jsb_cocos2d_Component_prototype; + +bool js_cocos2dx_Component_setEnabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Component* cobj = (cocos2d::Component *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Component_setEnabled : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Component_setEnabled : Error processing arguments"); + cobj->setEnabled(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Component_setEnabled : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Component_setName(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Component* cobj = (cocos2d::Component *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Component_setName : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Component_setName : Error processing arguments"); + cobj->setName(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Component_setName : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Component_isEnabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Component* cobj = (cocos2d::Component *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Component_isEnabled : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isEnabled(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Component_isEnabled : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Component_getOwner(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Component* cobj = (cocos2d::Component *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Component_getOwner : Invalid Native Object"); + if (argc == 0) { + cocos2d::Node* ret = cobj->getOwner(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Node*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Component_getOwner : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Component_init(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Component* cobj = (cocos2d::Component *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Component_init : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->init(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Component_init : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Component_getName(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Component* cobj = (cocos2d::Component *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Component_getName : Invalid Native Object"); + if (argc == 0) { + const std::string& ret = cobj->getName(); + jsval jsret = JSVAL_NULL; + jsret = std_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Component_getName : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Component_setOwner(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Component* cobj = (cocos2d::Component *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Component_setOwner : Invalid Native Object"); + if (argc == 1) { + cocos2d::Node* arg0; + do { + if (args.get(0).isNull()) { arg0 = nullptr; break; } + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Component_setOwner : Error processing arguments"); + cobj->setOwner(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Component_setOwner : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Component_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocos2d::Component* ret = cocos2d::Component::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Component*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_Component_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_Component_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::Component* cobj = new (std::nothrow) cocos2d::Component(); + cocos2d::Ref *_ccobj = dynamic_cast(cobj); + if (_ccobj) { + _ccobj->autorelease(); + } + TypeTest t; + js_type_class_t *typeClass = nullptr; + std::string typeName = t.s_name(); + auto typeMapIter = _js_global_type_map.find(typeName); + CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); + typeClass = typeMapIter->second; + CCASSERT(typeClass, "The value is null."); + // JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); + JS::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::Component"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +}static bool js_cocos2dx_Component_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::Component *nobj = new (std::nothrow) cocos2d::Component(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::Component"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} + +void js_cocos2d_Component_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (Component)", obj); +} + +void js_register_cocos2dx_Component(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_Component_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_Component_class->name = "Component"; + jsb_cocos2d_Component_class->addProperty = JS_PropertyStub; + jsb_cocos2d_Component_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_Component_class->getProperty = JS_PropertyStub; + jsb_cocos2d_Component_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_Component_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_Component_class->resolve = JS_ResolveStub; + jsb_cocos2d_Component_class->convert = JS_ConvertStub; + jsb_cocos2d_Component_class->finalize = js_cocos2d_Component_finalize; + jsb_cocos2d_Component_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("setEnabled", js_cocos2dx_Component_setEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setName", js_cocos2dx_Component_setName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isEnabled", js_cocos2dx_Component_isEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getOwner", js_cocos2dx_Component_getOwner, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("init", js_cocos2dx_Component_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getName", js_cocos2dx_Component_getName, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setOwner", js_cocos2dx_Component_setOwner, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2dx_Component_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_Component_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_Component_prototype = JS_InitClass( + cx, global, + JS::NullPtr(), // parent proto + jsb_cocos2d_Component_class, + js_cocos2dx_Component_constructor, 0, // constructor + properties, + funcs, + NULL, // no static properties + st_funcs); + // make the class enumerable in the registered namespace +// bool found; +//FIXME: Removed in Firefox v27 +// JS_SetPropertyAttributes(cx, global, "Component", JSPROP_ENUMERATE | JSPROP_READONLY, &found); + + // add the proto and JSClass to the type->js info hash table + TypeTest t; + js_type_class_t *p; + std::string typeName = t.s_name(); + if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) + { + p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); + p->jsclass = jsb_cocos2d_Component_class; + p->proto = jsb_cocos2d_Component_prototype; + p->parentProto = NULL; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } + anonEvaluate(cx, global, "(function () { cc.Component.extend = cc.Class.extend; })()"); +} + JSClass *jsb_cocos2d_Device_class; JSObject *jsb_cocos2d_Device_prototype; @@ -63756,11 +65919,27 @@ bool js_cocos2dx_AnimationCache_constructor(JSContext *cx, uint32_t argc, jsval if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; +}static bool js_cocos2dx_AnimationCache_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::AnimationCache *nobj = new (std::nothrow) cocos2d::AnimationCache(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::AnimationCache"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; } void js_cocos2d_AnimationCache_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (AnimationCache)", obj); } + void js_register_cocos2dx_AnimationCache(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_AnimationCache_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_AnimationCache_class->name = "AnimationCache"; @@ -63786,6 +65965,7 @@ void js_register_cocos2dx_AnimationCache(JSContext *cx, JS::HandleObject global) JS_FN("addAnimationsWithDictionary", js_cocos2dx_AnimationCache_addAnimationsWithDictionary, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("removeAnimation", js_cocos2dx_AnimationCache_removeAnimation, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("addAnimations", js_cocos2dx_AnimationCache_addAnimationsWithFile, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2dx_AnimationCache_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -63821,6 +66001,7 @@ void js_register_cocos2dx_AnimationCache(JSContext *cx, JS::HandleObject global) p->parentProto = NULL; _js_global_type_map.insert(std::make_pair(typeName, p)); } + anonEvaluate(cx, global, "(function () { cc.AnimationCache.extend = cc.Class.extend; })()"); } JSClass *jsb_cocos2d_SpriteBatchNode_class; @@ -68679,515 +70860,6 @@ void js_register_cocos2dx_TileMapAtlas(JSContext *cx, JS::HandleObject global) { anonEvaluate(cx, global, "(function () { cc.TileMapAtlas.extend = cc.Class.extend; })()"); } -JSClass *jsb_cocos2d_Component_class; -JSObject *jsb_cocos2d_Component_prototype; - -bool js_cocos2dx_Component_setEnabled(JSContext *cx, uint32_t argc, jsval *vp) -{ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - bool ok = true; - JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::Component* cobj = (cocos2d::Component *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Component_setEnabled : Invalid Native Object"); - if (argc == 1) { - bool arg0; - arg0 = JS::ToBoolean(args.get(0)); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Component_setEnabled : Error processing arguments"); - cobj->setEnabled(arg0); - args.rval().setUndefined(); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_Component_setEnabled : wrong number of arguments: %d, was expecting %d", argc, 1); - return false; -} -bool js_cocos2dx_Component_setName(JSContext *cx, uint32_t argc, jsval *vp) -{ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - bool ok = true; - JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::Component* cobj = (cocos2d::Component *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Component_setName : Invalid Native Object"); - if (argc == 1) { - std::string arg0; - ok &= jsval_to_std_string(cx, args.get(0), &arg0); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Component_setName : Error processing arguments"); - cobj->setName(arg0); - args.rval().setUndefined(); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_Component_setName : wrong number of arguments: %d, was expecting %d", argc, 1); - return false; -} -bool js_cocos2dx_Component_isEnabled(JSContext *cx, uint32_t argc, jsval *vp) -{ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::Component* cobj = (cocos2d::Component *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Component_isEnabled : Invalid Native Object"); - if (argc == 0) { - bool ret = cobj->isEnabled(); - jsval jsret = JSVAL_NULL; - jsret = BOOLEAN_TO_JSVAL(ret); - args.rval().set(jsret); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_Component_isEnabled : wrong number of arguments: %d, was expecting %d", argc, 0); - return false; -} -bool js_cocos2dx_Component_getOwner(JSContext *cx, uint32_t argc, jsval *vp) -{ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::Component* cobj = (cocos2d::Component *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Component_getOwner : Invalid Native Object"); - if (argc == 0) { - cocos2d::Node* ret = cobj->getOwner(); - jsval jsret = JSVAL_NULL; - do { - if (ret) { - js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Node*)ret); - jsret = OBJECT_TO_JSVAL(jsProxy->obj); - } else { - jsret = JSVAL_NULL; - } - } while (0); - args.rval().set(jsret); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_Component_getOwner : wrong number of arguments: %d, was expecting %d", argc, 0); - return false; -} -bool js_cocos2dx_Component_init(JSContext *cx, uint32_t argc, jsval *vp) -{ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::Component* cobj = (cocos2d::Component *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Component_init : Invalid Native Object"); - if (argc == 0) { - bool ret = cobj->init(); - jsval jsret = JSVAL_NULL; - jsret = BOOLEAN_TO_JSVAL(ret); - args.rval().set(jsret); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_Component_init : wrong number of arguments: %d, was expecting %d", argc, 0); - return false; -} -bool js_cocos2dx_Component_getName(JSContext *cx, uint32_t argc, jsval *vp) -{ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::Component* cobj = (cocos2d::Component *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Component_getName : Invalid Native Object"); - if (argc == 0) { - const std::string& ret = cobj->getName(); - jsval jsret = JSVAL_NULL; - jsret = std_string_to_jsval(cx, ret); - args.rval().set(jsret); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_Component_getName : wrong number of arguments: %d, was expecting %d", argc, 0); - return false; -} -bool js_cocos2dx_Component_setOwner(JSContext *cx, uint32_t argc, jsval *vp) -{ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - bool ok = true; - JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::Component* cobj = (cocos2d::Component *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Component_setOwner : Invalid Native Object"); - if (argc == 1) { - cocos2d::Node* arg0; - do { - if (args.get(0).isNull()) { arg0 = nullptr; break; } - if (!args.get(0).isObject()) { ok = false; break; } - js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); - jsProxy = jsb_get_js_proxy(tmpObj); - arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); - JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); - } while (0); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Component_setOwner : Error processing arguments"); - cobj->setOwner(arg0); - args.rval().setUndefined(); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_Component_setOwner : wrong number of arguments: %d, was expecting %d", argc, 1); - return false; -} -bool js_cocos2dx_Component_create(JSContext *cx, uint32_t argc, jsval *vp) -{ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - if (argc == 0) { - cocos2d::Component* ret = cocos2d::Component::create(); - jsval jsret = JSVAL_NULL; - do { - if (ret) { - js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Component*)ret); - jsret = OBJECT_TO_JSVAL(jsProxy->obj); - } else { - jsret = JSVAL_NULL; - } - } while (0); - args.rval().set(jsret); - return true; - } - JS_ReportError(cx, "js_cocos2dx_Component_create : wrong number of arguments"); - return false; -} - -bool js_cocos2dx_Component_constructor(JSContext *cx, uint32_t argc, jsval *vp) -{ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - bool ok = true; - cocos2d::Component* cobj = new (std::nothrow) cocos2d::Component(); - cocos2d::Ref *_ccobj = dynamic_cast(cobj); - if (_ccobj) { - _ccobj->autorelease(); - } - TypeTest t; - js_type_class_t *typeClass = nullptr; - std::string typeName = t.s_name(); - auto typeMapIter = _js_global_type_map.find(typeName); - CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); - typeClass = typeMapIter->second; - CCASSERT(typeClass, "The value is null."); - // JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); - JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); - args.rval().set(OBJECT_TO_JSVAL(obj)); - // link the native object with the javascript object - js_proxy_t* p = jsb_new_proxy(cobj, obj); - AddNamedObjectRoot(cx, &p->obj, "cocos2d::Component"); - if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) - ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); - return true; -}static bool js_cocos2dx_Component_ctor(JSContext *cx, uint32_t argc, jsval *vp) -{ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); - cocos2d::Component *nobj = new (std::nothrow) cocos2d::Component(); - if (nobj) { - nobj->autorelease(); - } - js_proxy_t* p = jsb_new_proxy(nobj, obj); - AddNamedObjectRoot(cx, &p->obj, "cocos2d::Component"); - bool isFound = false; - if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) - ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); - args.rval().setUndefined(); - return true; -} - -void js_cocos2d_Component_finalize(JSFreeOp *fop, JSObject *obj) { - CCLOGINFO("jsbindings: finalizing JS object %p (Component)", obj); -} - -void js_register_cocos2dx_Component(JSContext *cx, JS::HandleObject global) { - jsb_cocos2d_Component_class = (JSClass *)calloc(1, sizeof(JSClass)); - jsb_cocos2d_Component_class->name = "Component"; - jsb_cocos2d_Component_class->addProperty = JS_PropertyStub; - jsb_cocos2d_Component_class->delProperty = JS_DeletePropertyStub; - jsb_cocos2d_Component_class->getProperty = JS_PropertyStub; - jsb_cocos2d_Component_class->setProperty = JS_StrictPropertyStub; - jsb_cocos2d_Component_class->enumerate = JS_EnumerateStub; - jsb_cocos2d_Component_class->resolve = JS_ResolveStub; - jsb_cocos2d_Component_class->convert = JS_ConvertStub; - jsb_cocos2d_Component_class->finalize = js_cocos2d_Component_finalize; - jsb_cocos2d_Component_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); - - static JSPropertySpec properties[] = { - JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_PS_END - }; - - static JSFunctionSpec funcs[] = { - JS_FN("setEnabled", js_cocos2dx_Component_setEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("setName", js_cocos2dx_Component_setName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("isEnabled", js_cocos2dx_Component_isEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("getOwner", js_cocos2dx_Component_getOwner, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("init", js_cocos2dx_Component_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("getName", js_cocos2dx_Component_getName, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("setOwner", js_cocos2dx_Component_setOwner, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("ctor", js_cocos2dx_Component_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FS_END - }; - - static JSFunctionSpec st_funcs[] = { - JS_FN("create", js_cocos2dx_Component_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FS_END - }; - - jsb_cocos2d_Component_prototype = JS_InitClass( - cx, global, - JS::NullPtr(), // parent proto - jsb_cocos2d_Component_class, - js_cocos2dx_Component_constructor, 0, // constructor - properties, - funcs, - NULL, // no static properties - st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Component", JSPROP_ENUMERATE | JSPROP_READONLY, &found); - - // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_Component_class; - p->proto = jsb_cocos2d_Component_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } - anonEvaluate(cx, global, "(function () { cc.Component.extend = cc.Class.extend; })()"); -} - -JSClass *jsb_cocos2d_ComponentContainer_class; -JSObject *jsb_cocos2d_ComponentContainer_prototype; - -bool js_cocos2dx_ComponentContainer_visit(JSContext *cx, uint32_t argc, jsval *vp) -{ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - bool ok = true; - JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::ComponentContainer* cobj = (cocos2d::ComponentContainer *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ComponentContainer_visit : Invalid Native Object"); - if (argc == 1) { - double arg0; - ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ComponentContainer_visit : Error processing arguments"); - cobj->visit(arg0); - args.rval().setUndefined(); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_ComponentContainer_visit : wrong number of arguments: %d, was expecting %d", argc, 1); - return false; -} -bool js_cocos2dx_ComponentContainer_remove(JSContext *cx, uint32_t argc, jsval *vp) -{ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - bool ok = true; - - JS::RootedObject obj(cx); - cocos2d::ComponentContainer* cobj = NULL; - obj = args.thisv().toObjectOrNull(); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cobj = (cocos2d::ComponentContainer *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ComponentContainer_remove : Invalid Native Object"); - do { - if (argc == 1) { - cocos2d::Component* arg0; - do { - if (args.get(0).isNull()) { arg0 = nullptr; break; } - if (!args.get(0).isObject()) { ok = false; break; } - js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); - jsProxy = jsb_get_js_proxy(tmpObj); - arg0 = (cocos2d::Component*)(jsProxy ? jsProxy->ptr : NULL); - JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); - } while (0); - if (!ok) { ok = true; break; } - bool ret = cobj->remove(arg0); - jsval jsret = JSVAL_NULL; - jsret = BOOLEAN_TO_JSVAL(ret); - args.rval().set(jsret); - return true; - } - } while(0); - - do { - if (argc == 1) { - std::string arg0; - ok &= jsval_to_std_string(cx, args.get(0), &arg0); - if (!ok) { ok = true; break; } - bool ret = cobj->remove(arg0); - jsval jsret = JSVAL_NULL; - jsret = BOOLEAN_TO_JSVAL(ret); - args.rval().set(jsret); - return true; - } - } while(0); - - JS_ReportError(cx, "js_cocos2dx_ComponentContainer_remove : wrong number of arguments"); - return false; -} -bool js_cocos2dx_ComponentContainer_removeAll(JSContext *cx, uint32_t argc, jsval *vp) -{ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::ComponentContainer* cobj = (cocos2d::ComponentContainer *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ComponentContainer_removeAll : Invalid Native Object"); - if (argc == 0) { - cobj->removeAll(); - args.rval().setUndefined(); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_ComponentContainer_removeAll : wrong number of arguments: %d, was expecting %d", argc, 0); - return false; -} -bool js_cocos2dx_ComponentContainer_add(JSContext *cx, uint32_t argc, jsval *vp) -{ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - bool ok = true; - JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::ComponentContainer* cobj = (cocos2d::ComponentContainer *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ComponentContainer_add : Invalid Native Object"); - if (argc == 1) { - cocos2d::Component* arg0; - do { - if (args.get(0).isNull()) { arg0 = nullptr; break; } - if (!args.get(0).isObject()) { ok = false; break; } - js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); - jsProxy = jsb_get_js_proxy(tmpObj); - arg0 = (cocos2d::Component*)(jsProxy ? jsProxy->ptr : NULL); - JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); - } while (0); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ComponentContainer_add : Error processing arguments"); - bool ret = cobj->add(arg0); - jsval jsret = JSVAL_NULL; - jsret = BOOLEAN_TO_JSVAL(ret); - args.rval().set(jsret); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_ComponentContainer_add : wrong number of arguments: %d, was expecting %d", argc, 1); - return false; -} -bool js_cocos2dx_ComponentContainer_isEmpty(JSContext *cx, uint32_t argc, jsval *vp) -{ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::ComponentContainer* cobj = (cocos2d::ComponentContainer *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ComponentContainer_isEmpty : Invalid Native Object"); - if (argc == 0) { - bool ret = cobj->isEmpty(); - jsval jsret = JSVAL_NULL; - jsret = BOOLEAN_TO_JSVAL(ret); - args.rval().set(jsret); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_ComponentContainer_isEmpty : wrong number of arguments: %d, was expecting %d", argc, 0); - return false; -} -bool js_cocos2dx_ComponentContainer_get(JSContext *cx, uint32_t argc, jsval *vp) -{ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - bool ok = true; - JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::ComponentContainer* cobj = (cocos2d::ComponentContainer *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ComponentContainer_get : Invalid Native Object"); - if (argc == 1) { - std::string arg0; - ok &= jsval_to_std_string(cx, args.get(0), &arg0); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ComponentContainer_get : Error processing arguments"); - cocos2d::Component* ret = cobj->get(arg0); - jsval jsret = JSVAL_NULL; - do { - if (ret) { - js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Component*)ret); - jsret = OBJECT_TO_JSVAL(jsProxy->obj); - } else { - jsret = JSVAL_NULL; - } - } while (0); - args.rval().set(jsret); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_ComponentContainer_get : wrong number of arguments: %d, was expecting %d", argc, 1); - return false; -} - -void js_cocos2d_ComponentContainer_finalize(JSFreeOp *fop, JSObject *obj) { - CCLOGINFO("jsbindings: finalizing JS object %p (ComponentContainer)", obj); -} -void js_register_cocos2dx_ComponentContainer(JSContext *cx, JS::HandleObject global) { - jsb_cocos2d_ComponentContainer_class = (JSClass *)calloc(1, sizeof(JSClass)); - jsb_cocos2d_ComponentContainer_class->name = "ComponentContainer"; - jsb_cocos2d_ComponentContainer_class->addProperty = JS_PropertyStub; - jsb_cocos2d_ComponentContainer_class->delProperty = JS_DeletePropertyStub; - jsb_cocos2d_ComponentContainer_class->getProperty = JS_PropertyStub; - jsb_cocos2d_ComponentContainer_class->setProperty = JS_StrictPropertyStub; - jsb_cocos2d_ComponentContainer_class->enumerate = JS_EnumerateStub; - jsb_cocos2d_ComponentContainer_class->resolve = JS_ResolveStub; - jsb_cocos2d_ComponentContainer_class->convert = JS_ConvertStub; - jsb_cocos2d_ComponentContainer_class->finalize = js_cocos2d_ComponentContainer_finalize; - jsb_cocos2d_ComponentContainer_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); - - static JSPropertySpec properties[] = { - JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_PS_END - }; - - static JSFunctionSpec funcs[] = { - JS_FN("visit", js_cocos2dx_ComponentContainer_visit, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("remove", js_cocos2dx_ComponentContainer_remove, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("removeAll", js_cocos2dx_ComponentContainer_removeAll, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("add", js_cocos2dx_ComponentContainer_add, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("isEmpty", js_cocos2dx_ComponentContainer_isEmpty, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("getComponent", js_cocos2dx_ComponentContainer_get, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FS_END - }; - - JSFunctionSpec *st_funcs = NULL; - - jsb_cocos2d_ComponentContainer_prototype = JS_InitClass( - cx, global, - JS::NullPtr(), // parent proto - jsb_cocos2d_ComponentContainer_class, - empty_constructor, 0, - properties, - funcs, - NULL, // no static properties - st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "ComponentContainer", JSPROP_ENUMERATE | JSPROP_READONLY, &found); - - // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_ComponentContainer_class; - p->proto = jsb_cocos2d_ComponentContainer_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } -} - JSClass *jsb_CocosDenshion_SimpleAudioEngine_class; JSObject *jsb_CocosDenshion_SimpleAudioEngine_prototype; @@ -69807,12 +71479,11 @@ void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj) { js_register_cocos2dx_JumpBy(cx, ns); js_register_cocos2dx_EventListener(cx, ns); js_register_cocos2dx_EventListenerKeyboard(cx, ns); - js_register_cocos2dx_ActionEase(cx, ns); - js_register_cocos2dx_EaseBounce(cx, ns); - js_register_cocos2dx_EaseBounceIn(cx, ns); - js_register_cocos2dx_TransitionRotoZoom(cx, ns); + js_register_cocos2dx_EventListenerMouse(cx, ns); + js_register_cocos2dx_ComponentContainer(cx, ns); js_register_cocos2dx_Director(cx, ns); js_register_cocos2dx_Scheduler(cx, ns); + js_register_cocos2dx_ActionEase(cx, ns); js_register_cocos2dx_EaseElastic(cx, ns); js_register_cocos2dx_EaseElasticOut(cx, ns); js_register_cocos2dx_EaseQuadraticActionInOut(cx, ns); @@ -69835,7 +71506,6 @@ void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj) { js_register_cocos2dx_EaseQuadraticActionOut(cx, ns); js_register_cocos2dx_TransitionProgress(cx, ns); js_register_cocos2dx_TransitionProgressVertical(cx, ns); - js_register_cocos2dx_ComponentContainer(cx, ns); js_register_cocos2dx_TMXTiledMap(cx, ns); js_register_cocos2dx_Grid3DAction(cx, ns); js_register_cocos2dx_BaseLight(cx, ns); @@ -69851,6 +71521,7 @@ void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj) { js_register_cocos2dx_TransitionFlipAngular(cx, ns); js_register_cocos2dx_SimpleAudioEngine(cx, ns); js_register_cocos2dx_EaseElasticInOut(cx, ns); + js_register_cocos2dx_EaseBounce(cx, ns); js_register_cocos2dx_Show(cx, ns); js_register_cocos2dx_FadeOut(cx, ns); js_register_cocos2dx_CallFunc(cx, ns); @@ -69926,7 +71597,7 @@ void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj) { js_register_cocos2dx_NodeGrid(cx, ns); js_register_cocos2dx_TMXLayerInfo(cx, ns); js_register_cocos2dx_EaseSineIn(cx, ns); - js_register_cocos2dx_EventListenerMouse(cx, ns); + js_register_cocos2dx_EaseBounceIn(cx, ns); js_register_cocos2dx_Camera(cx, ns); js_register_cocos2dx_GLProgram(cx, ns); js_register_cocos2dx_ParticleGalaxy(cx, ns); @@ -69963,6 +71634,7 @@ void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj) { js_register_cocos2dx_TransitionZoomFlipX(cx, ns); js_register_cocos2dx_EventFocus(cx, ns); js_register_cocos2dx_EaseQuinticActionInOut(cx, ns); + js_register_cocos2dx_TransitionRotoZoom(cx, ns); js_register_cocos2dx_SpriteFrameCache(cx, ns); js_register_cocos2dx_PointLight(cx, ns); js_register_cocos2dx_TransitionCrossFade(cx, ns); diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.hpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.hpp index 35eb6bfb37..96a69c725e 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.hpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.hpp @@ -84,6 +84,20 @@ bool js_cocos2dx_EventTouch_getEventCode(JSContext *cx, uint32_t argc, jsval *vp bool js_cocos2dx_EventTouch_setEventCode(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_EventTouch_EventTouch(JSContext *cx, uint32_t argc, jsval *vp); +extern JSClass *jsb_cocos2d_ComponentContainer_class; +extern JSObject *jsb_cocos2d_ComponentContainer_prototype; + +bool js_cocos2dx_ComponentContainer_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_ComponentContainer_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_ComponentContainer(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_ComponentContainer_visit(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ComponentContainer_remove(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ComponentContainer_removeAll(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ComponentContainer_add(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ComponentContainer_isEmpty(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ComponentContainer_get(JSContext *cx, uint32_t argc, jsval *vp); + extern JSClass *jsb_cocos2d_Node_class; extern JSObject *jsb_cocos2d_Node_prototype; @@ -93,9 +107,7 @@ void js_register_cocos2dx_Node(JSContext *cx, JS::HandleObject global); void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); bool js_cocos2dx_Node_addChild(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Node_removeComponent(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_Node_setPhysicsBody(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Node_getGLProgram(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_Node_updateTransformFromPhysics(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Node_getDescription(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Node_setOpacityModifyRGB(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Node_setCascadeOpacityEnabled(JSContext *cx, uint32_t argc, jsval *vp); @@ -112,13 +124,11 @@ bool js_cocos2dx_Node_setScaleY(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Node_setScaleX(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Node_getColor(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Node_setonEnterTransitionDidFinishCallback(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_Node_removeFromPhysicsWorld(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Node_removeAllComponents(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Node_getOpacity(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Node_setCameraMask(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Node_getTag(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Node_getonEnterTransitionDidFinishCallback(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_Node_isOpacityModifyRGB(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Node_getNodeToWorldAffineTransform(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Node_getPosition3D(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Node_removeChild(JSContext *cx, uint32_t argc, jsval *vp); @@ -142,7 +152,7 @@ bool js_cocos2dx_Node_getRotation3D(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Node_getNodeToParentAffineTransform(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Node_convertTouchToNodeSpaceAR(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Node_getOnEnterCallback(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_Node_getPhysicsBody(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_isOpacityModifyRGB(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Node_stopActionByTag(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Node_reorderChild(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Node_ignoreAnchorPointForPosition(JSContext *cx, uint32_t argc, jsval *vp); @@ -177,7 +187,6 @@ bool js_cocos2dx_Node_getActionByTag(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Node_setRotationSkewX(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Node_setRotationSkewY(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Node_setName(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_Node_updatePhysicsBodyTransform(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Node_getDisplayedOpacity(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Node_getLocalZOrder(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Node_getScheduler(JSContext *cx, uint32_t argc, jsval *vp); @@ -253,6 +262,7 @@ bool js_cocos2dx_Scene_setCameraOrderDirty(JSContext *cx, uint32_t argc, jsval * bool js_cocos2dx_Scene_render(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Scene_stepPhysicsAndNavigation(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Scene_onProjectionChanged(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Scene_getPhysicsManager(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Scene_initWithSize(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Scene_getDefaultCamera(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Scene_createWithSize(JSContext *cx, uint32_t argc, jsval *vp); @@ -3692,6 +3702,23 @@ bool js_cocos2dx_TextureCache_removeTexture(JSContext *cx, uint32_t argc, jsval bool js_cocos2dx_TextureCache_waitForQuit(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_TextureCache_TextureCache(JSContext *cx, uint32_t argc, jsval *vp); +extern JSClass *jsb_cocos2d_Component_class; +extern JSObject *jsb_cocos2d_Component_prototype; + +bool js_cocos2dx_Component_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_Component_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_Component(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_Component_setEnabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Component_setName(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Component_isEnabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Component_getOwner(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Component_init(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Component_getName(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Component_setOwner(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Component_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Component_Component(JSContext *cx, uint32_t argc, jsval *vp); + extern JSClass *jsb_cocos2d_Device_class; extern JSObject *jsb_cocos2d_Device_prototype; @@ -3987,37 +4014,6 @@ bool js_cocos2dx_TileMapAtlas_setTGAInfo(JSContext *cx, uint32_t argc, jsval *vp bool js_cocos2dx_TileMapAtlas_create(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_TileMapAtlas_TileMapAtlas(JSContext *cx, uint32_t argc, jsval *vp); -extern JSClass *jsb_cocos2d_Component_class; -extern JSObject *jsb_cocos2d_Component_prototype; - -bool js_cocos2dx_Component_constructor(JSContext *cx, uint32_t argc, jsval *vp); -void js_cocos2dx_Component_finalize(JSContext *cx, JSObject *obj); -void js_register_cocos2dx_Component(JSContext *cx, JS::HandleObject global); -void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); -bool js_cocos2dx_Component_setEnabled(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_Component_setName(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_Component_isEnabled(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_Component_getOwner(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_Component_init(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_Component_getName(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_Component_setOwner(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_Component_create(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_Component_Component(JSContext *cx, uint32_t argc, jsval *vp); - -extern JSClass *jsb_cocos2d_ComponentContainer_class; -extern JSObject *jsb_cocos2d_ComponentContainer_prototype; - -bool js_cocos2dx_ComponentContainer_constructor(JSContext *cx, uint32_t argc, jsval *vp); -void js_cocos2dx_ComponentContainer_finalize(JSContext *cx, JSObject *obj); -void js_register_cocos2dx_ComponentContainer(JSContext *cx, JS::HandleObject global); -void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); -bool js_cocos2dx_ComponentContainer_visit(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_ComponentContainer_remove(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_ComponentContainer_removeAll(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_ComponentContainer_add(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_ComponentContainer_isEmpty(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_ComponentContainer_get(JSContext *cx, uint32_t argc, jsval *vp); - extern JSClass *jsb_CocosDenshion_SimpleAudioEngine_class; extern JSObject *jsb_CocosDenshion_SimpleAudioEngine_prototype; diff --git a/cocos/scripting/js-bindings/manual/ScriptingCore.cpp b/cocos/scripting/js-bindings/manual/ScriptingCore.cpp index c416671d3c..6da639bc6d 100644 --- a/cocos/scripting/js-bindings/manual/ScriptingCore.cpp +++ b/cocos/scripting/js-bindings/manual/ScriptingCore.cpp @@ -33,6 +33,7 @@ #include "cocos2d_specifics.hpp" #include "jsb_cocos2dx_auto.hpp" #include "js_bindings_config.h" + // for debug socket #if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) #include @@ -452,6 +453,14 @@ static const JSClass global_class = { JS_GlobalObjectTraceHook }; +ScriptingCore* ScriptingCore::getInstance() +{ + static ScriptingCore* instance = nullptr; + if (instance == nullptr) + instance = new ScriptingCore(); + + return instance; +} ScriptingCore::ScriptingCore() : _rt(nullptr) @@ -985,6 +994,35 @@ bool ScriptingCore::isFunctionOverridedInJS(JS::HandleObject obj, const std::str return false; } +int ScriptingCore::handleActionEvent(void* data) +{ + if (NULL == data) + return 0; + + ActionObjectScriptData* actionObjectScriptData = static_cast(data); + if (NULL == actionObjectScriptData->nativeObject || NULL == actionObjectScriptData->eventType) + return 0; + + Action* actionObject = static_cast(actionObjectScriptData->nativeObject); + int eventType = *((int*)(actionObjectScriptData->eventType)); + + js_proxy_t * p = jsb_get_native_proxy(actionObject); + if (!p) return 0; + + int ret = 0; + JS::RootedValue retval(_cx); + + if (eventType == kActionUpdate) + { + if (isFunctionOverridedInJS(JS::RootedObject(_cx, p->obj.get()), "update", js_cocos2dx_Action_update)) + { + jsval dataVal = DOUBLE_TO_JSVAL(*((float *)actionObjectScriptData->param)); + ret = executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), "update", 1, &dataVal, &retval); + } + } + return ret; +} + int ScriptingCore::handleNodeEvent(void* data) { if (NULL == data) @@ -1456,6 +1494,11 @@ int ScriptingCore::sendEvent(ScriptEvent* evt) return handleNodeEvent(evt->data); } break; + case kScriptActionEvent: + { + return handleActionEvent(evt->data); + } + break; case kMenuClickedEvent: break; case kTouchEvent: diff --git a/cocos/scripting/js-bindings/manual/ScriptingCore.h b/cocos/scripting/js-bindings/manual/ScriptingCore.h index 7e2e1df406..4bc565c8ef 100644 --- a/cocos/scripting/js-bindings/manual/ScriptingCore.h +++ b/cocos/scripting/js-bindings/manual/ScriptingCore.h @@ -70,13 +70,7 @@ private: public: ~ScriptingCore(); - static ScriptingCore *getInstance() { - static ScriptingCore* pInstance = NULL; - if (pInstance == NULL) { - pInstance = new ScriptingCore(); - } - return pInstance; - }; + static ScriptingCore *getInstance(); virtual cocos2d::ccScriptType getScriptType() { return cocos2d::kScriptTypeJavascript; }; @@ -263,6 +257,7 @@ private: public: int handleNodeEvent(void* data); + int handleActionEvent(void* data); int handleComponentEvent(void* data); bool handleTouchesEvent(void* nativeObj, cocos2d::EventTouch::EventCode eventCode, const std::vector& touches, cocos2d::Event* event); diff --git a/cocos/scripting/js-bindings/manual/js_manual_conversions.cpp b/cocos/scripting/js-bindings/manual/js_manual_conversions.cpp index 20a2bf7e9f..24097f76b9 100644 --- a/cocos/scripting/js-bindings/manual/js_manual_conversions.cpp +++ b/cocos/scripting/js-bindings/manual/js_manual_conversions.cpp @@ -2182,6 +2182,21 @@ jsval quaternion_to_jsval(JSContext* cx, const cocos2d::Quaternion& q) return JSVAL_NULL; } +jsval uniform_to_jsval(JSContext* cx, const cocos2d::Uniform* uniform) +{ + JS::RootedObject tmp(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr())); + if(!tmp) return JSVAL_NULL; + bool ok = JS_DefineProperty(cx, tmp, "location", uniform->location, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "size", uniform->size, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "type", uniform->type, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "name", JS::RootedValue(cx, std_string_to_jsval(cx, uniform->name)), JSPROP_ENUMERATE | JSPROP_PERMANENT); + if(ok) + return OBJECT_TO_JSVAL(tmp); + + return JSVAL_NULL; +} + + jsval meshVertexAttrib_to_jsval(JSContext* cx, const cocos2d::MeshVertexAttrib& q) { JS::RootedObject tmp(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr())); diff --git a/cocos/scripting/js-bindings/manual/js_manual_conversions.h b/cocos/scripting/js-bindings/manual/js_manual_conversions.h index 584fea58c9..ae99be38f3 100644 --- a/cocos/scripting/js-bindings/manual/js_manual_conversions.h +++ b/cocos/scripting/js-bindings/manual/js_manual_conversions.h @@ -271,6 +271,7 @@ jsval ccaffinetransform_to_jsval(JSContext* cx, const cocos2d::AffineTransform& jsval FontDefinition_to_jsval(JSContext* cx, const cocos2d::FontDefinition& t); jsval quaternion_to_jsval(JSContext* cx, const cocos2d::Quaternion& q); jsval meshVertexAttrib_to_jsval(JSContext* cx, const cocos2d::MeshVertexAttrib& q); +jsval uniform_to_jsval(JSContext* cx, const cocos2d::Uniform* uniform); template js_proxy_t *js_get_or_create_proxy(JSContext *cx, T *native_obj); diff --git a/cocos/scripting/js-bindings/script/jsb_boot.js b/cocos/scripting/js-bindings/script/jsb_boot.js index 86f5b740df..e6fbe904d3 100644 --- a/cocos/scripting/js-bindings/script/jsb_boot.js +++ b/cocos/scripting/js-bindings/script/jsb_boot.js @@ -786,6 +786,7 @@ cc.view.setDesignResolutionSize = function(width,height,resolutionPolicy){ cc.winSize = cc.director.getWinSize(); cc.visibleRect.init(); }; +cc.view.setRealPixelResolution = cc.view.setDesignResolutionSize; cc.view.setResolutionPolicy = function(resolutionPolicy){ var size = cc.view.getDesignResolutionSize(); cc.view.setDesignResolutionSize(size.width,size.height,resolutionPolicy); @@ -816,6 +817,10 @@ cc.audioEngine.end = function(){ this.stopMusic(); this.stopAllEffects(); }; +cc.audioEngine.features = { + MULTI_CHANNEL: true, + AUTOPLAY: true +}; /** * @type {Object} * @name cc.configuration @@ -1365,8 +1370,18 @@ cc._initSys = function(config, CONFIG_KEY){ } })(); + /** + * Indicate the real pixel resolution of the whole game window + * @memberof cc.sys + * @name windowPixelResolution + * @type {Number} + */ + locSys.windowPixelResolution = cc.view.getFrameSize(); + /** The type of browser */ - locSys.browserType = null;//null in jsb + locSys.browserType = null; //null in jsb + /** The version of browser */ + locSys.browserVersion = null; //null in jsb capabilities = locSys.capabilities = {"opengl":true}; if( locSys.isMobile ) { diff --git a/cocos/scripting/js-bindings/script/jsb_cocos2d.js b/cocos/scripting/js-bindings/script/jsb_cocos2d.js index 6adb05e786..42e1a4bc7f 100644 --- a/cocos/scripting/js-bindings/script/jsb_cocos2d.js +++ b/cocos/scripting/js-bindings/script/jsb_cocos2d.js @@ -1276,49 +1276,6 @@ cc.defineGetterSetter(_proto, "ORANGE", _proto._getOrange); _proto.GRAY; cc.defineGetterSetter(_proto, "GRAY", _proto._getGray); -// Extends -cc.Node.extend = cc.Class.extend; -cc.AtlasNode.extend = cc.Class.extend; -cc.Layer.extend = cc.Class.extend; -cc.LayerGradient.extend = cc.Class.extend; -cc.LayerColor.extend = cc.Class.extend; -cc.LayerMultiplex.extend = cc.Class.extend; -cc.Sprite.extend = cc.Class.extend; -cc.SpriteBatchNode.extend = cc.Class.extend; -cc.SpriteFrame.extend = cc.Class.extend; -cc.LabelTTF.extend = cc.Class.extend; -cc.LabelBMFont.extend = cc.Class.extend; -cc.LabelAtlas.extend = cc.Class.extend; -cc.Menu.extend = cc.Class.extend; -cc.MenuItem.extend = cc.Class.extend; -cc.MenuItemLabel.extend = cc.Class.extend; -cc.MenuItemFont.extend = cc.Class.extend; -cc.MenuItemAtlasFont.extend = cc.Class.extend; -cc.MenuItemSprite.extend = cc.Class.extend; -cc.MenuItemImage.extend = cc.Class.extend; -cc.MenuItemToggle.extend = cc.Class.extend; -cc.Scene.extend = cc.Class.extend; -cc.ClippingNode.extend = cc.Class.extend; -cc.ProgressTimer.extend = cc.Class.extend; -cc.ParallaxNode.extend = cc.Class.extend; -cc.DrawNode.extend = cc.Class.extend; -cc.Component.extend = cc.Class.extend; -cc.GridBase.extend = cc.Class.extend; -cc.Grid3D.extend = cc.Class.extend; -cc.TiledGrid3D.extend = cc.Class.extend; -cc.MotionStreak.extend = cc.Class.extend; -cc.ParticleBatchNode.extend = cc.Class.extend; -cc.ParticleSystem.extend = cc.Class.extend; -cc.TextFieldTTF.extend = cc.Class.extend; -cc.RenderTexture.extend = cc.Class.extend; -cc.TileMapAtlas.extend = cc.Class.extend; -cc.TMXLayer.extend = cc.Class.extend; -cc.TMXTiledMap.extend = cc.Class.extend; -cc.TMXMapInfo.extend = cc.Class.extend; -cc.TransitionScene.extend = cc.Class.extend; -cc.GLProgram.extend = cc.Class.extend; - - // Cocos2d-html5 supports multi scene resources preloading. // This is a compatible function for JSB. cc.Loader = cc.Class.extend({ diff --git a/cocos/scripting/lua-bindings/auto/api/ComponentPhysics2d.lua b/cocos/scripting/lua-bindings/auto/api/ComponentPhysics2d.lua new file mode 100644 index 0000000000..04cd94baf7 --- /dev/null +++ b/cocos/scripting/lua-bindings/auto/api/ComponentPhysics2d.lua @@ -0,0 +1,71 @@ + +-------------------------------- +-- @module ComponentPhysics2d +-- @extend Component +-- @parent_module cc + +-------------------------------- +-- Set physics body of this physics component. If the physics body is set to
+-- another physics component before, will set another physics component's physics
+-- body to null.
+-- param physicsBody The physics body belongs to this component. +-- @function [parent=#ComponentPhysics2d] setPhysicsBody +-- @param self +-- @param #cc.PhysicsBody physicsBody +-- @return ComponentPhysics2d#ComponentPhysics2d self (return value: cc.ComponentPhysics2d) + +-------------------------------- +-- Get the physics body of this component.
+-- return The physics body of this component. +-- @function [parent=#ComponentPhysics2d] getPhysicsBody +-- @param self +-- @return PhysicsBody#PhysicsBody ret (return value: cc.PhysicsBody) + +-------------------------------- +-- @overload self, cc.PhysicsBody +-- @overload self +-- @function [parent=#ComponentPhysics2d] create +-- @param self +-- @param #cc.PhysicsBody physicsBody +-- @return ComponentPhysics2d#ComponentPhysics2d ret (return value: cc.ComponentPhysics2d) + +-------------------------------- +-- +-- @function [parent=#ComponentPhysics2d] setEnabled +-- @param self +-- @param #bool value +-- @return ComponentPhysics2d#ComponentPhysics2d self (return value: cc.ComponentPhysics2d) + +-------------------------------- +-- +-- @function [parent=#ComponentPhysics2d] onRemove +-- @param self +-- @return ComponentPhysics2d#ComponentPhysics2d self (return value: cc.ComponentPhysics2d) + +-------------------------------- +-- +-- @function [parent=#ComponentPhysics2d] onEnter +-- @param self +-- @return ComponentPhysics2d#ComponentPhysics2d self (return value: cc.ComponentPhysics2d) + +-------------------------------- +-- +-- @function [parent=#ComponentPhysics2d] onExit +-- @param self +-- @return ComponentPhysics2d#ComponentPhysics2d self (return value: cc.ComponentPhysics2d) + +-------------------------------- +-- +-- @function [parent=#ComponentPhysics2d] onAdd +-- @param self +-- @return ComponentPhysics2d#ComponentPhysics2d self (return value: cc.ComponentPhysics2d) + +-------------------------------- +-- @overload self, cc.PhysicsBody +-- @overload self +-- @function [parent=#ComponentPhysics2d] ComponentPhysics2d +-- @param self +-- @param #cc.PhysicsBody phsicsBody +-- @return ComponentPhysics2d#ComponentPhysics2d self (return value: cc.ComponentPhysics2d) + +return nil diff --git a/cocos/scripting/lua-bindings/auto/api/Director.lua b/cocos/scripting/lua-bindings/auto/api/Director.lua index 8db28ae43d..eb6049ec18 100644 --- a/cocos/scripting/lua-bindings/auto/api/Director.lua +++ b/cocos/scripting/lua-bindings/auto/api/Director.lua @@ -358,7 +358,7 @@ -- @return Director#Director self (return value: cc.Director) -------------------------------- --- Whether or not to display the FPS on the bottom-left corner. +-- Whether or not displaying the FPS on the bottom-left corner of the screen. -- @function [parent=#Director] isDisplayStats -- @param self -- @return bool#bool ret (return value: bool) @@ -390,8 +390,8 @@ -- @return Director#Director self (return value: cc.Director) -------------------------------- --- Gets the distance between camera and near clipping frane.
--- It is correct for default camera that near clipping frane is the same as screen. +-- Gets the distance between camera and near clipping frame.
+-- It is correct for default camera that near clipping frame is same as the screen. -- @function [parent=#Director] getZEye -- @param self -- @return float#float ret (return value: float) @@ -450,7 +450,7 @@ -- @return bool#bool ret (return value: bool) -------------------------------- --- Display the FPS on the bottom-left corner. +-- Display the FPS on the bottom-left corner of the screen. -- @function [parent=#Director] setDisplayStats -- @param self -- @param #bool displayStats @@ -474,7 +474,7 @@ -- @return Director#Director self (return value: cc.Director) -------------------------------- --- Sets the FPS value. FPS = 1/internal. +-- Sets the FPS value. FPS = 1/interval. -- @function [parent=#Director] setAnimationInterval -- @param self -- @param #float interval diff --git a/cocos/scripting/lua-bindings/auto/api/Grid3D.lua b/cocos/scripting/lua-bindings/auto/api/Grid3D.lua index 6d70cce7cd..5c73a82676 100644 --- a/cocos/scripting/lua-bindings/auto/api/Grid3D.lua +++ b/cocos/scripting/lua-bindings/auto/api/Grid3D.lua @@ -40,7 +40,7 @@ -------------------------------- -- @{
--- Implementations for interfaces in base calss. +-- Implementations for interfaces in base class. -- @function [parent=#Grid3D] beforeBlit -- @param self -- @return Grid3D#Grid3D self (return value: cc.Grid3D) diff --git a/cocos/scripting/lua-bindings/auto/api/Node.lua b/cocos/scripting/lua-bindings/auto/api/Node.lua index 406ac0a66e..69f6882ad4 100644 --- a/cocos/scripting/lua-bindings/auto/api/Node.lua +++ b/cocos/scripting/lua-bindings/auto/api/Node.lua @@ -197,7 +197,7 @@ -- @return Node#Node self (return value: cc.Node) -------------------------------- --- +-- / @} end of component functions -- @function [parent=#Node] getOpacity -- @param self -- @return unsigned char#unsigned char ret (return value: unsigned char) @@ -423,6 +423,12 @@ -- @param #vec2_table worldPoint -- @return vec2_table#vec2_table ret (return value: vec2_table) +-------------------------------- +-- +-- @function [parent=#Node] isOpacityModifyRGB +-- @param self +-- @return bool#bool ret (return value: bool) + -------------------------------- -- @overload self, float, float -- @overload self, vec2_table @@ -599,12 +605,6 @@ -- @param #unsigned int parentFlags -- @return Node#Node self (return value: cc.Node) --------------------------------- --- --- @function [parent=#Node] isOpacityModifyRGB --- @param self --- @return bool#bool ret (return value: bool) - -------------------------------- -- Returns the rotation of the node in degrees.
-- see `setRotation(float)`
diff --git a/cocos/scripting/lua-bindings/auto/api/PhysicsManager.lua b/cocos/scripting/lua-bindings/auto/api/PhysicsManager.lua new file mode 100644 index 0000000000..c61521e211 --- /dev/null +++ b/cocos/scripting/lua-bindings/auto/api/PhysicsManager.lua @@ -0,0 +1,39 @@ + +-------------------------------- +-- @module PhysicsManager +-- @parent_module cc + +-------------------------------- +-- Remove a physics component from `PhysiscsManager`. Will remove physics component's physics
+-- body from the physics world managed by this `PhysicsManager`. +-- @function [parent=#PhysicsManager] removePhysicsComponent +-- @param self +-- @param #cc.ComponentPhysics2d componentPhsics2d +-- @return PhysicsManager#PhysicsManager self (return value: cc.PhysicsManager) + +-------------------------------- +-- Add a physics component to be managed by the `PhysicsManager`. Will register physics
+-- component's physics body to physics world managed by this `PhysicsManager`.
+-- param componentPhsics2d The physics component to be managed by this `PhysicsManager`. +-- @function [parent=#PhysicsManager] addPhysicsComponent +-- @param self +-- @param #cc.ComponentPhysics2d componentPhsics2d +-- @return PhysicsManager#PhysicsManager self (return value: cc.PhysicsManager) + +-------------------------------- +-- Get the physics world.
+-- return Physics world managed by this `PhysicsManager`. +-- @function [parent=#PhysicsManager] getPhysicsWorld +-- @param self +-- @return PhysicsWorld#PhysicsWorld ret (return value: cc.PhysicsWorld) + +-------------------------------- +-- Create a PhysicsManager with `Scene`. `Scene` will create it automatically,
+-- so don't create it yourself.
+-- scene The scene this `PhysicsManager` belongs to. +-- @function [parent=#PhysicsManager] PhysicsManager +-- @param self +-- @param #cc.Scene scene +-- @return PhysicsManager#PhysicsManager self (return value: cc.PhysicsManager) + +return nil diff --git a/cocos/scripting/lua-bindings/auto/api/Scene.lua b/cocos/scripting/lua-bindings/auto/api/Scene.lua index 82f13176e8..7a4c8dfa22 100644 --- a/cocos/scripting/lua-bindings/auto/api/Scene.lua +++ b/cocos/scripting/lua-bindings/auto/api/Scene.lua @@ -58,16 +58,6 @@ -- @param self -- @return Scene#Scene ret (return value: cc.Scene) --------------------------------- --- @overload self, cc.Node, int, string --- @overload self, cc.Node, int, int --- @function [parent=#Scene] addChild --- @param self --- @param #cc.Node child --- @param #int zOrder --- @param #int tag --- @return Scene#Scene self (return value: cc.Scene) - -------------------------------- -- -- @function [parent=#Scene] init diff --git a/cocos/scripting/lua-bindings/auto/api/Sprite3D.lua b/cocos/scripting/lua-bindings/auto/api/Sprite3D.lua index d8f4aa6252..3e05d25a70 100644 --- a/cocos/scripting/lua-bindings/auto/api/Sprite3D.lua +++ b/cocos/scripting/lua-bindings/auto/api/Sprite3D.lua @@ -172,7 +172,7 @@ -- @return Action#Action ret (return value: cc.Action) -------------------------------- --- just rember bind attributes +-- just remember bind attributes -- @function [parent=#Sprite3D] setGLProgram -- @param self -- @param #cc.GLProgram glprogram @@ -180,7 +180,7 @@ -------------------------------- -- Returns 2d bounding-box
--- Note: the bouding-box is just get from the AABB which as Z=0, so that is not very accurate. +-- Note: the bounding-box is just get from the AABB which as Z=0, so that is not very accurate. -- @function [parent=#Sprite3D] getBoundingBox -- @param self -- @return rect_table#rect_table ret (return value: rect_table) diff --git a/cocos/scripting/lua-bindings/auto/api/Terrain.lua b/cocos/scripting/lua-bindings/auto/api/Terrain.lua index 8630b342dc..385372f31b 100644 --- a/cocos/scripting/lua-bindings/auto/api/Terrain.lua +++ b/cocos/scripting/lua-bindings/auto/api/Terrain.lua @@ -97,7 +97,7 @@ -- @return bool#bool ret (return value: bool) -------------------------------- --- Set threshold distance of each LOD level,must equal or gereater than the chunk size
+-- Set threshold distance of each LOD level,must equal or greater than the chunk size
-- Note when invoke initHeightMap, the LOD distance will be automatic calculated. -- @function [parent=#Terrain] setLODDistance -- @param self @@ -113,7 +113,7 @@ -- @return size_table#size_table ret (return value: size_table) -------------------------------- --- get the normal of the specified pistion in terrain
+-- get the normal of the specified position in terrain
-- return the normal vector of the specified position of the terrain.
-- note the fast normal calculation may not get precise normal vector. -- @function [parent=#Terrain] getNormal @@ -152,13 +152,13 @@ -- @return Terrain#Terrain self (return value: cc.Terrain) -------------------------------- --- get the terrain's mininal height. +-- get the terrain's minimal height. -- @function [parent=#Terrain] getMinHeight -- @param self -- @return float#float ret (return value: float) -------------------------------- --- get the terrain's maximum height. +-- get the terrain's maximal height. -- @function [parent=#Terrain] getMaxHeight -- @param self -- @return float#float ret (return value: float) diff --git a/cocos/scripting/lua-bindings/auto/api/TiledGrid3D.lua b/cocos/scripting/lua-bindings/auto/api/TiledGrid3D.lua index b59e195164..002c48a64e 100644 --- a/cocos/scripting/lua-bindings/auto/api/TiledGrid3D.lua +++ b/cocos/scripting/lua-bindings/auto/api/TiledGrid3D.lua @@ -25,7 +25,7 @@ -------------------------------- -- @{
--- Implementations for interfaces in base calss. +-- Implementations for interfaces in base class. -- @function [parent=#TiledGrid3D] blit -- @param self -- @return TiledGrid3D#TiledGrid3D self (return value: cc.TiledGrid3D) diff --git a/cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_auto_api.lua b/cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_auto_api.lua index 9682fe5436..4eb148fb12 100644 --- a/cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_auto_api.lua +++ b/cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_auto_api.lua @@ -1236,6 +1236,11 @@ -- @field [parent=#cc] TextureCache#TextureCache TextureCache preloaded module +-------------------------------------------------------- +-- the cc Component +-- @field [parent=#cc] Component#Component Component preloaded module + + -------------------------------------------------------- -- the cc Device -- @field [parent=#cc] Device#Device Device preloaded module @@ -1306,9 +1311,4 @@ -- @field [parent=#cc] TileMapAtlas#TileMapAtlas TileMapAtlas preloaded module --------------------------------------------------------- --- the cc Component --- @field [parent=#cc] Component#Component Component preloaded module - - return nil diff --git a/cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_physics_auto_api.lua b/cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_physics_auto_api.lua index ce2faeb562..cd5dfccee6 100644 --- a/cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_physics_auto_api.lua +++ b/cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_physics_auto_api.lua @@ -151,4 +151,14 @@ -- @field [parent=#cc] PhysicsDebugDraw#PhysicsDebugDraw PhysicsDebugDraw preloaded module +-------------------------------------------------------- +-- the cc ComponentPhysics2d +-- @field [parent=#cc] ComponentPhysics2d#ComponentPhysics2d ComponentPhysics2d preloaded module + + +-------------------------------------------------------- +-- the cc PhysicsManager +-- @field [parent=#cc] PhysicsManager#PhysicsManager PhysicsManager preloaded module + + return nil diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp index 3e14809075..35b964559a 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp @@ -5376,6 +5376,53 @@ int lua_cocos2dx_Node_convertToNodeSpace(lua_State* tolua_S) return 0; } +int lua_cocos2dx_Node_isOpacityModifyRGB(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Node* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_isOpacityModifyRGB'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Node_isOpacityModifyRGB'", nullptr); + return 0; + } + bool ret = cobj->isOpacityModifyRGB(); + tolua_pushboolean(tolua_S,(bool)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Node:isOpacityModifyRGB",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_isOpacityModifyRGB'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_Node_setPosition(lua_State* tolua_S) { int argc = 0; @@ -6282,53 +6329,6 @@ int lua_cocos2dx_Node_visit(lua_State* tolua_S) return 0; } -int lua_cocos2dx_Node_isOpacityModifyRGB(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::Node* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_isOpacityModifyRGB'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Node_isOpacityModifyRGB'", nullptr); - return 0; - } - bool ret = cobj->isOpacityModifyRGB(); - tolua_pushboolean(tolua_S,(bool)ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Node:isOpacityModifyRGB",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_isOpacityModifyRGB'.",&tolua_err); -#endif - - return 0; -} int lua_cocos2dx_Node_getRotation(lua_State* tolua_S) { int argc = 0; @@ -9657,6 +9657,7 @@ int lua_register_cocos2dx_Node(lua_State* tolua_S) tolua_function(tolua_S,"getNodeToParentTransform",lua_cocos2dx_Node_getNodeToParentTransform); tolua_function(tolua_S,"convertTouchToNodeSpaceAR",lua_cocos2dx_Node_convertTouchToNodeSpaceAR); tolua_function(tolua_S,"convertToNodeSpace",lua_cocos2dx_Node_convertToNodeSpace); + tolua_function(tolua_S,"isOpacityModifyRGB",lua_cocos2dx_Node_isOpacityModifyRGB); tolua_function(tolua_S,"setPosition",lua_cocos2dx_Node_setPosition); tolua_function(tolua_S,"stopActionByTag",lua_cocos2dx_Node_stopActionByTag); tolua_function(tolua_S,"reorderChild",lua_cocos2dx_Node_reorderChild); @@ -9675,7 +9676,6 @@ int lua_register_cocos2dx_Node(lua_State* tolua_S) tolua_function(tolua_S,"addComponent",lua_cocos2dx_Node_addComponent); tolua_function(tolua_S,"runAction",lua_cocos2dx_Node_runAction); tolua_function(tolua_S,"visit",lua_cocos2dx_Node_visit); - tolua_function(tolua_S,"isOpacityModifyRGB",lua_cocos2dx_Node_isOpacityModifyRGB); tolua_function(tolua_S,"getRotation",lua_cocos2dx_Node_getRotation); tolua_function(tolua_S,"getAnchorPointInPoints",lua_cocos2dx_Node_getAnchorPointInPoints); tolua_function(tolua_S,"removeChildByName",lua_cocos2dx_Node_removeChildByName); @@ -85783,6 +85783,552 @@ int lua_register_cocos2dx_TextureCache(lua_State* tolua_S) return 1; } +int lua_cocos2dx_Component_setEnabled(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Component* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Component",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Component*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Component_setEnabled'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + bool arg0; + + ok &= luaval_to_boolean(tolua_S, 2,&arg0, "cc.Component:setEnabled"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Component_setEnabled'", nullptr); + return 0; + } + cobj->setEnabled(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Component:setEnabled",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Component_setEnabled'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_Component_setName(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Component* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Component",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Component*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Component_setName'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + std::string arg0; + + ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.Component:setName"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Component_setName'", nullptr); + return 0; + } + cobj->setName(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Component:setName",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Component_setName'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_Component_isEnabled(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Component* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Component",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Component*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Component_isEnabled'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Component_isEnabled'", nullptr); + return 0; + } + bool ret = cobj->isEnabled(); + tolua_pushboolean(tolua_S,(bool)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Component:isEnabled",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Component_isEnabled'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_Component_onRemove(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Component* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Component",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Component*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Component_onRemove'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Component_onRemove'", nullptr); + return 0; + } + cobj->onRemove(); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Component:onRemove",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Component_onRemove'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_Component_update(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Component* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Component",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Component*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Component_update'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + double arg0; + + ok &= luaval_to_number(tolua_S, 2,&arg0, "cc.Component:update"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Component_update'", nullptr); + return 0; + } + cobj->update(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Component:update",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Component_update'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_Component_getOwner(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Component* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Component",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Component*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Component_getOwner'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Component_getOwner'", nullptr); + return 0; + } + cocos2d::Node* ret = cobj->getOwner(); + object_to_luaval(tolua_S, "cc.Node",(cocos2d::Node*)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Component:getOwner",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Component_getOwner'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_Component_init(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Component* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Component",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Component*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Component_init'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Component_init'", nullptr); + return 0; + } + bool ret = cobj->init(); + tolua_pushboolean(tolua_S,(bool)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Component:init",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Component_init'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_Component_onAdd(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Component* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Component",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Component*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Component_onAdd'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Component_onAdd'", nullptr); + return 0; + } + cobj->onAdd(); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Component:onAdd",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Component_onAdd'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_Component_getName(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Component* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Component",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Component*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Component_getName'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Component_getName'", nullptr); + return 0; + } + const std::string& ret = cobj->getName(); + tolua_pushcppstring(tolua_S,ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Component:getName",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Component_getName'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_Component_setOwner(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Component* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Component",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Component*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Component_setOwner'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + cocos2d::Node* arg0; + + ok &= luaval_to_object(tolua_S, 2, "cc.Node",&arg0, "cc.Component:setOwner"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Component_setOwner'", nullptr); + return 0; + } + cobj->setOwner(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Component:setOwner",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Component_setOwner'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_Component_create(lua_State* tolua_S) +{ + int argc = 0; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertable(tolua_S,1,"cc.Component",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Component_create'", nullptr); + return 0; + } + cocos2d::Component* ret = cocos2d::Component::create(); + object_to_luaval(tolua_S, "cc.Component",(cocos2d::Component*)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.Component:create",argc, 0); + return 0; +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Component_create'.",&tolua_err); +#endif + return 0; +} +static int lua_cocos2dx_Component_finalize(lua_State* tolua_S) +{ + printf("luabindings: finalizing LUA object (Component)"); + return 0; +} + +int lua_register_cocos2dx_Component(lua_State* tolua_S) +{ + tolua_usertype(tolua_S,"cc.Component"); + tolua_cclass(tolua_S,"Component","cc.Component","cc.Ref",nullptr); + + tolua_beginmodule(tolua_S,"Component"); + tolua_function(tolua_S,"setEnabled",lua_cocos2dx_Component_setEnabled); + tolua_function(tolua_S,"setName",lua_cocos2dx_Component_setName); + tolua_function(tolua_S,"isEnabled",lua_cocos2dx_Component_isEnabled); + tolua_function(tolua_S,"onRemove",lua_cocos2dx_Component_onRemove); + tolua_function(tolua_S,"update",lua_cocos2dx_Component_update); + tolua_function(tolua_S,"getOwner",lua_cocos2dx_Component_getOwner); + tolua_function(tolua_S,"init",lua_cocos2dx_Component_init); + tolua_function(tolua_S,"onAdd",lua_cocos2dx_Component_onAdd); + tolua_function(tolua_S,"getName",lua_cocos2dx_Component_getName); + tolua_function(tolua_S,"setOwner",lua_cocos2dx_Component_setOwner); + tolua_function(tolua_S,"create", lua_cocos2dx_Component_create); + tolua_endmodule(tolua_S); + std::string typeName = typeid(cocos2d::Component).name(); + g_luaType[typeName] = "cc.Component"; + g_typeCast["Component"] = "cc.Component"; + return 1; +} + int lua_cocos2dx_Device_setAccelerometerEnabled(lua_State* tolua_S) { int argc = 0; @@ -93877,552 +94423,6 @@ int lua_register_cocos2dx_TileMapAtlas(lua_State* tolua_S) g_typeCast["TileMapAtlas"] = "cc.TileMapAtlas"; return 1; } - -int lua_cocos2dx_Component_setEnabled(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::Component* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Component",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::Component*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Component_setEnabled'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - bool arg0; - - ok &= luaval_to_boolean(tolua_S, 2,&arg0, "cc.Component:setEnabled"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Component_setEnabled'", nullptr); - return 0; - } - cobj->setEnabled(arg0); - lua_settop(tolua_S, 1); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Component:setEnabled",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Component_setEnabled'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_Component_setName(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::Component* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Component",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::Component*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Component_setName'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - std::string arg0; - - ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.Component:setName"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Component_setName'", nullptr); - return 0; - } - cobj->setName(arg0); - lua_settop(tolua_S, 1); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Component:setName",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Component_setName'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_Component_isEnabled(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::Component* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Component",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::Component*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Component_isEnabled'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Component_isEnabled'", nullptr); - return 0; - } - bool ret = cobj->isEnabled(); - tolua_pushboolean(tolua_S,(bool)ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Component:isEnabled",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Component_isEnabled'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_Component_onRemove(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::Component* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Component",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::Component*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Component_onRemove'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Component_onRemove'", nullptr); - return 0; - } - cobj->onRemove(); - lua_settop(tolua_S, 1); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Component:onRemove",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Component_onRemove'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_Component_update(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::Component* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Component",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::Component*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Component_update'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - double arg0; - - ok &= luaval_to_number(tolua_S, 2,&arg0, "cc.Component:update"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Component_update'", nullptr); - return 0; - } - cobj->update(arg0); - lua_settop(tolua_S, 1); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Component:update",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Component_update'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_Component_getOwner(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::Component* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Component",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::Component*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Component_getOwner'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Component_getOwner'", nullptr); - return 0; - } - cocos2d::Node* ret = cobj->getOwner(); - object_to_luaval(tolua_S, "cc.Node",(cocos2d::Node*)ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Component:getOwner",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Component_getOwner'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_Component_init(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::Component* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Component",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::Component*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Component_init'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Component_init'", nullptr); - return 0; - } - bool ret = cobj->init(); - tolua_pushboolean(tolua_S,(bool)ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Component:init",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Component_init'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_Component_onAdd(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::Component* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Component",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::Component*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Component_onAdd'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Component_onAdd'", nullptr); - return 0; - } - cobj->onAdd(); - lua_settop(tolua_S, 1); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Component:onAdd",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Component_onAdd'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_Component_getName(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::Component* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Component",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::Component*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Component_getName'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Component_getName'", nullptr); - return 0; - } - const std::string& ret = cobj->getName(); - tolua_pushcppstring(tolua_S,ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Component:getName",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Component_getName'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_Component_setOwner(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::Component* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Component",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::Component*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Component_setOwner'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - cocos2d::Node* arg0; - - ok &= luaval_to_object(tolua_S, 2, "cc.Node",&arg0, "cc.Component:setOwner"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Component_setOwner'", nullptr); - return 0; - } - cobj->setOwner(arg0); - lua_settop(tolua_S, 1); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Component:setOwner",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Component_setOwner'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_Component_create(lua_State* tolua_S) -{ - int argc = 0; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertable(tolua_S,1,"cc.Component",0,&tolua_err)) goto tolua_lerror; -#endif - - argc = lua_gettop(tolua_S) - 1; - - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Component_create'", nullptr); - return 0; - } - cocos2d::Component* ret = cocos2d::Component::create(); - object_to_luaval(tolua_S, "cc.Component",(cocos2d::Component*)ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.Component:create",argc, 0); - return 0; -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Component_create'.",&tolua_err); -#endif - return 0; -} -static int lua_cocos2dx_Component_finalize(lua_State* tolua_S) -{ - printf("luabindings: finalizing LUA object (Component)"); - return 0; -} - -int lua_register_cocos2dx_Component(lua_State* tolua_S) -{ - tolua_usertype(tolua_S,"cc.Component"); - tolua_cclass(tolua_S,"Component","cc.Component","cc.Ref",nullptr); - - tolua_beginmodule(tolua_S,"Component"); - tolua_function(tolua_S,"setEnabled",lua_cocos2dx_Component_setEnabled); - tolua_function(tolua_S,"setName",lua_cocos2dx_Component_setName); - tolua_function(tolua_S,"isEnabled",lua_cocos2dx_Component_isEnabled); - tolua_function(tolua_S,"onRemove",lua_cocos2dx_Component_onRemove); - tolua_function(tolua_S,"update",lua_cocos2dx_Component_update); - tolua_function(tolua_S,"getOwner",lua_cocos2dx_Component_getOwner); - tolua_function(tolua_S,"init",lua_cocos2dx_Component_init); - tolua_function(tolua_S,"onAdd",lua_cocos2dx_Component_onAdd); - tolua_function(tolua_S,"getName",lua_cocos2dx_Component_getName); - tolua_function(tolua_S,"setOwner",lua_cocos2dx_Component_setOwner); - tolua_function(tolua_S,"create", lua_cocos2dx_Component_create); - tolua_endmodule(tolua_S); - std::string typeName = typeid(cocos2d::Component).name(); - g_luaType[typeName] = "cc.Component"; - g_typeCast["Component"] = "cc.Component"; - return 1; -} TOLUA_API int register_all_cocos2dx(lua_State* tolua_S) { tolua_open(tolua_S); diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_physics_auto.cpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_physics_auto.cpp index 04bc6277ec..5c50f4e821 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_physics_auto.cpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_physics_auto.cpp @@ -3802,7 +3802,7 @@ int lua_cocos2dx_physics_PhysicsBody_getPosition(lua_State* tolua_S) tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_physics_PhysicsBody_getPosition'", nullptr); return 0; } - const cocos2d::Vec2& ret = cobj->getPosition(); + cocos2d::Vec2 ret = cobj->getPosition(); vec2_to_luaval(tolua_S, ret); return 1; } @@ -12611,6 +12611,425 @@ int lua_register_cocos2dx_physics_PhysicsDebugDraw(lua_State* tolua_S) g_typeCast["PhysicsDebugDraw"] = "cc.PhysicsDebugDraw"; return 1; } + +int lua_cocos2dx_physics_ComponentPhysics2d_setPhysicsBody(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ComponentPhysics2d* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.ComponentPhysics2d",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ComponentPhysics2d*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_ComponentPhysics2d_setPhysicsBody'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + cocos2d::PhysicsBody* arg0; + + ok &= luaval_to_object(tolua_S, 2, "cc.PhysicsBody",&arg0, "cc.ComponentPhysics2d:setPhysicsBody"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_physics_ComponentPhysics2d_setPhysicsBody'", nullptr); + return 0; + } + cobj->setPhysicsBody(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.ComponentPhysics2d:setPhysicsBody",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_ComponentPhysics2d_setPhysicsBody'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_physics_ComponentPhysics2d_getPhysicsBody(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ComponentPhysics2d* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.ComponentPhysics2d",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ComponentPhysics2d*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_ComponentPhysics2d_getPhysicsBody'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_physics_ComponentPhysics2d_getPhysicsBody'", nullptr); + return 0; + } + cocos2d::PhysicsBody* ret = cobj->getPhysicsBody(); + object_to_luaval(tolua_S, "cc.PhysicsBody",(cocos2d::PhysicsBody*)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.ComponentPhysics2d:getPhysicsBody",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_ComponentPhysics2d_getPhysicsBody'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_physics_ComponentPhysics2d_create(lua_State* tolua_S) +{ + int argc = 0; + bool ok = true; +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertable(tolua_S,1,"cc.ComponentPhysics2d",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S)-1; + + do + { + if (argc == 1) + { + cocos2d::PhysicsBody* arg0; + ok &= luaval_to_object(tolua_S, 2, "cc.PhysicsBody",&arg0, "cc.ComponentPhysics2d:create"); + if (!ok) { break; } + cocos2d::ComponentPhysics2d* ret = cocos2d::ComponentPhysics2d::create(arg0); + object_to_luaval(tolua_S, "cc.ComponentPhysics2d",(cocos2d::ComponentPhysics2d*)ret); + return 1; + } + } while (0); + ok = true; + do + { + if (argc == 0) + { + cocos2d::ComponentPhysics2d* ret = cocos2d::ComponentPhysics2d::create(); + object_to_luaval(tolua_S, "cc.ComponentPhysics2d",(cocos2d::ComponentPhysics2d*)ret); + return 1; + } + } while (0); + ok = true; + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d", "cc.ComponentPhysics2d:create",argc, 0); + return 0; +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_ComponentPhysics2d_create'.",&tolua_err); +#endif + return 0; +} +int lua_cocos2dx_physics_ComponentPhysics2d_constructor(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ComponentPhysics2d* cobj = nullptr; + bool ok = true; +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + argc = lua_gettop(tolua_S)-1; + do{ + if (argc == 1) { + cocos2d::PhysicsBody* arg0; + ok &= luaval_to_object(tolua_S, 2, "cc.PhysicsBody",&arg0, "cc.ComponentPhysics2d:ComponentPhysics2d"); + + if (!ok) { break; } + cobj = new cocos2d::ComponentPhysics2d(arg0); + cobj->autorelease(); + int ID = (int)cobj->_ID ; + int* luaID = &cobj->_luaID ; + toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.ComponentPhysics2d"); + return 1; + } + }while(0); + ok = true; + do{ + if (argc == 0) { + cobj = new cocos2d::ComponentPhysics2d(); + cobj->autorelease(); + int ID = (int)cobj->_ID ; + int* luaID = &cobj->_luaID ; + toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.ComponentPhysics2d"); + return 1; + } + }while(0); + ok = true; + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.ComponentPhysics2d:ComponentPhysics2d",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_ComponentPhysics2d_constructor'.",&tolua_err); +#endif + + return 0; +} + +static int lua_cocos2dx_physics_ComponentPhysics2d_finalize(lua_State* tolua_S) +{ + printf("luabindings: finalizing LUA object (ComponentPhysics2d)"); + return 0; +} + +int lua_register_cocos2dx_physics_ComponentPhysics2d(lua_State* tolua_S) +{ + tolua_usertype(tolua_S,"cc.ComponentPhysics2d"); + tolua_cclass(tolua_S,"ComponentPhysics2d","cc.ComponentPhysics2d","cc.Component",nullptr); + + tolua_beginmodule(tolua_S,"ComponentPhysics2d"); + tolua_function(tolua_S,"new",lua_cocos2dx_physics_ComponentPhysics2d_constructor); + tolua_function(tolua_S,"setPhysicsBody",lua_cocos2dx_physics_ComponentPhysics2d_setPhysicsBody); + tolua_function(tolua_S,"getPhysicsBody",lua_cocos2dx_physics_ComponentPhysics2d_getPhysicsBody); + tolua_function(tolua_S,"create", lua_cocos2dx_physics_ComponentPhysics2d_create); + tolua_endmodule(tolua_S); + std::string typeName = typeid(cocos2d::ComponentPhysics2d).name(); + g_luaType[typeName] = "cc.ComponentPhysics2d"; + g_typeCast["ComponentPhysics2d"] = "cc.ComponentPhysics2d"; + return 1; +} + +int lua_cocos2dx_physics_PhysicsManager_removePhysicsComponent(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::PhysicsManager* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.PhysicsManager",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::PhysicsManager*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsManager_removePhysicsComponent'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + cocos2d::ComponentPhysics2d* arg0; + + ok &= luaval_to_object(tolua_S, 2, "cc.ComponentPhysics2d",&arg0, "cc.PhysicsManager:removePhysicsComponent"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_physics_PhysicsManager_removePhysicsComponent'", nullptr); + return 0; + } + cobj->removePhysicsComponent(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.PhysicsManager:removePhysicsComponent",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsManager_removePhysicsComponent'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_physics_PhysicsManager_addPhysicsComponent(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::PhysicsManager* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.PhysicsManager",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::PhysicsManager*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsManager_addPhysicsComponent'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + cocos2d::ComponentPhysics2d* arg0; + + ok &= luaval_to_object(tolua_S, 2, "cc.ComponentPhysics2d",&arg0, "cc.PhysicsManager:addPhysicsComponent"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_physics_PhysicsManager_addPhysicsComponent'", nullptr); + return 0; + } + cobj->addPhysicsComponent(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.PhysicsManager:addPhysicsComponent",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsManager_addPhysicsComponent'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_physics_PhysicsManager_getPhysicsWorld(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::PhysicsManager* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.PhysicsManager",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::PhysicsManager*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsManager_getPhysicsWorld'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_physics_PhysicsManager_getPhysicsWorld'", nullptr); + return 0; + } + cocos2d::PhysicsWorld* ret = cobj->getPhysicsWorld(); + object_to_luaval(tolua_S, "cc.PhysicsWorld",(cocos2d::PhysicsWorld*)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.PhysicsManager:getPhysicsWorld",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsManager_getPhysicsWorld'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_physics_PhysicsManager_constructor(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::PhysicsManager* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + cocos2d::Scene* arg0; + + ok &= luaval_to_object(tolua_S, 2, "cc.Scene",&arg0, "cc.PhysicsManager:PhysicsManager"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_physics_PhysicsManager_constructor'", nullptr); + return 0; + } + cobj = new cocos2d::PhysicsManager(arg0); + tolua_pushusertype(tolua_S,(void*)cobj,"cc.PhysicsManager"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.PhysicsManager:PhysicsManager",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsManager_constructor'.",&tolua_err); +#endif + + return 0; +} + +static int lua_cocos2dx_physics_PhysicsManager_finalize(lua_State* tolua_S) +{ + printf("luabindings: finalizing LUA object (PhysicsManager)"); + return 0; +} + +int lua_register_cocos2dx_physics_PhysicsManager(lua_State* tolua_S) +{ + tolua_usertype(tolua_S,"cc.PhysicsManager"); + tolua_cclass(tolua_S,"PhysicsManager","cc.PhysicsManager","",nullptr); + + tolua_beginmodule(tolua_S,"PhysicsManager"); + tolua_function(tolua_S,"new",lua_cocos2dx_physics_PhysicsManager_constructor); + tolua_function(tolua_S,"removePhysicsComponent",lua_cocos2dx_physics_PhysicsManager_removePhysicsComponent); + tolua_function(tolua_S,"addPhysicsComponent",lua_cocos2dx_physics_PhysicsManager_addPhysicsComponent); + tolua_function(tolua_S,"getPhysicsWorld",lua_cocos2dx_physics_PhysicsManager_getPhysicsWorld); + tolua_endmodule(tolua_S); + std::string typeName = typeid(cocos2d::PhysicsManager).name(); + g_luaType[typeName] = "cc.PhysicsManager"; + g_typeCast["PhysicsManager"] = "cc.PhysicsManager"; + return 1; +} TOLUA_API int register_all_cocos2dx_physics(lua_State* tolua_S) { tolua_open(tolua_S); @@ -12628,6 +13047,7 @@ TOLUA_API int register_all_cocos2dx_physics(lua_State* tolua_S) lua_register_cocos2dx_physics_PhysicsShape(tolua_S); lua_register_cocos2dx_physics_PhysicsShapePolygon(tolua_S); lua_register_cocos2dx_physics_PhysicsShapeBox(tolua_S); + lua_register_cocos2dx_physics_PhysicsManager(tolua_S); lua_register_cocos2dx_physics_PhysicsJointMotor(tolua_S); lua_register_cocos2dx_physics_PhysicsJointRatchet(tolua_S); lua_register_cocos2dx_physics_PhysicsJointDistance(tolua_S); @@ -12636,6 +13056,7 @@ TOLUA_API int register_all_cocos2dx_physics(lua_State* tolua_S) lua_register_cocos2dx_physics_PhysicsJointPin(tolua_S); lua_register_cocos2dx_physics_PhysicsContactPreSolve(tolua_S); lua_register_cocos2dx_physics_PhysicsDebugDraw(tolua_S); + lua_register_cocos2dx_physics_ComponentPhysics2d(tolua_S); lua_register_cocos2dx_physics_PhysicsShapeEdgeChain(tolua_S); lua_register_cocos2dx_physics_PhysicsShapeEdgeSegment(tolua_S); lua_register_cocos2dx_physics_PhysicsJointGear(tolua_S); diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_physics_auto.hpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_physics_auto.hpp index d521804635..5edcef0fcc 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_physics_auto.hpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_physics_auto.hpp @@ -270,6 +270,16 @@ int register_all_cocos2dx_physics(lua_State* tolua_S); + + + + + + + + + + diff --git a/cocos/scripting/lua-bindings/manual/cocos2d/lua_cocos2dx_manual.cpp b/cocos/scripting/lua-bindings/manual/cocos2d/lua_cocos2dx_manual.cpp index 641413e080..cede2b32f3 100644 --- a/cocos/scripting/lua-bindings/manual/cocos2d/lua_cocos2dx_manual.cpp +++ b/cocos/scripting/lua-bindings/manual/cocos2d/lua_cocos2dx_manual.cpp @@ -2379,157 +2379,6 @@ tolua_lerror: return 0; } -#if CC_USE_PHYSICS - -int lua_cocos2dx_Node_setPhysicsBody(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::Node* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_setPhysicsBody'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - cocos2d::PhysicsBody* arg0; - - ok &= luaval_to_object(tolua_S, 2, "cc.PhysicsBody",&arg0, "cc.Node:setPhysicsBody"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Node_setPhysicsBody'", nullptr); - return 0; - } - cobj->setPhysicsBody(arg0); - lua_settop(tolua_S, 1); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Node:setPhysicsBody",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 -tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_setPhysicsBody'.",&tolua_err); -#endif - - return 0; -} - -int lua_cocos2dx_Node_removeFromPhysicsWorld(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::Node* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_removeFromPhysicsWorld'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Node_removeFromPhysicsWorld'", nullptr); - return 0; - } - cobj->removeFromPhysicsWorld(); - lua_settop(tolua_S, 1); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Node:removeFromPhysicsWorld",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 -tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_removeFromPhysicsWorld'.",&tolua_err); -#endif - - return 0; -} - -int lua_cocos2dx_Node_getPhysicsBody(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::Node* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_getPhysicsBody'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Node_getPhysicsBody'", nullptr); - return 0; - } - cocos2d::PhysicsBody* ret = cobj->getPhysicsBody(); - object_to_luaval(tolua_S, "cc.PhysicsBody",(cocos2d::PhysicsBody*)ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Node:getPhysicsBody",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 -tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_getPhysicsBody'.",&tolua_err); -#endif - - return 0; -} - -#endif //CC_USE_PHYSICS - #if CC_USE_NAVMESH #include "navmesh/CCNavMesh.h" int lua_cocos2dx_Scene_setNavMeshDebugCamera(lua_State* tolua_S) @@ -5083,18 +4932,6 @@ static void extendNode(lua_State* tolua_S) lua_pushstring(tolua_S, "setRotationQuat"); lua_pushcfunction(tolua_S, lua_cocos2dx_Node_setRotationQuat); lua_rawset(tolua_S, -3); -#if CC_USE_PHYSICS - lua_pushstring(tolua_S, "setPhysicsBody"); - lua_pushcfunction(tolua_S, lua_cocos2dx_Node_setPhysicsBody); - lua_rawset(tolua_S, -3); - lua_pushstring(tolua_S, "removeFromPhysicsWorld"); - lua_pushcfunction(tolua_S, lua_cocos2dx_Node_removeFromPhysicsWorld); - lua_rawset(tolua_S, -3); - lua_pushstring(tolua_S, "getPhysicsBody"); - lua_pushcfunction(tolua_S, lua_cocos2dx_Node_getPhysicsBody); - lua_rawset(tolua_S, -3); -#endif //CC_USE_PHYSICS - } lua_pop(tolua_S, 1); } diff --git a/cocos/ui/Android.mk b/cocos/ui/Android.mk index 09596acbd8..4031741943 100644 --- a/cocos/ui/Android.mk +++ b/cocos/ui/Android.mk @@ -42,6 +42,7 @@ UIWebView.cpp \ UIWebViewImpl-android.cpp \ UIEditBox/UIEditBox.cpp \ UIEditBox/UIEditBoxImpl-android.cpp \ +UIEditBox/UIEditBoxImpl-common.cpp \ UILayoutComponent.cpp \ LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../editor-support diff --git a/cocos/ui/UIEditBox/UIEditBoxImpl-android.cpp b/cocos/ui/UIEditBox/UIEditBoxImpl-android.cpp index f0426d456a..3ef3f6ce09 100644 --- a/cocos/ui/UIEditBox/UIEditBoxImpl-android.cpp +++ b/cocos/ui/UIEditBox/UIEditBoxImpl-android.cpp @@ -29,13 +29,12 @@ #include "UIEditBox.h" #include -#include "jni/Java_org_cocos2dx_lib_Cocos2dxBitmap.h" #include "jni/Java_org_cocos2dx_lib_Cocos2dxHelper.h" #include "2d/CCLabel.h" #include "base/ccUTF8.h" #include "math/Vec2.h" #include "ui/UIHelper.h" -#include "base/ccUTF8.h" +#include "base/CCDirector.h" NS_CC_BEGIN @@ -70,88 +69,9 @@ EditBoxImpl* __createSystemEditBox(EditBox* editBox) return new EditBoxImplAndroid(editBox); } -void EditBoxImplAndroid::editBoxEditingDidBegin() -{ - // LOGD("textFieldShouldBeginEditing..."); - cocos2d::ui::EditBoxDelegate *pDelegate = _editBox->getDelegate(); - - if (pDelegate != nullptr) - { - pDelegate->editBoxEditingDidBegin(_editBox); - } - -#if CC_ENABLE_SCRIPT_BINDING - if (NULL != _editBox && 0 != _editBox->getScriptEditBoxHandler()) - { - cocos2d::CommonScriptData data(_editBox->getScriptEditBoxHandler(), "began", _editBox); - cocos2d::ScriptEvent event(cocos2d::kCommonEvent, (void *)&data); - cocos2d::ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event); - } -#endif -} - -void EditBoxImplAndroid::editBoxEditingDidEnd(const std::string& text) -{ - // LOGD("textFieldShouldEndEditing..."); - _text = text; - this->refreshInactiveText(); - - cocos2d::ui::EditBoxDelegate *pDelegate = _editBox->getDelegate(); - if (pDelegate != nullptr) - { - pDelegate->editBoxEditingDidEnd(_editBox); - pDelegate->editBoxReturn(_editBox); - } - -#if CC_ENABLE_SCRIPT_BINDING - if (_editBox != nullptr && 0 != _editBox->getScriptEditBoxHandler()) - { - cocos2d::CommonScriptData data(_editBox->getScriptEditBoxHandler(), "ended", _editBox); - cocos2d::ScriptEvent event(cocos2d::kCommonEvent, (void *)&data); - cocos2d::ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event); - memset(data.eventName, 0, sizeof(data.eventName)); - strncpy(data.eventName, "return", sizeof(data.eventName)); - event.data = (void *)&data; - cocos2d::ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event); - } -#endif - - if (_editBox != nullptr) - { - this->onEndEditing(text); - } -} - -void EditBoxImplAndroid::editBoxEditingChanged(const std::string& text) -{ - // LOGD("editBoxTextChanged..."); - cocos2d::ui::EditBoxDelegate *pDelegate = _editBox->getDelegate(); - _text = text; - if (pDelegate != nullptr) - { - pDelegate->editBoxTextChanged(_editBox, text); - } - -#if CC_ENABLE_SCRIPT_BINDING - if (NULL != _editBox && 0 != _editBox->getScriptEditBoxHandler()) - { - cocos2d::CommonScriptData data(_editBox->getScriptEditBoxHandler(), "changed", _editBox); - cocos2d::ScriptEvent event(cocos2d::kCommonEvent, (void *)&data); - cocos2d::ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event); - } -#endif -} EditBoxImplAndroid::EditBoxImplAndroid(EditBox* pEditText) -: EditBoxImpl(pEditText) -, _label(nullptr) -, _labelPlaceHolder(nullptr) -, _editBoxInputMode(EditBox::InputMode::SINGLE_LINE) -, _editBoxInputFlag(EditBox::InputFlag::INTIAL_CAPS_ALL_CHARACTERS) -, _keyboardReturnType(EditBox::KeyboardReturnType::DEFAULT) -, _colText(Color3B::WHITE) -, _colPlaceHolder(Color3B::GRAY) -, _maxLength(-1) +: EditBoxImplCommon(pEditText) , _editBoxIndex(-1) { } @@ -162,124 +82,67 @@ EditBoxImplAndroid::~EditBoxImplAndroid() removeEditBoxJNI(_editBoxIndex); } -void EditBoxImplAndroid::doAnimationWhenKeyboardMove(float duration, float distance) -{ // don't need to be implemented on android platform. - -} - -static const int CC_EDIT_BOX_PADDING = 5; - -bool EditBoxImplAndroid::initWithSize(const Size& size) +void EditBoxImplAndroid::createNativeControl(const Rect& frame) { - auto rect = Rect(0,0, size.width, size.height); - _editBoxIndex = addEditBoxJNI(rect.origin.x, rect.origin.y, rect.size.width, rect.size.height); - s_allEditBoxes[_editBoxIndex] = this; - - _label = Label::create(); - _label->setSystemFontSize(size.height-12); - // align the text vertically center - _label->setAnchorPoint(Vec2(0, 0.5f)); - _label->setPosition(Vec2(CC_EDIT_BOX_PADDING, size.height / 2.0f)); - _label->setTextColor(_colText); - _editBox->addChild(_label); - - _labelPlaceHolder = Label::create(); - _labelPlaceHolder->setSystemFontSize(size.height-12); - // align the text vertically center - _labelPlaceHolder->setAnchorPoint(Vec2(0, 0.5f)); - _labelPlaceHolder->setPosition(CC_EDIT_BOX_PADDING, size.height / 2.0f); - _labelPlaceHolder->setVisible(false); - _labelPlaceHolder->setTextColor(_colPlaceHolder); - _editBox->addChild(_labelPlaceHolder); + auto director = cocos2d::Director::getInstance(); + auto glView = director->getOpenGLView(); + auto frameSize = glView->getFrameSize(); - _editSize = size; - return true; + auto winSize = director->getWinSize(); + auto leftBottom = _editBox->convertToWorldSpace(Point::ZERO); + + auto contentSize = frame.size; + auto rightTop = _editBox->convertToWorldSpace(Point(contentSize.width, contentSize.height)); + + auto uiLeft = frameSize.width / 2 + (leftBottom.x - winSize.width / 2 ) * glView->getScaleX(); + auto uiTop = frameSize.height /2 - (rightTop.y - winSize.height / 2) * glView->getScaleY(); + auto uiWidth = (rightTop.x - leftBottom.x) * glView->getScaleX(); + auto uiHeight = (rightTop.y - leftBottom.y) * glView->getScaleY(); + LOGD("scaleX = %f", glView->getScaleX()); + _editBoxIndex = addEditBoxJNI(uiLeft, uiTop, uiWidth, uiHeight, glView->getScaleX()); + s_allEditBoxes[_editBoxIndex] = this; } -void EditBoxImplAndroid::setFont(const char* pFontName, int fontSize) +void EditBoxImplAndroid::setNativeFont(const char* pFontName, int fontSize) { - if(_label != NULL) - { - if(strlen(pFontName) > 0) - { - _label->setSystemFontName(pFontName); - } - if(fontSize > 0) - { - _label->setSystemFontSize(fontSize); - } - } - - if(_labelPlaceHolder != NULL) - { - if(strlen(pFontName) > 0) - { - _labelPlaceHolder->setSystemFontName(pFontName); - } - if(fontSize > 0) - { - _labelPlaceHolder->setSystemFontSize(fontSize); - } - } - setFontEditBoxJNI(_editBoxIndex, pFontName, fontSize); + auto director = cocos2d::Director::getInstance(); + auto glView = director->getOpenGLView(); + setFontEditBoxJNI(_editBoxIndex, pFontName, fontSize * glView->getScaleX()); } -void EditBoxImplAndroid::setFontColor(const Color4B& color) +void EditBoxImplAndroid::setNativeFontColor(const Color4B& color) { - _colText = color; - _label->setTextColor(color); setFontColorEditBoxJNI(_editBoxIndex, color.r, color.g, color.b, color.a); } -void EditBoxImplAndroid::setPlaceholderFont(const char* pFontName, int fontSize) +void EditBoxImplAndroid::setNativePlaceholderFont(const char* pFontName, int fontSize) { - if(_labelPlaceHolder != NULL) - { - if(strlen(pFontName) > 0) - { - _labelPlaceHolder->setSystemFontName(pFontName); - } - if(fontSize > 0) - { - _labelPlaceHolder->setSystemFontSize(fontSize); - } - } - CCLOG("Wraning! You can't change Andriod Hint fontName and fontSize"); + CCLOG("Wraning! You can't change Andriod Hint fontName and fontSize"); } -void EditBoxImplAndroid::setPlaceholderFontColor(const Color4B& color) +void EditBoxImplAndroid::setNativePlaceholderFontColor(const Color4B& color) { - _colPlaceHolder = color; - _labelPlaceHolder->setTextColor(color); setPlaceHolderTextColorEditBoxJNI(_editBoxIndex, color.r, color.g, color.b, color.a); } -void EditBoxImplAndroid::setInputMode(EditBox::InputMode inputMode) +void EditBoxImplAndroid::setNativeInputMode(EditBox::InputMode inputMode) { - _editBoxInputMode = inputMode; setInputModeEditBoxJNI(_editBoxIndex, static_cast(inputMode)); } -void EditBoxImplAndroid::setMaxLength(int maxLength) +void EditBoxImplAndroid::setNativeMaxLength(int maxLength) { - _maxLength = maxLength; - setMaxLengthJNI(_editBoxIndex, _maxLength); + setMaxLengthJNI(_editBoxIndex, maxLength); } -int EditBoxImplAndroid::getMaxLength() -{ - return _maxLength; -} -void EditBoxImplAndroid::setInputFlag(EditBox::InputFlag inputFlag) +void EditBoxImplAndroid::setNativeInputFlag(EditBox::InputFlag inputFlag) { - _editBoxInputFlag = inputFlag; setInputFlagEditBoxJNI(_editBoxIndex, static_cast(inputFlag)); } -void EditBoxImplAndroid::setReturnType(EditBox::KeyboardReturnType returnType) +void EditBoxImplAndroid::setNativeReturnType(EditBox::KeyboardReturnType returnType) { - _keyboardReturnType = returnType; setReturnTypeEditBoxJNI(_editBoxIndex, static_cast(returnType)); } @@ -288,129 +151,40 @@ bool EditBoxImplAndroid::isEditing() return false; } -void EditBoxImplAndroid::setInactiveText(const char* pText) -{ - if(EditBox::InputFlag::PASSWORD == _editBoxInputFlag) - { - std::string passwordString; - for(int i = 0; i < strlen(pText); ++i) - passwordString.append("\u25CF"); - _label->setString(passwordString.c_str()); - } - else - { - _label->setString(pText); - } - // Clip the text width to fit to the text box - float fMaxWidth = _editBox->getContentSize().width - CC_EDIT_BOX_PADDING * 2; - Size labelSize = _label->getContentSize(); - if(labelSize.width > fMaxWidth) { - _label->setDimensions(fMaxWidth,labelSize.height); - } -} - -void EditBoxImplAndroid::refreshInactiveText() -{ - setInactiveText(_text.c_str()); - if(_text.size() == 0) - { - _label->setVisible(false); - _labelPlaceHolder->setVisible(true); - } - else - { - _label->setVisible(true); - _labelPlaceHolder->setVisible(false); - } -} -void EditBoxImplAndroid::setText(const char* pText) +void EditBoxImplAndroid::setNativeText(const char* pText) { setTextEditBoxJNI(_editBoxIndex, pText); - _text = pText; - refreshInactiveText(); } -const char* EditBoxImplAndroid::getText(void) +void EditBoxImplAndroid::setNativePlaceHolder(const char* pText) { - return _text.c_str(); + setPlaceHolderTextEditBoxJNI(_editBoxIndex, pText); } -void EditBoxImplAndroid::setPlaceHolder(const char* pText) -{ - if (pText != NULL) - { - _placeHolder = pText; - if (_placeHolder.length() > 0 && _text.length() == 0) - { - _labelPlaceHolder->setVisible(true); - } - - _labelPlaceHolder->setString(_placeHolder.c_str()); - setPlaceHolderTextEditBoxJNI(_editBoxIndex, pText); - } -} -void EditBoxImplAndroid::setPosition(const Vec2& pos) -{ // don't need to be implemented on android platform. -} - -void EditBoxImplAndroid::setVisible(bool visible) +void EditBoxImplAndroid::setNativeVisible(bool visible) { // don't need to be implemented on android platform. setVisibleEditBoxJNI(_editBoxIndex, visible); } -void EditBoxImplAndroid::setContentSize(const Size& size) -{ // don't need to be implemented on android platform. -} - -void EditBoxImplAndroid::setAnchorPoint(const Vec2& anchorPoint) -{ // don't need to be implemented on android platform. -} - -void EditBoxImplAndroid::draw(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) -{ // don't need to be implemented on android platform. - if(parentFlags) - { - auto rect = ui::Helper::convertBoundingBoxToScreen(_editBox); - setEditBoxViewRectJNI(_editBoxIndex, rect.origin.x, rect.origin.y, rect.size.width, rect.size.height); - } -} - -void EditBoxImplAndroid::onEnter(void) -{ // don't need to be implemented on android platform. -} - -void EditBoxImplAndroid::openKeyboard() +void EditBoxImplAndroid::updateNativeFrame(const Rect& rect) { - _label->setVisible(false); - _labelPlaceHolder->setVisible(false); + setEditBoxViewRectJNI(_editBoxIndex, rect.origin.x, rect.origin.y, rect.size.width, rect.size.height); +} + +void EditBoxImplAndroid::nativeOpenKeyboard() +{ //it will also open up the soft keyboard setVisibleEditBoxJNI(_editBoxIndex,true); } -void EditBoxImplAndroid::closeKeyboard() +void EditBoxImplAndroid::nativeCloseKeyboard() { closeEditBoxKeyboardJNI(_editBoxIndex); } -void EditBoxImplAndroid::onEndEditing(const std::string& text) -{ - setVisibleEditBoxJNI(_editBoxIndex, false); - if(text.size() == 0) - { - _label->setVisible(false); - _labelPlaceHolder->setVisible(true); - } - else - { - _label->setVisible(true); - _labelPlaceHolder->setVisible(false); - setInactiveText(text.c_str()); - } -} - void editBoxEditingDidBegin(int index) { auto it = s_allEditBoxes.find(index); @@ -436,6 +210,12 @@ void editBoxEditingDidEnd(int index, const std::string& text) s_allEditBoxes[index]->editBoxEditingDidEnd(text); } } + +const char* EditBoxImplAndroid::getNativeDefaultFontName() +{ + return ""; +} + } //end of ui namespace NS_CC_END diff --git a/cocos/ui/UIEditBox/UIEditBoxImpl-android.h b/cocos/ui/UIEditBox/UIEditBoxImpl-android.h index 90c273a0b3..66eae9ba45 100644 --- a/cocos/ui/UIEditBox/UIEditBoxImpl-android.h +++ b/cocos/ui/UIEditBox/UIEditBoxImpl-android.h @@ -30,7 +30,7 @@ #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) -#include "UIEditBoxImpl.h" +#include "UIEditBoxImpl-common.h" NS_CC_BEGIN @@ -40,7 +40,7 @@ namespace ui { class EditBox; -class EditBoxImplAndroid : public EditBoxImpl +class EditBoxImplAndroid : public EditBoxImplCommon { public: /** @@ -53,64 +53,30 @@ public: */ virtual ~EditBoxImplAndroid(); - virtual bool initWithSize(const Size& size) override; - virtual void setFont(const char* pFontName, int fontSize) override; - virtual void setFontColor(const Color4B& color) override; - virtual void setPlaceholderFont(const char* pFontName, int fontSize) override; - virtual void setPlaceholderFontColor(const Color4B& color) override; - virtual void setInputMode(EditBox::InputMode inputMode) override; - virtual void setInputFlag(EditBox::InputFlag inputFlag) override; - virtual void setMaxLength(int maxLength) override; - virtual int getMaxLength() override; - virtual void setReturnType(EditBox::KeyboardReturnType returnType) override; + virtual bool isEditing() override; + virtual void createNativeControl(const Rect& frame) override; + virtual void setNativeFont(const char* pFontName, int fontSize) override; + virtual void setNativeFontColor(const Color4B& color) override; + virtual void setNativePlaceholderFont(const char* pFontName, int fontSize) override; + virtual void setNativePlaceholderFontColor(const Color4B& color) override; + virtual void setNativeInputMode(EditBox::InputMode inputMode) override; + virtual void setNativeInputFlag(EditBox::InputFlag inputFlag) override; + virtual void setNativeReturnType(EditBox::KeyboardReturnType returnType)override; + virtual void setNativeText(const char* pText) override; + virtual void setNativePlaceHolder(const char* pText) override; + virtual void setNativeVisible(bool visible) override; + virtual void updateNativeFrame(const Rect& rect) override; + virtual void setNativeContentSize(const Size& size) override {}; + virtual const char* getNativeDefaultFontName() override; + virtual void nativeOpenKeyboard() override; + virtual void nativeCloseKeyboard() override; + virtual void setNativeMaxLength(int maxLength); + - virtual void setText(const char* pText) override; - virtual const char* getText(void) override; - virtual void setPlaceHolder(const char* pText) override; - virtual void setPosition(const Vec2& pos) override; - virtual void setVisible(bool visible) override; - virtual void setContentSize(const Size& size) override; - virtual void setAnchorPoint(const Vec2& anchorPoint) override; - /** - * @js NA - * @lua NA - */ - virtual void draw(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) override; - /** - * @js NA - * @lua NA - */ - virtual void onEnter(void) override; - virtual void doAnimationWhenKeyboardMove(float duration, float distance) override; - virtual void openKeyboard() override; - virtual void closeKeyboard() override; - - - void editBoxEditingDidBegin(); - void editBoxEditingChanged(const std::string& text); - void editBoxEditingDidEnd(const std::string& text); private: - void setInactiveText(const char* pText); - void onEndEditing(const std::string& text); - void refreshInactiveText(); + virtual void doAnimationWhenKeyboardMove(float duration, float distance)override {} - - Label* _label; - Label* _labelPlaceHolder; - EditBox::InputMode _editBoxInputMode; - EditBox::InputFlag _editBoxInputFlag; - EditBox::KeyboardReturnType _keyboardReturnType; - - std::string _text; - std::string _placeHolder; - - Color4B _colText; - Color4B _colPlaceHolder; - - int _maxLength; - Size _editSize; - int _editBoxIndex; }; diff --git a/cocos/ui/UIEditBox/UIEditBoxImpl-common.cpp b/cocos/ui/UIEditBox/UIEditBoxImpl-common.cpp new file mode 100644 index 0000000000..427b3122e0 --- /dev/null +++ b/cocos/ui/UIEditBox/UIEditBoxImpl-common.cpp @@ -0,0 +1,381 @@ +/**************************************************************************** + Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2012 James Chen + + http://www.cocos2d-x.org + + 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. + ****************************************************************************/ +#include "UIEditBoxImpl-common.h" + +#define kLabelZOrder 9999 + +#include "UIEditBox.h" +#include "base/CCDirector.h" +#include "2d/CCLabel.h" +#include "ui/UIHelper.h" + +static const int CC_EDIT_BOX_PADDING = 5; + +NS_CC_BEGIN + +namespace ui { + +EditBoxImplCommon::EditBoxImplCommon(EditBox* pEditText) +: EditBoxImpl(pEditText) +, _label(nullptr) +, _labelPlaceHolder(nullptr) +, _editBoxInputMode(EditBox::InputMode::SINGLE_LINE) +, _editBoxInputFlag(EditBox::InputFlag::INTIAL_CAPS_ALL_CHARACTERS) +, _keyboardReturnType(EditBox::KeyboardReturnType::DEFAULT) +, _colText(Color3B::WHITE) +, _colPlaceHolder(Color3B::GRAY) +, _maxLength(-1) +{ +} + +EditBoxImplCommon::~EditBoxImplCommon() +{ +} + + +bool EditBoxImplCommon::initWithSize(const Size& size) +{ + do + { + + Rect rect = Rect(0, 0, size.width, size.height); + + this->createNativeControl(rect); + + initInactiveLabels(size); + setContentSize(size); + + return true; + }while (0); + + return false; +} + +void EditBoxImplCommon::initInactiveLabels(const Size& size) +{ + const char* pDefaultFontName = this->getNativeDefaultFontName(); + + _label = Label::create(); + _label->setAnchorPoint(Vec2(0, 0.5f)); + _label->setColor(Color3B::WHITE); + _label->setVisible(false); + _editBox->addChild(_label, kLabelZOrder); + + _labelPlaceHolder = Label::create(); + _labelPlaceHolder->setAnchorPoint(Vec2(0, 0.5f)); + _labelPlaceHolder->setColor(Color3B::GRAY); + _editBox->addChild(_labelPlaceHolder, kLabelZOrder); + + setFont(pDefaultFontName, size.height*2/3); + setPlaceholderFont(pDefaultFontName, size.height*2/3); +} + +void EditBoxImplCommon::placeInactiveLabels() +{ + _label->setPosition(CC_EDIT_BOX_PADDING, _contentSize.height / 2.0f); + _labelPlaceHolder->setPosition(CC_EDIT_BOX_PADDING, _contentSize.height / 2.0f); +} + +void EditBoxImplCommon::setInactiveText(const char* pText) +{ + if(EditBox::InputFlag::PASSWORD == _editBoxInputFlag) + { + std::string passwordString; + for(int i = 0; i < strlen(pText); ++i) + passwordString.append("\u25CF"); + _label->setString(passwordString.c_str()); + } + else + { + _label->setString(pText); + } + // Clip the text width to fit to the text box + float fMaxWidth = _editBox->getContentSize().width; + float fMaxHeight = _editBox->getContentSize().height; + Size labelSize = _label->getContentSize(); + if(labelSize.width > fMaxWidth || labelSize.height > fMaxHeight) + { + _label->setDimensions(fMaxWidth, fMaxHeight); + } +} + +void EditBoxImplCommon::setFont(const char* pFontName, int fontSize) +{ + this->setNativeFont(pFontName, fontSize); + + if(strlen(pFontName) > 0) + { + _label->setSystemFontName(pFontName); + } + if(fontSize > 0) + { + _label->setSystemFontSize(fontSize); + } +} + +void EditBoxImplCommon::setFontColor(const Color4B& color) +{ + this->setNativeFontColor(color); + + _label->setTextColor(color); +} + +void EditBoxImplCommon::setPlaceholderFont(const char* pFontName, int fontSize) +{ + this->setNativePlaceholderFont(pFontName, fontSize); + + if( strlen(pFontName) > 0) + { + _labelPlaceHolder->setSystemFontName(pFontName); + } + if(fontSize > 0) + { + _labelPlaceHolder->setSystemFontSize(fontSize); + } +} + +void EditBoxImplCommon::setPlaceholderFontColor(const Color4B &color) +{ + this->setNativePlaceholderFontColor(color); + + _labelPlaceHolder->setTextColor(color); +} + +void EditBoxImplCommon::setInputMode(EditBox::InputMode inputMode) +{ + _editBoxInputMode = inputMode; + this->setNativeInputMode(inputMode); +} + +void EditBoxImplCommon::setMaxLength(int maxLength) +{ + _maxLength = maxLength; + this->setNativeMaxLength(maxLength); +} + +int EditBoxImplCommon::getMaxLength() +{ + return _maxLength; +} + +void EditBoxImplCommon::setInputFlag(EditBox::InputFlag inputFlag) +{ + _editBoxInputFlag = inputFlag; + this->setNativeInputFlag(inputFlag); +} + +void EditBoxImplCommon::setReturnType(EditBox::KeyboardReturnType returnType) +{ + _keyboardReturnType = returnType; + this->setNativeReturnType(returnType); +} + +void EditBoxImplCommon::refreshInactiveText() +{ + setInactiveText(_text.c_str()); + if(_text.size() == 0) + { + _label->setVisible(false); + _labelPlaceHolder->setVisible(true); + } + else + { + _label->setVisible(true); + _labelPlaceHolder->setVisible(false); + } +} + +void EditBoxImplCommon::setText(const char* text) +{ + this->setNativeText(text); + _text = text; + refreshInactiveText(); +} + +const char* EditBoxImplCommon::getText(void) +{ + return _text.c_str(); +} + +void EditBoxImplCommon::setPlaceHolder(const char* pText) +{ + if (pText != NULL) + { + _placeHolder = pText; + if (_placeHolder.length() > 0 && _text.length() == 0) + { + _labelPlaceHolder->setVisible(true); + } + + _labelPlaceHolder->setString(_placeHolder.c_str()); + this->setNativePlaceHolder(pText); + } +} + + +void EditBoxImplCommon::setVisible(bool visible) +{ + this->setNativeVisible(visible); +} + +void EditBoxImplCommon::setContentSize(const Size& size) +{ + _contentSize = size; + CCLOG("[Edit text] content size = (%f, %f)", size.width, size.height); + placeInactiveLabels(); + + auto director = cocos2d::Director::getInstance(); + auto glview = director->getOpenGLView(); + Size controlSize = Size(size.width * glview->getScaleX(),size.height * glview->getScaleY()); + + this->setNativeContentSize(controlSize); + +} + +void EditBoxImplCommon::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) +{ + if(flags) + { + auto rect = ui::Helper::convertBoundingBoxToScreen(_editBox); + this->updateNativeFrame(rect); + } +} + +void EditBoxImplCommon::onEnter(void) +{ + const char* pText = getText(); + if (pText) { + setInactiveText(pText); + } +} + +void EditBoxImplCommon::openKeyboard() +{ + _label->setVisible(false); + _labelPlaceHolder->setVisible(false); + + this->nativeOpenKeyboard(); +} + +void EditBoxImplCommon::closeKeyboard() +{ + this->nativeCloseKeyboard(); +} + +void EditBoxImplCommon::onEndEditing(const std::string& text) +{ + this->setNativeVisible(false); + + if(text.size() == 0) + { + _label->setVisible(false); + _labelPlaceHolder->setVisible(true); + } + else + { + _label->setVisible(true); + _labelPlaceHolder->setVisible(false); + setInactiveText(text.c_str()); + } +} + +void EditBoxImplCommon::editBoxEditingDidBegin() +{ + // LOGD("textFieldShouldBeginEditing..."); + cocos2d::ui::EditBoxDelegate *pDelegate = _editBox->getDelegate(); + + if (pDelegate != nullptr) + { + pDelegate->editBoxEditingDidBegin(_editBox); + } + +#if CC_ENABLE_SCRIPT_BINDING + if (NULL != _editBox && 0 != _editBox->getScriptEditBoxHandler()) + { + cocos2d::CommonScriptData data(_editBox->getScriptEditBoxHandler(), "began", _editBox); + cocos2d::ScriptEvent event(cocos2d::kCommonEvent, (void *)&data); + cocos2d::ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event); + } +#endif +} + +void EditBoxImplCommon::editBoxEditingDidEnd(const std::string& text) +{ + // LOGD("textFieldShouldEndEditing..."); + _text = text; + this->refreshInactiveText(); + + cocos2d::ui::EditBoxDelegate *pDelegate = _editBox->getDelegate(); + if (pDelegate != nullptr) + { + pDelegate->editBoxEditingDidEnd(_editBox); + pDelegate->editBoxReturn(_editBox); + } + +#if CC_ENABLE_SCRIPT_BINDING + if (_editBox != nullptr && 0 != _editBox->getScriptEditBoxHandler()) + { + cocos2d::CommonScriptData data(_editBox->getScriptEditBoxHandler(), "ended", _editBox); + cocos2d::ScriptEvent event(cocos2d::kCommonEvent, (void *)&data); + cocos2d::ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event); + memset(data.eventName, 0, sizeof(data.eventName)); + strncpy(data.eventName, "return", sizeof(data.eventName)); + event.data = (void *)&data; + cocos2d::ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event); + } +#endif + + if (_editBox != nullptr) + { + this->onEndEditing(text); + } +} + +void EditBoxImplCommon::editBoxEditingChanged(const std::string& text) +{ + // LOGD("editBoxTextChanged..."); + cocos2d::ui::EditBoxDelegate *pDelegate = _editBox->getDelegate(); + _text = text; + if (pDelegate != nullptr) + { + pDelegate->editBoxTextChanged(_editBox, text); + } + +#if CC_ENABLE_SCRIPT_BINDING + if (NULL != _editBox && 0 != _editBox->getScriptEditBoxHandler()) + { + cocos2d::CommonScriptData data(_editBox->getScriptEditBoxHandler(), "changed", _editBox); + cocos2d::ScriptEvent event(cocos2d::kCommonEvent, (void *)&data); + cocos2d::ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event); + } +#endif +} + + +} + +NS_CC_END + + diff --git a/cocos/ui/UIEditBox/UIEditBoxImpl-common.h b/cocos/ui/UIEditBox/UIEditBoxImpl-common.h new file mode 100644 index 0000000000..ae32efa090 --- /dev/null +++ b/cocos/ui/UIEditBox/UIEditBoxImpl-common.h @@ -0,0 +1,144 @@ +/**************************************************************************** + Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2012 James Chen + + http://www.cocos2d-x.org + + 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. + ****************************************************************************/ + +#ifndef __UIEditBoxIMPLICOMMON_H__ +#define __UIEditBoxIMPLICOMMON_H__ + +#include "platform/CCPlatformConfig.h" + +#include "UIEditBoxImpl.h" + +NS_CC_BEGIN + +namespace ui { + +class EditBox; + +class EditBoxImplCommon : public EditBoxImpl +{ +public: + /** + * @js NA + */ + EditBoxImplCommon(EditBox* pEditText); + /** + * @js NA + * @lua NA + */ + virtual ~EditBoxImplCommon(); + + virtual bool initWithSize(const Size& size); + + virtual void setFont(const char* pFontName, int fontSize); + virtual void setFontColor(const Color4B& color); + virtual void setPlaceholderFont(const char* pFontName, int fontSize); + virtual void setPlaceholderFontColor(const Color4B& color); + virtual void setInputMode(EditBox::InputMode inputMode); + virtual void setInputFlag(EditBox::InputFlag inputFlag); + virtual void setReturnType(EditBox::KeyboardReturnType returnType); + virtual void setText(const char* pText); + virtual void setPlaceHolder(const char* pText); + virtual void setVisible(bool visible); + + + virtual void setMaxLength(int maxLength); + virtual int getMaxLength(); + + virtual const char* getText(void); + virtual void refreshInactiveText(); + + virtual void setContentSize(const Size& size); + + virtual void setAnchorPoint(const Vec2& anchorPoint){} + virtual void setPosition(const Vec2& pos) {} + + /** + * @js NA + * @lua NA + */ + virtual void draw(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) override; + /** + * @js NA + * @lua NA + */ + virtual void onEnter(void); + virtual void openKeyboard(); + virtual void closeKeyboard(); + + virtual void onEndEditing(const std::string& text); + + void editBoxEditingDidBegin(); + void editBoxEditingChanged(const std::string& text); + void editBoxEditingDidEnd(const std::string& text); + + virtual bool isEditing() = 0; + virtual void createNativeControl(const Rect& frame) = 0; + virtual void setNativeFont(const char* pFontName, int fontSize) = 0; + virtual void setNativeFontColor(const Color4B& color) = 0; + virtual void setNativePlaceholderFont(const char* pFontName, int fontSize) = 0; + virtual void setNativePlaceholderFontColor(const Color4B& color) = 0; + virtual void setNativeInputMode(EditBox::InputMode inputMode) = 0; + virtual void setNativeInputFlag(EditBox::InputFlag inputFlag) = 0; + virtual void setNativeReturnType(EditBox::KeyboardReturnType returnType) = 0; + virtual void setNativeText(const char* pText) = 0; + virtual void setNativePlaceHolder(const char* pText) = 0; + virtual void setNativeVisible(bool visible) = 0; + virtual void updateNativeFrame(const Rect& rect) = 0; + virtual void setNativeContentSize(const Size& size) = 0; + virtual const char* getNativeDefaultFontName() = 0; + virtual void nativeOpenKeyboard() = 0; + virtual void nativeCloseKeyboard() = 0; + virtual void setNativeMaxLength(int maxLength) {}; + + +private: + void initInactiveLabels(const Size& size); + void setInactiveText(const char* pText); + void placeInactiveLabels(); + + Label* _label; + Label* _labelPlaceHolder; + EditBox::InputMode _editBoxInputMode; + EditBox::InputFlag _editBoxInputFlag; + EditBox::KeyboardReturnType _keyboardReturnType; + + std::string _text; + std::string _placeHolder; + + Color4B _colText; + Color4B _colPlaceHolder; + + int _maxLength; + Size _contentSize; +}; + + +} + +NS_CC_END + + +#endif /* __UIEditBoxIMPLICOMMON_H__ */ + diff --git a/cocos/ui/UIEditBox/UIEditBoxImpl-ios.h b/cocos/ui/UIEditBox/UIEditBoxImpl-ios.h index 37db60bfcb..34efc8b265 100644 --- a/cocos/ui/UIEditBox/UIEditBoxImpl-ios.h +++ b/cocos/ui/UIEditBox/UIEditBoxImpl-ios.h @@ -26,14 +26,14 @@ #ifndef __UIEditBoxIMPLIOS_H__ #define __UIEditBoxIMPLIOS_H__ -#include "platform/CCPlatformConfig.h" - #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) -#include "extensions/ExtensionMacros.h" -#include "UIEditBoxImpl.h" +#include "UIEditBoxImpl-common.h" + + @class UIEditBoxImplIOS_objc; +@class UIFont; NS_CC_BEGIN @@ -41,7 +41,7 @@ namespace ui { class EditBox; -class EditBoxImplIOS : public EditBoxImpl +class EditBoxImplIOS : public EditBoxImplCommon { public: /** @@ -53,57 +53,39 @@ public: * @lua NA */ virtual ~EditBoxImplIOS(); - - virtual bool initWithSize(const Size& size); - virtual void setFont(const char* pFontName, int fontSize); - virtual void setFontColor(const Color4B& color); - virtual void setPlaceholderFont(const char* pFontName, int fontSize); - virtual void setPlaceholderFontColor(const Color4B& color); - virtual void setInputMode(EditBox::InputMode inputMode); - virtual void setInputFlag(EditBox::InputFlag inputFlag); - virtual void setMaxLength(int maxLength); - virtual int getMaxLength(); - virtual void setReturnType(EditBox::KeyboardReturnType returnType); - virtual bool isEditing(); - - virtual void setText(const char* pText); - virtual const char* getText(void); - virtual void refreshInactiveText(); - virtual void setPlaceHolder(const char* pText); - virtual void setPosition(const Vec2& pos); - virtual void setVisible(bool visible); - virtual void setContentSize(const Size& size); - virtual void setAnchorPoint(const Vec2& anchorPoint); + virtual void setPosition(const Vec2& pos) override; + virtual void setAnchorPoint(const Vec2& anchorPoint) override; virtual void updatePosition(float dt) override; - /** - * @js NA - * @lua NA - */ - virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)override; - /** - * @js NA - * @lua NA - */ - virtual void onEnter(void); + + virtual bool isEditing() override; + virtual void createNativeControl(const Rect& frame) override; + virtual void setNativeFont(const char* pFontName, int fontSize) override; + virtual void setNativeFontColor(const Color4B& color) override; + virtual void setNativePlaceholderFont(const char* pFontName, int fontSize) override; + virtual void setNativePlaceholderFontColor(const Color4B& color) override; + virtual void setNativeInputMode(EditBox::InputMode inputMode) override; + virtual void setNativeInputFlag(EditBox::InputFlag inputFlag) override; + virtual void setNativeReturnType(EditBox::KeyboardReturnType returnType)override; + virtual void setNativeText(const char* pText) override; + virtual void setNativePlaceHolder(const char* pText) override; + virtual void setNativeVisible(bool visible) override; + virtual void updateNativeFrame(const Rect& rect) override; + virtual void setNativeContentSize(const Size& size) override; + virtual const char* getNativeDefaultFontName() override; + virtual void nativeOpenKeyboard() override; + virtual void nativeCloseKeyboard() override; + + //need to remove siri text + virtual const char* getText(void)override; + virtual void doAnimationWhenKeyboardMove(float duration, float distance); - virtual void openKeyboard(); - virtual void closeKeyboard(); - - virtual void onEndEditing(); private: - void initInactiveLabels(const Size& size); - void setInactiveText(const char* pText); - void adjustTextFieldPosition(); - void placeInactiveLabels(); UIFont* constructFont(const char* fontName, int fontSize); - - Label* _label; - Label* _labelPlaceHolder; - Size _contentSize; + void adjustTextFieldPosition(); + + UIEditBoxImplIOS_objc* _systemControl; Vec2 _position; Vec2 _anchorPoint; - UIEditBoxImplIOS_objc* _systemControl; - int _maxTextLength; }; diff --git a/cocos/ui/UIEditBox/UIEditBoxImpl-ios.mm b/cocos/ui/UIEditBox/UIEditBoxImpl-ios.mm index 711c1fefbc..e042462b2e 100644 --- a/cocos/ui/UIEditBox/UIEditBoxImpl-ios.mm +++ b/cocos/ui/UIEditBox/UIEditBoxImpl-ios.mm @@ -197,21 +197,8 @@ static const int CC_EDIT_BOX_PADDING = 5; textField.text = [textField.text substringToIndex:maxLength]; } - cocos2d::ui::EditBoxDelegate *pDelegate = getEditBoxImplIOS()->getDelegate(); - if (pDelegate != NULL) - { - pDelegate->editBoxTextChanged(getEditBoxImplIOS()->getEditBox(), getEditBoxImplIOS()->getText()); - } - -#if CC_ENABLE_SCRIPT_BINDING - cocos2d::ui::EditBox* pEditBox= getEditBoxImplIOS()->getEditBox(); - if (NULL != pEditBox && 0 != pEditBox->getScriptEditBoxHandler()) - { - cocos2d::CommonScriptData data(pEditBox->getScriptEditBoxHandler(), "changed", pEditBox); - cocos2d::ScriptEvent event(cocos2d::kCommonEvent, (void *)&data); - cocos2d::ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event); - } -#endif + const char* inputText = [textField.text UTF8String]; + getEditBoxImplIOS()->editBoxEditingChanged(inputText); } #pragma mark - UITextField delegate methods @@ -229,23 +216,7 @@ static const int CC_EDIT_BOX_PADDING = 5; [self performSelector:@selector(animationSelector) withObject:nil afterDelay:0.0f]; } - cocos2d::ui::EditBoxDelegate *pDelegate = getEditBoxImplIOS()->getDelegate(); - - if (pDelegate != NULL) - { - pDelegate->editBoxEditingDidBegin(getEditBoxImplIOS()->getEditBox()); - } - -#if CC_ENABLE_SCRIPT_BINDING - cocos2d::ui::EditBox *pEditBox= getEditBoxImplIOS()->getEditBox(); - if (NULL != pEditBox && 0 != pEditBox->getScriptEditBoxHandler()) - { - cocos2d::CommonScriptData data(pEditBox->getScriptEditBoxHandler(), "began", pEditBox); - cocos2d::ScriptEvent event(cocos2d::kCommonEvent, (void *)&data); - cocos2d::ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event); - } -#endif - + getEditBoxImplIOS()->editBoxEditingDidBegin(); return YES; } @@ -253,33 +224,9 @@ static const int CC_EDIT_BOX_PADDING = 5; { CCLOG("textFieldShouldEndEditing..."); _editState = NO; - getEditBoxImplIOS()->refreshInactiveText(); - - cocos2d::ui::EditBoxDelegate *pDelegate = getEditBoxImplIOS()->getDelegate(); - if (pDelegate != NULL) - { - pDelegate->editBoxEditingDidEnd(getEditBoxImplIOS()->getEditBox()); - pDelegate->editBoxReturn(getEditBoxImplIOS()->getEditBox()); - } - -#if CC_ENABLE_SCRIPT_BINDING - cocos2d::ui::EditBox *pEditBox= getEditBoxImplIOS()->getEditBox(); - if (pEditBox != nullptr && 0 != pEditBox->getScriptEditBoxHandler()) - { - cocos2d::CommonScriptData data(pEditBox->getScriptEditBoxHandler(), "ended", pEditBox); - cocos2d::ScriptEvent event(cocos2d::kCommonEvent, (void *)&data); - cocos2d::ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event); - memset(data.eventName, 0, sizeof(data.eventName)); - strncpy(data.eventName, "return", sizeof(data.eventName)); - event.data = (void *)&data; - cocos2d::ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event); - } -#endif - - if (_editBox != nil) - { - getEditBoxImplIOS()->onEndEditing(); - } + const char* inputText = [sender.text UTF8String]; + + getEditBoxImplIOS()->editBoxEditingDidEnd(inputText); return YES; } @@ -327,18 +274,41 @@ EditBoxImpl* __createSystemEditBox(EditBox* pEditBox) } EditBoxImplIOS::EditBoxImplIOS(EditBox* pEditText) -: EditBoxImpl(pEditText) -, _label(nullptr) -, _labelPlaceHolder(nullptr) +: EditBoxImplCommon(pEditText) +,_systemControl(nullptr) , _anchorPoint(Vec2(0.5f, 0.5f)) -, _systemControl(nullptr) -, _maxTextLength(-1) { + } EditBoxImplIOS::~EditBoxImplIOS() { [_systemControl release]; + _systemControl = nil; +} + +void EditBoxImplIOS::createNativeControl(const Rect& frame) +{ + auto glview = cocos2d::Director::getInstance()->getOpenGLView(); + + Rect rect(0, 0, frame.size.width * glview->getScaleX(), frame.size.height * glview->getScaleY()); + + float factor = cocos2d::Director::getInstance()->getContentScaleFactor(); + + rect.size.width /= factor; + rect.size.height /= factor; + + _systemControl = [[UIEditBoxImplIOS_objc alloc] initWithFrame:CGRectMake(rect.origin.x, + rect.origin.y, + rect.size.width, + rect.size.height) + editBox:this]; + +} + +bool EditBoxImplIOS::isEditing() +{ + return [_systemControl isEditState] ? true : false; } void EditBoxImplIOS::doAnimationWhenKeyboardMove(float duration, float distance) @@ -348,150 +318,35 @@ void EditBoxImplIOS::doAnimationWhenKeyboardMove(float duration, float distance) [_systemControl doAnimationWhenKeyboardMoveWithDuration:duration distance:distance]; } } - -bool EditBoxImplIOS::initWithSize(const Size& size) -{ - do - { - auto glview = cocos2d::Director::getInstance()->getOpenGLView(); - - CGRect rect = CGRectMake(0, 0, size.width * glview->getScaleX(),size.height * glview->getScaleY()); - - CCEAGLView *eaglview = static_cast(glview->getEAGLView()); - float factor = eaglview.contentScaleFactor; - rect.size.width /= factor; - rect.size.height /= factor; - - _systemControl = [[UIEditBoxImplIOS_objc alloc] initWithFrame:rect editBox:this]; - if (!_systemControl) break; - - initInactiveLabels(size); - setContentSize(size); - - return true; - }while (0); - return false; -} - -void EditBoxImplIOS::initInactiveLabels(const Size& size) -{ - const char* pDefaultFontName = [[_systemControl.textField.font fontName] UTF8String]; - - _label = Label::create(); - _label->setAnchorPoint(Vec2(0, 0.5f)); - _label->setColor(Color3B::WHITE); - _label->setVisible(false); - _editBox->addChild(_label, kLabelZOrder); - - _labelPlaceHolder = Label::create(); - // align the text vertically center - _labelPlaceHolder->setAnchorPoint(Vec2(0, 0.5f)); - _labelPlaceHolder->setColor(Color3B::GRAY); - _editBox->addChild(_labelPlaceHolder, kLabelZOrder); - - setFont(pDefaultFontName, size.height*2/3); - setPlaceholderFont(pDefaultFontName, size.height*2/3); -} - -void EditBoxImplIOS::placeInactiveLabels() -{ - _label->setPosition(CC_EDIT_BOX_PADDING, _contentSize.height / 2.0f); - _labelPlaceHolder->setPosition(CC_EDIT_BOX_PADDING, _contentSize.height / 2.0f); -} - -void EditBoxImplIOS::setInactiveText(const char* pText) -{ - if(_systemControl.textField.secureTextEntry == YES) - { - std::string passwordString; - for(int i = 0; i < strlen(pText); ++i) - passwordString.append("\u25CF"); - _label->setString(passwordString.c_str()); - } - else - _label->setString(getText()); - - // Clip the text width to fit to the text box - float fMaxWidth = _editBox->getContentSize().width - CC_EDIT_BOX_PADDING * 2; - Size labelSize = _label->getContentSize(); - if(labelSize.width > fMaxWidth) { - _label->setDimensions(fMaxWidth,labelSize.height); - } -} - -UIFont* EditBoxImplIOS::constructFont(const char *fontName, int fontSize) -{ - CCASSERT(fontName != nullptr, "fontName can't be nullptr"); - CCEAGLView *eaglview = static_cast(cocos2d::Director::getInstance()->getOpenGLView()->getEAGLView()); - float retinaFactor = eaglview.contentScaleFactor; - NSString * fntName = [NSString stringWithUTF8String:fontName]; - - auto glview = cocos2d::Director::getInstance()->getOpenGLView(); - float scaleFactor = glview->getScaleX(); - - if (fontSize == -1) - { - fontSize = [_systemControl.textField frame].size.height*2/3; - } - else - { - fontSize = fontSize * scaleFactor / retinaFactor; - } - - UIFont *textFont = nil; - if (strlen(fontName) > 0) - { - textFont = [UIFont fontWithName:fntName size:fontSize]; - } - else - { - textFont = [UIFont systemFontOfSize:fontSize]; - } - return textFont; -} - -void EditBoxImplIOS::setFont(const char* pFontName, int fontSize) +void EditBoxImplIOS::setNativeFont(const char* pFontName, int fontSize) { UIFont* textFont = constructFont(pFontName, fontSize); if(textFont != nil) { [_systemControl.textField setFont:textFont]; } - - if(strlen(pFontName) > 0) - { - _label->setSystemFontName(pFontName); - } - if(fontSize > 0) - { - _label->setSystemFontSize(fontSize); - } -} - -void EditBoxImplIOS::setFontColor(const Color4B& color) -{ - _systemControl.textField.textColor = [UIColor colorWithRed:color.r / 255.0f green:color.g / 255.0f blue:color.b / 255.0f alpha:color.a / 255.f]; - _label->setTextColor(color); -} - -void EditBoxImplIOS::setPlaceholderFont(const char* pFontName, int fontSize) -{ - if( strlen(pFontName) > 0) - { - _labelPlaceHolder->setSystemFontName(pFontName); - } - if(fontSize > 0) - { - _labelPlaceHolder->setSystemFontSize(fontSize); - } } -void EditBoxImplIOS::setPlaceholderFontColor(const Color4B &color) +void EditBoxImplIOS::setNativeFontColor(const Color4B& color) { - _labelPlaceHolder->setTextColor(color); + _systemControl.textField.textColor = [UIColor colorWithRed:color.r / 255.0f + green:color.g / 255.0f + blue:color.b / 255.0f + alpha:color.a / 255.f]; + } -void EditBoxImplIOS::setInputMode(EditBox::InputMode inputMode) +void EditBoxImplIOS::setNativePlaceholderFont(const char* pFontName, int fontSize) +{ + //TODO:: +} + +void EditBoxImplIOS::setNativePlaceholderFontColor(const Color4B& color) +{ + //TODO:: +} + +void EditBoxImplIOS::setNativeInputMode(EditBox::InputMode inputMode) { switch (inputMode) { @@ -519,17 +374,7 @@ void EditBoxImplIOS::setInputMode(EditBox::InputMode inputMode) } } -void EditBoxImplIOS::setMaxLength(int maxLength) -{ - _maxTextLength = maxLength; -} - -int EditBoxImplIOS::getMaxLength() -{ - return _maxTextLength; -} - -void EditBoxImplIOS::setInputFlag(EditBox::InputFlag inputFlag) +void EditBoxImplIOS::setNativeInputFlag(EditBox::InputFlag inputFlag) { switch (inputFlag) { @@ -552,8 +397,20 @@ void EditBoxImplIOS::setInputFlag(EditBox::InputFlag inputFlag) break; } } + +NSString* removeSiriString(NSString* str) +{ + NSString* siriString = @"\xef\xbf\xbc"; + return [str stringByReplacingOccurrencesOfString:siriString withString:@""]; +} -void EditBoxImplIOS::setReturnType(EditBox::KeyboardReturnType returnType) +const char* EditBoxImplIOS::getText(void) +{ + return [removeSiriString(_systemControl.textField.text) UTF8String]; +} + + +void EditBoxImplIOS::setNativeReturnType(EditBox::KeyboardReturnType returnType) { switch (returnType) { case EditBox::KeyboardReturnType::DEFAULT: @@ -577,63 +434,113 @@ void EditBoxImplIOS::setReturnType(EditBox::KeyboardReturnType returnType) } } -bool EditBoxImplIOS::isEditing() +void EditBoxImplIOS::setNativeText(const char* pText) { - return [_systemControl isEditState] ? true : false; -} - -void EditBoxImplIOS::refreshInactiveText() -{ - const char* text = getText(); - if(_systemControl.textField.hidden == YES) - { - setInactiveText(text); - if(strlen(text) == 0) - { - _label->setVisible(false); - _labelPlaceHolder->setVisible(true); - } - else - { - _label->setVisible(true); - _labelPlaceHolder->setVisible(false); - } - } -} - -void EditBoxImplIOS::setText(const char* text) -{ - NSString* nsText =[NSString stringWithUTF8String:text]; + NSString* nsText =[NSString stringWithUTF8String:pText]; if ([nsText compare:_systemControl.textField.text] != NSOrderedSame) { _systemControl.textField.text = nsText; } - - refreshInactiveText(); } -NSString* removeSiriString(NSString* str) -{ - NSString* siriString = @"\xef\xbf\xbc"; - return [str stringByReplacingOccurrencesOfString:siriString withString:@""]; -} - -const char* EditBoxImplIOS::getText(void) -{ - return [removeSiriString(_systemControl.textField.text) UTF8String]; -} - -void EditBoxImplIOS::setPlaceHolder(const char* pText) +void EditBoxImplIOS::setNativePlaceHolder(const char* pText) { _systemControl.textField.placeholder = [NSString stringWithUTF8String:pText]; - _labelPlaceHolder->setString(pText); +} + +void EditBoxImplIOS::setNativeVisible(bool visible) +{ + _systemControl.textField.hidden = !visible; +} + +void EditBoxImplIOS::updateNativeFrame(const Rect& rect) +{ + //no-op +} + +void EditBoxImplIOS::setNativeContentSize(const Size& size) +{ + auto director = cocos2d::Director::getInstance(); + auto glview = director->getOpenGLView(); + CCEAGLView *eaglview = static_cast(glview->getEAGLView()); + float factor = eaglview.contentScaleFactor; + + [_systemControl setContentSize:CGSizeMake(size.width / factor, size.height / factor)]; +} + +const char* EditBoxImplIOS::getNativeDefaultFontName() +{ + const char* pDefaultFontName = [[_systemControl.textField.font fontName] UTF8String]; + return pDefaultFontName; +} + +void EditBoxImplIOS::nativeOpenKeyboard() +{ + _systemControl.textField.hidden = NO; + [_systemControl openKeyboard]; +} + +void EditBoxImplIOS::nativeCloseKeyboard() +{ + [_systemControl closeKeyboard]; +} + +UIFont* EditBoxImplIOS::constructFont(const char *fontName, int fontSize) +{ + CCASSERT(fontName != nullptr, "fontName can't be nullptr"); + CCEAGLView *eaglview = static_cast(cocos2d::Director::getInstance()->getOpenGLView()->getEAGLView()); + float retinaFactor = eaglview.contentScaleFactor; + NSString * fntName = [NSString stringWithUTF8String:fontName]; + + auto glview = cocos2d::Director::getInstance()->getOpenGLView(); + float scaleFactor = glview->getScaleX(); + + if (fontSize == -1) + { + fontSize = [_systemControl.textField frame].size.height*2/3; + } + else + { + fontSize = fontSize * scaleFactor / retinaFactor; + } + + UIFont *textFont = nil; + if (strlen(fontName) > 0) + { + textFont = [UIFont fontWithName:fntName size:fontSize]; + } + else + { + textFont = [UIFont systemFontOfSize:fontSize]; + } + return textFont; +} + +void EditBoxImplIOS::setPosition(const Vec2& pos) +{ + _position = pos; + adjustTextFieldPosition(); +} + +void EditBoxImplIOS::setAnchorPoint(const Vec2& anchorPoint) +{ + CCLOG("[Edit text] anchor point = (%f, %f)", anchorPoint.x, anchorPoint.y); + _anchorPoint = anchorPoint; + setPosition(_position); +} + +void EditBoxImplIOS::updatePosition(float dt) +{ + if (nullptr != _systemControl) { + this->adjustTextFieldPosition(); + } } static CGPoint convertDesignCoordToScreenCoord(const Vec2& designCoord) { auto glview = cocos2d::Director::getInstance()->getOpenGLView(); CCEAGLView *eaglview = (CCEAGLView *) glview->getEAGLView(); - + float viewH = (float)[eaglview getHeight]; Vec2 visiblePos = Vec2(designCoord.x * glview->getScaleX(), designCoord.y * glview->getScaleY()); @@ -644,66 +551,11 @@ static CGPoint convertDesignCoordToScreenCoord(const Vec2& designCoord) float factor = eaglview.contentScaleFactor; screenPos.x = screenPos.x / factor; screenPos.y = screenPos.y / factor; - + CCLOGINFO("[EditBox] pos x = %f, y = %f", screenGLPos.x, screenGLPos.y); return screenPos; } -void EditBoxImplIOS::setPosition(const Vec2& pos) -{ - _position = pos; - adjustTextFieldPosition(); -} - -void EditBoxImplIOS::setVisible(bool visible) -{ -// _systemControl.textField.hidden = !visible; -} - -void EditBoxImplIOS::setContentSize(const Size& size) -{ - _contentSize = size; - CCLOG("[Edit text] content size = (%f, %f)", size.width, size.height); - placeInactiveLabels(); - auto glview = cocos2d::Director::getInstance()->getOpenGLView(); - CGSize controlSize = CGSizeMake(size.width * glview->getScaleX(),size.height * glview->getScaleY()); - - CCEAGLView *eaglview = static_cast(glview->getEAGLView()); - float factor = eaglview.contentScaleFactor; - controlSize.width /= factor; - controlSize.height /= factor; - - [_systemControl setContentSize:controlSize]; -} - -void EditBoxImplIOS::setAnchorPoint(const Vec2& anchorPoint) -{ - CCLOG("[Edit text] anchor point = (%f, %f)", anchorPoint.x, anchorPoint.y); - _anchorPoint = anchorPoint; - setPosition(_position); -} - -void EditBoxImplIOS::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) -{ -} - -void EditBoxImplIOS::onEnter(void) -{ - adjustTextFieldPosition(); - const char* pText = getText(); - if (pText) { - setInactiveText(pText); - } -} - -void EditBoxImplIOS::updatePosition(float dt) -{ - if (nullptr != _systemControl) { - this->adjustTextFieldPosition(); - } -} - - void EditBoxImplIOS::adjustTextFieldPosition() { @@ -715,36 +567,6 @@ void EditBoxImplIOS::adjustTextFieldPosition() [_systemControl setPosition:convertDesignCoordToScreenCoord(designCoord)]; } -void EditBoxImplIOS::openKeyboard() -{ - _label->setVisible(false); - _labelPlaceHolder->setVisible(false); - - _systemControl.textField.hidden = NO; - [_systemControl openKeyboard]; -} - -void EditBoxImplIOS::closeKeyboard() -{ - [_systemControl closeKeyboard]; -} - -void EditBoxImplIOS::onEndEditing() -{ - _systemControl.textField.hidden = YES; - if(strlen(getText()) == 0) - { - _label->setVisible(false); - _labelPlaceHolder->setVisible(true); - } - else - { - _label->setVisible(true); - _labelPlaceHolder->setVisible(false); - setInactiveText(getText()); - } -} - } NS_CC_END diff --git a/cocos/ui/UIHelper.cpp b/cocos/ui/UIHelper.cpp index 9345a4bb3e..5bdde18f67 100644 --- a/cocos/ui/UIHelper.cpp +++ b/cocos/ui/UIHelper.cpp @@ -193,25 +193,25 @@ Rect Helper::restrictCapInsetRect(const cocos2d::Rect &capInsets, const Size& te return Rect(x, y, width, height); } - Rect Helper::convertBoundingBoxToScreen(Node* node) - { - auto director = Director::getInstance(); - auto glView = director->getOpenGLView(); - auto frameSize = glView->getFrameSize(); +Rect Helper::convertBoundingBoxToScreen(Node* node) +{ + auto director = Director::getInstance(); + auto glView = director->getOpenGLView(); + auto frameSize = glView->getFrameSize(); - auto winSize = director->getWinSize(); - auto leftBottom = node->convertToWorldSpace(Point::ZERO); + auto winSize = director->getWinSize(); + auto leftBottom = node->convertToWorldSpace(Point::ZERO); - auto contentSize = node->getContentSize(); - auto rightTop = node->convertToWorldSpace(Point(contentSize.width, contentSize.height)); + auto contentSize = node->getContentSize(); + auto rightTop = node->convertToWorldSpace(Point(contentSize.width, contentSize.height)); - auto uiLeft = frameSize.width / 2 + (leftBottom.x - winSize.width / 2 ) * glView->getScaleX(); - auto uiTop = frameSize.height /2 - (rightTop.y - winSize.height / 2) * glView->getScaleY(); - - return Rect(uiLeft,uiTop, - (rightTop.x - leftBottom.x) * glView->getScaleX(), - (rightTop.y - leftBottom.y) * glView->getScaleY()); - } + auto uiLeft = frameSize.width / 2 + (leftBottom.x - winSize.width / 2 ) * glView->getScaleX(); + auto uiTop = frameSize.height /2 - (rightTop.y - winSize.height / 2) * glView->getScaleY(); + auto uiWidth = (rightTop.x - leftBottom.x) * glView->getScaleX(); + auto uiHeight = (rightTop.y - leftBottom.y) * glView->getScaleY(); + + return Rect(uiLeft, uiTop, uiWidth, uiHeight); +} } NS_CC_END diff --git a/cocos/ui/UIScrollView.cpp b/cocos/ui/UIScrollView.cpp index 2c23915930..34f405b159 100644 --- a/cocos/ui/UIScrollView.cpp +++ b/cocos/ui/UIScrollView.cpp @@ -31,11 +31,10 @@ THE SOFTWARE. #include "2d/CCCamera.h" NS_CC_BEGIN -namespace ui { - -static const float INERTIA_DEACCELERATION = 700.0f; -static const float INERTIA_VELOCITY_MAX = 2500; +static const float OUT_OF_BOUND_TIME_RESCALE = 0.05f; +static const float OUT_OF_BOUND_DISTANCE_RESCALE = 0.05f; static const float BOUNCE_BACK_DURATION = 1.0f; + #define MOVE_INCH 7.0f/160.0f static float convertDistanceFromPointToInch(const Vec2& dis) @@ -46,6 +45,8 @@ static float convertDistanceFromPointToInch(const Vec2& dis) return distance; } +namespace ui { + IMPLEMENT_CLASS_GUI_INFO(ScrollView) ScrollView::ScrollView(): @@ -57,17 +58,17 @@ _leftBoundary(0.0f), _rightBoundary(0.0f), _bePressed(false), _childFocusCancelOffsetInInch(MOVE_INCH), -_inertiaScrollEnabled(true), -_inertiaScrolling(false), -_inertiaPrevTouchTimestamp(0), -_inertiaScrollExpectedTime(0), -_inertiaScrollElapsedTime(0), +_touchMovePreviousTimestamp(0), _autoScrolling(false), _autoScrollAttenuate(true), _autoScrollDuration(0), _autoScrollAccumulatedTime(0), +_autoScrollCompleteCallback(nullptr), +_autoScrollMoveCallback(nullptr), +_outOfBoundaryDuringInertiaScroll(false), +_inertiaScrollEnabled(true), +_inertiaScrolling(false), _bounceEnabled(false), -_bouncingBack(false), _scrollBarEnabled(true), _verticalScrollBar(nullptr), _horizontalScrollBar(nullptr), @@ -223,6 +224,10 @@ const Size& ScrollView::getInnerContainerSize() const void ScrollView::setInnerContainerPosition(const Vec2 &position) { + if(position == _innerContainer->getPosition()) + { + return; + } _innerContainer->setPosition(position); this->retain(); @@ -340,8 +345,27 @@ bool ScrollView::startBounceBackIfNeeded() return false; } - _bouncingBack = true; - startAutoScroll(outOfBoundary, BOUNCE_BACK_DURATION, true); + startAutoScroll(outOfBoundary, BOUNCE_BACK_DURATION, true, + nullptr, + [this](const Vec2& moveDelta) { + if(moveDelta.x > 0) + { + processScrollEvent(MoveDirection::RIGHT, true); + } + else if(moveDelta.x < 0) + { + processScrollEvent(MoveDirection::LEFT, true); + } + if(moveDelta.y > 0) + { + processScrollEvent(MoveDirection::TOP, true); + } + else if(moveDelta.y < 0) + { + processScrollEvent(MoveDirection::BOTTOM, true); + } + } + ); return true; } @@ -369,57 +393,16 @@ Vec2 ScrollView::getHowMuchOutOfBoundary(const Vec2& addition) const return result; } -void ScrollView::processAutoScrolling(float deltaTime) -{ - _autoScrollAccumulatedTime += deltaTime; - float percentage = _autoScrollAccumulatedTime / _autoScrollDuration; - if(percentage >= 1) - { - moveChildrenToPosition(_autoScrollStartPosition + _autoScrollTargetDelta); - _autoScrolling = false; - _bouncingBack = false; - } - else - { - if(_autoScrollAttenuate) - { - percentage = tweenfunc::quintEaseOut(percentage); - } - Vec2 moveDelta = _autoScrollTargetDelta * percentage; - moveChildrenToPosition(_autoScrollStartPosition + moveDelta); - - // Dispatch related events if bouncing - if(_bouncingBack) - { - if(moveDelta.x > 0) - { - processScrollEvent(MoveDirection::RIGHT, true); - } - else if(moveDelta.x < 0) - { - processScrollEvent(MoveDirection::LEFT, true); - } - if(moveDelta.y > 0) - { - processScrollEvent(MoveDirection::TOP, true); - } - else if(moveDelta.y < 0) - { - processScrollEvent(MoveDirection::BOTTOM, true); - } - } - } -} - bool ScrollView::isOutOfBoundary(MoveDirection dir) const { switch(dir) { - case MoveDirection::TOP: return _innerContainer->getTopBoundary() < _topBoundary; - case MoveDirection::BOTTOM: return _innerContainer->getBottomBoundary() > _bottomBoundary; - case MoveDirection::LEFT: return _innerContainer->getLeftBoundary() > _leftBoundary; - case MoveDirection::RIGHT: return _innerContainer->getRightBoundary() < _rightBoundary; + case MoveDirection::TOP: return _innerContainer->getTopBoundary() < _topBoundary; + case MoveDirection::BOTTOM: return _innerContainer->getBottomBoundary() > _bottomBoundary; + case MoveDirection::LEFT: return _innerContainer->getLeftBoundary() > _leftBoundary; + case MoveDirection::RIGHT: return _innerContainer->getRightBoundary() < _rightBoundary; } + return false; } bool ScrollView::isOutOfBoundaryTopOrBottom() const @@ -432,7 +415,17 @@ bool ScrollView::isOutOfBoundaryLeftOrRight() const return isOutOfBoundary(MoveDirection::LEFT) || isOutOfBoundary(MoveDirection::RIGHT); } -void ScrollView::startAutoScroll(const Vec2& deltaMove, float duration, bool attenuated) +bool ScrollView::isOutOfBoundary() const +{ + return isOutOfBoundaryTopOrBottom() || isOutOfBoundaryLeftOrRight(); +} + +void ScrollView::startAutoScrollChildrenWithDestination(const Vec2& des, float second, bool attenuated) +{ + startAutoScroll(des - _innerContainer->getPosition(), second, attenuated); +} + +void ScrollView::startAutoScroll(const Vec2& deltaMove, float duration, bool attenuated, std::function completeCallback, std::function moveCallback) { _autoScrolling = true; _autoScrollTargetDelta = deltaMove; @@ -440,11 +433,79 @@ void ScrollView::startAutoScroll(const Vec2& deltaMove, float duration, bool att _autoScrollStartPosition = _innerContainer->getPosition(); _autoScrollDuration = duration; _autoScrollAccumulatedTime = 0; + _autoScrollCompleteCallback = completeCallback; + _autoScrollMoveCallback = moveCallback; + _outOfBoundaryDuringInertiaScroll = false; + _outOfBoundaryPositionDuringInertiaScroll = Vec2::ZERO; } -void ScrollView::startAutoScrollChildrenWithDestination(const Vec2& des, float second, bool attenuated) +void ScrollView::processAutoScrolling(float deltaTime) { - startAutoScroll(des - _innerContainer->getPosition(), second, attenuated); + // Shorten the auto scroll distance and time if it is out of boundary during inertia scroll. + float timeRescale = 1; + float distanceRescale = 1; + { + bool currentlyOutOfBoundDuringInertiaScroll = (_inertiaScrolling && isOutOfBoundary()); + if(!_outOfBoundaryDuringInertiaScroll && currentlyOutOfBoundDuringInertiaScroll) + { + _outOfBoundaryDuringInertiaScroll = true; + _outOfBoundaryPositionDuringInertiaScroll = getInnerContainerPosition(); + } + timeRescale = (_outOfBoundaryDuringInertiaScroll ? OUT_OF_BOUND_TIME_RESCALE : 1); + distanceRescale = (_outOfBoundaryDuringInertiaScroll ? OUT_OF_BOUND_DISTANCE_RESCALE : 1); + } + + // Calculate the percentage + float percentage = 0; + { + _autoScrollAccumulatedTime += deltaTime * (1 / timeRescale); + percentage = MIN(1, _autoScrollAccumulatedTime / _autoScrollDuration); + if(_autoScrollAttenuate) + { + // Use quintic(5th degree) polynomial + percentage = tweenfunc::quintEaseOut(percentage); + } + } + + // Calculate the new position + Vec2 deltaFromInitialPosition = _autoScrollTargetDelta * percentage; + Vec2 newPosition = _autoScrollStartPosition + deltaFromInitialPosition; + bool reachedEnd = false; + + // Adjust the new position according to the bounce opiton + { + if(_bounceEnabled) + { + newPosition = _outOfBoundaryPositionDuringInertiaScroll + (newPosition - _outOfBoundaryPositionDuringInertiaScroll) * distanceRescale; + } + else + { + Vec2 moveDelta = newPosition - getInnerContainerPosition(); + Vec2 outOfBoundary = getHowMuchOutOfBoundary(moveDelta); + if(outOfBoundary != Vec2::ZERO) + { + newPosition += outOfBoundary; + reachedEnd = true; + } + } + } + + moveChildrenToPosition(newPosition); + + if(_autoScrollMoveCallback) + { + _autoScrollMoveCallback(getInnerContainerPosition() - newPosition); + } + + // Finish auto scroll if it ended + if(percentage == 1 || reachedEnd) + { + _autoScrolling = false; + if(_autoScrollCompleteCallback) + { + _autoScrollCompleteCallback(); + } + } } void ScrollView::jumpToDestination(const Vec2 &des) @@ -462,75 +523,43 @@ void ScrollView::jumpToDestination(const Vec2 &des) moveChildrenToPosition(Vec2(finalOffsetX, finalOffsetY)); } -void ScrollView::startInertiaScroll() +Vec2 ScrollView::calculateTouchMoveVelocity() const { float totalDuration = 0; - for(auto &timeDelta : _inertiaTouchTimeDeltas) - { - totalDuration += timeDelta; - } + for(auto &timeDelta : _touchMoveTimeDeltas) + { + totalDuration += timeDelta; + } if(totalDuration == 0 || totalDuration >= 0.5f) { - return; + return Vec2::ZERO; } - _inertiaScrolling = true; - - // Calcualte the initial velocity Vec2 totalMovement; - for(auto &displacement : _inertiaTouchDisplacements) - { - totalMovement += displacement; - } - - for(auto i = _inertiaTouchDisplacements.begin(); i != _inertiaTouchDisplacements.end(); ++i) + for(auto &displacement : _touchMoveDisplacements) { - totalMovement += (*i); + totalMovement += displacement; } - totalMovement.x = (_direction == Direction::VERTICAL ? 0 : totalMovement.x); - totalMovement.y = (_direction == Direction::HORIZONTAL ? 0 : totalMovement.y); - - _inertiaInitiVelocity = totalMovement / totalDuration; - _inertiaInitiVelocity.x = MIN(_inertiaInitiVelocity.x, INERTIA_VELOCITY_MAX); - _inertiaInitiVelocity.y = MIN(_inertiaInitiVelocity.y, INERTIA_VELOCITY_MAX); - _inertiaInitiVelocity.x = MAX(_inertiaInitiVelocity.x, -INERTIA_VELOCITY_MAX); - _inertiaInitiVelocity.y = MAX(_inertiaInitiVelocity.y, -INERTIA_VELOCITY_MAX); - - // Calculate values for ease out - _inertiaScrollExpectedTime = _inertiaInitiVelocity.length() / INERTIA_DEACCELERATION; - _inertiaScrollElapsedTime = 0; + return totalMovement / totalDuration; } -void ScrollView::processInertiaScrolling(float dt) +void ScrollView::startInertiaScroll(const Vec2& touchMoveVelocity) { - _inertiaScrollElapsedTime += dt; - if(isOutOfBoundaryLeftOrRight() || isOutOfBoundaryTopOrBottom()) - { - // If the inner container is out of boundary, shorten the inertia time. - _inertiaScrollElapsedTime += dt * (45000 / INERTIA_DEACCELERATION); - } - float percentage = _inertiaScrollElapsedTime / _inertiaScrollExpectedTime; - if(percentage >= 1) - { + Vec2 initialVelocity = touchMoveVelocity; + initialVelocity.x = (_direction == Direction::VERTICAL ? 0 : initialVelocity.x); + initialVelocity.y = (_direction == Direction::HORIZONTAL ? 0 : initialVelocity.y); + + const float MOVEMENT_FACTOR = 0.7f; + Vec2 inertiaTotalDisplacement = initialVelocity * MOVEMENT_FACTOR; + + // Calculate the duration from the initial velocity according to quintic polynomial. + float duration = sqrtf(sqrtf(initialVelocity.length() / 5)); + + _inertiaScrolling = true; + startAutoScroll(inertiaTotalDisplacement, duration, true, [this]() { _inertiaScrolling = false; startBounceBackIfNeeded(); - return; - } - percentage = tweenfunc::quartEaseOut(percentage); - - Vec2 inertiaVelocity = _inertiaInitiVelocity * (1 - percentage); - Vec2 displacement = inertiaVelocity * dt; - if(!_bounceEnabled) - { - Vec2 outOfBoundary = getHowMuchOutOfBoundary(displacement); - if(outOfBoundary != Vec2::ZERO) - { - // Don't allow to go out of boundary - displacement += outOfBoundary; - _inertiaScrolling = false; - } - } - moveChildren(displacement.x, displacement.y); + }); } bool ScrollView::scrollChildren(float touchOffsetX, float touchOffsetY) @@ -803,36 +832,18 @@ void ScrollView::jumpToPercentBothDirection(const Vec2& percent) jumpToDestination(Vec2(-(percent.x * w / 100.0f), minY + percent.y * h / 100.0f)); } -void ScrollView::startRecordSlidAction() -{ - if (_inertiaScrolling) - { - _inertiaScrolling = false; - } - if(_autoScrolling) - { - _autoScrolling = false; - _bouncingBack = false; - } -} - -void ScrollView::endRecordSlidAction() -{ - bool bounceBackStarted = startBounceBackIfNeeded(); - if(!bounceBackStarted && _inertiaScrollEnabled) - { - startInertiaScroll(); - } -} - void ScrollView::handlePressLogic(Touch *touch) { - startRecordSlidAction(); _bePressed = true; - - _inertiaPrevTouchTimestamp = utils::getTimeInMilliseconds(); - _inertiaTouchDisplacements.clear(); - _inertiaTouchTimeDeltas.clear(); + _autoScrolling = false; + _inertiaScrolling = false; + + // Initialize touch move information + { + _touchMovePreviousTimestamp = utils::getTimeInMilliseconds(); + _touchMoveDisplacements.clear(); + _touchMoveTimeDeltas.clear(); + } if(_verticalScrollBar != nullptr) { @@ -856,24 +867,36 @@ void ScrollView::handleMoveLogic(Touch *touch) Vec3 delta3 = currPt - prevPt; Vec2 delta(delta3.x, delta3.y); scrollChildren(delta.x, delta.y); - - while(_inertiaTouchDisplacements.size() > 5) + + // Gather touch move information for speed calculation { - _inertiaTouchDisplacements.pop_front(); - _inertiaTouchTimeDeltas.pop_front(); + while(_touchMoveDisplacements.size() > 5) + { + _touchMoveDisplacements.pop_front(); + _touchMoveTimeDeltas.pop_front(); + } + _touchMoveDisplacements.push_back(delta); + + long long timestamp = utils::getTimeInMilliseconds(); + _touchMoveTimeDeltas.push_back((timestamp - _touchMovePreviousTimestamp) / 1000.0f); + _touchMovePreviousTimestamp = timestamp; } - _inertiaTouchDisplacements.push_back(delta); - - long long timestamp = utils::getTimeInMilliseconds(); - _inertiaTouchTimeDeltas.push_back((timestamp - _inertiaPrevTouchTimestamp) / 1000.0f); - _inertiaPrevTouchTimestamp = timestamp; } void ScrollView::handleReleaseLogic(Touch *touch) { - endRecordSlidAction(); _bePressed = false; + bool bounceBackStarted = startBounceBackIfNeeded(); + if(!bounceBackStarted && _inertiaScrollEnabled) + { + Vec2 touchMoveVelocity = calculateTouchMoveVelocity(); + if(touchMoveVelocity != Vec2::ZERO) + { + startInertiaScroll(touchMoveVelocity); + } + } + if(_verticalScrollBar != nullptr) { _verticalScrollBar->onTouchEnded(); @@ -928,11 +951,7 @@ void ScrollView::onTouchCancelled(Touch *touch, Event *unusedEvent) void ScrollView::update(float dt) { - if (_inertiaScrolling) - { - processInertiaScrolling(dt); - } - else if (_autoScrolling) + if (_autoScrolling) { processAutoScrolling(dt); } @@ -1002,29 +1021,29 @@ void ScrollView::processScrollEvent(MoveDirection dir, bool bounce) ScrollviewEventType scrollEventType; EventType eventType; switch(dir) { - case MoveDirection::TOP: - { - scrollEventType = (bounce ? SCROLLVIEW_EVENT_BOUNCE_TOP : SCROLLVIEW_EVENT_SCROLL_TO_TOP); - eventType = (bounce ? EventType::BOUNCE_TOP : EventType::SCROLL_TO_TOP); - break; - } - case MoveDirection::BOTTOM: - { - scrollEventType = (bounce ? SCROLLVIEW_EVENT_BOUNCE_BOTTOM : SCROLLVIEW_EVENT_SCROLL_TO_BOTTOM); - eventType = (bounce ? EventType::BOUNCE_BOTTOM : EventType::SCROLL_TO_BOTTOM); - break; - } - case MoveDirection::LEFT: - { - scrollEventType = (bounce ? SCROLLVIEW_EVENT_BOUNCE_LEFT : SCROLLVIEW_EVENT_SCROLL_TO_LEFT); - eventType = (bounce ? EventType::BOUNCE_LEFT : EventType::SCROLL_TO_LEFT); - break; - } - case MoveDirection::RIGHT: - { - scrollEventType = (bounce ? SCROLLVIEW_EVENT_BOUNCE_RIGHT : SCROLLVIEW_EVENT_SCROLL_TO_RIGHT); - eventType = (bounce ? EventType::BOUNCE_RIGHT : EventType::SCROLL_TO_RIGHT); - break; + case MoveDirection::TOP: + { + scrollEventType = (bounce ? SCROLLVIEW_EVENT_BOUNCE_TOP : SCROLLVIEW_EVENT_SCROLL_TO_TOP); + eventType = (bounce ? EventType::BOUNCE_TOP : EventType::SCROLL_TO_TOP); + break; + } + case MoveDirection::BOTTOM: + { + scrollEventType = (bounce ? SCROLLVIEW_EVENT_BOUNCE_BOTTOM : SCROLLVIEW_EVENT_SCROLL_TO_BOTTOM); + eventType = (bounce ? EventType::BOUNCE_BOTTOM : EventType::SCROLL_TO_BOTTOM); + break; + } + case MoveDirection::LEFT: + { + scrollEventType = (bounce ? SCROLLVIEW_EVENT_BOUNCE_LEFT : SCROLLVIEW_EVENT_SCROLL_TO_LEFT); + eventType = (bounce ? EventType::BOUNCE_LEFT : EventType::SCROLL_TO_LEFT); + break; + } + case MoveDirection::RIGHT: + { + scrollEventType = (bounce ? SCROLLVIEW_EVENT_BOUNCE_RIGHT : SCROLLVIEW_EVENT_SCROLL_TO_RIGHT); + eventType = (bounce ? EventType::BOUNCE_RIGHT : EventType::SCROLL_TO_RIGHT); + break; } } dispatchEvent(scrollEventType, eventType); @@ -1351,22 +1370,22 @@ void ScrollView::copySpecialProperties(Widget *widget) _rightBoundary = scrollView->_rightBoundary; _bePressed = scrollView->_bePressed; _childFocusCancelOffsetInInch = scrollView->_childFocusCancelOffsetInInch; - setInertiaScrollEnabled(scrollView->_inertiaScrollEnabled); - _inertiaScrolling = scrollView->_inertiaScrolling; - _inertiaInitiVelocity = scrollView->_inertiaInitiVelocity; - _inertiaTouchDisplacements = scrollView->_inertiaTouchDisplacements; - _inertiaTouchTimeDeltas = scrollView->_inertiaTouchTimeDeltas; - _inertiaPrevTouchTimestamp = scrollView->_inertiaPrevTouchTimestamp; - _inertiaScrollExpectedTime = scrollView->_inertiaScrollExpectedTime; - _inertiaScrollElapsedTime = scrollView->_inertiaScrollElapsedTime; + _touchMoveDisplacements = scrollView->_touchMoveDisplacements; + _touchMoveTimeDeltas = scrollView->_touchMoveTimeDeltas; + _touchMovePreviousTimestamp = scrollView->_touchMovePreviousTimestamp; _autoScrolling = scrollView->_autoScrolling; _autoScrollAttenuate = scrollView->_autoScrollAttenuate; _autoScrollStartPosition = scrollView->_autoScrollStartPosition; _autoScrollTargetDelta = scrollView->_autoScrollTargetDelta; _autoScrollDuration = scrollView->_autoScrollDuration; _autoScrollAccumulatedTime = scrollView->_autoScrollAccumulatedTime; + _outOfBoundaryDuringInertiaScroll = scrollView->_outOfBoundaryDuringInertiaScroll; + _outOfBoundaryPositionDuringInertiaScroll = scrollView->_outOfBoundaryPositionDuringInertiaScroll; + _autoScrollCompleteCallback = scrollView->_autoScrollCompleteCallback; + _autoScrollMoveCallback = scrollView->_autoScrollMoveCallback; + setInertiaScrollEnabled(scrollView->_inertiaScrollEnabled); + _inertiaScrolling = scrollView->_inertiaScrolling; setBounceEnabled(scrollView->_bounceEnabled); - _bouncingBack = scrollView->_bouncingBack; _scrollViewEventListener = scrollView->_scrollViewEventListener; _scrollViewEventSelector = scrollView->_scrollViewEventSelector; _eventCallback = scrollView->_eventCallback; diff --git a/cocos/ui/UIScrollView.h b/cocos/ui/UIScrollView.h index 8f311ee458..f6a1247649 100644 --- a/cocos/ui/UIScrollView.h +++ b/cocos/ui/UIScrollView.h @@ -568,14 +568,16 @@ protected: bool isOutOfBoundary(MoveDirection dir) const; bool isOutOfBoundaryTopOrBottom() const; bool isOutOfBoundaryLeftOrRight() const; + bool isOutOfBoundary() const; void moveChildren(float offsetX, float offsetY); void moveChildrenToPosition(const Vec2& position); - void startInertiaScroll(); - void processInertiaScrolling(float dt); + Vec2 calculateTouchMoveVelocity() const; - void startAutoScroll(const Vec2& deltaMove, float duration, bool attenuated); + void startInertiaScroll(const Vec2& touchMoveVelocity); + + void startAutoScroll(const Vec2& deltaMove, float duration, bool attenuated, std::function completeCallback = nullptr, std::function moveCallback = nullptr); void startAutoScrollChildrenWithDestination(const Vec2& des, float second, bool attenuated); void processAutoScrolling(float deltaTime); @@ -585,10 +587,6 @@ protected: virtual bool scrollChildren(float touchOffsetX, float touchOffsetY); - void startRecordSlidAction(); - virtual void endRecordSlidAction(); - - //ScrollViewProtocol virtual void handlePressLogic(Touch *touch); virtual void handleMoveLogic(Touch *touch); virtual void handleReleaseLogic(Touch *touch); @@ -616,25 +614,28 @@ protected: bool _bePressed; float _childFocusCancelOffsetInInch; - - bool _inertiaScrollEnabled; - bool _inertiaScrolling; - Vec2 _inertiaInitiVelocity; - std::list _inertiaTouchDisplacements; - std::list _inertiaTouchTimeDeltas; - long long _inertiaPrevTouchTimestamp; - float _inertiaScrollExpectedTime; - float _inertiaScrollElapsedTime; - + + // Touch move speed + std::list _touchMoveDisplacements; + std::list _touchMoveTimeDeltas; + long long _touchMovePreviousTimestamp; + bool _autoScrolling; bool _autoScrollAttenuate; Vec2 _autoScrollStartPosition; Vec2 _autoScrollTargetDelta; float _autoScrollDuration; float _autoScrollAccumulatedTime; + bool _outOfBoundaryDuringInertiaScroll; + Vec2 _outOfBoundaryPositionDuringInertiaScroll; + std::function _autoScrollCompleteCallback; + std::function _autoScrollMoveCallback; + // Inertia scroll + bool _inertiaScrollEnabled; + bool _inertiaScrolling; + bool _bounceEnabled; - bool _bouncingBack; bool _scrollBarEnabled; ScrollViewBar* _verticalScrollBar; diff --git a/templates/cocos2dx_files.json b/templates/cocos2dx_files.json index 3683794f2a..84efb25a58 100644 --- a/templates/cocos2dx_files.json +++ b/templates/cocos2dx_files.json @@ -3,6 +3,7 @@ "AUTHORS", "CHANGELOG", "CMakeLists.txt", + "CONTRIBUTING.md", "README.cmake", "README.md", "build/android-build.py", @@ -830,6 +831,8 @@ "cocos/network/SocketIO.h", "cocos/network/WebSocket.cpp", "cocos/network/WebSocket.h", + "cocos/physics/CCComponentPhysics2d.cpp", + "cocos/physics/CCComponentPhysics2d.h", "cocos/physics/CCPhysicsBody.cpp", "cocos/physics/CCPhysicsBody.h", "cocos/physics/CCPhysicsContact.cpp", @@ -837,6 +840,8 @@ "cocos/physics/CCPhysicsHelper.h", "cocos/physics/CCPhysicsJoint.cpp", "cocos/physics/CCPhysicsJoint.h", + "cocos/physics/CCPhysicsManager.cpp", + "cocos/physics/CCPhysicsManager.h", "cocos/physics/CCPhysicsShape.cpp", "cocos/physics/CCPhysicsShape.h", "cocos/physics/CCPhysicsWorld.cpp", @@ -1195,6 +1200,8 @@ "cocos/ui/UIEditBox/UIEditBox.h", "cocos/ui/UIEditBox/UIEditBoxImpl-android.cpp", "cocos/ui/UIEditBox/UIEditBoxImpl-android.h", + "cocos/ui/UIEditBox/UIEditBoxImpl-common.cpp", + "cocos/ui/UIEditBox/UIEditBoxImpl-common.h", "cocos/ui/UIEditBox/UIEditBoxImpl-ios.h", "cocos/ui/UIEditBox/UIEditBoxImpl-ios.mm", "cocos/ui/UIEditBox/UIEditBoxImpl-mac.h", @@ -1265,7 +1272,6 @@ "cocos/ui/proj.win32/libui.vcxproj", "cocos/ui/proj.win32/libui.vcxproj.filters", "docs/CODING_STYLE.md", - "docs/CONTRIBUTE.md", "docs/Groups.h", "docs/MainPage.h", "docs/MainPageWhiteBook.h", @@ -6474,6 +6480,7 @@ "cocos/scripting/lua-bindings/auto/api/ComExtensionData.lua", "cocos/scripting/lua-bindings/auto/api/ComRender.lua", "cocos/scripting/lua-bindings/auto/api/Component.lua", + "cocos/scripting/lua-bindings/auto/api/ComponentPhysics2d.lua", "cocos/scripting/lua-bindings/auto/api/Console.lua", "cocos/scripting/lua-bindings/auto/api/ContourData.lua", "cocos/scripting/lua-bindings/auto/api/Control.lua", @@ -6676,6 +6683,7 @@ "cocos/scripting/lua-bindings/auto/api/PhysicsJointRotaryLimit.lua", "cocos/scripting/lua-bindings/auto/api/PhysicsJointRotarySpring.lua", "cocos/scripting/lua-bindings/auto/api/PhysicsJointSpring.lua", + "cocos/scripting/lua-bindings/auto/api/PhysicsManager.lua", "cocos/scripting/lua-bindings/auto/api/PhysicsShape.lua", "cocos/scripting/lua-bindings/auto/api/PhysicsShapeBox.lua", "cocos/scripting/lua-bindings/auto/api/PhysicsShapeCircle.lua", diff --git a/templates/cpp-template-default/cocos-project-template.json b/templates/cpp-template-default/cocos-project-template.json index 4bca350bc7..e5e3104fa3 100644 --- a/templates/cpp-template-default/cocos-project-template.json +++ b/templates/cpp-template-default/cocos-project-template.json @@ -49,6 +49,7 @@ "proj.android/build.xml", "proj.android/res/values/strings.xml", "proj.android-studio/settings.gradle", + "proj.android-studio/app/res/values/strings.xml", "proj.ios_mac/ios/main.m", "proj.ios_mac/ios/Prefix.pch", "proj.ios_mac/PROJECT_NAME.xcodeproj/project.pbxproj", diff --git a/templates/js-template-default/cocos-project-template.json b/templates/js-template-default/cocos-project-template.json index d069a1fdce..e0277c40dc 100644 --- a/templates/js-template-default/cocos-project-template.json +++ b/templates/js-template-default/cocos-project-template.json @@ -66,6 +66,7 @@ "frameworks/runtime-src/proj.android/build.xml", "frameworks/runtime-src/proj.android/res/values/strings.xml", "frameworks/runtime-src/proj.android-studio/settings.gradle", + "frameworks/runtime-src/proj.android-studio/app/res/values/strings.xml", "frameworks/runtime-src/proj.ios_mac/ios/main.m", "frameworks/runtime-src/proj.ios_mac/ios/Prefix.pch", "frameworks/runtime-src/proj.ios_mac/PROJECT_NAME.xcodeproj/project.pbxproj", diff --git a/templates/lua-template-default/cocos-project-template.json b/templates/lua-template-default/cocos-project-template.json index fb4eedf4e6..6d44944420 100644 --- a/templates/lua-template-default/cocos-project-template.json +++ b/templates/lua-template-default/cocos-project-template.json @@ -174,6 +174,7 @@ "frameworks/runtime-src/proj.android/build.xml", "frameworks/runtime-src/proj.android/res/values/strings.xml", "frameworks/runtime-src/proj.android-studio/settings.gradle", + "frameworks/runtime-src/proj.android-studio/app/res/values/strings.xml", "frameworks/runtime-src/proj.ios_mac/ios/main.m", "frameworks/runtime-src/proj.ios_mac/ios/Prefix.pch", "frameworks/runtime-src/proj.ios_mac/mac/SimulatorApp.mm", diff --git a/templates/lua-template-runtime/cocos-project-template.json b/templates/lua-template-runtime/cocos-project-template.json index 0671b8e5a2..a4f6b3779c 100644 --- a/templates/lua-template-runtime/cocos-project-template.json +++ b/templates/lua-template-runtime/cocos-project-template.json @@ -174,6 +174,7 @@ "frameworks/runtime-src/proj.android/build.xml", "frameworks/runtime-src/proj.android/res/values/strings.xml", "frameworks/runtime-src/proj.android-studio/settings.gradle", + "frameworks/runtime-src/proj.android-studio/app/res/values/strings.xml", "frameworks/runtime-src/proj.ios_mac/ios/main.m", "frameworks/runtime-src/proj.ios_mac/ios/Prefix.pch", "frameworks/runtime-src/proj.ios_mac/mac/SimulatorApp.mm", diff --git a/tests/cpp-tests/Classes/PhysicsTest/PhysicsTest.cpp b/tests/cpp-tests/Classes/PhysicsTest/PhysicsTest.cpp index c4441e7099..b63d7b63fd 100644 --- a/tests/cpp-tests/Classes/PhysicsTest/PhysicsTest.cpp +++ b/tests/cpp-tests/Classes/PhysicsTest/PhysicsTest.cpp @@ -1,18 +1,22 @@ #include "PhysicsTest.h" + +#if CC_USE_PHYSICS + #include -#include "../testResource.h" #include "ui/CocosGUI.h" +#include "physics/CCComponentPhysics2d.h" +#include "../testResource.h" + USING_NS_CC; PhysicsTests::PhysicsTests() { -#if CC_USE_PHYSICS ADD_TEST_CASE(PhysicsDemoLogoSmash); ADD_TEST_CASE(PhysicsDemoPyramidStack); ADD_TEST_CASE(PhysicsDemoClickAdd); ADD_TEST_CASE(PhysicsDemoRayCast); - ADD_TEST_CASE(PhysicsDemoJoints); ADD_TEST_CASE(PhysicsDemoActions); + ADD_TEST_CASE(PhysicsDemoJoints); ADD_TEST_CASE(PhysicsDemoPump); ADD_TEST_CASE(PhysicsDemoOneWayPlatform); ADD_TEST_CASE(PhysicsDemoSlice); @@ -20,38 +24,26 @@ PhysicsTests::PhysicsTests() ADD_TEST_CASE(PhysicsContactTest); ADD_TEST_CASE(PhysicsPositionRotationTest); ADD_TEST_CASE(PhysicsSetGravityEnableTest); - ADD_TEST_CASE(Bug5482); + ADD_TEST_CASE(PhysicsDemoBug5482); ADD_TEST_CASE(PhysicsFixedUpdate); ADD_TEST_CASE(PhysicsTransformTest); ADD_TEST_CASE(PhysicsIssue9959); -#else - ADD_TEST_CASE(PhysicsDemoDisabled); -#endif } - -static const Color4F STATIC_COLOR(1.0f, 0.0f, 0.0f, 1.0f); -static const int DRAG_BODYS_TAG = 0x80; + +namespace +{ + Color4F STATIC_COLOR(1.0f, 0.0f, 0.0f, 1.0f); + const int DRAG_BODYS_TAG = 0x80; +} void PhysicsDemo::toggleDebug() { #if CC_USE_PHYSICS _debugDraw = !_debugDraw; - getPhysicsWorld()->setDebugDrawMask(_debugDraw ? PhysicsWorld::DEBUGDRAW_ALL : PhysicsWorld::DEBUGDRAW_NONE); + _physicsWorld->setDebugDrawMask(_debugDraw ? PhysicsWorld::DEBUGDRAW_ALL : PhysicsWorld::DEBUGDRAW_NONE); #endif } -#if CC_USE_PHYSICS == 0 -void PhysicsDemoDisabled::onEnter() -{ - auto label = Label::createWithTTF("Should define CC_USE_PHYSICS\n to run this test case", - "fonts/arial.ttf", - 18); - auto size = Director::getInstance()->getWinSize(); - label->setPosition(Vec2(size.width/2, size.height/2)); - - addChild(label); -} -#else PhysicsDemo::PhysicsDemo() : _spriteTexture(nullptr) @@ -60,22 +52,19 @@ PhysicsDemo::PhysicsDemo() { } -PhysicsDemo::~PhysicsDemo() -{ - -} - bool PhysicsDemo::init() { - if (TestCase::init()) - { - return initWithPhysics(); - } - return false; + TestCase::init(); + return initWithPhysics(); } + +PhysicsDemo::~PhysicsDemo() +{ +} + std::string PhysicsDemo::title() const { - return "PhysicsTest"; + return "PhysicsComponentTest"; } void PhysicsDemo::onEnter() @@ -90,12 +79,12 @@ void PhysicsDemo::onEnter() auto menu = Menu::create(item, nullptr); this->addChild(menu); - menu->setPosition(Vec2(VisibleRect::right().x-50, VisibleRect::top().y-10)); + menu->setPosition(Vec2(VisibleRect::right().x - item->getContentSize().width / 2 - 10, VisibleRect::top().y - item->getContentSize().height / 2 - 10)); } Sprite* PhysicsDemo::addGrossiniAtPosition(Vec2 p, float scale/* = 1.0*/) { - CCLOG("Add sprite %0.2f x %02.f",p.x,p.y); + CCLOG("Add sprite %0.2f x %02.f", p.x, p.y); int posx, posy; @@ -106,10 +95,12 @@ Sprite* PhysicsDemo::addGrossiniAtPosition(Vec2 p, float scale/* = 1.0*/) posy = (posy % 3) * 121; auto sp = Sprite::createWithTexture(_spriteTexture, Rect(posx, posy, 85, 121)); + sp->setScale(scale); - sp->setPhysicsBody(PhysicsBody::createBox(Size(48.0f * scale, 108.0f * scale))); - this->addChild(sp); sp->setPosition(p); + addPhysicsComponent(sp, PhysicsBody::createBox(Size(48.0f, 108.0f))); + //addPhysicsComponent(sp, PhysicsBody::createCircle(sp->getContentSize().height/2)); + this->addChild(sp); return sp; } @@ -119,116 +110,56 @@ void PhysicsDemo::toggleDebugCallback(Ref* sender) toggleDebug(); } -PhysicsDemoClickAdd::~PhysicsDemoClickAdd() -{ - Device::setAccelerometerEnabled(false); -} - -void PhysicsDemoClickAdd::onEnter() -{ - PhysicsDemo::onEnter(); - - auto touchListener = EventListenerTouchAllAtOnce::create(); - touchListener->onTouchesEnded = CC_CALLBACK_2(PhysicsDemoClickAdd::onTouchesEnded, this); - _eventDispatcher->addEventListenerWithSceneGraphPriority(touchListener, this); - - Device::setAccelerometerEnabled(true); - auto accListener = EventListenerAcceleration::create(CC_CALLBACK_2(PhysicsDemoClickAdd::onAcceleration, this)); - _eventDispatcher->addEventListenerWithSceneGraphPriority(accListener, this); - - auto node = Node::create(); - node->setPhysicsBody(PhysicsBody::createEdgeBox(VisibleRect::getVisibleRect().size)); - node->setPosition(VisibleRect::center()); - this->addChild(node); - - addGrossiniAtPosition(VisibleRect::center()); -} - -std::string PhysicsDemoClickAdd::subtitle() const -{ - return "multi touch to add grossini"; -} - -void PhysicsDemoClickAdd::onTouchesEnded(const std::vector& touches, Event* event) -{ - //Add a new body/atlas sprite at the touched location - - for( auto &touch: touches) - { - auto location = touch->getLocation(); - - addGrossiniAtPosition( location ); - } -} - -void PhysicsDemoClickAdd::onAcceleration(Acceleration* acc, Event* event) -{ - static float prevX=0, prevY=0; - -#define kFilterFactor 0.05f - - float accelX = (float) acc->x * kFilterFactor + (1- kFilterFactor)*prevX; - float accelY = (float) acc->y * kFilterFactor + (1- kFilterFactor)*prevY; - - prevX = accelX; - prevY = accelY; - - auto v = Vec2( accelX, accelY); - v = v * 200; - - getPhysicsWorld()->setGravity(v); -} - namespace { - static const int logo_width = 188; - static const int logo_height = 35; - static const int logo_row_length = 24; - static const char logo_image[] = + const int LOGO_WIDTH = 188; + const int LOGO_HEIGHT = 35; + const int LOGO_RAW_LENGTH = 24; + const char LOGO_IMAGE[] = { - 15,-16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7,-64,15,63,-32,-2,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,31,-64,15,127,-125,-1,-128,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,127,-64,15,127,15,-1,-64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,-1,-64,15,-2, - 31,-1,-64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,-1,-64,0,-4,63,-1,-32,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,1,-1,-64,15,-8,127,-1,-32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 1,-1,-64,0,-8,-15,-1,-32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,-31,-1,-64,15,-8,-32, - -1,-32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7,-15,-1,-64,9,-15,-32,-1,-32,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,31,-15,-1,-64,0,-15,-32,-1,-32,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,63,-7,-1,-64,9,-29,-32,127,-61,-16,63,15,-61,-1,-8,31,-16,15,-8,126,7,-31, - -8,31,-65,-7,-1,-64,9,-29,-32,0,7,-8,127,-97,-25,-1,-2,63,-8,31,-4,-1,15,-13, - -4,63,-1,-3,-1,-64,9,-29,-32,0,7,-8,127,-97,-25,-1,-2,63,-8,31,-4,-1,15,-13, - -2,63,-1,-3,-1,-64,9,-29,-32,0,7,-8,127,-97,-25,-1,-1,63,-4,63,-4,-1,15,-13, - -2,63,-33,-1,-1,-32,9,-25,-32,0,7,-8,127,-97,-25,-1,-1,63,-4,63,-4,-1,15,-13, - -1,63,-33,-1,-1,-16,9,-25,-32,0,7,-8,127,-97,-25,-1,-1,63,-4,63,-4,-1,15,-13, - -1,63,-49,-1,-1,-8,9,-57,-32,0,7,-8,127,-97,-25,-8,-1,63,-2,127,-4,-1,15,-13, - -1,-65,-49,-1,-1,-4,9,-57,-32,0,7,-8,127,-97,-25,-8,-1,63,-2,127,-4,-1,15,-13, - -1,-65,-57,-1,-1,-2,9,-57,-32,0,7,-8,127,-97,-25,-8,-1,63,-2,127,-4,-1,15,-13, - -1,-1,-57,-1,-1,-1,9,-57,-32,0,7,-1,-1,-97,-25,-8,-1,63,-1,-1,-4,-1,15,-13,-1, - -1,-61,-1,-1,-1,-119,-57,-32,0,7,-1,-1,-97,-25,-8,-1,63,-1,-1,-4,-1,15,-13,-1, - -1,-61,-1,-1,-1,-55,-49,-32,0,7,-1,-1,-97,-25,-8,-1,63,-1,-1,-4,-1,15,-13,-1, - -1,-63,-1,-1,-1,-23,-49,-32,127,-57,-1,-1,-97,-25,-1,-1,63,-1,-1,-4,-1,15,-13, - -1,-1,-63,-1,-1,-1,-16,-49,-32,-1,-25,-1,-1,-97,-25,-1,-1,63,-33,-5,-4,-1,15, - -13,-1,-1,-64,-1,-9,-1,-7,-49,-32,-1,-25,-8,127,-97,-25,-1,-1,63,-33,-5,-4,-1, - 15,-13,-1,-1,-64,-1,-13,-1,-32,-49,-32,-1,-25,-8,127,-97,-25,-1,-2,63,-49,-13, - -4,-1,15,-13,-1,-1,-64,127,-7,-1,-119,-17,-15,-1,-25,-8,127,-97,-25,-1,-2,63, - -49,-13,-4,-1,15,-13,-3,-1,-64,127,-8,-2,15,-17,-1,-1,-25,-8,127,-97,-25,-1, - -8,63,-49,-13,-4,-1,15,-13,-3,-1,-64,63,-4,120,0,-17,-1,-1,-25,-8,127,-97,-25, - -8,0,63,-57,-29,-4,-1,15,-13,-4,-1,-64,63,-4,0,15,-17,-1,-1,-25,-8,127,-97, - -25,-8,0,63,-57,-29,-4,-1,-1,-13,-4,-1,-64,31,-2,0,0,103,-1,-1,-57,-8,127,-97, - -25,-8,0,63,-57,-29,-4,-1,-1,-13,-4,127,-64,31,-2,0,15,103,-1,-1,-57,-8,127, - -97,-25,-8,0,63,-61,-61,-4,127,-1,-29,-4,127,-64,15,-8,0,0,55,-1,-1,-121,-8, - 127,-97,-25,-8,0,63,-61,-61,-4,127,-1,-29,-4,63,-64,15,-32,0,0,23,-1,-2,3,-16, - 63,15,-61,-16,0,31,-127,-127,-8,31,-1,-127,-8,31,-128,7,-128,0,0 + 15, -16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, -64, 15, 63, -32, -2, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 31, -64, 15, 127, -125, -1, -128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 127, -64, 15, 127, 15, -1, -64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, -1, -64, 15, -2, + 31, -1, -64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, -1, -64, 0, -4, 63, -1, -32, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, -1, -64, 15, -8, 127, -1, -32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, -1, -64, 0, -8, -15, -1, -32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, -31, -1, -64, 15, -8, -32, + -1, -32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, -15, -1, -64, 9, -15, -32, -1, -32, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 31, -15, -1, -64, 0, -15, -32, -1, -32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 63, -7, -1, -64, 9, -29, -32, 127, -61, -16, 63, 15, -61, -1, -8, 31, -16, 15, -8, 126, 7, -31, + -8, 31, -65, -7, -1, -64, 9, -29, -32, 0, 7, -8, 127, -97, -25, -1, -2, 63, -8, 31, -4, -1, 15, -13, + -4, 63, -1, -3, -1, -64, 9, -29, -32, 0, 7, -8, 127, -97, -25, -1, -2, 63, -8, 31, -4, -1, 15, -13, + -2, 63, -1, -3, -1, -64, 9, -29, -32, 0, 7, -8, 127, -97, -25, -1, -1, 63, -4, 63, -4, -1, 15, -13, + -2, 63, -33, -1, -1, -32, 9, -25, -32, 0, 7, -8, 127, -97, -25, -1, -1, 63, -4, 63, -4, -1, 15, -13, + -1, 63, -33, -1, -1, -16, 9, -25, -32, 0, 7, -8, 127, -97, -25, -1, -1, 63, -4, 63, -4, -1, 15, -13, + -1, 63, -49, -1, -1, -8, 9, -57, -32, 0, 7, -8, 127, -97, -25, -8, -1, 63, -2, 127, -4, -1, 15, -13, + -1, -65, -49, -1, -1, -4, 9, -57, -32, 0, 7, -8, 127, -97, -25, -8, -1, 63, -2, 127, -4, -1, 15, -13, + -1, -65, -57, -1, -1, -2, 9, -57, -32, 0, 7, -8, 127, -97, -25, -8, -1, 63, -2, 127, -4, -1, 15, -13, + -1, -1, -57, -1, -1, -1, 9, -57, -32, 0, 7, -1, -1, -97, -25, -8, -1, 63, -1, -1, -4, -1, 15, -13, -1, + -1, -61, -1, -1, -1, -119, -57, -32, 0, 7, -1, -1, -97, -25, -8, -1, 63, -1, -1, -4, -1, 15, -13, -1, + -1, -61, -1, -1, -1, -55, -49, -32, 0, 7, -1, -1, -97, -25, -8, -1, 63, -1, -1, -4, -1, 15, -13, -1, + -1, -63, -1, -1, -1, -23, -49, -32, 127, -57, -1, -1, -97, -25, -1, -1, 63, -1, -1, -4, -1, 15, -13, + -1, -1, -63, -1, -1, -1, -16, -49, -32, -1, -25, -1, -1, -97, -25, -1, -1, 63, -33, -5, -4, -1, 15, + -13, -1, -1, -64, -1, -9, -1, -7, -49, -32, -1, -25, -8, 127, -97, -25, -1, -1, 63, -33, -5, -4, -1, + 15, -13, -1, -1, -64, -1, -13, -1, -32, -49, -32, -1, -25, -8, 127, -97, -25, -1, -2, 63, -49, -13, + -4, -1, 15, -13, -1, -1, -64, 127, -7, -1, -119, -17, -15, -1, -25, -8, 127, -97, -25, -1, -2, 63, + -49, -13, -4, -1, 15, -13, -3, -1, -64, 127, -8, -2, 15, -17, -1, -1, -25, -8, 127, -97, -25, -1, + -8, 63, -49, -13, -4, -1, 15, -13, -3, -1, -64, 63, -4, 120, 0, -17, -1, -1, -25, -8, 127, -97, -25, + -8, 0, 63, -57, -29, -4, -1, 15, -13, -4, -1, -64, 63, -4, 0, 15, -17, -1, -1, -25, -8, 127, -97, + -25, -8, 0, 63, -57, -29, -4, -1, -1, -13, -4, -1, -64, 31, -2, 0, 0, 103, -1, -1, -57, -8, 127, -97, + -25, -8, 0, 63, -57, -29, -4, -1, -1, -13, -4, 127, -64, 31, -2, 0, 15, 103, -1, -1, -57, -8, 127, + -97, -25, -8, 0, 63, -61, -61, -4, 127, -1, -29, -4, 127, -64, 15, -8, 0, 0, 55, -1, -1, -121, -8, + 127, -97, -25, -8, 0, 63, -61, -61, -4, 127, -1, -29, -4, 63, -64, 15, -32, 0, 0, 23, -1, -2, 3, -16, + 63, 15, -61, -16, 0, 31, -127, -127, -8, 31, -1, -127, -8, 31, -128, 7, -128, 0, 0 }; - static inline int get_pixel(int x, int y) + int getPixel(int x, int y) { - return (logo_image[(x>>3) + y*logo_row_length]>>(~x&0x7)) & 1; + return (LOGO_IMAGE[(x >> 3) + y * LOGO_RAW_LENGTH] >> (~x & 0x7)) & 1; } - static inline float frand(void) + float frand(void) { - return rand()/RAND_MAX; + return rand() / RAND_MAX; } } @@ -236,17 +167,13 @@ Sprite* PhysicsDemo::makeBall(Vec2 point, float radius, PhysicsMaterial material { Sprite* ball = nullptr; if (_ball != nullptr) - { ball = Sprite::createWithTexture(_ball->getTexture()); - }else - { + else ball = Sprite::create("Images/ball.png"); - } ball->setScale(0.13f * radius); - auto body = PhysicsBody::createCircle(radius, material); - ball->setPhysicsBody(body); + addPhysicsComponent(ball, PhysicsBody::createCircle(ball->getContentSize().width / 2, material)); ball->setPosition(Vec2(point.x, point.y)); return ball; @@ -258,18 +185,18 @@ Sprite* PhysicsDemo::makeBox(Vec2 point, Size size, int color, PhysicsMaterial m if (color == 0) { yellow = CCRANDOM_0_1() > 0.5f; - }else + } + else { yellow = color == 1; } auto box = yellow ? Sprite::create("Images/YellowSquare.png") : Sprite::create("Images/CyanSquare.png"); + box->setScaleX(size.width / 100.0f); + box->setScaleY(size.height / 100.0f); - box->setScaleX(size.width/100.0f); - box->setScaleY(size.height/100.0f); + addPhysicsComponent(box, PhysicsBody::createBox(box->getContentSize(), material)); - auto body = PhysicsBody::createBox(size, material); - box->setPhysicsBody(body); box->setPosition(Vec2(point.x, point.y)); return box; @@ -281,26 +208,27 @@ Sprite* PhysicsDemo::makeTriangle(Vec2 point, Size size, int color, PhysicsMater if (color == 0) { yellow = CCRANDOM_0_1() > 0.5f; - }else + } + else { yellow = color == 1; } auto triangle = yellow ? Sprite::create("Images/YellowTriangle.png") : Sprite::create("Images/CyanTriangle.png"); - if(size.height == 0) + if (size.height == 0) { - triangle->setScale(size.width/100.0f); - }else + triangle->setScale(size.width / 100.0f); + } + else { - triangle->setScaleX(size.width/50.0f); - triangle->setScaleY(size.height/43.5f); + triangle->setScaleX(size.width / 50.0f); + triangle->setScaleY(size.height / 43.5f); } - Vec2 vers[] = { Vec2(0, size.height/2), Vec2(size.width/2, -size.height/2), Vec2(-size.width/2, -size.height/2)}; + Vec2 vers[] = { Vec2(0, triangle->getContentSize().height / 2), Vec2(triangle->getContentSize().width / 2, -triangle->getContentSize().height / 2), Vec2(-triangle->getContentSize().width / 2, -triangle->getContentSize().height / 2) }; - auto body = PhysicsBody::createPolygon(vers, 3, material); - triangle->setPhysicsBody(body); + addPhysicsComponent(triangle, PhysicsBody::createPolygon(vers, 3, material)); triangle->setPosition(Vec2(point.x, point.y)); return triangle; @@ -309,7 +237,7 @@ Sprite* PhysicsDemo::makeTriangle(Vec2 point, Size size, int color, PhysicsMater bool PhysicsDemo::onTouchBegan(Touch* touch, Event* event) { auto location = touch->getLocation(); - auto arr = getPhysicsWorld()->getShapes(location); + auto arr = _physicsWorld->getShapes(location); PhysicsBody* body = nullptr; for (auto& obj : arr) @@ -324,13 +252,14 @@ bool PhysicsDemo::onTouchBegan(Touch* touch, Event* event) if (body != nullptr) { Node* mouse = Node::create(); - mouse->setPhysicsBody(PhysicsBody::create(PHYSICS_INFINITY, PHYSICS_INFINITY)); - mouse->getPhysicsBody()->setDynamic(false); + auto physicsBody = PhysicsBody::create(PHYSICS_INFINITY, PHYSICS_INFINITY); + physicsBody->setDynamic(false); + addPhysicsComponent(mouse, physicsBody); mouse->setPosition(location); this->addChild(mouse); - PhysicsJointPin* joint = PhysicsJointPin::construct(mouse->getPhysicsBody(), body, location); + PhysicsJointPin* joint = PhysicsJointPin::construct(physicsBody, body, location); joint->setMaxForce(5000.0f * body->getMass()); - getPhysicsWorld()->addJoint(joint); + _physicsWorld->addJoint(joint); _mouses.insert(std::make_pair(touch->getID(), mouse)); return true; @@ -360,40 +289,49 @@ void PhysicsDemo::onTouchEnded(Touch* touch, Event* event) } } +void PhysicsDemo::addPhysicsComponent(Node *node, PhysicsBody *physicsBody) +{ + auto physicsComponent = ComponentPhysics2d::create(); + physicsComponent->setPhysicsBody(physicsBody); + node->addComponent(physicsComponent); +} + +// Implementation of PhysicsComponentDemoLogoSmash + void PhysicsDemoLogoSmash::onEnter() { PhysicsDemo::onEnter(); - getPhysicsWorld()->setGravity(Vec2(0, 0)); - getPhysicsWorld()->setUpdateRate(5.0f); + _physicsWorld->setGravity(Vec2(0, 0)); + _physicsWorld->setUpdateRate(5.0f); - _ball = SpriteBatchNode::create("Images/ball.png", sizeof(logo_image)/sizeof(logo_image[0])); + _ball = SpriteBatchNode::create("Images/ball.png", sizeof(LOGO_IMAGE)/sizeof(LOGO_IMAGE[0])); addChild(_ball); - for (int y = 0; y < logo_height; ++y) + for (int y = 0; y < LOGO_HEIGHT; ++y) { - for (int x = 0; x < logo_width; ++x) + for (int x = 0; x < LOGO_WIDTH; ++x) { - if (get_pixel(x, y)) + if (getPixel(x, y)) { - float x_jitter = 0.05*frand(); - float y_jitter = 0.05*frand(); + float xJitter = 0.05 * frand(); + float yJitter = 0.05 * frand(); - Node* ball = makeBall(Vec2(2*(x - logo_width/2 + x_jitter) + VisibleRect::getVisibleRect().size.width/2, - 2*(logo_height-y + y_jitter) + VisibleRect::getVisibleRect().size.height/2 - logo_height/2), + Node* ball = makeBall(Vec2(2*(x - LOGO_WIDTH/2 + xJitter) + VisibleRect::getVisibleRect().size.width/2, + 2*(LOGO_HEIGHT-y + yJitter) + VisibleRect::getVisibleRect().size.height/2 - LOGO_HEIGHT/2), 0.95f, PhysicsMaterial(0.01f, 0.0f, 0.0f)); - ball->getPhysicsBody()->setMass(1.0); - ball->getPhysicsBody()->setMoment(PHYSICS_INFINITY); + auto physicsBody = ball->getComponent()->getPhysicsBody(); + physicsBody->setMass(1.0); + physicsBody->setMoment(PHYSICS_INFINITY); _ball->addChild(ball); - } } } auto bullet = makeBall(Vec2(400, 0), 10, PhysicsMaterial(PHYSICS_INFINITY, 0, 0)); - bullet->getPhysicsBody()->setVelocity(Vec2(200, 0)); + bullet->getComponent()->getPhysicsBody()->setVelocity(Vec2(200, 0)); bullet->setPosition(Vec2(-500, VisibleRect::getVisibleRect().size.height/2)); @@ -405,13 +343,66 @@ std::string PhysicsDemoLogoSmash::title() const return "Logo Smash"; } -void PhysicsDemoPyramidStack::updateOnce(float delta) +// Implementation of PhysicsComponentDemoClickAdd + +PhysicsDemoClickAdd::~PhysicsDemoClickAdd() { - auto ball = getChildByTag(100); + Device::setAccelerometerEnabled(false); +} + +void PhysicsDemoClickAdd::onEnter() +{ + PhysicsDemo::onEnter(); - ball->setScale(ball->getScale() * 3); - ball->setPhysicsBody(PhysicsBody::createCircle(30)); - ball->getPhysicsBody()->setTag(DRAG_BODYS_TAG); + auto touchListener = EventListenerTouchAllAtOnce::create(); + touchListener->onTouchesEnded = CC_CALLBACK_2(PhysicsDemoClickAdd::onTouchesEnded, this); + _eventDispatcher->addEventListenerWithSceneGraphPriority(touchListener, this); + + Device::setAccelerometerEnabled(true); + auto accListener = EventListenerAcceleration::create(CC_CALLBACK_2(PhysicsDemoClickAdd::onAcceleration, this)); + _eventDispatcher->addEventListenerWithSceneGraphPriority(accListener, this); + + auto node = Node::create(); + addPhysicsComponent(node, PhysicsBody::createEdgeBox(VisibleRect::getVisibleRect().size)); + node->setPosition(VisibleRect::center()); + this->addChild(node); + + addGrossiniAtPosition(VisibleRect::center()); +} + +std::string PhysicsDemoClickAdd::subtitle() const +{ + return "multi touch to add grossini"; +} + +void PhysicsDemoClickAdd::onTouchesEnded(const std::vector& touches, Event* event) +{ + //Add a new body/atlas sprite at the touched location + + for( auto touch: touches) + { + auto location = touch->getLocation(); + + addGrossiniAtPosition( location ); + } +} + +void PhysicsDemoClickAdd::onAcceleration(Acceleration* acc, Event* event) +{ + static float prevX=0, prevY=0; + +#define FILTER_FACTOR 0.05f + + float accelX = (float) acc->x * FILTER_FACTOR + (1- FILTER_FACTOR)*prevX; + float accelY = (float) acc->y * FILTER_FACTOR + (1- FILTER_FACTOR)*prevY; + + prevX = accelX; + prevY = accelY; + + auto v = Vec2( accelX, accelY); + v = v * 200; + + _physicsWorld->setGravity(v); } void PhysicsDemoPyramidStack::onEnter() @@ -425,28 +416,36 @@ void PhysicsDemoPyramidStack::onEnter() _eventDispatcher->addEventListenerWithSceneGraphPriority(touchListener, this); auto node = Node::create(); - node->setPhysicsBody(PhysicsBody::createEdgeSegment(VisibleRect::leftBottom() + Vec2(0, 50), VisibleRect::rightBottom() + Vec2(0, 50))); + addPhysicsComponent(node, PhysicsBody::createEdgeSegment(VisibleRect::leftBottom() + Vec2(0, 50), VisibleRect::rightBottom() + Vec2(0, 50))); this->addChild(node); auto ball = Sprite::create("Images/ball.png"); ball->setScale(1); ball->setTag(100); - ball->setPhysicsBody(PhysicsBody::createCircle(10)); - ball->getPhysicsBody()->setTag(DRAG_BODYS_TAG); + addPhysicsComponent(ball, PhysicsBody::createCircle(10)); + ball->getComponent()->getPhysicsBody()->setTag(DRAG_BODYS_TAG); ball->setPosition(VisibleRect::bottom() + Vec2(0, 60)); this->addChild(ball); scheduleOnce(CC_SCHEDULE_SELECTOR(PhysicsDemoPyramidStack::updateOnce), 3.0); - - for(int i=0; i<14; i++) + + for (int i = 0; i < 14; i++) { - for(int j=0; j<=i; j++) + for (int j = 0; j <= i; j++) { - auto sp = addGrossiniAtPosition(VisibleRect::bottom() + Vec2((i/2 - j) * 11, (14 - i) * 23 + 100), 0.2f); - sp->getPhysicsBody()->setTag(DRAG_BODYS_TAG); + auto sp = addGrossiniAtPosition(VisibleRect::bottom() + Vec2((i / 2 - j) * 11, (14 - i) * 23 + 100), 0.2f); + sp->getComponent()->getPhysicsBody()->setTag(DRAG_BODYS_TAG); } } } + +void PhysicsDemoPyramidStack::updateOnce(float delta) +{ + auto ball = getChildByTag(100); + if (ball) + ball->setScale(ball->getScale() * 3); +} + std::string PhysicsDemoPyramidStack::title() const { return "Pyramid Stack"; @@ -466,10 +465,10 @@ void PhysicsDemoRayCast::onEnter() listener->onTouchesEnded = CC_CALLBACK_2(PhysicsDemoRayCast::onTouchesEnded, this); _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this); - getPhysicsWorld()->setGravity(Point::ZERO); + _physicsWorld->setGravity(Point::ZERO); auto node = DrawNode::create(); - node->setPhysicsBody(PhysicsBody::createEdgeSegment(VisibleRect::leftBottom() + Vec2(0, 50), VisibleRect::rightBottom() + Vec2(0, 50))); + addPhysicsComponent(node, PhysicsBody::createEdgeSegment(VisibleRect::leftBottom() + Vec2(0, 50), VisibleRect::rightBottom() + Vec2(0, 50))); node->drawSegment(VisibleRect::leftBottom() + Vec2(0, 50), VisibleRect::rightBottom() + Vec2(0, 50), 1, STATIC_COLOR); this->addChild(node); @@ -478,7 +477,7 @@ void PhysicsDemoRayCast::onEnter() auto menu = Menu::create(item, nullptr); this->addChild(menu); - menu->setPosition(Vec2(VisibleRect::left().x+100, VisibleRect::top().y-10)); + menu->setPosition(Vec2(VisibleRect::left().x + 100, VisibleRect::top().y - 10)); scheduleUpdate(); } @@ -526,7 +525,7 @@ void PhysicsDemoRayCast::update(float delta) Vec2 point3 = point2; auto func = CC_CALLBACK_3(PhysicsDemoRayCast::anyRay, this); - getPhysicsWorld()->rayCast(func, point1, point2, &point3); + _physicsWorld->rayCast(func, point1, point2, &point3); _node->drawSegment(point1, point3, 1, STATIC_COLOR); if (point2 != point3) @@ -552,7 +551,7 @@ void PhysicsDemoRayCast::update(float delta) return true; }; - getPhysicsWorld()->rayCast(func, point1, point2, nullptr); + _physicsWorld->rayCast(func, point1, point2, nullptr); _node->drawSegment(point1, point3, 1, STATIC_COLOR); if (point2 != point3) @@ -579,7 +578,7 @@ void PhysicsDemoRayCast::update(float delta) return true; }; - getPhysicsWorld()->rayCast(func, point1, point2, nullptr); + _physicsWorld->rayCast(func, point1, point2, nullptr); _node->drawSegment(point1, point2, 1, STATIC_COLOR); @@ -604,21 +603,23 @@ void PhysicsDemoRayCast::onTouchesEnded(const std::vector& touches, Even { //Add a new body/atlas sprite at the touched location - for( auto &touch: touches) + for (auto &touch : touches) { auto location = touch->getLocation(); float r = CCRANDOM_0_1(); - if (r < 1.0f/3.0f) + if (r < 1.0f / 3.0f) { - addChild(makeBall(location, 5 + CCRANDOM_0_1()*10)); - }else if(r < 2.0f/3.0f) + addChild(makeBall(location, 5 + CCRANDOM_0_1() * 10)); + } + else if (r < 2.0f / 3.0f) { - addChild(makeBox(location, Size(10 + CCRANDOM_0_1()*15, 10 + CCRANDOM_0_1()*15))); - }else + addChild(makeBox(location, Size(10 + CCRANDOM_0_1() * 15, 10 + CCRANDOM_0_1() * 15))); + } + else { - addChild(makeTriangle(location, Size(10 + CCRANDOM_0_1()*20, 10 + CCRANDOM_0_1()*20))); + addChild(makeTriangle(location, Size(10 + CCRANDOM_0_1() * 20, 10 + CCRANDOM_0_1() * 20))); } } } @@ -628,15 +629,63 @@ std::string PhysicsDemoRayCast::title() const return "Ray Cast"; } +void PhysicsDemoActions::onEnter() +{ + PhysicsDemo::onEnter(); + _physicsWorld->setGravity(Vect::ZERO); + + auto touchListener = EventListenerTouchOneByOne::create(); + touchListener->onTouchBegan = CC_CALLBACK_2(PhysicsDemoActions::onTouchBegan, this); + touchListener->onTouchMoved = CC_CALLBACK_2(PhysicsDemoActions::onTouchMoved, this); + touchListener->onTouchEnded = CC_CALLBACK_2(PhysicsDemoActions::onTouchEnded, this); + _eventDispatcher->addEventListenerWithSceneGraphPriority(touchListener, this); + + auto node = Node::create(); + addPhysicsComponent(node, PhysicsBody::createEdgeBox(VisibleRect::getVisibleRect().size)); + node->setPosition(VisibleRect::center()); + this->addChild(node); + + Sprite* sp1 = addGrossiniAtPosition(VisibleRect::center()); + Sprite* sp2 = addGrossiniAtPosition(VisibleRect::left() + Vec2(50, 0)); + Sprite* sp3 = addGrossiniAtPosition(VisibleRect::right() - Vec2(20, 0)); + Sprite* sp4 = addGrossiniAtPosition(VisibleRect::leftTop() + Vec2(50, -50)); + sp4->getComponent()->getPhysicsBody()->setGravityEnable(false); + + sp1->getComponent()->getPhysicsBody()->setTag(DRAG_BODYS_TAG); + sp2->getComponent()->getPhysicsBody()->setTag(DRAG_BODYS_TAG); + sp3->getComponent()->getPhysicsBody()->setTag(DRAG_BODYS_TAG); + sp4->getComponent()->getPhysicsBody()->setTag(DRAG_BODYS_TAG); + + auto actionTo = JumpTo::create(2, Vec2(100, 100), 50, 4); + auto actionBy = JumpBy::create(2, Vec2(300, 0), 50, 4); + auto actionUp = JumpBy::create(2, Vec2(0, 50), 80, 4); + auto actionByBack = actionBy->reverse(); + auto rotateBy = RotateBy::create(2, 180); + auto rotateByBack = RotateBy::create(2, -180); + + sp1->runAction(RepeatForever::create(actionUp)); + sp2->runAction(RepeatForever::create(Sequence::create(actionBy, actionByBack, nullptr))); + sp3->runAction(actionTo); + sp4->runAction(RepeatForever::create(Sequence::create(rotateBy, rotateByBack, nullptr))); +} + +std::string PhysicsDemoActions::title() const +{ + return "Actions"; +} + +// implementation of PhysicsDemoJoints + + void PhysicsDemoJoints::onEnter() { PhysicsDemo::onEnter(); toggleDebug(); auto listener = EventListenerTouchOneByOne::create(); - listener->onTouchBegan = CC_CALLBACK_2(PhysicsDemoJoints::onTouchBegan, this); - listener->onTouchMoved = CC_CALLBACK_2(PhysicsDemoJoints::onTouchMoved, this); - listener->onTouchEnded = CC_CALLBACK_2(PhysicsDemoJoints::onTouchEnded, this); + listener->onTouchBegan = CC_CALLBACK_2(PhysicsDemo::onTouchBegan, this); + listener->onTouchMoved = CC_CALLBACK_2(PhysicsDemo::onTouchMoved, this); + listener->onTouchEnded = CC_CALLBACK_2(PhysicsDemo::onTouchEnded, this); _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this); float width = (VisibleRect::getVisibleRect().size.width - 10) / 4; @@ -644,7 +693,8 @@ void PhysicsDemoJoints::onEnter() Node* node = Node::create(); PhysicsBody* box = PhysicsBody::create(); - node->setPhysicsBody(box); + addPhysicsComponent(node, box); + box->setDynamic(false); node->setPosition(Point::ZERO); this->addChild(node); @@ -655,17 +705,20 @@ void PhysicsDemoJoints::onEnter() { Vec2 offset(VisibleRect::leftBottom().x + 5 + j * width + width/2, VisibleRect::leftBottom().y + 50 + i * height + height/2); box->addShape(PhysicsShapeEdgeBox::create(Size(width, height), PHYSICSSHAPE_MATERIAL_DEFAULT, 1, offset)); - + switch (i*4 + j) { case 0: { auto sp1 = makeBall(offset - Vec2(30, 0), 10); - sp1->getPhysicsBody()->setTag(DRAG_BODYS_TAG); - auto sp2 = makeBall(offset + Vec2(30, 0), 10); - sp2->getPhysicsBody()->setTag(DRAG_BODYS_TAG); + auto sp1PhysicsBody = sp1->getComponent()->getPhysicsBody(); + sp1PhysicsBody->setTag(DRAG_BODYS_TAG); - PhysicsJointPin* joint = PhysicsJointPin::construct(sp1->getPhysicsBody(), sp2->getPhysicsBody(), offset); + auto sp2 = makeBall(offset + Vec2(30, 0), 10); + auto sp2PhysicsBody = sp2->getComponent()->getPhysicsBody(); + sp2PhysicsBody->setTag(DRAG_BODYS_TAG); + + PhysicsJointPin* joint = PhysicsJointPin::construct(sp1PhysicsBody, sp2PhysicsBody, offset); getPhysicsWorld()->addJoint(joint); this->addChild(sp1); @@ -676,11 +729,14 @@ void PhysicsDemoJoints::onEnter() { auto sp1 = makeBall(offset - Vec2(30, 0), 10); - sp1->getPhysicsBody()->setTag(DRAG_BODYS_TAG); - auto sp2 = makeBox(offset + Vec2(30, 0), Size(30, 10)); - sp2->getPhysicsBody()->setTag(DRAG_BODYS_TAG); + auto sp1PhysicsBody = sp1->getComponent()->getPhysicsBody(); + sp1PhysicsBody->setTag(DRAG_BODYS_TAG); - PhysicsJointFixed* joint = PhysicsJointFixed::construct(sp1->getPhysicsBody(), sp2->getPhysicsBody(), offset); + auto sp2 = makeBox(offset + Vec2(30, 0), Size(30, 10)); + auto sp2PhysicsBody = sp2->getComponent()->getPhysicsBody(); + sp2PhysicsBody->setTag(DRAG_BODYS_TAG); + + PhysicsJointFixed* joint = PhysicsJointFixed::construct(sp1PhysicsBody, sp2PhysicsBody, offset); getPhysicsWorld()->addJoint(joint); this->addChild(sp1); @@ -690,11 +746,14 @@ void PhysicsDemoJoints::onEnter() case 2: { auto sp1 = makeBall(offset - Vec2(30, 0), 10); - sp1->getPhysicsBody()->setTag(DRAG_BODYS_TAG); - auto sp2 = makeBox(offset + Vec2(30, 0), Size(30, 10)); - sp2->getPhysicsBody()->setTag(DRAG_BODYS_TAG); + auto sp1PhysicsBody = sp1->getComponent()->getPhysicsBody(); + sp1PhysicsBody->setTag(DRAG_BODYS_TAG); - PhysicsJointDistance* joint = PhysicsJointDistance::construct(sp1->getPhysicsBody(), sp2->getPhysicsBody(), Point::ZERO, Point::ZERO); + auto sp2 = makeBox(offset + Vec2(30, 0), Size(30, 10)); + auto sp2PhysicsBody = sp2->getComponent()->getPhysicsBody(); + sp2PhysicsBody->setTag(DRAG_BODYS_TAG); + + PhysicsJointDistance* joint = PhysicsJointDistance::construct(sp1PhysicsBody, sp2PhysicsBody, Point::ZERO, Point::ZERO); getPhysicsWorld()->addJoint(joint); this->addChild(sp1); @@ -704,11 +763,14 @@ void PhysicsDemoJoints::onEnter() case 3: { auto sp1 = makeBall(offset - Vec2(30, 0), 10); - sp1->getPhysicsBody()->setTag(DRAG_BODYS_TAG); - auto sp2 = makeBox(offset + Vec2(30, 0), Size(30, 10)); - sp2->getPhysicsBody()->setTag(DRAG_BODYS_TAG); + auto sp1PhysicsBody = sp1->getComponent()->getPhysicsBody(); + sp1PhysicsBody->setTag(DRAG_BODYS_TAG); - PhysicsJointLimit* joint = PhysicsJointLimit::construct(sp1->getPhysicsBody(), sp2->getPhysicsBody(), Point::ZERO, Point::ZERO, 30.0f, 60.0f); + auto sp2 = makeBox(offset + Vec2(30, 0), Size(30, 10)); + auto sp2PhysicsBody = sp2->getComponent()->getPhysicsBody(); + sp2PhysicsBody->setTag(DRAG_BODYS_TAG); + + PhysicsJointLimit* joint = PhysicsJointLimit::construct(sp1PhysicsBody, sp2PhysicsBody, Point::ZERO, Point::ZERO, 30.0f, 60.0f); getPhysicsWorld()->addJoint(joint); this->addChild(sp1); @@ -718,11 +780,14 @@ void PhysicsDemoJoints::onEnter() case 4: { auto sp1 = makeBall(offset - Vec2(30, 0), 10); - sp1->getPhysicsBody()->setTag(DRAG_BODYS_TAG); - auto sp2 = makeBox(offset + Vec2(30, 0), Size(30, 10)); - sp2->getPhysicsBody()->setTag(DRAG_BODYS_TAG); + auto sp1PhysicsBody = sp1->getComponent()->getPhysicsBody(); + sp1PhysicsBody->setTag(DRAG_BODYS_TAG); - PhysicsJointSpring* joint = PhysicsJointSpring::construct(sp1->getPhysicsBody(), sp2->getPhysicsBody(), Point::ZERO, Point::ZERO, 500.0f, 0.3f); + auto sp2 = makeBox(offset + Vec2(30, 0), Size(30, 10)); + auto sp2PhysicsBody = sp2->getComponent()->getPhysicsBody(); + sp2PhysicsBody->setTag(DRAG_BODYS_TAG); + + PhysicsJointSpring* joint = PhysicsJointSpring::construct(sp1PhysicsBody, sp2PhysicsBody, Point::ZERO, Point::ZERO, 500.0f, 0.3f); getPhysicsWorld()->addJoint(joint); this->addChild(sp1); @@ -732,11 +797,14 @@ void PhysicsDemoJoints::onEnter() case 5: { auto sp1 = makeBall(offset - Vec2(30, 0), 10); - sp1->getPhysicsBody()->setTag(DRAG_BODYS_TAG); - auto sp2 = makeBox(offset + Vec2(30, 0), Size(30, 10)); - sp2->getPhysicsBody()->setTag(DRAG_BODYS_TAG); + auto sp1PhysicsBody = sp1->getComponent()->getPhysicsBody(); + sp1PhysicsBody->setTag(DRAG_BODYS_TAG); - PhysicsJointGroove* joint = PhysicsJointGroove::construct(sp1->getPhysicsBody(), sp2->getPhysicsBody(), Vec2(30, 15), Vec2(30, -15), Vec2(-30, 0)); + auto sp2 = makeBox(offset + Vec2(30, 0), Size(30, 10)); + auto sp2PhysicsBody = sp2->getComponent()->getPhysicsBody(); + sp2PhysicsBody->setTag(DRAG_BODYS_TAG); + + PhysicsJointGroove* joint = PhysicsJointGroove::construct(sp1PhysicsBody, sp2PhysicsBody, Vec2(30, 15), Vec2(30, -15), Vec2(-30, 0)); getPhysicsWorld()->addJoint(joint); this->addChild(sp1); @@ -746,13 +814,16 @@ void PhysicsDemoJoints::onEnter() case 6: { auto sp1 = makeBox(offset - Vec2(30, 0), Size(30, 10)); - sp1->getPhysicsBody()->setTag(DRAG_BODYS_TAG); - auto sp2 = makeBox(offset + Vec2(30, 0), Size(30, 10)); - sp2->getPhysicsBody()->setTag(DRAG_BODYS_TAG); + auto sp1PhysicsBody = sp1->getComponent()->getPhysicsBody(); + sp1PhysicsBody->setTag(DRAG_BODYS_TAG); - getPhysicsWorld()->addJoint(PhysicsJointPin::construct(sp1->getPhysicsBody(), box, sp1->getPosition())); - getPhysicsWorld()->addJoint(PhysicsJointPin::construct(sp2->getPhysicsBody(), box, sp2->getPosition())); - PhysicsJointRotarySpring* joint = PhysicsJointRotarySpring::construct(sp1->getPhysicsBody(), sp2->getPhysicsBody(), 3000.0f, 60.0f); + auto sp2 = makeBox(offset + Vec2(30, 0), Size(30, 10)); + auto sp2PhysicsBody = sp2->getComponent()->getPhysicsBody(); + sp2PhysicsBody->setTag(DRAG_BODYS_TAG); + + getPhysicsWorld()->addJoint(PhysicsJointPin::construct(sp1PhysicsBody, box, sp1->getPosition())); + getPhysicsWorld()->addJoint(PhysicsJointPin::construct(sp2PhysicsBody, box, sp2->getPosition())); + PhysicsJointRotarySpring* joint = PhysicsJointRotarySpring::construct(sp1PhysicsBody, sp2PhysicsBody, 3000.0f, 60.0f); getPhysicsWorld()->addJoint(joint); this->addChild(sp1); @@ -762,13 +833,16 @@ void PhysicsDemoJoints::onEnter() case 7: { auto sp1 = makeBox(offset - Vec2(30, 0), Size(30, 10)); - sp1->getPhysicsBody()->setTag(DRAG_BODYS_TAG); - auto sp2 = makeBox(offset + Vec2(30, 0), Size(30, 10)); - sp2->getPhysicsBody()->setTag(DRAG_BODYS_TAG); + auto sp1PhysicsBody = sp1->getComponent()->getPhysicsBody(); + sp1PhysicsBody->setTag(DRAG_BODYS_TAG); - getPhysicsWorld()->addJoint(PhysicsJointPin::construct(sp1->getPhysicsBody(), box, sp1->getPosition())); - getPhysicsWorld()->addJoint(PhysicsJointPin::construct(sp2->getPhysicsBody(), box, sp2->getPosition())); - PhysicsJointRotaryLimit* joint = PhysicsJointRotaryLimit::construct(sp1->getPhysicsBody(), sp2->getPhysicsBody(), 0.0f,(float) M_PI_2); + auto sp2 = makeBox(offset + Vec2(30, 0), Size(30, 10)); + auto sp2PhysicsBody = sp2->getComponent()->getPhysicsBody(); + sp2PhysicsBody->setTag(DRAG_BODYS_TAG); + + getPhysicsWorld()->addJoint(PhysicsJointPin::construct(sp1PhysicsBody, box, sp1->getPosition())); + getPhysicsWorld()->addJoint(PhysicsJointPin::construct(sp2PhysicsBody, box, sp2->getPosition())); + PhysicsJointRotaryLimit* joint = PhysicsJointRotaryLimit::construct(sp1PhysicsBody, sp2PhysicsBody, 0.0f,(float) M_PI_2); getPhysicsWorld()->addJoint(joint); this->addChild(sp1); @@ -778,13 +852,16 @@ void PhysicsDemoJoints::onEnter() case 8: { auto sp1 = makeBox(offset - Vec2(30, 0), Size(30, 10)); - sp1->getPhysicsBody()->setTag(DRAG_BODYS_TAG); - auto sp2 = makeBox(offset + Vec2(30, 0), Size(30, 10)); - sp2->getPhysicsBody()->setTag(DRAG_BODYS_TAG); + auto sp1PhysicsBody = sp1->getComponent()->getPhysicsBody(); + sp1PhysicsBody->setTag(DRAG_BODYS_TAG); - getPhysicsWorld()->addJoint(PhysicsJointPin::construct(sp1->getPhysicsBody(), box, sp1->getPosition())); - getPhysicsWorld()->addJoint(PhysicsJointPin::construct(sp2->getPhysicsBody(), box, sp2->getPosition())); - PhysicsJointRatchet* joint = PhysicsJointRatchet::construct(sp1->getPhysicsBody(), sp2->getPhysicsBody(), 0.0f, (float)M_PI_2); + auto sp2 = makeBox(offset + Vec2(30, 0), Size(30, 10)); + auto sp2PhysicsBody = sp2->getComponent()->getPhysicsBody(); + sp2PhysicsBody->setTag(DRAG_BODYS_TAG); + + getPhysicsWorld()->addJoint(PhysicsJointPin::construct(sp1PhysicsBody, box, sp1->getPosition())); + getPhysicsWorld()->addJoint(PhysicsJointPin::construct(sp2PhysicsBody, box, sp2->getPosition())); + PhysicsJointRatchet* joint = PhysicsJointRatchet::construct(sp1PhysicsBody, sp2PhysicsBody, 0.0f, (float)M_PI_2); getPhysicsWorld()->addJoint(joint); this->addChild(sp1); @@ -794,13 +871,16 @@ void PhysicsDemoJoints::onEnter() case 9: { auto sp1 = makeBox(offset - Vec2(30, 0), Size(30, 10)); - sp1->getPhysicsBody()->setTag(DRAG_BODYS_TAG); - auto sp2 = makeBox(offset + Vec2(30, 0), Size(30, 10)); - sp2->getPhysicsBody()->setTag(DRAG_BODYS_TAG); + auto sp1PhysicsBody = sp1->getComponent()->getPhysicsBody(); + sp1PhysicsBody->setTag(DRAG_BODYS_TAG); - getPhysicsWorld()->addJoint(PhysicsJointPin::construct(sp1->getPhysicsBody(), box, sp1->getPosition())); - getPhysicsWorld()->addJoint(PhysicsJointPin::construct(sp2->getPhysicsBody(), box, sp2->getPosition())); - PhysicsJointGear* joint = PhysicsJointGear::construct(sp1->getPhysicsBody(), sp2->getPhysicsBody(), 0.0f, 2.0f); + auto sp2 = makeBox(offset + Vec2(30, 0), Size(30, 10)); + auto sp2PhysicsBody = sp2->getComponent()->getPhysicsBody(); + sp2PhysicsBody->setTag(DRAG_BODYS_TAG); + + getPhysicsWorld()->addJoint(PhysicsJointPin::construct(sp1PhysicsBody, box, sp1->getPosition())); + getPhysicsWorld()->addJoint(PhysicsJointPin::construct(sp2PhysicsBody, box, sp2->getPosition())); + PhysicsJointGear* joint = PhysicsJointGear::construct(sp1PhysicsBody, sp2PhysicsBody, 0.0f, 2.0f); getPhysicsWorld()->addJoint(joint); this->addChild(sp1); @@ -810,13 +890,16 @@ void PhysicsDemoJoints::onEnter() case 10: { auto sp1 = makeBox(offset - Vec2(30, 0), Size(30, 10)); - sp1->getPhysicsBody()->setTag(DRAG_BODYS_TAG); - auto sp2 = makeBox(offset + Vec2(30, 0), Size(30, 10)); - sp2->getPhysicsBody()->setTag(DRAG_BODYS_TAG); + auto sp1PhysicsBody = sp1->getComponent()->getPhysicsBody(); + sp1PhysicsBody->setTag(DRAG_BODYS_TAG); - getPhysicsWorld()->addJoint(PhysicsJointPin::construct(sp1->getPhysicsBody(), box, sp1->getPosition())); - getPhysicsWorld()->addJoint(PhysicsJointPin::construct(sp2->getPhysicsBody(), box, sp2->getPosition())); - PhysicsJointMotor* joint = PhysicsJointMotor::construct(sp1->getPhysicsBody(), sp2->getPhysicsBody(), (float)M_PI_2); + auto sp2 = makeBox(offset + Vec2(30, 0), Size(30, 10)); + auto sp2PhysicsBody = sp2->getComponent()->getPhysicsBody(); + sp2PhysicsBody->setTag(DRAG_BODYS_TAG); + + getPhysicsWorld()->addJoint(PhysicsJointPin::construct(sp1PhysicsBody, box, sp1->getPosition())); + getPhysicsWorld()->addJoint(PhysicsJointPin::construct(sp2PhysicsBody, box, sp2->getPosition())); + PhysicsJointMotor* joint = PhysicsJointMotor::construct(sp1PhysicsBody, sp2PhysicsBody, (float)M_PI_2); getPhysicsWorld()->addJoint(joint); this->addChild(sp1); @@ -835,51 +918,6 @@ std::string PhysicsDemoJoints::title() const return "Joints"; } -void PhysicsDemoActions::onEnter() -{ - PhysicsDemo::onEnter(); - getPhysicsWorld()->setGravity(Vect::ZERO); - - auto touchListener = EventListenerTouchOneByOne::create(); - touchListener->onTouchBegan = CC_CALLBACK_2(PhysicsDemoActions::onTouchBegan, this); - touchListener->onTouchMoved = CC_CALLBACK_2(PhysicsDemoActions::onTouchMoved, this); - touchListener->onTouchEnded = CC_CALLBACK_2(PhysicsDemoActions::onTouchEnded, this); - _eventDispatcher->addEventListenerWithSceneGraphPriority(touchListener, this); - - auto node = Node::create(); - node->setPhysicsBody(PhysicsBody::createEdgeBox(VisibleRect::getVisibleRect().size)); - node->setPosition(VisibleRect::center()); - this->addChild(node); - - Sprite* sp1 = addGrossiniAtPosition(VisibleRect::center()); - Sprite* sp2 = addGrossiniAtPosition(VisibleRect::left() + Vec2(50, 0)); - Sprite* sp3 = addGrossiniAtPosition(VisibleRect::right() - Vec2(20, 0)); - Sprite* sp4 = addGrossiniAtPosition(VisibleRect::leftTop() + Vec2(50, -50)); - sp4->getPhysicsBody()->setGravityEnable(false); - - sp1->getPhysicsBody()->setTag(DRAG_BODYS_TAG); - sp2->getPhysicsBody()->setTag(DRAG_BODYS_TAG); - sp3->getPhysicsBody()->setTag(DRAG_BODYS_TAG); - sp4->getPhysicsBody()->setTag(DRAG_BODYS_TAG); - - auto actionTo = JumpTo::create(2, Vec2(100,100), 50, 4); - auto actionBy = JumpBy::create(2, Vec2(300,0), 50, 4); - auto actionUp = JumpBy::create(2, Vec2(0,50), 80, 4); - auto actionByBack = actionBy->reverse(); - auto rotateBy = RotateBy::create(2, 180); - auto rotateByBack = RotateBy::create(2, -180); - - sp1->runAction(RepeatForever::create(actionUp)); - sp2->runAction(RepeatForever::create(Sequence::create(actionBy, actionByBack, nullptr))); - sp3->runAction(actionTo); - sp4->runAction(RepeatForever::create(Sequence::create(rotateBy, rotateByBack, nullptr))); -} - -std::string PhysicsDemoActions::title() const -{ - return "Actions"; -} - void PhysicsDemoPump::onEnter() { PhysicsDemo::onEnter(); @@ -895,20 +933,19 @@ void PhysicsDemoPump::onEnter() scheduleUpdate(); auto node = Node::create(); - auto body = PhysicsBody::create(); - body->setDynamic(false); + addPhysicsComponent(node, PhysicsBody::create()); + node->getComponent()->getPhysicsBody()->setDynamic(false); PhysicsMaterial staticMaterial(PHYSICS_INFINITY, 0, 0.5f); - body->addShape(PhysicsShapeEdgeSegment::create(VisibleRect::leftTop() + Vec2(50, 0), VisibleRect::leftTop() + Vec2(50, -130), staticMaterial, 2.0f)); - body->addShape(PhysicsShapeEdgeSegment::create(VisibleRect::leftTop() + Vec2(190, 0), VisibleRect::leftTop() + Vec2(100, -50), staticMaterial, 2.0f)); - body->addShape(PhysicsShapeEdgeSegment::create(VisibleRect::leftTop() + Vec2(100, -50), VisibleRect::leftTop() + Vec2(100, -90), staticMaterial, 2.0f)); - body->addShape(PhysicsShapeEdgeSegment::create(VisibleRect::leftTop() + Vec2(50, -130), VisibleRect::leftTop() + Vec2(100, -145), staticMaterial, 2.0f)); - body->addShape(PhysicsShapeEdgeSegment::create(VisibleRect::leftTop() + Vec2(100, -145), VisibleRect::leftBottom() + Vec2(100, 80), staticMaterial, 2.0f)); - body->addShape(PhysicsShapeEdgeSegment::create(VisibleRect::leftTop() + Vec2(150, -80), VisibleRect::leftBottom() + Vec2(150, 80), staticMaterial, 2.0f)); - body->addShape(PhysicsShapeEdgeSegment::create(VisibleRect::leftTop() + Vec2(150, -80), VisibleRect::rightTop() + Vec2(-100, -150), staticMaterial, 2.0f)); + node->getComponent()->getPhysicsBody()->addShape(PhysicsShapeEdgeSegment::create(VisibleRect::leftTop() + Vec2(50, 0), VisibleRect::leftTop() + Vec2(50, -130), staticMaterial, 2.0f)); + node->getComponent()->getPhysicsBody()->addShape(PhysicsShapeEdgeSegment::create(VisibleRect::leftTop() + Vec2(190, 0), VisibleRect::leftTop() + Vec2(100, -50), staticMaterial, 2.0f)); + node->getComponent()->getPhysicsBody()->addShape(PhysicsShapeEdgeSegment::create(VisibleRect::leftTop() + Vec2(100, -50), VisibleRect::leftTop() + Vec2(100, -90), staticMaterial, 2.0f)); + node->getComponent()->getPhysicsBody()->addShape(PhysicsShapeEdgeSegment::create(VisibleRect::leftTop() + Vec2(50, -130), VisibleRect::leftTop() + Vec2(100, -145), staticMaterial, 2.0f)); + node->getComponent()->getPhysicsBody()->addShape(PhysicsShapeEdgeSegment::create(VisibleRect::leftTop() + Vec2(100, -145), VisibleRect::leftBottom() + Vec2(100, 80), staticMaterial, 2.0f)); + node->getComponent()->getPhysicsBody()->addShape(PhysicsShapeEdgeSegment::create(VisibleRect::leftTop() + Vec2(150, -80), VisibleRect::leftBottom() + Vec2(150, 80), staticMaterial, 2.0f)); + node->getComponent()->getPhysicsBody()->addShape(PhysicsShapeEdgeSegment::create(VisibleRect::leftTop() + Vec2(150, -80), VisibleRect::rightTop() + Vec2(-100, -150), staticMaterial, 2.0f)); - body->setCategoryBitmask(0x01); - node->setPhysicsBody(body); + node->getComponent()->getPhysicsBody()->setCategoryBitmask(0x01); node->setPosition(Vec2::ZERO); this->addChild(node); @@ -916,12 +953,10 @@ void PhysicsDemoPump::onEnter() for (int i = 0; i < 6; ++i) { auto ball = makeBall(VisibleRect::leftTop() + Vec2(75 + CCRANDOM_0_1() * 90, 0), 22, PhysicsMaterial(0.05f, 0.0f, 0.1f)); - ball->getPhysicsBody()->setTag(DRAG_BODYS_TAG); + ball->getComponent()->getPhysicsBody()->setTag(DRAG_BODYS_TAG); addChild(ball); } - auto _world = getPhysicsWorld(); - Vec2 vec[4] = { VisibleRect::leftTop() + Vec2(102, -148), @@ -934,75 +969,73 @@ void PhysicsDemoPump::onEnter() auto pump = Node::create(); auto center = PhysicsShape::getPolyonCenter(vec, 4); pump->setPosition(center); - auto pumpB = PhysicsBody::createPolygon(vec, 4, PHYSICSBODY_MATERIAL_DEFAULT, -center); - pump->setPhysicsBody(pumpB); + addPhysicsComponent(pump, PhysicsBody::createPolygon(vec, 4, PHYSICSBODY_MATERIAL_DEFAULT, -center)); this->addChild(pump); - pumpB->setCategoryBitmask(0x02); - pumpB->setGravityEnable(false); + pump->getComponent()->getPhysicsBody()->setCategoryBitmask(0x02); + pump->getComponent()->getPhysicsBody()->setGravityEnable(false); // small gear auto sgear = Node::create(); - auto sgearB = PhysicsBody::createCircle(44); - sgear->setPhysicsBody(sgearB); + addPhysicsComponent(sgear, PhysicsBody::createCircle(44)); sgear->setPosition(VisibleRect::leftBottom() + Vec2(125, 0)); this->addChild(sgear); - sgearB->setCategoryBitmask(0x04); - sgearB->setCollisionBitmask(0x04); - sgearB->setTag(1); - - _world->addJoint(PhysicsJointPin::construct(body, sgearB, sgear->getPosition())); - _world->addJoint(PhysicsJointDistance::construct(pumpB, sgearB, Vec2(0, 0), Vec2(0, -44))); + sgear->getComponent()->getPhysicsBody()->setCategoryBitmask(0x04); + sgear->getComponent()->getPhysicsBody()->setCollisionBitmask(0x04); + sgear->getComponent()->getPhysicsBody()->setTag(1); + + _physicsWorld->addJoint(PhysicsJointPin::construct(node->getComponent()->getPhysicsBody(), sgear->getComponent()->getPhysicsBody(), sgear->getPosition())); + _physicsWorld->addJoint(PhysicsJointDistance::construct(pump->getComponent()->getPhysicsBody(), sgear->getComponent()->getPhysicsBody(), Vec2(0, 0), Vec2(0, -44))); // big gear auto bgear = Node::create(); - auto bgearB = PhysicsBody::createCircle(100); - bgear->setPhysicsBody(bgearB); + addPhysicsComponent(bgear, PhysicsBody::createCircle(100)); bgear->setPosition(VisibleRect::leftBottom() + Vec2(275, 0)); this->addChild(bgear); - bgearB->setCategoryBitmask(0x04); - - _world->addJoint(PhysicsJointPin::construct(bgearB, body, bgear->getPosition())); - _world->addJoint(PhysicsJointGear::construct(sgearB, bgearB, (float)-M_PI_2, -2.0f)); - + bgear->getComponent()->getPhysicsBody()->setCategoryBitmask(0x04); + + _physicsWorld->addJoint(PhysicsJointPin::construct(bgear->getComponent()->getPhysicsBody(), node->getComponent()->getPhysicsBody(), bgear->getPosition())); + _physicsWorld->addJoint(PhysicsJointGear::construct(sgear->getComponent()->getPhysicsBody(), bgear->getComponent()->getPhysicsBody(), (float)-M_PI_2, -2.0f)); + // plugger - Vec2 seg[] = {VisibleRect::leftTop() + Vec2(75, -120), VisibleRect::leftBottom() + Vec2(75, -100)}; - Vec2 segCenter = (seg[1] + seg[0])/2; + Vec2 seg[] = { VisibleRect::leftTop() + Vec2(75, -120), VisibleRect::leftBottom() + Vec2(75, -100) }; + Vec2 segCenter = (seg[1] + seg[0]) / 2; seg[1] -= segCenter; seg[0] -= segCenter; auto plugger = Node::create(); - auto pluggerB = PhysicsBody::createEdgeSegment(seg[0], seg[1], PhysicsMaterial(0.01f, 0.0f, 0.5f), 20); - pluggerB->setDynamic(true); - pluggerB->setMass(30); - pluggerB->setMoment(100000); - plugger->setPhysicsBody(pluggerB); + addPhysicsComponent(plugger, PhysicsBody::createEdgeSegment(seg[0], seg[1], PhysicsMaterial(0.01f, 0.0f, 0.5f), 20)); + plugger->getComponent()->getPhysicsBody()->setDynamic(true); + plugger->getComponent()->getPhysicsBody()->setMass(30); + plugger->getComponent()->getPhysicsBody()->setMoment(100000); plugger->setPosition(segCenter); this->addChild(plugger); - pluggerB->setCategoryBitmask(0x02); - sgearB->setCollisionBitmask(0x04 | 0x01); - _world->addJoint(PhysicsJointPin::construct(body, pluggerB, VisibleRect::leftBottom() + Vec2(75, -90))); - _world->addJoint(PhysicsJointDistance::construct(pluggerB, sgearB, Vec2::ZERO, Vec2(44, 0))); + plugger->getComponent()->getPhysicsBody()->setCategoryBitmask(0x02); + sgear->getComponent()->getPhysicsBody()->setCollisionBitmask(0x04 | 0x01); + _physicsWorld->addJoint(PhysicsJointPin::construct(node->getComponent()->getPhysicsBody(), plugger->getComponent()->getPhysicsBody(), VisibleRect::leftBottom() + Vec2(75, -90))); + _physicsWorld->addJoint(PhysicsJointDistance::construct(plugger->getComponent()->getPhysicsBody(), sgear->getComponent()->getPhysicsBody(), Vec2::ZERO, Vec2(44, 0))); } void PhysicsDemoPump::update(float delta) { - auto physicsWorld = getPhysicsWorld(); - - for (const auto& body : physicsWorld->getAllBodies()) + for (const auto& body : _physicsWorld->getAllBodies()) { if (body->getTag() == DRAG_BODYS_TAG && body->getPosition().y < 0.0f) { - body->getNode()->setPosition(VisibleRect::leftTop() + Vec2(75 + CCRANDOM_0_1() * 90, 0)); + if (body->getNode()!=nullptr) + { + body->getNode()->setPosition(VisibleRect::leftTop() + Vec2(75 + CCRANDOM_0_1() * 90, 0)); + } + body->setVelocity(Vec2(0, 0)); } } - PhysicsBody* gear = physicsWorld->getBody(1); + PhysicsBody* gear = _physicsWorld->getBody(1); if (gear != nullptr) { if (_distance != 0.0f) { - _rotationV += _distance/2500.0f; + _rotationV += _distance / 2500.0f; if (_rotationV > 30) _rotationV = 30.0f; if (_rotationV < -30) _rotationV = -30.0f; @@ -1057,22 +1090,22 @@ void PhysicsDemoOneWayPlatform::onEnter() _eventDispatcher->addEventListenerWithSceneGraphPriority(touchListener, this); auto ground = Node::create(); - ground->setPhysicsBody(PhysicsBody::createEdgeSegment(VisibleRect::leftBottom() + Vec2(0, 50), VisibleRect::rightBottom() + Vec2(0, 50))); + addPhysicsComponent(ground, PhysicsBody::createEdgeSegment(VisibleRect::leftBottom() + Vec2(0, 50), VisibleRect::rightBottom() + Vec2(0, 50))); this->addChild(ground); auto platform = makeBox(VisibleRect::center(), Size(200, 50)); - platform->getPhysicsBody()->setDynamic(false); - platform->getPhysicsBody()->setContactTestBitmask(0xFFFFFFFF); + platform->getComponent()->getPhysicsBody()->setDynamic(false); + platform->getComponent()->getPhysicsBody()->setContactTestBitmask(0xFFFFFFFF); this->addChild(platform); auto ball = makeBall(VisibleRect::center() - Vec2(0, 50), 20); - ball->getPhysicsBody()->setVelocity(Vec2(0, 150)); - ball->getPhysicsBody()->setTag(DRAG_BODYS_TAG); - ball->getPhysicsBody()->setMass(1.0f); - ball->getPhysicsBody()->setContactTestBitmask(0xFFFFFFFF); + ball->getComponent()->getPhysicsBody()->setVelocity(Vec2(0, 150)); + ball->getComponent()->getPhysicsBody()->setTag(DRAG_BODYS_TAG); + ball->getComponent()->getPhysicsBody()->setMass(1.0f); + ball->getComponent()->getPhysicsBody()->setContactTestBitmask(0xFFFFFFFF); this->addChild(ball); - auto contactListener = EventListenerPhysicsContactWithBodies::create(platform->getPhysicsBody(), ball->getPhysicsBody()); + auto contactListener = EventListenerPhysicsContactWithBodies::create(platform->getComponent()->getPhysicsBody(), ball->getComponent()->getPhysicsBody()); contactListener->onContactBegin = CC_CALLBACK_1(PhysicsDemoOneWayPlatform::onContactBegin, this); _eventDispatcher->addEventListenerWithSceneGraphPriority(contactListener, this); } @@ -1100,14 +1133,14 @@ void PhysicsDemoSlice::onEnter() _eventDispatcher->addEventListenerWithSceneGraphPriority(touchListener, this); auto ground = Node::create(); - ground->setPhysicsBody(PhysicsBody::createEdgeSegment(VisibleRect::leftBottom() + Vec2(0, 50), VisibleRect::rightBottom() + Vec2(0, 50))); + addPhysicsComponent(ground, PhysicsBody::createEdgeSegment(VisibleRect::leftBottom() + Vec2(0, 50), VisibleRect::rightBottom() + Vec2(0, 50))); this->addChild(ground); auto box = Node::create(); Vec2 points[4] = {Vec2(-100, -100), Vec2(-100, 100), Vec2(100, 100), Vec2(100, -100)}; - box->setPhysicsBody(PhysicsBody::createPolygon(points, 4)); + addPhysicsComponent(box, PhysicsBody::createPolygon(points, 4)); box->setPosition(VisibleRect::center()); - box->getPhysicsBody()->setTag(_sliceTag); + box->getComponent()->getPhysicsBody()->setTag(_sliceTag); addChild(box); } @@ -1166,7 +1199,7 @@ void PhysicsDemoSlice::clipPoly(PhysicsShapePolygon* shape, Vec2 normal, float d Node* node = Node::create(); PhysicsBody* polyon = PhysicsBody::createPolygon(points, pointsCount, PHYSICSBODY_MATERIAL_DEFAULT, -center); node->setPosition(center); - node->setPhysicsBody(polyon); + addPhysicsComponent(node, polyon); polyon->setVelocity(body->getVelocityAtWorldPoint(center)); polyon->setAngularVelocity(body->getAngularVelocity()); polyon->setTag(_sliceTag); @@ -1191,21 +1224,20 @@ std::string PhysicsDemoSlice::subtitle() const return "click and drag to slice up the block"; } - void PhysicsDemoBug3988::onEnter() { PhysicsDemo::onEnter(); toggleDebug(); - getPhysicsWorld()->setGravity(Vect::ZERO); - - auto ball = Sprite::create("Images/YellowSquare.png"); - ball->setPosition(VisibleRect::center() - Vec2(100, 0)); - ball->setRotation(30.0f); - this->addChild(ball); - - auto physicsBall = makeBox(VisibleRect::center() + Vec2(100, 0), Size(100, 100)); - physicsBall->setRotation(30.0f); - this->addChild(physicsBall); + _physicsWorld->setGravity(Vect::ZERO); + + auto ball = Sprite::create("Images/YellowSquare.png"); + ball->setPosition(VisibleRect::center() - Vec2(100, 0)); + ball->setRotation(30.0f); + this->addChild(ball); + + auto physicsBall = makeBox(VisibleRect::center() + Vec2(100, 0), Size(100, 100)); + physicsBall->setRotation(30.0f); + this->addChild(physicsBall); } std::string PhysicsDemoBug3988::title() const @@ -1221,7 +1253,7 @@ std::string PhysicsDemoBug3988::subtitle() const void PhysicsContactTest::onEnter() { PhysicsDemo::onEnter(); - getPhysicsWorld()->setGravity(Vect::ZERO); + _physicsWorld->setGravity(Vect::ZERO); auto s = VisibleRect::getVisibleRect().size; _yellowBoxNum = 50; @@ -1232,69 +1264,69 @@ void PhysicsContactTest::onEnter() MenuItemFont::setFontSize(65); auto decrease1 = MenuItemFont::create(" - ", CC_CALLBACK_1(PhysicsContactTest::onDecrease, this)); - decrease1->setColor(Color3B(0,200,20)); + decrease1->setColor(Color3B(0, 200, 20)); auto increase1 = MenuItemFont::create(" + ", CC_CALLBACK_1(PhysicsContactTest::onIncrease, this)); - increase1->setColor(Color3B(0,200,20)); + increase1->setColor(Color3B(0, 200, 20)); decrease1->setTag(1); increase1->setTag(1); auto menu1 = Menu::create(decrease1, increase1, nullptr); menu1->alignItemsHorizontally(); - menu1->setPosition(Vec2(s.width/2, s.height-50)); + menu1->setPosition(Vec2(s.width / 2, s.height - 50)); addChild(menu1, 1); auto label = Label::createWithTTF("yellow box", "fonts/arial.ttf", 32); addChild(label, 1); - label->setPosition(Vec2(s.width/2 - 150, s.height-50)); + label->setPosition(Vec2(s.width / 2 - 150, s.height - 50)); auto decrease2 = MenuItemFont::create(" - ", CC_CALLBACK_1(PhysicsContactTest::onDecrease, this)); - decrease2->setColor(Color3B(0,200,20)); + decrease2->setColor(Color3B(0, 200, 20)); auto increase2 = MenuItemFont::create(" + ", CC_CALLBACK_1(PhysicsContactTest::onIncrease, this)); - increase2->setColor(Color3B(0,200,20)); + increase2->setColor(Color3B(0, 200, 20)); decrease2->setTag(2); increase2->setTag(2); auto menu2 = Menu::create(decrease2, increase2, nullptr); menu2->alignItemsHorizontally(); - menu2->setPosition(Vec2(s.width/2, s.height-90)); + menu2->setPosition(Vec2(s.width / 2, s.height - 90)); addChild(menu2, 1); label = Label::createWithTTF("blue box", "fonts/arial.ttf", 32); addChild(label, 1); - label->setPosition(Vec2(s.width/2 - 150, s.height-90)); + label->setPosition(Vec2(s.width / 2 - 150, s.height - 90)); auto decrease3 = MenuItemFont::create(" - ", CC_CALLBACK_1(PhysicsContactTest::onDecrease, this)); - decrease3->setColor(Color3B(0,200,20)); + decrease3->setColor(Color3B(0, 200, 20)); auto increase3 = MenuItemFont::create(" + ", CC_CALLBACK_1(PhysicsContactTest::onIncrease, this)); - increase3->setColor(Color3B(0,200,20)); + increase3->setColor(Color3B(0, 200, 20)); decrease3->setTag(3); increase3->setTag(3); auto menu3 = Menu::create(decrease3, increase3, nullptr); menu3->alignItemsHorizontally(); - menu3->setPosition(Vec2(s.width/2, s.height-130)); + menu3->setPosition(Vec2(s.width / 2, s.height - 130)); addChild(menu3, 1); label = Label::createWithTTF("yellow triangle", "fonts/arial.ttf", 32); addChild(label, 1); - label->setPosition(Vec2(s.width/2 - 150, s.height-130)); + label->setPosition(Vec2(s.width / 2 - 150, s.height - 130)); auto decrease4 = MenuItemFont::create(" - ", CC_CALLBACK_1(PhysicsContactTest::onDecrease, this)); - decrease4->setColor(Color3B(0,200,20)); + decrease4->setColor(Color3B(0, 200, 20)); auto increase4 = MenuItemFont::create(" + ", CC_CALLBACK_1(PhysicsContactTest::onIncrease, this)); - increase4->setColor(Color3B(0,200,20)); + increase4->setColor(Color3B(0, 200, 20)); decrease4->setTag(4); increase4->setTag(4); auto menu4 = Menu::create(decrease4, increase4, nullptr); menu4->alignItemsHorizontally(); - menu4->setPosition(Vec2(s.width/2, s.height-170)); + menu4->setPosition(Vec2(s.width / 2, s.height - 170)); addChild(menu4, 1); label = Label::createWithTTF("blue triangle", "fonts/arial.ttf", 32); addChild(label, 1); - label->setPosition(Vec2(s.width/2 - 150, s.height-170)); - + label->setPosition(Vec2(s.width / 2 - 150, s.height - 170)); + resetTest(); } @@ -1303,16 +1335,16 @@ void PhysicsContactTest::onDecrease(Ref* sender) switch (dynamic_cast(sender)->getTag()) { case 1: - if(_yellowBoxNum > 0) _yellowBoxNum -= 50; + if (_yellowBoxNum > 0) _yellowBoxNum -= 50; break; case 2: - if(_blueBoxNum > 0) _blueBoxNum -= 50; + if (_blueBoxNum > 0) _blueBoxNum -= 50; break; case 3: - if(_yellowTriangleNum > 0) _yellowTriangleNum -= 50; + if (_yellowTriangleNum > 0) _yellowTriangleNum -= 50; break; case 4: - if(_blueTriangleNum > 0) _blueTriangleNum -= 50; + if (_blueTriangleNum > 0) _blueTriangleNum -= 50; break; default: @@ -1360,25 +1392,25 @@ void PhysicsContactTest::resetTest() sprintf(buffer, "%d", _yellowBoxNum); auto label = Label::createWithTTF(buffer, "fonts/arial.ttf", 32); root->addChild(label, 1); - label->setPosition(Vec2(s.width/2, s.height-50)); + label->setPosition(Vec2(s.width / 2, s.height - 50)); sprintf(buffer, "%d", _blueBoxNum); label = Label::createWithTTF(buffer, "fonts/arial.ttf", 32); root->addChild(label, 1); - label->setPosition(Vec2(s.width/2, s.height-90)); + label->setPosition(Vec2(s.width / 2, s.height - 90)); sprintf(buffer, "%d", _yellowTriangleNum); label = Label::createWithTTF(buffer, "fonts/arial.ttf", 32); root->addChild(label, 1); - label->setPosition(Vec2(s.width/2, s.height-130)); + label->setPosition(Vec2(s.width / 2, s.height - 130)); sprintf(buffer, "%d", _blueTriangleNum); label = Label::createWithTTF(buffer, "fonts/arial.ttf", 32); root->addChild(label, 1); - label->setPosition(Vec2(s.width/2, s.height-170)); + label->setPosition(Vec2(s.width / 2, s.height - 170)); auto wall = Node::create(); - wall->setPhysicsBody(PhysicsBody::createEdgeBox(VisibleRect::getVisibleRect().size, PhysicsMaterial(0.1f, 1, 0.0f))); + addPhysicsComponent(wall, PhysicsBody::createEdgeBox(VisibleRect::getVisibleRect().size, PhysicsMaterial(0.1f, 1, 0.0f))); wall->setPosition(VisibleRect::center()); root->addChild(wall); @@ -1389,72 +1421,72 @@ void PhysicsContactTest::resetTest() // yellow box, will collide with itself and blue box. for (int i = 0; i < _yellowBoxNum; ++i) { - Size size(10 + CCRANDOM_0_1()*10, 10 + CCRANDOM_0_1()*10); + Size size(10 + CCRANDOM_0_1() * 10, 10 + CCRANDOM_0_1() * 10); Size winSize = VisibleRect::getVisibleRect().size; Vec2 position = Vec2(winSize.width, winSize.height) - Vec2(size.width, size.height); position.x = position.x * CCRANDOM_0_1(); position.y = position.y * CCRANDOM_0_1(); - position = VisibleRect::leftBottom() + position + Vec2(size.width/2, size.height/2); - Vect velocity((CCRANDOM_0_1() - 0.5)*200, (CCRANDOM_0_1() - 0.5)*200); + position = VisibleRect::leftBottom() + position + Vec2(size.width / 2, size.height / 2); + Vect velocity((CCRANDOM_0_1() - 0.5) * 200, (CCRANDOM_0_1() - 0.5) * 200); auto box = makeBox(position, size, 1, PhysicsMaterial(0.1f, 1, 0.0f)); - box->getPhysicsBody()->setVelocity(velocity); - box->getPhysicsBody()->setCategoryBitmask(0x01); // 0001 - box->getPhysicsBody()->setContactTestBitmask(0x04); // 0100 - box->getPhysicsBody()->setCollisionBitmask(0x03); // 0011 + box->getComponent()->getPhysicsBody()->setVelocity(velocity); + box->getComponent()->getPhysicsBody()->setCategoryBitmask(0x01); // 0001 + box->getComponent()->getPhysicsBody()->setContactTestBitmask(0x04); // 0100 + box->getComponent()->getPhysicsBody()->setCollisionBitmask(0x03); // 0011 root->addChild(box); } // blue box, will collide with blue box. for (int i = 0; i < _blueBoxNum; ++i) { - Size size(10 + CCRANDOM_0_1()*10, 10 + CCRANDOM_0_1()*10); + Size size(10 + CCRANDOM_0_1() * 10, 10 + CCRANDOM_0_1() * 10); Size winSize = VisibleRect::getVisibleRect().size; Vec2 position = Vec2(winSize.width, winSize.height) - Vec2(size.width, size.height); position.x = position.x * CCRANDOM_0_1(); position.y = position.y * CCRANDOM_0_1(); - position = VisibleRect::leftBottom() + position + Vec2(size.width/2, size.height/2); - Vect velocity((CCRANDOM_0_1() - 0.5)*200, (CCRANDOM_0_1() - 0.5)*200); + position = VisibleRect::leftBottom() + position + Vec2(size.width / 2, size.height / 2); + Vect velocity((CCRANDOM_0_1() - 0.5) * 200, (CCRANDOM_0_1() - 0.5) * 200); auto box = makeBox(position, size, 2, PhysicsMaterial(0.1f, 1, 0.0f)); - box->getPhysicsBody()->setVelocity(velocity); - box->getPhysicsBody()->setCategoryBitmask(0x02); // 0010 - box->getPhysicsBody()->setContactTestBitmask(0x08); // 1000 - box->getPhysicsBody()->setCollisionBitmask(0x01); // 0001 + box->getComponent()->getPhysicsBody()->setVelocity(velocity); + box->getComponent()->getPhysicsBody()->setCategoryBitmask(0x02); // 0010 + box->getComponent()->getPhysicsBody()->setContactTestBitmask(0x08); // 1000 + box->getComponent()->getPhysicsBody()->setCollisionBitmask(0x01); // 0001 root->addChild(box); } // yellow triangle, will collide with itself and blue box. for (int i = 0; i < _yellowTriangleNum; ++i) { - Size size(10 + CCRANDOM_0_1()*10, 10 + CCRANDOM_0_1()*10); + Size size(10 + CCRANDOM_0_1() * 10, 10 + CCRANDOM_0_1() * 10); Size winSize = VisibleRect::getVisibleRect().size; Vec2 position = Vec2(winSize.width, winSize.height) - Vec2(size.width, size.height); position.x = position.x * CCRANDOM_0_1(); position.y = position.y * CCRANDOM_0_1(); - position = VisibleRect::leftBottom() + position + Vec2(size.width/2, size.height/2); - Vect velocity((CCRANDOM_0_1() - 0.5)*300, (CCRANDOM_0_1() - 0.5)*300); + position = VisibleRect::leftBottom() + position + Vec2(size.width / 2, size.height / 2); + Vect velocity((CCRANDOM_0_1() - 0.5) * 300, (CCRANDOM_0_1() - 0.5) * 300); auto triangle = makeTriangle(position, size, 1, PhysicsMaterial(0.1f, 1, 0.0f)); - triangle->getPhysicsBody()->setVelocity(velocity); - triangle->getPhysicsBody()->setCategoryBitmask(0x04); // 0100 - triangle->getPhysicsBody()->setContactTestBitmask(0x01); // 0001 - triangle->getPhysicsBody()->setCollisionBitmask(0x06); // 0110 + triangle->getComponent()->getPhysicsBody()->setVelocity(velocity); + triangle->getComponent()->getPhysicsBody()->setCategoryBitmask(0x04); // 0100 + triangle->getComponent()->getPhysicsBody()->setContactTestBitmask(0x01); // 0001 + triangle->getComponent()->getPhysicsBody()->setCollisionBitmask(0x06); // 0110 root->addChild(triangle); } // blue triangle, will collide with yellow box. for (int i = 0; i < _blueTriangleNum; ++i) { - Size size(10 + CCRANDOM_0_1()*10, 10 + CCRANDOM_0_1()*10); + Size size(10 + CCRANDOM_0_1() * 10, 10 + CCRANDOM_0_1() * 10); Size winSize = VisibleRect::getVisibleRect().size; Vec2 position = Vec2(winSize.width, winSize.height) - Vec2(size.width, size.height); position.x = position.x * CCRANDOM_0_1(); position.y = position.y * CCRANDOM_0_1(); - position = VisibleRect::leftBottom() + position + Vec2(size.width/2, size.height/2); - Vect velocity((CCRANDOM_0_1() - 0.5)*300, (CCRANDOM_0_1() - 0.5)*300); + position = VisibleRect::leftBottom() + position + Vec2(size.width / 2, size.height / 2); + Vect velocity((CCRANDOM_0_1() - 0.5) * 300, (CCRANDOM_0_1() - 0.5) * 300); auto triangle = makeTriangle(position, size, 2, PhysicsMaterial(0.1f, 1, 0.0f)); - triangle->getPhysicsBody()->setVelocity(velocity); - triangle->getPhysicsBody()->setCategoryBitmask(0x08); // 1000 - triangle->getPhysicsBody()->setContactTestBitmask(0x02); // 0010 - triangle->getPhysicsBody()->setCollisionBitmask(0x01); // 0001 + triangle->getComponent()->getPhysicsBody()->setVelocity(velocity); + triangle->getComponent()->getPhysicsBody()->setCategoryBitmask(0x08); // 1000 + triangle->getComponent()->getPhysicsBody()->setContactTestBitmask(0x02); // 0010 + triangle->getComponent()->getPhysicsBody()->setCollisionBitmask(0x01); // 0001 root->addChild(triangle); } } @@ -1484,7 +1516,7 @@ void PhysicsPositionRotationTest::onEnter() { PhysicsDemo::onEnter(); toggleDebug(); - getPhysicsWorld()->setGravity(Point::ZERO); + _physicsWorld->setGravity(Point::ZERO); auto touchListener = EventListenerTouchOneByOne::create(); touchListener->onTouchBegan = CC_CALLBACK_2(PhysicsDemo::onTouchBegan, this); @@ -1493,41 +1525,41 @@ void PhysicsPositionRotationTest::onEnter() _eventDispatcher->addEventListenerWithSceneGraphPriority(touchListener, this); auto wall = Node::create(); - wall->setPhysicsBody(PhysicsBody::createEdgeBox(VisibleRect::getVisibleRect().size)); + addPhysicsComponent(wall, PhysicsBody::createEdgeBox(VisibleRect::getVisibleRect().size)); wall->setPosition(VisibleRect::center()); addChild(wall); // anchor test auto anchorNode = Sprite::create("Images/YellowSquare.png"); - anchorNode->setAnchorPoint(Vec2(0.1f, 0.9f)); + //anchorNode->setAnchorPoint(Vec2(0.1f, 0.9f)); anchorNode->setPosition(100, 100); anchorNode->setScale(0.25); + addPhysicsComponent(anchorNode, PhysicsBody::createBox(anchorNode->getContentSize())); + anchorNode->getComponent()->getPhysicsBody()->setTag(DRAG_BODYS_TAG); addChild(anchorNode); - anchorNode->setPhysicsBody(PhysicsBody::createBox(anchorNode->getContentSize()*anchorNode->getScale())); - anchorNode->getPhysicsBody()->setTag(DRAG_BODYS_TAG); //parent test auto parent = Sprite::create("Images/YellowSquare.png"); parent->setPosition(200, 100); parent->setScale(0.25); - parent->setPhysicsBody(PhysicsBody::createBox(parent->getContentSize()*anchorNode->getScale())); - parent->getPhysicsBody()->setTag(DRAG_BODYS_TAG); + addPhysicsComponent(parent,PhysicsBody::createBox(parent->getContentSize())); + parent->getComponent()->getPhysicsBody()->setTag(DRAG_BODYS_TAG); addChild(parent); auto leftBall = Sprite::create("Images/ball.png"); leftBall->setPosition(-30, 0); - leftBall->cocos2d::Node::setScale(2); - leftBall->setPhysicsBody(PhysicsBody::createCircle(leftBall->getContentSize().width)); - leftBall->getPhysicsBody()->setTag(DRAG_BODYS_TAG); + leftBall->Node::setScale(2); + addPhysicsComponent(leftBall, PhysicsBody::createCircle(leftBall->getContentSize().width/2)); + leftBall->getComponent()->getPhysicsBody()->setTag(DRAG_BODYS_TAG); parent->addChild(leftBall); // offset position rotation test auto offsetPosNode = Sprite::create("Images/YellowSquare.png"); offsetPosNode->setPosition(100, 200); - offsetPosNode->setPhysicsBody(PhysicsBody::createBox(offsetPosNode->getContentSize()/2)); - offsetPosNode->getPhysicsBody()->setPositionOffset(-Vec2(offsetPosNode->getContentSize()/2)); - offsetPosNode->getPhysicsBody()->setRotationOffset(45); - offsetPosNode->getPhysicsBody()->setTag(DRAG_BODYS_TAG); + addPhysicsComponent(offsetPosNode, PhysicsBody::createBox(offsetPosNode->getContentSize()/2)); + offsetPosNode->getComponent()->getPhysicsBody()->setPositionOffset(-Vec2(offsetPosNode->getContentSize() / 2)); + offsetPosNode->getComponent()->getPhysicsBody()->setRotationOffset(45); + offsetPosNode->getComponent()->getPhysicsBody()->setTag(DRAG_BODYS_TAG); addChild(offsetPosNode); return; @@ -1538,7 +1570,6 @@ std::string PhysicsPositionRotationTest::title() const return "Position/Rotation Test"; } - void PhysicsSetGravityEnableTest::onEnter() { PhysicsDemo::onEnter(); @@ -1551,36 +1582,36 @@ void PhysicsSetGravityEnableTest::onEnter() // wall auto wall = Node::create(); - wall->setPhysicsBody(PhysicsBody::createEdgeBox(VisibleRect::getVisibleRect().size, PhysicsMaterial(0.1f, 1.0f, 0.0f))); + addPhysicsComponent(wall, PhysicsBody::createEdgeBox(VisibleRect::getVisibleRect().size, PhysicsMaterial(0.1f, 1.0f, 0.0f))); wall->setPosition(VisibleRect::center()); addChild(wall); // common box auto commonBox = makeBox(Vec2(100, 100), Size(50, 50), 1); - commonBox->getPhysicsBody()->setTag(DRAG_BODYS_TAG); + commonBox->getComponent()->getPhysicsBody()->setTag(DRAG_BODYS_TAG); addChild(commonBox); auto box = makeBox(Vec2(200, 100), Size(50, 50), 2); - box->getPhysicsBody()->setMass(20); - box->getPhysicsBody()->setTag(DRAG_BODYS_TAG); - box->getPhysicsBody()->setGravityEnable(false); + box->getComponent()->getPhysicsBody()->setMass(20); + box->getComponent()->getPhysicsBody()->setTag(DRAG_BODYS_TAG); + box->getComponent()->getPhysicsBody()->setGravityEnable(false); addChild(box); auto ball = makeBall(Vec2(200, 200), 50); ball->setTag(2); - ball->getPhysicsBody()->setTag(DRAG_BODYS_TAG); - ball->getPhysicsBody()->setGravityEnable(false); + ball->getComponent()->getPhysicsBody()->setTag(DRAG_BODYS_TAG); + ball->getComponent()->getPhysicsBody()->setGravityEnable(false); addChild(ball); - ball->getPhysicsBody()->setMass(50); + ball->getComponent()->getPhysicsBody()->setMass(50); scheduleOnce(CC_SCHEDULE_SELECTOR(PhysicsSetGravityEnableTest::onScheduleOnce), 1.0); } void PhysicsSetGravityEnableTest::onScheduleOnce(float delta) { auto ball = getChildByTag(2); - ball->getPhysicsBody()->setMass(200); + ball->getComponent()->getPhysicsBody()->setMass(200); - getPhysicsWorld()->setGravity(Vect(0, 98)); + _physicsWorld->setGravity(Vect(0, 98)); } std::string PhysicsSetGravityEnableTest::title() const @@ -1593,7 +1624,7 @@ std::string PhysicsSetGravityEnableTest::subtitle() const return "only yellow box drop down"; } -void Bug5482::onEnter() +void PhysicsDemoBug5482::onEnter() { PhysicsDemo::onEnter(); @@ -1609,23 +1640,25 @@ void Bug5482::onEnter() // wall auto wall = Node::create(); - wall->setPhysicsBody(PhysicsBody::createEdgeBox(VisibleRect::getVisibleRect().size, PhysicsMaterial(0.1f, 1.0f, 0.0f))); + addPhysicsComponent(wall, PhysicsBody::createEdgeBox(VisibleRect::getVisibleRect().size, PhysicsMaterial(0.1f, 1.0f, 0.0f))); wall->setPosition(VisibleRect::center()); addChild(wall); //button MenuItemFont::setFontSize(18); - _button = MenuItemFont::create("Set Body To A", CC_CALLBACK_1(Bug5482::changeBodyCallback, this)); + _button = MenuItemFont::create("Set Body To A", CC_CALLBACK_1(PhysicsDemoBug5482::changeBodyCallback, this)); auto menu = Menu::create(_button, nullptr); this->addChild(menu); _nodeA = Sprite::create("Images/YellowSquare.png"); _nodeA->setPosition(VisibleRect::center().x - 150, 100); + _nodeA->addComponent(ComponentPhysics2d::create()); this->addChild(_nodeA); _nodeB = Sprite::create("Images/YellowSquare.png"); _nodeB->setPosition(VisibleRect::center().x + 150, 100); + _nodeB->addComponent(ComponentPhysics2d::create()); this->addChild(_nodeB); _body = PhysicsBody::createBox(_nodeA->getContentSize()); @@ -1633,27 +1666,25 @@ void Bug5482::onEnter() _body->retain(); } -void Bug5482::onExit() +void PhysicsDemoBug5482::onExit() { PhysicsDemo::onExit(); _body->release(); } -void Bug5482::changeBodyCallback(Ref* sender) +void PhysicsDemoBug5482::changeBodyCallback(Ref* sender) { Sprite* node = _bodyInA ? _nodeB : _nodeA; - - node->setPhysicsBody(_body); - + node->getComponent()->setPhysicsBody(_body); _bodyInA = !_bodyInA; } -std::string Bug5482::title() const +std::string PhysicsDemoBug5482::title() const { return "bug 5482: setPhysicsBodyTest"; } -std::string Bug5482::subtitle() const +std::string PhysicsDemoBug5482::subtitle() const { return "change physics body to the other."; } @@ -1662,12 +1693,12 @@ void PhysicsFixedUpdate::onEnter() { PhysicsDemo::onEnter(); - getPhysicsWorld()->setDebugDrawMask(PhysicsWorld::DEBUGDRAW_ALL); - getPhysicsWorld()->setGravity(Point::ZERO); + _physicsWorld->setDebugDrawMask(PhysicsWorld::DEBUGDRAW_ALL); + _physicsWorld->setGravity(Point::ZERO); // wall auto wall = Node::create(); - wall->setPhysicsBody(PhysicsBody::createEdgeBox(VisibleRect::getVisibleRect().size, PhysicsMaterial(0.1f, 1, 0.0f))); + addPhysicsComponent(wall, PhysicsBody::createEdgeBox(VisibleRect::getVisibleRect().size, PhysicsMaterial(0.1f, 1, 0.0f))); wall->setPosition(VisibleRect::center()); this->addChild(wall); @@ -1680,9 +1711,9 @@ void PhysicsFixedUpdate::addBall() { auto ball = Sprite::create("Images/ball.png"); ball->setPosition(100, 100); - ball->setPhysicsBody(PhysicsBody::createCircle(ball->getContentSize().width/2, PhysicsMaterial(0.1f, 1, 0.0f))); - ball->getPhysicsBody()->setTag(DRAG_BODYS_TAG); - ball->getPhysicsBody()->setVelocity(Point(1000, 20)); + addPhysicsComponent(ball, PhysicsBody::createCircle(ball->getContentSize().width/2, PhysicsMaterial(0.1f, 1, 0.0f))); + ball->getComponent()->getPhysicsBody()->setTag(DRAG_BODYS_TAG); + ball->getComponent()->getPhysicsBody()->setVelocity(Point(1000, 20)); this->addChild(ball); } @@ -1690,7 +1721,7 @@ void PhysicsFixedUpdate::updateStart(float delta) { addBall(); - getPhysicsWorld()->setAutoStep(false); + _physicsWorld->setAutoStep(false); scheduleUpdate(); } @@ -1700,7 +1731,7 @@ void PhysicsFixedUpdate::update(float delta) // use fixed time and calculate 3 times per frame makes physics simulate more precisely. for (int i = 0; i < 3; ++i) { - getPhysicsWorld()->step(1/180.0f); + _physicsWorld->step(1/180.0f); } } @@ -1724,7 +1755,7 @@ void PhysicsTransformTest::onEnter() { PhysicsDemo::onEnter(); toggleDebug(); - getPhysicsWorld()->setGravity(Point::ZERO); + _physicsWorld->setGravity(Point::ZERO); auto touchListener = EventListenerTouchOneByOne::create(); touchListener->onTouchBegan = CC_CALLBACK_2(PhysicsTransformTest::onTouchBegan, this); @@ -1734,7 +1765,7 @@ void PhysicsTransformTest::onEnter() addChild(_rootLayer); auto wall = Node::create(); - wall->setPhysicsBody(PhysicsBody::createEdgeBox(VisibleRect::getVisibleRect().size, PhysicsMaterial(0.1f, 1.0f, 0.0f))); + addPhysicsComponent(wall, PhysicsBody::createEdgeBox(VisibleRect::getVisibleRect().size, PhysicsMaterial(0.1f, 1.0f, 0.0f))); wall->setPosition(VisibleRect::center()); _rootLayer->addChild(wall); @@ -1742,16 +1773,16 @@ void PhysicsTransformTest::onEnter() _parentSprite = Sprite::create("Images/YellowSquare.png"); _parentSprite->setPosition(200, 100); _parentSprite->setScale(0.25); - _parentSprite->setPhysicsBody(PhysicsBody::createBox(_parentSprite->getContentSize()*_parentSprite->getScale(), PhysicsMaterial(0.1f, 1.0f, 0.0f))); - _parentSprite->getPhysicsBody()->setTag(DRAG_BODYS_TAG); + addPhysicsComponent(_parentSprite, PhysicsBody::createBox(_parentSprite->getContentSize(), PhysicsMaterial(0.1f, 1.0f, 0.0f))); + _parentSprite->getComponent()->getPhysicsBody()->setTag(DRAG_BODYS_TAG); _parentSprite->setTag(1); _rootLayer->addChild(_parentSprite); auto leftBall = Sprite::create("Images/ball.png"); leftBall->setPosition(-30, 0); - leftBall->cocos2d::Node::setScale(2); - leftBall->setPhysicsBody(PhysicsBody::createCircle(leftBall->getContentSize().width, PhysicsMaterial(0.1f, 1.0f, 0.0f))); - leftBall->getPhysicsBody()->setTag(DRAG_BODYS_TAG); + leftBall->setScale(2); + addPhysicsComponent(leftBall, PhysicsBody::createCircle(leftBall->getContentSize().width/2, PhysicsMaterial(0.1f, 1.0f, 0.0f))); + leftBall->getComponent()->getPhysicsBody()->setTag(DRAG_BODYS_TAG); _parentSprite->addChild(leftBall); ScaleTo* scaleTo = ScaleTo::create(2.0, 0.5); @@ -1761,20 +1792,16 @@ void PhysicsTransformTest::onEnter() auto normal = Sprite::create("Images/YellowSquare.png"); normal->setPosition(300, 100); normal->setScale(0.25, 0.5); - auto size = _parentSprite->getContentSize(); - size.width *= normal->getScaleX(); - size.height *= normal->getScaleY(); - normal->setPhysicsBody(PhysicsBody::createBox(size, PhysicsMaterial(0.1f, 1.0f, 0.0f))); - normal->getPhysicsBody()->setTag(DRAG_BODYS_TAG); + addPhysicsComponent(normal,PhysicsBody::createBox(normal->getContentSize(), PhysicsMaterial(0.1f, 1.0f, 0.0f))); + normal->getComponent()->getPhysicsBody()->setTag(DRAG_BODYS_TAG); _rootLayer->addChild(normal); auto bullet = Sprite::create("Images/ball.png"); bullet->setPosition(200, 200); - bullet->setPhysicsBody(PhysicsBody::createCircle(bullet->getContentSize().width/2, PhysicsMaterial(0.1f, 1.0f, 0.0f))); - bullet->getPhysicsBody()->setVelocity(Vect(100, 100)); + addPhysicsComponent(bullet,PhysicsBody::createCircle(bullet->getContentSize().width/2, PhysicsMaterial(0.1f, 1.0f, 0.0f))); + bullet->getComponent()->getPhysicsBody()->setVelocity(Vect(100, 100)); _rootLayer->addChild(bullet); - MoveBy* move = MoveBy::create(2.0f, Vec2(100, 100)); MoveBy* move2 = MoveBy::create(2.0f, Vec2(-200, 0)); MoveBy* move3 = MoveBy::create(2.0f, Vec2(100, -100)); @@ -1826,4 +1853,4 @@ std::string PhysicsIssue9959::subtitle() const return "Test Scale9Sprite run scale/move/rotation action in physics scene"; } -#endif // ifndef CC_USE_PHYSICS +#endif \ No newline at end of file diff --git a/tests/cpp-tests/Classes/PhysicsTest/PhysicsTest.h b/tests/cpp-tests/Classes/PhysicsTest/PhysicsTest.h index 0e3646c9fd..4163e1d13b 100644 --- a/tests/cpp-tests/Classes/PhysicsTest/PhysicsTest.h +++ b/tests/cpp-tests/Classes/PhysicsTest/PhysicsTest.h @@ -1,22 +1,13 @@ -#ifndef _PHYSICS_TEST_H_ -#define _PHYSICS_TEST_H_ - -#include "cocos2d.h" -#include "../BaseTest.h" +#pragma once #include -DEFINE_TEST_SUITE(PhysicsTests); +#include "../BaseTest.h" -#if CC_USE_PHYSICS == 0 -class PhysicsDemoDisabled : public TestCase -{ -public: - CREATE_FUNC(PhysicsDemoDisabled); - - virtual void onEnter() override; -}; -#else +#if CC_USE_PHYSICS + + +DEFINE_TEST_SUITE(PhysicsTests); class PhysicsDemo : public TestCase { @@ -38,20 +29,32 @@ public: bool onTouchBegan(cocos2d::Touch* touch, cocos2d::Event* event); void onTouchMoved(cocos2d::Touch* touch, cocos2d::Event* event); void onTouchEnded(cocos2d::Touch* touch, cocos2d::Event* event); - + void toggleDebug(); + protected: + void addPhysicsComponent(cocos2d::Node *node, cocos2d::PhysicsBody *physicsBody); + cocos2d::Texture2D* _spriteTexture; cocos2d::SpriteBatchNode* _ball; std::unordered_map _mouses; bool _debugDraw; }; +class PhysicsDemoLogoSmash : public PhysicsDemo +{ +public: + CREATE_FUNC(PhysicsDemoLogoSmash); + + void onEnter() override; + virtual std::string title() const override; +}; + class PhysicsDemoClickAdd : public PhysicsDemo { public: CREATE_FUNC(PhysicsDemoClickAdd); - + virtual ~PhysicsDemoClickAdd(); void onEnter() override; virtual std::string subtitle() const override; @@ -60,20 +63,11 @@ public: void onAcceleration(cocos2d::Acceleration* acc, cocos2d::Event* event); }; -class PhysicsDemoLogoSmash : public PhysicsDemo -{ -public: - CREATE_FUNC(PhysicsDemoLogoSmash); - - void onEnter() override; - virtual std::string title() const override; -}; - class PhysicsDemoPyramidStack : public PhysicsDemo { public: CREATE_FUNC(PhysicsDemoPyramidStack); - + void onEnter() override; void updateOnce(float delta); virtual std::string title() const override; @@ -83,9 +77,9 @@ class PhysicsDemoRayCast : public PhysicsDemo { public: CREATE_FUNC(PhysicsDemoRayCast); - + PhysicsDemoRayCast(); - + void onEnter() override; virtual std::string title() const override; void update(float delta) override; @@ -101,20 +95,20 @@ private: int _mode; }; -class PhysicsDemoJoints : public PhysicsDemo -{ -public: - CREATE_FUNC(PhysicsDemoJoints); - - void onEnter() override; - virtual std::string title() const override; -}; - class PhysicsDemoActions : public PhysicsDemo { public: CREATE_FUNC(PhysicsDemoActions); + + void onEnter() override; + virtual std::string title() const override; +}; +class PhysicsDemoJoints : public PhysicsDemo +{ +public: + CREATE_FUNC(PhysicsDemoJoints); + void onEnter() override; virtual std::string title() const override; }; @@ -123,7 +117,7 @@ class PhysicsDemoPump : public PhysicsDemo { public: CREATE_FUNC(PhysicsDemoPump); - + void onEnter() override; void update(float delta) override; virtual std::string title() const override; @@ -142,7 +136,7 @@ class PhysicsDemoOneWayPlatform : public PhysicsDemo { public: CREATE_FUNC(PhysicsDemoOneWayPlatform); - + void onEnter() override; virtual std::string title() const override; @@ -153,7 +147,7 @@ class PhysicsDemoSlice : public PhysicsDemo { public: CREATE_FUNC(PhysicsDemoSlice); - + void onEnter() override; virtual std::string title() const override; virtual std::string subtitle() const override; @@ -171,7 +165,7 @@ class PhysicsDemoBug3988 : public PhysicsDemo { public: CREATE_FUNC(PhysicsDemoBug3988); - + void onEnter() override; virtual std::string title() const override; virtual std::string subtitle() const override; @@ -218,10 +212,10 @@ public: virtual std::string subtitle() const override; }; -class Bug5482 : public PhysicsDemo +class PhysicsDemoBug5482 : public PhysicsDemo { public: - CREATE_FUNC(Bug5482); + CREATE_FUNC(PhysicsDemoBug5482); void onEnter() override; void onExit() override; @@ -274,5 +268,4 @@ public: virtual std::string subtitle() const override; }; -#endif -#endif +#endif // #if CC_USE_PHYSICS \ No newline at end of file diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIEditBoxTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIEditBoxTest.cpp index 9c5cae002a..8e2d44897e 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIEditBoxTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIEditBoxTest.cpp @@ -53,18 +53,17 @@ bool UIEditBoxTest::init() addChild(_TTFShowEditReturn); - auto editBoxSize = Size(visibleSize.width - 100, 60); + auto editBoxSize = Size(visibleSize.width - 100, visibleSize.height * 0.1); // top std::string pNormalSprite = "extensions/green_edit.png"; _editName = ui::EditBox::create(editBoxSize, ui::Scale9Sprite::create(pNormalSprite)); _editName->setPosition(Vec2(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y+visibleSize.height*3/4)); - _editName->setFontName("Paint Boy"); _editName->setFontColor(Color3B::RED); _editName->setPlaceHolder("Name:"); _editName->setPlaceholderFontColor(Color3B::WHITE); _editName->setMaxLength(8); - _editName->setFontSize(editBoxSize.height/2); + _editName->setFontSize(editBoxSize.height/2); _editName->setText("v👐👊💝"); _editName->setReturnType(ui::EditBox::KeyboardReturnType::DONE); _editName->setDelegate(this); @@ -78,7 +77,7 @@ bool UIEditBoxTest::init() _editPassword->setMaxLength(6); _editPassword->setInputFlag(ui::EditBox::InputFlag::PASSWORD); _editPassword->setInputMode(ui::EditBox::InputMode::SINGLE_LINE); - _editPassword->setFontSize(editBoxSize.height/2); + _editPassword->setFontSize(editBoxSize.height/2); _editPassword->setDelegate(this); addChild(_editPassword); @@ -89,7 +88,6 @@ bool UIEditBoxTest::init() _editEmail->setPlaceHolder("Email:"); _editEmail->setInputMode(ui::EditBox::InputMode::EMAIL_ADDRESS); _editEmail->setDelegate(this); - _editEmail->setFontSize(bottomButtonSize.height/2); addChild(_editEmail); return true; diff --git a/tests/cpp-tests/Classes/controller.cpp b/tests/cpp-tests/Classes/controller.cpp index c18faa8e07..8d8595eec5 100644 --- a/tests/cpp-tests/Classes/controller.cpp +++ b/tests/cpp-tests/Classes/controller.cpp @@ -71,7 +71,9 @@ public: addTest("Node: Parallax", [](){return new ParallaxTests(); }); addTest("Node: Particles", [](){return new ParticleTests(); }); addTest("Node: Particle3D (PU)", [](){return new Particle3DTests(); }); +#if CC_USE_PHYSICS addTest("Node: Physics", []() { return new PhysicsTests(); }); +#endif addTest("Node: Physics3D", []() { return new Physics3DTests(); } ); addTest("Node: RenderTexture", [](){return new RenderTextureTests(); }); addTest("Node: Scene", [](){return new SceneTests(); }); diff --git a/tests/js-tests/src/ActionsTest/ActionsTest.js b/tests/js-tests/src/ActionsTest/ActionsTest.js index 7952e6c8a5..153729201d 100644 --- a/tests/js-tests/src/ActionsTest/ActionsTest.js +++ b/tests/js-tests/src/ActionsTest/ActionsTest.js @@ -2662,6 +2662,296 @@ var SequenceRepeatTest = ActionsDemo.extend({ } }); +// custom action sample code +var customMoveBy = cc.MoveBy.extend({ + ctor:function (duration, deltaPos, deltaY) { + this._super(duration, deltaPos, deltaY); + }, + update:function (dt) { + this._super(dt); + + if (this.getTarget()) { // rand color + this.getTarget().setColor(cc.color(cc.rand()%255, cc.rand()%255, cc.rand()%255)); + } + + } +}); + +// special code, just for reduce code redundancy +var createCustomAction = function(actionObject) { + var customAction = actionObject.extend({ + ctor:function () { + actionObject.prototype.ctor.apply(this, arguments); + }, + update:function (dt) { + this._super(dt); + if (this.getTarget()) { // rand color + this.getTarget().setColor(cc.color(cc.rand()%255, cc.rand()%255, cc.rand()%255)); + } + + } + }); + return customAction; +} + +var ActionCustomTest = ActionsDemo.extend({ + _spritePos:null, + _layer:null, + onEnter:function () { + //----start47----onEnter + this._super(); + + this.centerSprites(0); + + this._layer = new cc.Layer(); + this.addChild(this._layer); + + var label1 = new cc.MenuItemLabel(new cc.LabelTTF("showInterval(click me)", "arial", 25), this.createActionInterval, this); + var label2 = new cc.MenuItemLabel(new cc.LabelTTF("showInstant(click me)", "arial", 25), this.createActionInstant, this); + var buttonTemp = new cc.Menu(label1, label2); + buttonTemp.alignItemsVerticallyWithPadding(10); + buttonTemp.setPosition(cc.p(100, cc.winSize.height / 2 + 100)); + this.addChild(buttonTemp); + + this.createActionInterval(); + + }, + initActionProperty:function(){ + this._spritePos = cc.p(25, 50); + this._layer.removeAllChildren(); + }, + createActionInstant:function(){ + this.initActionProperty(); + + /** + * group 1 + */ + var spriteTemp = this.addandCreateSpriteTemp("cc.Show"); + spriteTemp.setVisible(false); + var show = new (createCustomAction(cc.Show))(); + spriteTemp.runAction(show); + + spriteTemp = this.addandCreateSpriteTemp("cc.Hide", true); + var hide = new (createCustomAction(cc.Hide))(); + spriteTemp.runAction(hide); + + spriteTemp = this.addandCreateSpriteTemp("cc.FlipX"); + var flipX = new (createCustomAction(cc.FlipX))(true); + spriteTemp.runAction(flipX); + + /** + * group 2 + */ + + spriteTemp = this.addandCreateSpriteTemp("cc.FlipY"); + var flipY = new (createCustomAction(cc.FlipY))(true); + spriteTemp.runAction(flipY); + + // RemoveSelf action don't need test + // skip + + spriteTemp = this.addandCreateSpriteTemp("cc.Place"); + var place = new (createCustomAction(cc.Place))(spriteTemp.getPosition()); + spriteTemp.runAction(place); + + spriteTemp = this.addandCreateSpriteTemp("cc.CallFunc"); + var callFunc = new (createCustomAction(cc.CallFunc))(function(){cc.log("callfunc");}, this); + spriteTemp.runAction(callFunc); + }, + createActionInterval:function(){ + this.initActionProperty(); + + /** + * group 1 + */ + var spriteTemp = this.addandCreateSpriteTemp("cc.MoveBy"); + var move = new customMoveBy(5, cc.p(50, 0)); + spriteTemp.runAction(move); + + spriteTemp = this.addandCreateSpriteTemp("cc.MoveTo"); + var customMoveTo = new (createCustomAction(cc.MoveTo))(5, cc.p(spriteTemp.getPosition().x + 50, spriteTemp.getPosition().y)); + spriteTemp.runAction(customMoveTo); + + spriteTemp = this.addandCreateSpriteTemp("cc.sequence"); + var moveSeq = cc.sequence(new (createCustomAction(cc.MoveBy))(5, cc.p(50, 0)), cc.delayTime(1), + new (createCustomAction(cc.MoveBy))(5, cc.p(50, 0)), cc.delayTime(1)); + spriteTemp.runAction(moveSeq); + /** + * group 2 + */ + spriteTemp = this.addandCreateSpriteTemp("cc.repeat"); + var moveRepeat = cc.repeat(new (createCustomAction(cc.MoveBy))(5, cc.p(50, 0)), 2); + spriteTemp.runAction(moveRepeat); + + spriteTemp = this.addandCreateSpriteTemp("cc.repeatForever"); + var moveRepeatForever = cc.repeatForever(cc.sequence(new (createCustomAction(cc.MoveBy))(5, cc.p(50, 0)), + new (createCustomAction(cc.MoveBy))(5, cc.p(-50, 0)))); + spriteTemp.runAction(moveRepeatForever); + + spriteTemp = this.addandCreateSpriteTemp("cc.spawn"); + var moveRoationSpawn = cc.spawn(new (createCustomAction(cc.MoveBy))(5, cc.p(50, 0)), + new (createCustomAction(cc.RotateBy))(5, 360)); + spriteTemp.runAction(moveRoationSpawn); + + /** + * group 3 + */ + spriteTemp = this.addandCreateSpriteTemp("cc.RotateTo"); + var rotateTo = new (createCustomAction(cc.RotateTo))(5, 180); + spriteTemp.runAction(rotateTo); + + spriteTemp = this.addandCreateSpriteTemp("cc.RotateBy"); + var rotateBy = new (createCustomAction(cc.RotateBy))(5, 270); + spriteTemp.runAction(rotateBy); + + spriteTemp = this.addandCreateSpriteTemp("cc.SkewTo"); + var skewTo = new (createCustomAction(cc.SkewTo))(5, 20, 20); + spriteTemp.runAction(skewTo); + + /** + * group 4 + */ + spriteTemp = this.addandCreateSpriteTemp("cc.SkewBy"); + var skewBy = new (createCustomAction(cc.SkewBy))(5, 20, 20); + spriteTemp.runAction(skewBy); + + spriteTemp = this.addandCreateSpriteTemp("cc.JumpBy"); + var jumpBy = new (createCustomAction(cc.JumpBy))(5, spriteTemp.getPosition(), 50, 4); + spriteTemp.runAction(jumpBy); + + spriteTemp = this.addandCreateSpriteTemp("cc.JumpTo"); + var jumpTo = new (createCustomAction(cc.JumpTo))(5, spriteTemp.getPosition(), 50, 4); + spriteTemp.runAction(jumpTo); + + /** + * group 5 + */ + spriteTemp = this.addandCreateSpriteTemp("cc.BezierBy"); + var bezierBy = new (createCustomAction(cc.BezierBy))(5, [spriteTemp.getPosition(), cc.p(0, spriteTemp.getPosition().y), + cc.p(cc.winSize.x, spriteTemp.getPosition().y), spriteTemp.getPosition()]); + spriteTemp.runAction(bezierBy); + + spriteTemp = this.addandCreateSpriteTemp("cc.BezierTo"); + var bezierTo = new (createCustomAction(cc.BezierTo))(5, [cc.p(0, cc.winSize.height / 2), cc.p(300, -cc.winSize.height / 2), cc.p(300, 100)]); + spriteTemp.runAction(bezierTo); + + spriteTemp = this.addandCreateSpriteTemp("cc.ScaleTo"); + var scaleTo = new (createCustomAction(cc.ScaleTo))(5, 0.5); + spriteTemp.runAction(scaleTo); + + /** + * group 6 + */ + spriteTemp = this.addandCreateSpriteTemp("cc.ScaleBy"); + var scaleBy = new (createCustomAction(cc.ScaleBy))(5, 1.5); + spriteTemp.runAction(scaleBy); + + spriteTemp = this.addandCreateSpriteTemp("cc.Blink"); + var blink = new (createCustomAction(cc.Blink))(5, 2); + spriteTemp.runAction(blink); + + spriteTemp = this.addandCreateSpriteTemp("cc.FadeTo"); + var fadeTo = new (createCustomAction(cc.FadeTo))(5, 64); + spriteTemp.runAction(fadeTo); + + /** + * group 7 + */ + spriteTemp = this.addandCreateSpriteTemp("cc.FadeIn"); + spriteTemp.setOpacity(128); + var fadeIn = new (createCustomAction(cc.FadeIn))(5); + spriteTemp.runAction(fadeIn); + + spriteTemp = this.addandCreateSpriteTemp("cc.FadeOut"); + spriteTemp.setOpacity(128); + var fadeOut = new (createCustomAction(cc.FadeOut))(5); + spriteTemp.runAction(fadeOut); + + spriteTemp = this.addandCreateSpriteTemp("cc.TintTo"); + var tintTo = new (createCustomAction(cc.TintTo))(5, 255, 0, 255); + spriteTemp.runAction(tintTo); + + /** + * group 8 + */ + spriteTemp = this.addandCreateSpriteTemp("cc.TintBy"); + var tintBy = new (createCustomAction(cc.TintBy))(5, -127, -255, -127); + spriteTemp.runAction(tintBy); + + spriteTemp = this.addandCreateSpriteTemp("cc.Animate"); + var animation = new cc.Animation(); + for (var i = 1; i < 15; i++) { + var frameName = "Images/grossini_dance_" + ((i < 10) ? ("0" + i) : i) + ".png"; + animation.addSpriteFrameWithFile(frameName); + } + animation.setDelayPerUnit(5 / 14); + animation.setRestoreOriginalFrame(true); + var animate = new (createCustomAction(cc.Animate))(animation); + spriteTemp.runAction(animate); + }, + addandCreateSpriteTemp:function(actionTypeName, addLabelInLayerFlag){ + var spriteTemp = new cc.Sprite(s_pathGrossini); + this._layer.addChild(spriteTemp); + spriteTemp.setPosition(this._spritePos); + var spriteContentSize = spriteTemp.getContentSize(); + this._spritePos.y += spriteContentSize.height; + if (this._spritePos.y > cc.winSize.height - spriteContentSize.height){ + this._spritePos.x += spriteContentSize.width; + this._spritePos.y = 50; + } + + if (actionTypeName){ + var label = new cc.LabelTTF(actionTypeName, "arial", 18); + if (addLabelInLayerFlag){ + label.setPosition(spriteTemp.getPosition()); + this._layer.addChild(label); + } + else{ + label.setPosition(spriteContentSize.width/2, spriteContentSize.height / 2); + spriteTemp.addChild(label); + } + + } + + return spriteTemp; + }, + title:function () { + return "ActionCustomTest"; + }, + + subtitle:function () { + return "Tests custom action, every sprite changing rand color when they run actions"; + } +}); + +var ActionIssue13605 = ActionsDemo.extend({ + onEnter:function () { + //----start47----onEnter + this._super(); + this.centerSprites(2); + + var move = new customMoveBy(2, cc.p(50, 0)); + var move_back = move.reverse(); + var move_seq = cc.sequence(move, cc.delayTime(1), move_back, cc.delayTime(1)); + this._kathia.runAction(move_seq.repeat(2)); + + var moveClone = move.clone(); + var moveCloneBack = moveClone.reverse(); + var moveCloneSeq = cc.sequence(moveClone, cc.delayTime(1), moveCloneBack, cc.delayTime(1)); + this._tamara.runAction(moveCloneSeq.repeat(2)); + //----end47---- + }, + + title:function () { + return "action reverse and clone issue"; + }, + + subtitle:function () { + return "action move and back will change rand color"; + } +}); + + //- // // Flow control @@ -2717,7 +3007,9 @@ var arrayOfActionsTest = [ ActionAnimate, Issue1438, Issue1446, - SequenceRepeatTest + SequenceRepeatTest, + ActionCustomTest, + ActionIssue13605 ]; if("opengl" in cc.sys.capabilities){ diff --git a/tests/js-tests/src/MaterialSystemTest/MaterialSystemTest.js b/tests/js-tests/src/MaterialSystemTest/MaterialSystemTest.js index 829a59da38..3cff9e818a 100644 --- a/tests/js-tests/src/MaterialSystemTest/MaterialSystemTest.js +++ b/tests/js-tests/src/MaterialSystemTest/MaterialSystemTest.js @@ -151,6 +151,50 @@ var Material_2DEffects = MaterialSystemTestDemo.extend({ } }); +var Material_UniformCallback = MaterialSystemTestDemo.extend({ + _subtitle:"Testing uniforms call back", + + ctor:function(){ + this._super(); + var properties = cc.Properties.createNonRefCounted("Materials/auto_binding_test.material#sample"); + + var mat1 = cc.Material.createWithProperties(properties); + + var spriteBlur = new cc.Sprite("Images/grossini.png"); + spriteBlur.setNormalizedPosition(cc.p(0.2, 0.5)); + this.addChild(spriteBlur); + var spriteBlurProgram = mat1.getTechniqueByName("blur").getPassByIndex(0).getGLProgramState(); + spriteBlur.setGLProgramState(spriteBlurProgram); + spriteBlurProgram.setUniformCallback("blurRadius", function(glprogram, uniform){ + glprogram.setUniformLocationWith1f(uniform.location, Math.random() * 10); + }); + + + var spriteOutline = new cc.Sprite("Images/grossini.png"); + spriteOutline.setNormalizedPosition(cc.p(0.4, 0.5)); + this.addChild(spriteOutline); + var spriteOutlineProgram = mat1.getTechniqueByName("outline").getPassByIndex(0).getGLProgramState(); + spriteOutline.setGLProgramState(spriteOutlineProgram); + spriteOutlineProgram.setUniformCallback("u_outlineColor", function(glprogram, uniform){ + var r = Math.random(); + var g = Math.random(); + var b = Math.random(); + glprogram.setUniformLocationWith3f(uniform.location, r, g, b); + }); + + var spriteNoise = new cc.Sprite("Images/grossini.png"); + spriteNoise.setNormalizedPosition(cc.p(0.6, 0.5)); + this.addChild(spriteNoise); + spriteNoise.setGLProgramState(mat1.getTechniqueByName("noise").getPassByIndex(0).getGLProgramState()); + + var spriteEdgeDetect = new cc.Sprite("Images/grossini.png"); + spriteEdgeDetect.setNormalizedPosition(cc.p(0.8, 0.5)); + this.addChild(spriteEdgeDetect); + spriteEdgeDetect.setGLProgramState(mat1.getTechniqueByName("edge_detect").getPassByIndex(0).getGLProgramState()); + } +}); + + var Material_setTechnique = MaterialSystemTestDemo.extend({ _subtitle:"Testing setTechnique()", _techniqueState:0, @@ -307,6 +351,7 @@ var Material_parsePerformance = MaterialSystemTestDemo.extend({ // var arrayOfMaterialSystemTest = [ Material_2DEffects, + Material_UniformCallback, Material_setTechnique, Material_clone, Material_MultipleSprite3D, diff --git a/tests/lua-tests/src/PhysicsTest/PhysicsTest.lua b/tests/lua-tests/src/PhysicsTest/PhysicsTest.lua index 59d00d315f..54bcb41b9a 100644 --- a/tests/lua-tests/src/PhysicsTest/PhysicsTest.lua +++ b/tests/lua-tests/src/PhysicsTest/PhysicsTest.lua @@ -3,6 +3,7 @@ local MATERIAL_DEFAULT = cc.PhysicsMaterial(0.1, 0.5, 0.5) local curLayer = nil local STATIC_COLOR = cc.c4f(1.0, 0.0, 0.0, 1.0) local DRAG_BODYS_TAG = 0x80 +local PHYSICS_COMPONENT_NAME = "physics_component" local function range(from, to, step) step = step or 1 @@ -26,7 +27,7 @@ local function initWithLayer(layer, callback) cc.Director:getInstance():getRunningScene():getPhysicsWorld():setDebugDrawMask(debug and cc.PhysicsWorld.DEBUGDRAW_ALL or cc.PhysicsWorld.DEBUGDRAW_NONE) end - layer.toggleDebug = function(self) toggleDebugCallback(nil) end; + layer.toggleDebug = function(self) toggleDebugCallback(nil) end cc.MenuItemFont:setFontSize(18) local item = cc.MenuItemFont:create("Toogle debug") item:registerScriptTapHandler(toggleDebugCallback) @@ -43,6 +44,12 @@ local function initWithLayer(layer, callback) layer:registerScriptHandler(onNodeEvent) end +local function addPhysicsComponent(node, physicsBody) + local component = cc.ComponentPhysics2d:create(physicsBody) + component:setName(PHYSICS_COMPONENT_NAME) + node:addComponent(component) +end + local function addGrossiniAtPosition(layer, p, scale) scale = scale or 1.0 @@ -53,7 +60,8 @@ local function addGrossiniAtPosition(layer, p, scale) local sp = cc.Sprite:createWithTexture(layer.spriteTexture, cc.rect(posx, posy, 85, 121)) sp:setScale(scale) - sp:setPhysicsBody(cc.PhysicsBody:createBox(cc.size(48.0*scale, 108.0*scale))) + -- sp:setPhysicsBody(cc.PhysicsBody:createBox(cc.size(48.0*scale, 108.0*scale))) + addPhysicsComponent(sp, cc.PhysicsBody:createBox(cc.size(48.0, 108.0))) layer:addChild(sp) sp:setPosition(p) return sp @@ -66,31 +74,32 @@ local function onTouchBegan(touch, event) local body for _, obj in ipairs(arr) do if bit.band(obj:getBody():getTag(), DRAG_BODYS_TAG) ~= 0 then - body = obj:getBody(); - break; + body = obj:getBody() + break end end if body then - local mouse = cc.Node:create(); - mouse:setPhysicsBody(cc.PhysicsBody:create(PHYSICS_INFINITY, PHYSICS_INFINITY)); - mouse:getPhysicsBody():setDynamic(false); - mouse:setPosition(location); - curLayer:addChild(mouse); - local joint = cc.PhysicsJointPin:construct(mouse:getPhysicsBody(), body, location); - joint:setMaxForce(5000.0 * body:getMass()); - cc.Director:getInstance():getRunningScene():getPhysicsWorld():addJoint(joint); + local mouse = cc.Node:create() + local physicsBody = cc.PhysicsBody:create(PHYSICS_INFINITY, PHYSICS_INFINITY) + addPhysicsComponent(mouse, physicsBody) + physicsBody:setDynamic(false) + mouse:setPosition(location) + curLayer:addChild(mouse) + local joint = cc.PhysicsJointPin:construct(physicsBody, body, location) + joint:setMaxForce(5000.0 * body:getMass()) + cc.Director:getInstance():getRunningScene():getPhysicsWorld():addJoint(joint) touch.mouse = mouse - return true; + return true end - return false; + return false end local function onTouchMoved(touch, event) if touch.mouse then - touch.mouse:setPosition(touch:getLocation()); + touch.mouse:setPosition(touch:getLocation()) end end @@ -113,8 +122,9 @@ local function makeBall(layer, point, radius, material) ball:setScale(0.13 * radius) - local body = cc.PhysicsBody:createCircle(radius, material) - ball:setPhysicsBody(body) + local body = cc.PhysicsBody:createCircle(ball:getContentSize().width / 2, material) + -- ball:setPhysicsBody(body) + addPhysicsComponent(ball, body) ball:setPosition(point) return ball @@ -123,58 +133,61 @@ end local function makeBox(point, size, color, material) material = material or MATERIAL_DEFAULT - local yellow = false; + local yellow = false if color == 0 then - yellow = math.random() > 0.5; + yellow = math.random() > 0.5 else - yellow = color == 1; + yellow = color == 1 end - local box = yellow and cc.Sprite:create("Images/YellowSquare.png") or cc.Sprite:create("Images/CyanSquare.png"); + local box = yellow and cc.Sprite:create("Images/YellowSquare.png") or cc.Sprite:create("Images/CyanSquare.png") - box:setScaleX(size.width/100.0); - box:setScaleY(size.height/100.0); + box:setScaleX(size.width/100.0) + box:setScaleY(size.height/100.0) - local body = cc.PhysicsBody:createBox(size, material); - box:setPhysicsBody(body); - box:setPosition(cc.p(point.x, point.y)); + local body = cc.PhysicsBody:createBox(box:getContentSize(), material) + addPhysicsComponent(box, body) + box:setPosition(cc.p(point.x, point.y)) - return box; + return box end local function makeTriangle(point, size, color, material) material = material or MATERIAL_DEFAULT - local yellow = false; + local yellow = false if color == 0 then - yellow = math.random() > 0.5; + yellow = math.random() > 0.5 else - yellow = color == 1; + yellow = color == 1 end - local triangle = yellow and cc.Sprite:create("Images/YellowTriangle.png") or cc.Sprite:create("Images/CyanTriangle.png"); + local triangle = yellow and cc.Sprite:create("Images/YellowTriangle.png") or cc.Sprite:create("Images/CyanTriangle.png") if size.height == 0 then - triangle:setScale(size.width/100.0); + triangle:setScale(size.width/100.0) else triangle:setScaleX(size.width/50.0) triangle:setScaleY(size.height/43.5) end + + vers = { cc.p(0, triangle:getContentSize().height/2), + cc.p(triangle:getContentSize().width/2, -triangle:getContentSize().height/2), + cc.p(-triangle:getContentSize().width/2, -triangle:getContentSize().height/2) + } + + local body = cc.PhysicsBody:createPolygon(vers, material) + addPhysicsComponent(triangle, body) + triangle:setPosition(point) - vers = { cc.p(0, size.height/2), cc.p(size.width/2, -size.height/2), cc.p(-size.width/2, -size.height/2)}; - - local body = cc.PhysicsBody:createPolygon(vers, material); - triangle:setPhysicsBody(body); - triangle:setPosition(point); - - return triangle; + return triangle end local function PhysicsDemoClickAdd() local layer = cc.Layer:create() local function onEnter() local function onTouchEnded(touch, event) - local location = touch:getLocation(); - addGrossiniAtPosition(layer, location) + local location = touch:getLocation() + addGrossiniAtPosition(layer, location) end local touchListener = cc.EventListenerTouchOneByOne:create() @@ -186,7 +199,12 @@ local function PhysicsDemoClickAdd() addGrossiniAtPosition(layer, VisibleRect:center()) local node = cc.Node:create() - node:setPhysicsBody(cc.PhysicsBody:createEdgeBox(cc.size(VisibleRect:getVisibleRect().width, VisibleRect:getVisibleRect().height))) + addPhysicsComponent(node, + cc.PhysicsBody:createEdgeBox(cc.size(VisibleRect:getVisibleRect().width, + VisibleRect:getVisibleRect().height + ) + ) + ) node:setPosition(VisibleRect:center()) layer:addChild(node) end @@ -211,66 +229,69 @@ local function PhysicsDemoLogoSmash() 31,-1,-64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,-1,-64,0,-4,63,-1,-32,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,1,-1,-64,15,-8,127,-1,-32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1,-1,-64,0,-8,-15,-1,-32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,-31,-1,-64,15,-8,-32, - -1,-32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7,-15,-1,-64,9,-15,-32,-1,-32,0,0,0,0,0, + -1,-32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7,-15,-1,-64,9,-15,-32,-1,-32,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,31,-15,-1,-64,0,-15,-32,-1,-32,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,63,-7,-1,-64,9,-29,-32,127,-61,-16,63,15,-61,-1,-8,31,-16,15,-8,126,7,-31, - -8,31,-65,-7,-1,-64,9,-29,-32,0,7,-8,127,-97,-25,-1,-2,63,-8,31,-4,-1,15,-13, - -4,63,-1,-3,-1,-64,9,-29,-32,0,7,-8,127,-97,-25,-1,-2,63,-8,31,-4,-1,15,-13, - -2,63,-1,-3,-1,-64,9,-29,-32,0,7,-8,127,-97,-25,-1,-1,63,-4,63,-4,-1,15,-13, - -2,63,-33,-1,-1,-32,9,-25,-32,0,7,-8,127,-97,-25,-1,-1,63,-4,63,-4,-1,15,-13, - -1,63,-33,-1,-1,-16,9,-25,-32,0,7,-8,127,-97,-25,-1,-1,63,-4,63,-4,-1,15,-13, - -1,63,-49,-1,-1,-8,9,-57,-32,0,7,-8,127,-97,-25,-8,-1,63,-2,127,-4,-1,15,-13, - -1,-65,-49,-1,-1,-4,9,-57,-32,0,7,-8,127,-97,-25,-8,-1,63,-2,127,-4,-1,15,-13, - -1,-65,-57,-1,-1,-2,9,-57,-32,0,7,-8,127,-97,-25,-8,-1,63,-2,127,-4,-1,15,-13, - -1,-1,-57,-1,-1,-1,9,-57,-32,0,7,-1,-1,-97,-25,-8,-1,63,-1,-1,-4,-1,15,-13,-1, - -1,-61,-1,-1,-1,-119,-57,-32,0,7,-1,-1,-97,-25,-8,-1,63,-1,-1,-4,-1,15,-13,-1, - -1,-61,-1,-1,-1,-55,-49,-32,0,7,-1,-1,-97,-25,-8,-1,63,-1,-1,-4,-1,15,-13,-1, - -1,-63,-1,-1,-1,-23,-49,-32,127,-57,-1,-1,-97,-25,-1,-1,63,-1,-1,-4,-1,15,-13, - -1,-1,-63,-1,-1,-1,-16,-49,-32,-1,-25,-1,-1,-97,-25,-1,-1,63,-33,-5,-4,-1,15, - -13,-1,-1,-64,-1,-9,-1,-7,-49,-32,-1,-25,-8,127,-97,-25,-1,-1,63,-33,-5,-4,-1, + -8,31,-65,-7,-1,-64,9,-29,-32,0,7,-8,127,-97,-25,-1,-2,63,-8,31,-4,-1,15,-13, + -4,63,-1,-3,-1,-64,9,-29,-32,0,7,-8,127,-97,-25,-1,-2,63,-8,31,-4,-1,15,-13, + -2,63,-1,-3,-1,-64,9,-29,-32,0,7,-8,127,-97,-25,-1,-1,63,-4,63,-4,-1,15,-13, + -2,63,-33,-1,-1,-32,9,-25,-32,0,7,-8,127,-97,-25,-1,-1,63,-4,63,-4,-1,15,-13, + -1,63,-33,-1,-1,-16,9,-25,-32,0,7,-8,127,-97,-25,-1,-1,63,-4,63,-4,-1,15,-13, + -1,63,-49,-1,-1,-8,9,-57,-32,0,7,-8,127,-97,-25,-8,-1,63,-2,127,-4,-1,15,-13, + -1,-65,-49,-1,-1,-4,9,-57,-32,0,7,-8,127,-97,-25,-8,-1,63,-2,127,-4,-1,15,-13, + -1,-65,-57,-1,-1,-2,9,-57,-32,0,7,-8,127,-97,-25,-8,-1,63,-2,127,-4,-1,15,-13, + -1,-1,-57,-1,-1,-1,9,-57,-32,0,7,-1,-1,-97,-25,-8,-1,63,-1,-1,-4,-1,15,-13,-1, + -1,-61,-1,-1,-1,-119,-57,-32,0,7,-1,-1,-97,-25,-8,-1,63,-1,-1,-4,-1,15,-13,-1, + -1,-61,-1,-1,-1,-55,-49,-32,0,7,-1,-1,-97,-25,-8,-1,63,-1,-1,-4,-1,15,-13,-1, + -1,-63,-1,-1,-1,-23,-49,-32,127,-57,-1,-1,-97,-25,-1,-1,63,-1,-1,-4,-1,15,-13, + -1,-1,-63,-1,-1,-1,-16,-49,-32,-1,-25,-1,-1,-97,-25,-1,-1,63,-33,-5,-4,-1,15, + -13,-1,-1,-64,-1,-9,-1,-7,-49,-32,-1,-25,-8,127,-97,-25,-1,-1,63,-33,-5,-4,-1, 15,-13,-1,-1,-64,-1,-13,-1,-32,-49,-32,-1,-25,-8,127,-97,-25,-1,-2,63,-49,-13, - -4,-1,15,-13,-1,-1,-64,127,-7,-1,-119,-17,-15,-1,-25,-8,127,-97,-25,-1,-2,63, - -49,-13,-4,-1,15,-13,-3,-1,-64,127,-8,-2,15,-17,-1,-1,-25,-8,127,-97,-25,-1, - -8,63,-49,-13,-4,-1,15,-13,-3,-1,-64,63,-4,120,0,-17,-1,-1,-25,-8,127,-97,-25, - -8,0,63,-57,-29,-4,-1,15,-13,-4,-1,-64,63,-4,0,15,-17,-1,-1,-25,-8,127,-97, - -25,-8,0,63,-57,-29,-4,-1,-1,-13,-4,-1,-64,31,-2,0,0,103,-1,-1,-57,-8,127,-97, - -25,-8,0,63,-57,-29,-4,-1,-1,-13,-4,127,-64,31,-2,0,15,103,-1,-1,-57,-8,127, - -97,-25,-8,0,63,-61,-61,-4,127,-1,-29,-4,127,-64,15,-8,0,0,55,-1,-1,-121,-8, + -4,-1,15,-13,-1,-1,-64,127,-7,-1,-119,-17,-15,-1,-25,-8,127,-97,-25,-1,-2,63, + -49,-13,-4,-1,15,-13,-3,-1,-64,127,-8,-2,15,-17,-1,-1,-25,-8,127,-97,-25,-1, + -8,63,-49,-13,-4,-1,15,-13,-3,-1,-64,63,-4,120,0,-17,-1,-1,-25,-8,127,-97,-25, + -8,0,63,-57,-29,-4,-1,15,-13,-4,-1,-64,63,-4,0,15,-17,-1,-1,-25,-8,127,-97, + -25,-8,0,63,-57,-29,-4,-1,-1,-13,-4,-1,-64,31,-2,0,0,103,-1,-1,-57,-8,127,-97, + -25,-8,0,63,-57,-29,-4,-1,-1,-13,-4,127,-64,31,-2,0,15,103,-1,-1,-57,-8,127, + -97,-25,-8,0,63,-61,-61,-4,127,-1,-29,-4,127,-64,15,-8,0,0,55,-1,-1,-121,-8, 127,-97,-25,-8,0,63,-61,-61,-4,127,-1,-29,-4,63,-64,15,-32,0,0,23,-1,-2,3,-16, 63,15,-61,-16,0,31,-127,-127,-8,31,-1,-127,-8,31,-128,7,-128,0,0 - }; + } local function get_pixel(x, y) - return bit.band(bit.rshift(logo_image[bit.rshift(x, 3) + y*logo_raw_length + 1], bit.band(bit.bnot(x), 0x07)), 1) + return bit.band(bit.rshift(logo_image[bit.rshift(x, 3) + y*logo_raw_length + 1], bit.band(bit.bnot(x), 0x07)), 1) end - cc.Director:getInstance():getRunningScene():getPhysicsWorld():setGravity(cc.p(0, 0)); - cc.Director:getInstance():getRunningScene():getPhysicsWorld():setUpdateRate(5.0); + cc.Director:getInstance():getRunningScene():getPhysicsWorld():setGravity(cc.p(0, 0)) + cc.Director:getInstance():getRunningScene():getPhysicsWorld():setUpdateRate(5.0) - layer.ball = cc.SpriteBatchNode:create("Images/ball.png", #logo_image); - layer:addChild(layer.ball); + layer.ball = cc.SpriteBatchNode:create("Images/ball.png", #logo_image) + layer:addChild(layer.ball) for y in range(0, logo_height-1) do - for x in range(0, logo_width-1) do - if get_pixel(x, y) == 1 then - local x_jitter = 0.05*math.random(); - local y_jitter = 0.05*math.random(); + for x in range(0, logo_width-1) do + if get_pixel(x, y) == 1 then + local x_jitter = 0.05*math.random() + local y_jitter = 0.05*math.random() - local ball = makeBall(layer, cc.p(2*(x - logo_width/2 + x_jitter) + VisibleRect:getVisibleRect().width/2, - 2*(logo_height-y + y_jitter) + VisibleRect:getVisibleRect().height/2 - logo_height/2), - 0.95, cc.PhysicsMaterial(0.01, 0.0, 0.0)); - - ball:getPhysicsBody():setMass(1.0); - ball:getPhysicsBody():setMoment(PHYSICS_INFINITY); + local ball = makeBall(layer, + cc.p(2*(x - logo_width/2 + x_jitter) + VisibleRect:getVisibleRect().width/2, + 2*(logo_height-y + y_jitter) + VisibleRect:getVisibleRect().height/2 - logo_height/2), + 0.95, + cc.PhysicsMaterial(0.01, 0.0, 0.0)) + local physicsBody = ball:getComponent(PHYSICS_COMPONENT_NAME):getPhysicsBody() + physicsBody:setMass(1.0) + physicsBody:setMoment(PHYSICS_INFINITY) - layer.ball:addChild(ball); - end - end + layer.ball:addChild(ball) + end + end end - local bullet = makeBall(layer, cc.p(400, 0), 10, cc.PhysicsMaterial(PHYSICS_INFINITY, 0, 0)); - bullet:getPhysicsBody():setVelocity(cc.p(200, 0)); + local bullet = makeBall(layer, cc.p(400, 0), 10, cc.PhysicsMaterial(PHYSICS_INFINITY, 0, 0)) + + bullet:getComponent(PHYSICS_COMPONENT_NAME):getPhysicsBody():setVelocity(cc.p(200, 0)) bullet:setPosition(cc.p(-500, VisibleRect:getVisibleRect().height/2)) - layer.ball:addChild(bullet); + layer.ball:addChild(bullet) end initWithLayer(layer, onEnter) @@ -282,7 +303,7 @@ end local function PhysicsDemoJoints() local layer = cc.Layer:create() local function onEnter() - layer:toggleDebug(); + layer:toggleDebug() local touchListener = cc.EventListenerTouchOneByOne:create() touchListener:registerScriptHandler(onTouchBegan, cc.Handler.EVENT_TOUCH_BEGAN) @@ -291,153 +312,239 @@ local function PhysicsDemoJoints() local eventDispatcher = layer:getEventDispatcher() eventDispatcher:addEventListenerWithSceneGraphPriority(touchListener, layer) - local width = (VisibleRect:getVisibleRect().width - 10) / 4; - local height = (VisibleRect:getVisibleRect().height - 50) / 4; + local width = (VisibleRect:getVisibleRect().width - 10) / 4 + local height = (VisibleRect:getVisibleRect().height - 50) / 4 - local node = cc.Node:create(); - local box = cc.PhysicsBody:create(); - node:setPhysicsBody(box); - box:setDynamic(false); - node:setPosition(cc.p(0, 0)); - layer:addChild(node); + local node = cc.Node:create() + local box = cc.PhysicsBody:create() + addPhysicsComponent(node, box) + box:setDynamic(false) + node:setPosition(cc.p(0, 0)) + layer:addChild(node) - local scene = cc.Director:getInstance():getRunningScene(); + local scene = cc.Director:getInstance():getRunningScene() for i in range(0, 3) do for j in range(0, 3) do - local offset = cc.p(VisibleRect:leftBottom().x + 5 + j * width + width/2, VisibleRect:leftBottom().y + 50 + i * height + height/2); - box:addShape(cc.PhysicsShapeEdgeBox:create(cc.size(width, height), cc.PHYSICSSHAPE_MATERIAL_DEFAULT, 1, offset)); + local offset = cc.p(VisibleRect:leftBottom().x + 5 + j * width + width/2, + VisibleRect:leftBottom().y + 50 + i * height + height/2) + box:addShape(cc.PhysicsShapeEdgeBox:create(cc.size(width, height), + cc.PHYSICSSHAPE_MATERIAL_DEFAULT, + 1, + offset) + ) local index = i*4 + j + if index == 0 then - local sp1 = makeBall(layer, cc.p(offset.x - 30, offset.y), 10); - sp1:getPhysicsBody():setTag(DRAG_BODYS_TAG); - local sp2 = makeBall(layer, cc.p(offset.x + 30, offset.y), 10); - sp2:getPhysicsBody():setTag(DRAG_BODYS_TAG); + local sp1 = makeBall(layer, cc.p(offset.x - 30, offset.y), 10) + local sp1PhysicsBody = sp1:getComponent(PHYSICS_COMPONENT_NAME):getPhysicsBody() + sp1PhysicsBody:setTag(DRAG_BODYS_TAG) + + local sp2 = makeBall(layer, cc.p(offset.x + 30, offset.y), 10) + local sp2PhysicsBody = sp2:getComponent(PHYSICS_COMPONENT_NAME):getPhysicsBody() + sp2PhysicsBody:setTag(DRAG_BODYS_TAG) - local joint = cc.PhysicsJointPin:construct(sp1:getPhysicsBody(), sp2:getPhysicsBody(), offset); - cc.Director:getInstance():getRunningScene():getPhysicsWorld():addJoint(joint); + local joint = cc.PhysicsJointPin:construct(sp1PhysicsBody, sp2PhysicsBody, offset) + cc.Director:getInstance():getRunningScene():getPhysicsWorld():addJoint(joint) - layer:addChild(sp1); - layer:addChild(sp2); + layer:addChild(sp1) + layer:addChild(sp2) elseif index == 1 then - local sp1 = makeBall(layer, cc.p(offset.x - 30, offset.y), 10); - sp1:getPhysicsBody():setTag(DRAG_BODYS_TAG); - local sp2 = makeBox(cc.p(offset.x + 30, offset.y), cc.size(30, 10)); - sp2:getPhysicsBody():setTag(DRAG_BODYS_TAG); + local sp1 = makeBall(layer, cc.p(offset.x - 30, offset.y), 10) + local sp1PhysicsBody = sp1:getComponent(PHYSICS_COMPONENT_NAME):getPhysicsBody() + sp1PhysicsBody:setTag(DRAG_BODYS_TAG) + + local sp2 = makeBox(cc.p(offset.x + 30, offset.y), cc.size(30, 10)) + local sp2PhysicsBody = sp2:getComponent(PHYSICS_COMPONENT_NAME):getPhysicsBody() + sp2PhysicsBody:setTag(DRAG_BODYS_TAG) - local joint = cc.PhysicsJointFixed:construct(sp1:getPhysicsBody(), sp2:getPhysicsBody(), offset); - scene:getPhysicsWorld():addJoint(joint); + local joint = cc.PhysicsJointFixed:construct(sp1PhysicsBody, sp2PhysicsBody, offset) + scene:getPhysicsWorld():addJoint(joint) - layer:addChild(sp1); - layer:addChild(sp2); + layer:addChild(sp1) + layer:addChild(sp2) elseif index == 2 then - local sp1 = makeBall(layer, cc.p(offset.x - 30, offset.y), 10); - sp1:getPhysicsBody():setTag(DRAG_BODYS_TAG); - local sp2 = makeBox(cc.p(offset.x + 30, offset.y), cc.size(30, 10)); - sp2:getPhysicsBody():setTag(DRAG_BODYS_TAG); + local sp1 = makeBall(layer, cc.p(offset.x - 30, offset.y), 10) + local sp1PhysicsBody = sp1:getComponent(PHYSICS_COMPONENT_NAME):getPhysicsBody() + sp1PhysicsBody:setTag(DRAG_BODYS_TAG) + + local sp2 = makeBox(cc.p(offset.x + 30, offset.y), cc.size(30, 10)) + local sp2PhysicsBody = sp2:getComponent(PHYSICS_COMPONENT_NAME):getPhysicsBody() + sp2PhysicsBody:setTag(DRAG_BODYS_TAG) - local joint = cc.PhysicsJointDistance:construct(sp1:getPhysicsBody(), sp2:getPhysicsBody(), cc.p(0, 0), cc.p(0, 0)); - scene:getPhysicsWorld():addJoint(joint); + local joint = cc.PhysicsJointDistance:construct(sp1PhysicsBody, + sp2PhysicsBody, + cc.p(0, 0), + cc.p(0, 0)) + scene:getPhysicsWorld():addJoint(joint) - layer:addChild(sp1); - layer:addChild(sp2); - elseif index == 3 then - local sp1 = makeBall(layer, cc.p(offset.x - 30, offset.y), 10); - sp1:getPhysicsBody():setTag(DRAG_BODYS_TAG); - local sp2 = makeBox(cc.p(offset.x + 30, offset.y), cc.size(30, 10)); - sp2:getPhysicsBody():setTag(DRAG_BODYS_TAG); + layer:addChild(sp1) + layer:addChild(sp2) + elseif index == 3 then + local sp1 = makeBall(layer, cc.p(offset.x - 30, offset.y), 10) + local sp1PhysicsBody = sp1:getComponent(PHYSICS_COMPONENT_NAME):getPhysicsBody() + sp1PhysicsBody:setTag(DRAG_BODYS_TAG) + + local sp2 = makeBox(cc.p(offset.x + 30, offset.y), cc.size(30, 10)) + local sp2PhysicsBody = sp2:getComponent(PHYSICS_COMPONENT_NAME):getPhysicsBody() + sp2PhysicsBody:setTag(DRAG_BODYS_TAG) - local joint = cc.PhysicsJointLimit:construct(sp1:getPhysicsBody(), sp2:getPhysicsBody(), cc.p(0, 0), cc.p(0, 0), 30.0, 60.0); - scene:getPhysicsWorld():addJoint(joint); + local joint = cc.PhysicsJointLimit:construct(sp1PhysicsBody, + sp2PhysicsBody, + cc.p(0, 0), + cc.p(0, 0), + 30.0, + 60.0) + scene:getPhysicsWorld():addJoint(joint) - layer:addChild(sp1); - layer:addChild(sp2); - elseif index == 4 then - local sp1 = makeBall(layer, cc.p(offset.x - 30, offset.y), 10); - sp1:getPhysicsBody():setTag(DRAG_BODYS_TAG); - local sp2 = makeBox(cc.p(offset.x + 30, offset.y), cc.size(30, 10)); - sp2:getPhysicsBody():setTag(DRAG_BODYS_TAG); + layer:addChild(sp1) + layer:addChild(sp2) + elseif index == 4 then + local sp1 = makeBall(layer, cc.p(offset.x - 30, offset.y), 10) + local sp1PhysicsBody = sp1:getComponent(PHYSICS_COMPONENT_NAME):getPhysicsBody() + sp1PhysicsBody:setTag(DRAG_BODYS_TAG) + + local sp2 = makeBox(cc.p(offset.x + 30, offset.y), cc.size(30, 10)) + local sp2PhysicsBody = sp2:getComponent(PHYSICS_COMPONENT_NAME):getPhysicsBody() + sp2PhysicsBody:setTag(DRAG_BODYS_TAG) - local joint = cc.PhysicsJointSpring:construct(sp1:getPhysicsBody(), sp2:getPhysicsBody(), cc.p(0, 0), cc.p(0, 0), 500.0, 0.3); - scene:getPhysicsWorld():addJoint(joint); + local joint = cc.PhysicsJointSpring:construct(sp1PhysicsBody, + sp2PhysicsBody, + cc.p(0, 0), + cc.p(0, 0), + 500.0, + 0.3) + scene:getPhysicsWorld():addJoint(joint) - layer:addChild(sp1); - layer:addChild(sp2); - elseif index == 5 then - local sp1 = makeBall(layer, cc.p(offset.x - 30, offset.y), 10); - sp1:getPhysicsBody():setTag(DRAG_BODYS_TAG); - local sp2 = makeBox(cc.p(offset.x + 30, offset.y), cc.size(30, 10)); - sp2:getPhysicsBody():setTag(DRAG_BODYS_TAG); + layer:addChild(sp1) + layer:addChild(sp2) + elseif index == 5 then + local sp1 = makeBall(layer, cc.p(offset.x - 30, offset.y), 10) + local sp1PhysicsBody = sp1:getComponent(PHYSICS_COMPONENT_NAME):getPhysicsBody() + sp1PhysicsBody:setTag(DRAG_BODYS_TAG) + + local sp2 = makeBox(cc.p(offset.x + 30, offset.y), cc.size(30, 10)) + local sp2PhysicsBody = sp2:getComponent(PHYSICS_COMPONENT_NAME):getPhysicsBody() + sp2PhysicsBody:setTag(DRAG_BODYS_TAG) - local joint = cc.PhysicsJointGroove:construct(sp1:getPhysicsBody(), sp2:getPhysicsBody(), cc.p(30, 15), cc.p(30, -15), cc.p(-30, 0)) - scene:getPhysicsWorld():addJoint(joint); + local joint = cc.PhysicsJointGroove:construct(sp1PhysicsBody, + sp2PhysicsBody, + cc.p(30, 15), + cc.p(30, -15), + cc.p(-30, 0)) + scene:getPhysicsWorld():addJoint(joint) - layer:addChild(sp1); - layer:addChild(sp2); - elseif index == 6 then - local sp1 = makeBox(cc.p(offset.x - 30, offset.y), cc.size(30, 10)); - sp1:getPhysicsBody():setTag(DRAG_BODYS_TAG); - local sp2 = makeBox(cc.p(offset.x + 30, offset.y), cc.size(30, 10)); - sp2:getPhysicsBody():setTag(DRAG_BODYS_TAG); - scene:getPhysicsWorld():addJoint(cc.PhysicsJointPin:construct(sp1:getPhysicsBody(), box, cc.p(sp1:getPosition()))); - scene:getPhysicsWorld():addJoint(cc.PhysicsJointPin:construct(sp2:getPhysicsBody(), box, cc.p(sp2:getPosition()))); - local joint = cc.PhysicsJointRotarySpring:construct(sp1:getPhysicsBody(), sp2:getPhysicsBody(), 3000.0, 60.0); - scene:getPhysicsWorld():addJoint(joint); + layer:addChild(sp1) + layer:addChild(sp2) + elseif index == 6 then + local sp1 = makeBox(cc.p(offset.x - 30, offset.y), cc.size(30, 10)) + local sp1PhysicsBody = sp1:getComponent(PHYSICS_COMPONENT_NAME):getPhysicsBody() + sp1PhysicsBody:setTag(DRAG_BODYS_TAG) + + local sp2 = makeBox(cc.p(offset.x + 30, offset.y), cc.size(30, 10)) + local sp2PhysicsBody = sp2:getComponent(PHYSICS_COMPONENT_NAME):getPhysicsBody() + sp2PhysicsBody:setTag(DRAG_BODYS_TAG) + + scene:getPhysicsWorld():addJoint(cc.PhysicsJointPin:construct(sp1PhysicsBody, + box, + cc.p(sp1:getPosition()))) + scene:getPhysicsWorld():addJoint(cc.PhysicsJointPin:construct(sp2PhysicsBody, + box, + cc.p(sp2:getPosition()))) + local joint = cc.PhysicsJointRotarySpring:construct(sp1PhysicsBody, + sp2PhysicsBody, + 3000.0, + 60.0) + scene:getPhysicsWorld():addJoint(joint) - layer:addChild(sp1); - layer:addChild(sp2); - elseif index == 7 then - local sp1 = makeBox(cc.p(offset.x - 30, offset.y), cc.size(30, 10)); - sp1:getPhysicsBody():setTag(DRAG_BODYS_TAG); - local sp2 = makeBox(cc.p(offset.x + 30, offset.y), cc.size(30, 10)); - sp2:getPhysicsBody():setTag(DRAG_BODYS_TAG); + layer:addChild(sp1) + layer:addChild(sp2) + elseif index == 7 then + local sp1 = makeBox(cc.p(offset.x - 30, offset.y), cc.size(30, 10)) + local sp1PhysicsBody = sp1:getComponent(PHYSICS_COMPONENT_NAME):getPhysicsBody() + sp1PhysicsBody:setTag(DRAG_BODYS_TAG) + + local sp2 = makeBox(cc.p(offset.x + 30, offset.y), cc.size(30, 10)) + local sp2PhysicsBody = sp2:getComponent(PHYSICS_COMPONENT_NAME):getPhysicsBody() + sp2PhysicsBody:setTag(DRAG_BODYS_TAG) - scene:getPhysicsWorld():addJoint(cc.PhysicsJointPin:construct(sp1:getPhysicsBody(), box, cc.p(sp1:getPosition()))); - scene:getPhysicsWorld():addJoint(cc.PhysicsJointPin:construct(sp2:getPhysicsBody(), box, cc.p(sp2:getPosition()))); - local joint = cc.PhysicsJointRotaryLimit:construct(sp1:getPhysicsBody(), sp2:getPhysicsBody(), 0.0, math.pi/2); - scene:getPhysicsWorld():addJoint(joint); + scene:getPhysicsWorld():addJoint(cc.PhysicsJointPin:construct(sp1PhysicsBody, + box, + cc.p(sp1:getPosition()))) + scene:getPhysicsWorld():addJoint(cc.PhysicsJointPin:construct(sp2PhysicsBody, + box, + cc.p(sp2:getPosition()))) + local joint = cc.PhysicsJointRotaryLimit:construct(sp1PhysicsBody, + sp2PhysicsBody, + 0.0, + math.pi/2) + scene:getPhysicsWorld():addJoint(joint) - layer:addChild(sp1); - layer:addChild(sp2); - elseif index == 8 then - local sp1 = makeBox(cc.p(offset.x - 30, offset.y), cc.size(30, 10)); - sp1:getPhysicsBody():setTag(DRAG_BODYS_TAG); - local sp2 = makeBox(cc.p(offset.x + 30, offset.y), cc.size(30, 10)); - sp2:getPhysicsBody():setTag(DRAG_BODYS_TAG); + layer:addChild(sp1) + layer:addChild(sp2) + elseif index == 8 then + local sp1 = makeBox(cc.p(offset.x - 30, offset.y), cc.size(30, 10)) + local sp1PhysicsBody = sp1:getComponent(PHYSICS_COMPONENT_NAME):getPhysicsBody() + sp1PhysicsBody:setTag(DRAG_BODYS_TAG) + + local sp2 = makeBox(cc.p(offset.x + 30, offset.y), cc.size(30, 10)) + local sp2PhysicsBody = sp2:getComponent(PHYSICS_COMPONENT_NAME):getPhysicsBody() + sp2PhysicsBody:setTag(DRAG_BODYS_TAG) - scene:getPhysicsWorld():addJoint(cc.PhysicsJointPin:construct(sp1:getPhysicsBody(), box, cc.p(sp1:getPosition()))); - scene:getPhysicsWorld():addJoint(cc.PhysicsJointPin:construct(sp2:getPhysicsBody(), box, cc.p(sp2:getPosition()))); - local joint = cc.PhysicsJointRatchet:construct(sp1:getPhysicsBody(), sp2:getPhysicsBody(), 0.0, math.pi/2); - scene:getPhysicsWorld():addJoint(joint); + scene:getPhysicsWorld():addJoint(cc.PhysicsJointPin:construct(sp1PhysicsBody, + box, + cc.p(sp1:getPosition()))) + scene:getPhysicsWorld():addJoint(cc.PhysicsJointPin:construct(sp2PhysicsBody, + box, + cc.p(sp2:getPosition()))) + local joint = cc.PhysicsJointRatchet:construct(sp1PhysicsBody, + sp2PhysicsBody, + 0.0, + math.pi/2) + scene:getPhysicsWorld():addJoint(joint) - layer:addChild(sp1); - layer:addChild(sp2); - elseif index == 9 then - local sp1 = makeBox(cc.p(offset.x - 30, offset.y), cc.size(30, 10)); - sp1:getPhysicsBody():setTag(DRAG_BODYS_TAG); - local sp2 = makeBox(cc.p(offset.x + 30, offset.y), cc.size(30, 10)); - sp2:getPhysicsBody():setTag(DRAG_BODYS_TAG); + layer:addChild(sp1) + layer:addChild(sp2) + elseif index == 9 then + local sp1 = makeBox(cc.p(offset.x - 30, offset.y), cc.size(30, 10)) + local sp1PhysicsBody = sp1:getComponent(PHYSICS_COMPONENT_NAME):getPhysicsBody() + sp1PhysicsBody:setTag(DRAG_BODYS_TAG) + + local sp2 = makeBox(cc.p(offset.x + 30, offset.y), cc.size(30, 10)) + local sp2PhysicsBody = sp2:getComponent(PHYSICS_COMPONENT_NAME):getPhysicsBody() + sp2PhysicsBody:setTag(DRAG_BODYS_TAG) - scene:getPhysicsWorld():addJoint(cc.PhysicsJointPin:construct(sp1:getPhysicsBody(), box, cc.p(sp1:getPosition()))); - scene:getPhysicsWorld():addJoint(cc.PhysicsJointPin:construct(sp2:getPhysicsBody(), box, cc.p(sp2:getPosition()))); - local joint = cc.PhysicsJointGear:construct(sp1:getPhysicsBody(), sp2:getPhysicsBody(), 0.0, 2.0); - scene:getPhysicsWorld():addJoint(joint); + scene:getPhysicsWorld():addJoint(cc.PhysicsJointPin:construct(sp1PhysicsBody, + box, + cc.p(sp1:getPosition()))) + scene:getPhysicsWorld():addJoint(cc.PhysicsJointPin:construct(sp2PhysicsBody, + box, + cc.p(sp2:getPosition()))) + local joint = cc.PhysicsJointGear:construct(sp1PhysicsBody, sp2PhysicsBody, 0.0, 2.0) + scene:getPhysicsWorld():addJoint(joint) - layer:addChild(sp1); - layer:addChild(sp2); - elseif index == 10 then - local sp1 = makeBox(cc.p(offset.x - 30, offset.y), cc.size(30, 10)); - sp1:getPhysicsBody():setTag(DRAG_BODYS_TAG); - local sp2 = makeBox(cc.p(offset.x + 30, offset.y), cc.size(30, 10)); - sp2:getPhysicsBody():setTag(DRAG_BODYS_TAG); + layer:addChild(sp1) + layer:addChild(sp2) + elseif index == 10 then + local sp1 = makeBox(cc.p(offset.x - 30, offset.y), cc.size(30, 10)) + local sp1PhysicsBody = sp1:getComponent(PHYSICS_COMPONENT_NAME):getPhysicsBody() + sp1PhysicsBody:setTag(DRAG_BODYS_TAG) + + local sp2 = makeBox(cc.p(offset.x + 30, offset.y), cc.size(30, 10)) + local sp2PhysicsBody = sp2:getComponent(PHYSICS_COMPONENT_NAME):getPhysicsBody() + sp2PhysicsBody:setTag(DRAG_BODYS_TAG) - scene:getPhysicsWorld():addJoint(cc.PhysicsJointPin:construct(sp1:getPhysicsBody(), box, cc.p(sp1:getPosition()))); - scene:getPhysicsWorld():addJoint(cc.PhysicsJointPin:construct(sp2:getPhysicsBody(), box, cc.p(sp2:getPosition()))); - local joint = cc.PhysicsJointMotor:construct(sp1:getPhysicsBody(), sp2:getPhysicsBody(), math.pi/2); - scene:getPhysicsWorld():addJoint(joint); + scene:getPhysicsWorld():addJoint(cc.PhysicsJointPin:construct(sp1PhysicsBody, + box, + cc.p(sp1:getPosition()))) + scene:getPhysicsWorld():addJoint(cc.PhysicsJointPin:construct(sp2PhysicsBody, + box, + cc.p(sp2:getPosition()))) + local joint = cc.PhysicsJointMotor:construct(sp1PhysicsBody, sp2PhysicsBody, math.pi/2) + scene:getPhysicsWorld():addJoint(joint) - layer:addChild(sp1); - layer:addChild(sp2); - end + layer:addChild(sp1) + layer:addChild(sp2) + end end end end @@ -451,31 +558,38 @@ local function PhysicsDemoPyramidStack() local layer = cc.Layer:create() local function onEnter() - local touchListener = cc.EventListenerTouchOneByOne:create(); - touchListener:registerScriptHandler(onTouchBegan, cc.Handler.EVENT_TOUCH_BEGAN); - touchListener:registerScriptHandler(onTouchMoved, cc.Handler.EVENT_TOUCH_MOVED); - touchListener:registerScriptHandler(onTouchEnded, cc.Handler.EVENT_TOUCH_ENDED); + local touchListener = cc.EventListenerTouchOneByOne:create() + touchListener:registerScriptHandler(onTouchBegan, cc.Handler.EVENT_TOUCH_BEGAN) + touchListener:registerScriptHandler(onTouchMoved, cc.Handler.EVENT_TOUCH_MOVED) + touchListener:registerScriptHandler(onTouchEnded, cc.Handler.EVENT_TOUCH_ENDED) local eventDispatcher = layer:getEventDispatcher() - eventDispatcher:addEventListenerWithSceneGraphPriority(touchListener, layer); + eventDispatcher:addEventListenerWithSceneGraphPriority(touchListener, layer) - local node = cc.Node:create(); - node:setPhysicsBody(cc.PhysicsBody:createEdgeSegment(cc.p(VisibleRect:leftBottom().x, VisibleRect:leftBottom().y + 50), cc.p(VisibleRect:rightBottom().x, VisibleRect:rightBottom().y + 50))); - layer:addChild(node); + local node = cc.Node:create() + addPhysicsComponent(node, + cc.PhysicsBody:createEdgeSegment(cc.p(VisibleRect:leftBottom().x, + VisibleRect:leftBottom().y + 50), + cc.p(VisibleRect:rightBottom().x, + VisibleRect:rightBottom().y + 50))) + layer:addChild(node) - local ball = cc.Sprite:create("Images/ball.png"); - ball:setScale(1); - ball:setPhysicsBody(cc.PhysicsBody:createCircle(10)); - ball:getPhysicsBody():setTag(DRAG_BODYS_TAG); - ball:setPosition(cc.p(VisibleRect:bottom().x, VisibleRect:bottom().y + 60)); - layer:addChild(ball); + local ball = cc.Sprite:create("Images/ball.png") + ball:setScale(1) + addPhysicsComponent(ball, cc.PhysicsBody:createCircle(10)) + ball:getComponent(PHYSICS_COMPONENT_NAME):getPhysicsBody():setTag(DRAG_BODYS_TAG) + ball:setPosition(cc.p(VisibleRect:bottom().x, VisibleRect:bottom().y + 60)) + layer:addChild(ball) + ball:runAction(cc.Sequence:create(cc.DelayTime:create(3), + cc.ScaleTo:create(0, 3))) + for i in range(0, 13) do - for j in range(0, i) do - local x = VisibleRect:bottom().x + (i/2 - j) * 11 - local y = VisibleRect:bottom().y + (14 - i) * 23 + 100 - local sp = addGrossiniAtPosition(layer, cc.p(x, y), 0.2); - sp:getPhysicsBody():setTag(DRAG_BODYS_TAG); - end + for j in range(0, i) do + local x = VisibleRect:bottom().x + (i/2 - j) * 11 + local y = VisibleRect:bottom().y + (14 - i) * 23 + 100 + local sp = addGrossiniAtPosition(layer, cc.p(x, y), 0.2) + sp:getComponent(PHYSICS_COMPONENT_NAME):getPhysicsBody():setTag(DRAG_BODYS_TAG) + end end end @@ -490,117 +604,124 @@ local function PhysicsDemoRayCast() local function onEnter() local function onTouchEnded(touch, event) - local location = touch:getLocation(); + local location = touch:getLocation() - local r = math.random(3); - if r ==1 then - layer:addChild(makeBall(layer, location, 5 + math.random()*10)); - elseif r == 2 then - layer:addChild(makeBox(location, cc.size(10 + math.random()*15, 10 + math.random()*15))); - elseif r == 3 then - layer:addChild(makeTriangle(location, cc.size(10 + math.random()*20, 10 + math.random()*20))); - end + local r = math.random(3) + if r ==1 then + layer:addChild(makeBall(layer, location, 5 + math.random()*10)) + elseif r == 2 then + layer:addChild(makeBox(location, cc.size(10 + math.random()*15, 10 + math.random()*15))) + elseif r == 3 then + layer:addChild(makeTriangle(location, cc.size(10 + math.random()*20, 10 + math.random()*20))) + end end - local touchListener = cc.EventListenerTouchOneByOne:create(); - touchListener:registerScriptHandler(function() return true end, cc.Handler.EVENT_TOUCH_BEGAN); - touchListener:registerScriptHandler(onTouchEnded, cc.Handler.EVENT_TOUCH_ENDED); + local touchListener = cc.EventListenerTouchOneByOne:create() + touchListener:registerScriptHandler(function() return true end, cc.Handler.EVENT_TOUCH_BEGAN) + touchListener:registerScriptHandler(onTouchEnded, cc.Handler.EVENT_TOUCH_ENDED) local eventDispatcher = layer:getEventDispatcher() - eventDispatcher:addEventListenerWithSceneGraphPriority(touchListener, layer); + eventDispatcher:addEventListenerWithSceneGraphPriority(touchListener, layer) - cc.Director:getInstance():getRunningScene():getPhysicsWorld():setGravity(cc.p(0,0)); + cc.Director:getInstance():getRunningScene():getPhysicsWorld():setGravity(cc.p(0,0)) - local node = cc.DrawNode:create(); - node:setPhysicsBody(cc.PhysicsBody:createEdgeSegment(cc.p(VisibleRect:leftBottom().x, VisibleRect:leftBottom().y + 50), cc.p(VisibleRect:rightBottom().x, VisibleRect:rightBottom().y + 50))) - node:drawSegment(cc.p(VisibleRect:leftBottom().x, VisibleRect:leftBottom().y + 50), cc.p(VisibleRect:rightBottom().x, VisibleRect:rightBottom().y + 50), 1, STATIC_COLOR); - layer:addChild(node); + local node = cc.DrawNode:create() + addPhysicsComponent(node, + cc.PhysicsBody:createEdgeSegment(cc.p(VisibleRect:leftBottom().x, + VisibleRect:leftBottom().y + 50), + cc.p(VisibleRect:rightBottom().x, + VisibleRect:rightBottom().y + 50))) + node:drawSegment(cc.p(VisibleRect:leftBottom().x, VisibleRect:leftBottom().y + 50), + cc.p(VisibleRect:rightBottom().x, VisibleRect:rightBottom().y + 50), + 1, + STATIC_COLOR) + layer:addChild(node) local mode = 0 - cc.MenuItemFont:setFontSize(18); + cc.MenuItemFont:setFontSize(18) local item = cc.MenuItemFont:create("Toogle debugChange Mode(any)") local function changeModeCallback(sender) - mode = (mode + 1) % 3; + mode = (mode + 1) % 3 - if mode == 0 then - item:setString("Change Mode(any)"); - elseif mode == 1 then - item:setString("Change Mode(nearest)"); - elseif mode == 2 then - item:setString("Change Mode(multiple)"); - end + if mode == 0 then + item:setString("Change Mode(any)") + elseif mode == 1 then + item:setString("Change Mode(nearest)") + elseif mode == 2 then + item:setString("Change Mode(multiple)") + end end item:registerScriptTapHandler(changeModeCallback) - local menu = cc.Menu:create(item); - layer:addChild(menu); - menu:setPosition(cc.p(VisibleRect:left().x+100, VisibleRect:top().y-10)); + local menu = cc.Menu:create(item) + layer:addChild(menu) + menu:setPosition(cc.p(VisibleRect:left().x+100, VisibleRect:top().y-10)) local angle = 0 local drawNode = nil local function update(delta) - local L = 150.0; - local point1 = VisibleRect:center() - local d = cc.p(L * math.cos(angle), L * math.sin(angle)); - local point2 = cc.p(point1.x + d.x, point1.y + d.y) + local L = 150.0 + local point1 = VisibleRect:center() + local d = cc.p(L * math.cos(angle), L * math.sin(angle)) + local point2 = cc.p(point1.x + d.x, point1.y + d.y) - if drawNode then layer:removeChild(drawNode); end - drawNode = cc.DrawNode:create(); + if drawNode then layer:removeChild(drawNode) end + drawNode = cc.DrawNode:create() if mode == 0 then - local point3 = cc.p(point2.x, point2.y) - local function func(world, info) - point3 = info.contact - return false - end + local point3 = cc.p(point2.x, point2.y) + local function func(world, info) + point3 = info.contact + return false + end - cc.Director:getInstance():getRunningScene():getPhysicsWorld():rayCast(func, point1, point2); - drawNode:drawSegment(point1, point3, 1, STATIC_COLOR); + cc.Director:getInstance():getRunningScene():getPhysicsWorld():rayCast(func, point1, point2) + drawNode:drawSegment(point1, point3, 1, STATIC_COLOR) - if point2.x ~= point3.x or point2.y ~= point3.y then - drawNode:drawDot(point3, 2, cc.c4f(1.0, 1.0, 1.0, 1.0)); - end - layer:addChild(drawNode); - elseif mode == 1 then - local point3 = cc.p(point2.x, point2.y) - local friction = 1.0; - local function func(world, info) - if friction > info.fraction then - point3 = info.contact; - friction = info.fraction; - end - return true; - end + if point2.x ~= point3.x or point2.y ~= point3.y then + drawNode:drawDot(point3, 2, cc.c4f(1.0, 1.0, 1.0, 1.0)) + end + layer:addChild(drawNode) + elseif mode == 1 then + local point3 = cc.p(point2.x, point2.y) + local friction = 1.0 + local function func(world, info) + if friction > info.fraction then + point3 = info.contact + friction = info.fraction + end + return true + end - cc.Director:getInstance():getRunningScene():getPhysicsWorld():rayCast(func, point1, point2); - drawNode:drawSegment(point1, point3, 1, STATIC_COLOR); + cc.Director:getInstance():getRunningScene():getPhysicsWorld():rayCast(func, point1, point2) + drawNode:drawSegment(point1, point3, 1, STATIC_COLOR) - if point2.x ~= point3.x or point2.y ~= point3.y then - drawNode:drawDot(point3, 2, cc.c4f(1.0, 1.0, 1.0, 1.0)); - end - layer:addChild(drawNode); + if point2.x ~= point3.x or point2.y ~= point3.y then + drawNode:drawDot(point3, 2, cc.c4f(1.0, 1.0, 1.0, 1.0)) + end + layer:addChild(drawNode) elseif mode == 2 then - local points = {} + local points = {} - local function func(world, info) - points[#points + 1] = info.contact; - return true; - end + local function func(world, info) + points[#points + 1] = info.contact + return true + end - cc.Director:getInstance():getRunningScene():getPhysicsWorld():rayCast(func, point1, point2); - drawNode:drawSegment(point1, point2, 1, STATIC_COLOR); + cc.Director:getInstance():getRunningScene():getPhysicsWorld():rayCast(func, point1, point2) + drawNode:drawSegment(point1, point2, 1, STATIC_COLOR) - for _, p in ipairs(points) do - drawNode:drawDot(p, 2, cc.c4f(1.0, 1.0, 1.0, 1.0)); - end + for _, p in ipairs(points) do + drawNode:drawDot(p, 2, cc.c4f(1.0, 1.0, 1.0, 1.0)) + end - layer:addChild(drawNode); + layer:addChild(drawNode) end - angle = angle + 0.25 * math.pi / 180.0; + angle = angle + 0.25 * math.pi / 180.0 - end + end - layer:scheduleUpdateWithPriorityLua(update, 0); + layer:scheduleUpdateWithPriorityLua(update, 0) end initWithLayer(layer, onEnter) @@ -613,35 +734,41 @@ local function PhysicsDemoOneWayPlatform() local layer = cc.Layer:create() local function onEnter() - local touchListener = cc.EventListenerTouchOneByOne:create(); - touchListener:registerScriptHandler(onTouchBegan, cc.Handler.EVENT_TOUCH_BEGAN); - touchListener:registerScriptHandler(onTouchMoved, cc.Handler.EVENT_TOUCH_MOVED); - touchListener:registerScriptHandler(onTouchEnded, cc.Handler.EVENT_TOUCH_ENDED); + local touchListener = cc.EventListenerTouchOneByOne:create() + touchListener:registerScriptHandler(onTouchBegan, cc.Handler.EVENT_TOUCH_BEGAN) + touchListener:registerScriptHandler(onTouchMoved, cc.Handler.EVENT_TOUCH_MOVED) + touchListener:registerScriptHandler(onTouchEnded, cc.Handler.EVENT_TOUCH_ENDED) local eventDispatcher = layer:getEventDispatcher() - eventDispatcher:addEventListenerWithSceneGraphPriority(touchListener, layer); + eventDispatcher:addEventListenerWithSceneGraphPriority(touchListener, layer) - local ground = cc.Node:create(); - ground:setPhysicsBody(cc.PhysicsBody:createEdgeSegment(cc.p(VisibleRect:leftBottom().x, VisibleRect:leftBottom().y + 50), cc.p(VisibleRect:rightBottom().x, VisibleRect:rightBottom().y + 50))); - layer:addChild(ground); + local ground = cc.Node:create() + addPhysicsComponent(ground, + cc.PhysicsBody:createEdgeSegment(cc.p(VisibleRect:leftBottom().x, + VisibleRect:leftBottom().y + 50), + cc.p(VisibleRect:rightBottom().x, + VisibleRect:rightBottom().y + 50))) + layer:addChild(ground) - local platform = makeBox(VisibleRect:center(), cc.size(200, 50)); - platform:getPhysicsBody():setDynamic(false); - platform:getPhysicsBody():setContactTestBitmask(1); - layer:addChild(platform); + local platform = makeBox(VisibleRect:center(), cc.size(200, 50)) + local platformPhysicsBody = platform:getComponent(PHYSICS_COMPONENT_NAME):getPhysicsBody() + platformPhysicsBody:setDynamic(false) + platformPhysicsBody:setContactTestBitmask(0xFFFFFFFF) + layer:addChild(platform) - local ball = makeBall(layer, cc.p(VisibleRect:center().x, VisibleRect:center().y - 50), 20); - ball:getPhysicsBody():setVelocity(cc.p(0, 150)); - ball:getPhysicsBody():setTag(DRAG_BODYS_TAG); - ball:getPhysicsBody():setMass(1.0); - ball:getPhysicsBody():setContactTestBitmask(1); - layer:addChild(ball); + local ball = makeBall(layer, cc.p(VisibleRect:center().x, VisibleRect:center().y - 50), 20) + local ballPhysicsBody = ball:getComponent(PHYSICS_COMPONENT_NAME):getPhysicsBody() + ballPhysicsBody:setVelocity(cc.p(0, 150)) + ballPhysicsBody:setTag(DRAG_BODYS_TAG) + ballPhysicsBody:setMass(1.0) + ballPhysicsBody:setContactTestBitmask(0xFFFFFFFF) + layer:addChild(ball) local function onContactBegin(contact) - return contact:getContactData().normal.y < 0; + return contact:getContactData().normal.y < 0 end - local contactListener = cc.EventListenerPhysicsContactWithBodies:create(platform:getPhysicsBody(), ball:getPhysicsBody()); - contactListener:registerScriptHandler(onContactBegin, cc.Handler.EVENT_PHYSICS_CONTACT_BEGIN); - eventDispatcher:addEventListenerWithSceneGraphPriority(contactListener, layer); + local contactListener = cc.EventListenerPhysicsContactWithBodies:create(platformPhysicsBody, ballPhysicsBody) + contactListener:registerScriptHandler(onContactBegin, cc.Handler.EVENT_PHYSICS_CONTACT_BEGIN) + eventDispatcher:addEventListenerWithSceneGraphPriority(contactListener, layer) end initWithLayer(layer, onEnter) @@ -660,27 +787,31 @@ local function PhysicsDemoActions() local eventDispatcher = layer:getEventDispatcher() eventDispatcher:addEventListenerWithSceneGraphPriority(touchListener, layer) - local node = cc.Node:create(); - node:setPhysicsBody(cc.PhysicsBody:createEdgeBox(cc.size(VisibleRect:getVisibleRect().width, VisibleRect:getVisibleRect().height))); - node:setPosition(VisibleRect:center()); - layer:addChild(node); + local node = cc.Node:create() + addPhysicsComponent(node, + cc.PhysicsBody:createEdgeBox(cc.size(VisibleRect:getVisibleRect().width, + VisibleRect:getVisibleRect().height))) + node:setPosition(VisibleRect:center()) + layer:addChild(node) - local sp1 = addGrossiniAtPosition(layer, VisibleRect:center()); - local sp2 = addGrossiniAtPosition(layer, cc.p(VisibleRect:left().x + 50, VisibleRect:left().y)); - local sp3 = addGrossiniAtPosition(layer, cc.p(VisibleRect:right().x - 20, VisibleRect:right().y)); - local sp4 = addGrossiniAtPosition(layer, cc.p(VisibleRect:leftTop().x + 50, VisibleRect:leftTop().y-50)); - sp4:getPhysicsBody():setGravityEnable(false); + local sp1 = addGrossiniAtPosition(layer, VisibleRect:center()) + local sp2 = addGrossiniAtPosition(layer, cc.p(VisibleRect:left().x + 50, VisibleRect:left().y)) + local sp3 = addGrossiniAtPosition(layer, cc.p(VisibleRect:right().x - 20, VisibleRect:right().y)) + local sp4 = addGrossiniAtPosition(layer, cc.p(VisibleRect:leftTop().x + 50, VisibleRect:leftTop().y-50)) + sp4:getComponent(PHYSICS_COMPONENT_NAME):getPhysicsBody():setGravityEnable(false) - local actionTo = cc.JumpTo:create(2, cc.p(100,100), 50, 4); - local actionBy = cc.JumpBy:create(2, cc.p(300,0), 50, 4); - local actionUp = cc.JumpBy:create(2, cc.p(0,50), 80, 4); - local actionByBack = actionBy:reverse(); + local actionTo = cc.JumpTo:create(2, cc.p(100,100), 50, 4) + local actionBy = cc.JumpBy:create(2, cc.p(300,0), 50, 4) + local actionUp = cc.JumpBy:create(2, cc.p(0,50), 80, 4) + local actionByBack = actionBy:reverse() + local rotateBy = cc.RotateBy:create(2, 180) + local rotateByBack = cc.RotateBy:create(2, -180) - sp1:runAction(cc.RepeatForever:create(actionUp)); - sp2:runAction(cc.RepeatForever:create(cc.Sequence:create(actionBy, actionByBack))); - sp3:runAction(actionTo); - sp4:runAction(cc.RepeatForever:create(cc.Sequence:create(actionBy:clone(), actionByBack:clone()))); + sp1:runAction(cc.RepeatForever:create(actionUp)) + sp2:runAction(cc.RepeatForever:create(cc.Sequence:create(actionBy, actionByBack))) + sp3:runAction(actionTo) + sp4:runAction(cc.RepeatForever:create(cc.Sequence:create(rotateBy, rotateByBack))) end initWithLayer(layer, onEnter) @@ -692,24 +823,24 @@ end local function PhysicsDemoPump() local layer = cc.Layer:create() local function onEnter() - layer:toggleDebug(); + layer:toggleDebug() - local distance = 0.0; - local rotationV = 0.0; + local distance = 0.0 + local rotationV = 0.0 local function onTouchBeganEx(touch, event) onTouchBegan(touch, event) - distance = touch:getLocation().x - VisibleRect:center().x; - return true; + distance = touch:getLocation().x - VisibleRect:center().x + return true end local function onTouchMovedEx(touch, event) - onTouchMoved(touch, event); - distance = touch:getLocation().x - VisibleRect:center().x; + onTouchMoved(touch, event) + distance = touch:getLocation().x - VisibleRect:center().x end local function onTouchEndedEx(touch, event) onTouchEnded(touch, event) - distance = 0; + distance = 0 end local touchListener = cc.EventListenerTouchOneByOne:create() @@ -722,63 +853,89 @@ local function PhysicsDemoPump() local function update() for _, body in ipairs(cc.Director:getInstance():getRunningScene():getPhysicsWorld():getAllBodies()) do if body:getTag() == DRAG_BODYS_TAG and body:getPosition().y < 0.0 then - body:getNode():setPosition(cc.p(VisibleRect:leftTop().x + 75, VisibleRect:leftTop().y + math.random() * 90, 0)); - body:setVelocity(cc.p(0, 0)); + body:getNode():setPosition(cc.p(VisibleRect:leftTop().x + 75, + VisibleRect:leftTop().y + math.random() * 90)) + body:setVelocity(cc.p(0, 0)) end end - local gear = cc.Director:getInstance():getRunningScene():getPhysicsWorld():getBody(1); + local gear = cc.Director:getInstance():getRunningScene():getPhysicsWorld():getBody(1) if gear then if distance ~= 0.0 then - rotationV = rotationV + distance/2500.0; + rotationV = rotationV + distance/2500.0 end if rotationV > 30 then rotationV = 30.0 end if rotationV < -30 then rotationV = -30.0 end - gear:setAngularVelocity(rotationV); - rotationV = rotationV*0.995; + gear:setAngularVelocity(rotationV) + rotationV = rotationV * 0.995 end end - layer:scheduleUpdateWithPriorityLua(update, 0); + layer:scheduleUpdateWithPriorityLua(update, 0) - local node = cc.Node:create(); - local body = cc.PhysicsBody:create(); - body:setDynamic(false); + local node = cc.Node:create() + local body = cc.PhysicsBody:create() + body:setDynamic(false) - local staticMaterial = cc.PhysicsMaterial(cc.PHYSICS_INFINITY, 0, 0.5); - body:addShape(cc.PhysicsShapeEdgeSegment:create( - cc.p(VisibleRect:leftTop().x + 50, VisibleRect:leftTop().y), - cc.p(VisibleRect:leftTop().x + 50, VisibleRect:leftTop().y-130), staticMaterial, 2.0)); - body:addShape(cc.PhysicsShapeEdgeSegment:create( - cc.p(VisibleRect:leftTop().x + 190, VisibleRect:leftTop().y), - cc.p(VisibleRect:leftTop().x + 100, VisibleRect:leftTop().y-50), staticMaterial, 2.0)); - body:addShape(cc.PhysicsShapeEdgeSegment:create( - cc.p(VisibleRect:leftTop().x + 100, VisibleRect:leftTop().y-50), - cc.p(VisibleRect:leftTop().x + 100, VisibleRect:leftTop().y-90), staticMaterial, 2.0)); - body:addShape(cc.PhysicsShapeEdgeSegment:create( - cc.p(VisibleRect:leftTop().x + 50, VisibleRect:leftTop().y-130), - cc.p(VisibleRect:leftTop().x + 100, VisibleRect:leftTop().y-145), staticMaterial, 2.0)); - body:addShape(cc.PhysicsShapeEdgeSegment:create( - cc.p(VisibleRect:leftTop().x + 100, VisibleRect:leftTop().y-145), - cc.p(VisibleRect:leftBottom().x + 100, VisibleRect:leftBottom().y + 80), staticMaterial, 2.0)); - body:addShape(cc.PhysicsShapeEdgeSegment:create( - cc.p(VisibleRect:leftTop().x + 150, VisibleRect:leftTop().y-80), - cc.p(VisibleRect:leftBottom().x + 150, VisibleRect:leftBottom().y + 80), staticMaterial, 2.0)); - body:addShape(cc.PhysicsShapeEdgeSegment:create( - cc.p(VisibleRect:leftTop().x + 150, VisibleRect:leftTop().y-80), - cc.p(VisibleRect:rightTop().x -100, VisibleRect:rightTop().y-150), staticMaterial, 2.0)); + local staticMaterial = cc.PhysicsMaterial(cc.PHYSICS_INFINITY, 0, 0.5) + body:addShape(cc.PhysicsShapeEdgeSegment:create(cc.p(VisibleRect:leftTop().x + 50, + VisibleRect:leftTop().y), + cc.p(VisibleRect:leftTop().x + 50, + VisibleRect:leftTop().y-130), + staticMaterial, + 2.0)) + body:addShape(cc.PhysicsShapeEdgeSegment:create(cc.p(VisibleRect:leftTop().x + 190, + VisibleRect:leftTop().y), + cc.p(VisibleRect:leftTop().x + 100, + VisibleRect:leftTop().y-50), + staticMaterial, + 2.0)) + body:addShape(cc.PhysicsShapeEdgeSegment:create(cc.p(VisibleRect:leftTop().x + 100, + VisibleRect:leftTop().y-50), + cc.p(VisibleRect:leftTop().x + 100, + VisibleRect:leftTop().y-90), + staticMaterial, + 2.0)) + body:addShape(cc.PhysicsShapeEdgeSegment:create(cc.p(VisibleRect:leftTop().x + 50, + VisibleRect:leftTop().y-130), + cc.p(VisibleRect:leftTop().x + 100, + VisibleRect:leftTop().y-145), + staticMaterial, + 2.0)) + body:addShape(cc.PhysicsShapeEdgeSegment:create(cc.p(VisibleRect:leftTop().x + 100, + VisibleRect:leftTop().y-145), + cc.p(VisibleRect:leftBottom().x + 100, + VisibleRect:leftBottom().y + 80), + staticMaterial, + 2.0)) + body:addShape(cc.PhysicsShapeEdgeSegment:create(cc.p(VisibleRect:leftTop().x + 150, + VisibleRect:leftTop().y-80), + cc.p(VisibleRect:leftBottom().x + 150, + VisibleRect:leftBottom().y + 80), + staticMaterial, + 2.0)) + body:addShape(cc.PhysicsShapeEdgeSegment:create(cc.p(VisibleRect:leftTop().x + 150, + VisibleRect:leftTop().y-80), + cc.p(VisibleRect:rightTop().x -100, + VisibleRect:rightTop().y-150), + staticMaterial, + 2.0)) - body:setCategoryBitmask(1); + body:setCategoryBitmask(1) for _ in range(1, 6) do - local ball = makeBall(layer, cc.p(VisibleRect:leftTop().x + 75 + math.random() * 90, VisibleRect:leftTop().y), 22, cc.PhysicsMaterial(0.05, 0.0, 0.1)); - ball:getPhysicsBody():setTag(DRAG_BODYS_TAG); - layer:addChild(ball); + local ball = makeBall(layer, + cc.p(VisibleRect:leftTop().x + 75 + math.random() * 90, + VisibleRect:leftTop().y), + 22, + cc.PhysicsMaterial(0.05, 0.0, 0.1)) + ball:getComponent(PHYSICS_COMPONENT_NAME):getPhysicsBody():setTag(DRAG_BODYS_TAG) + layer:addChild(ball) end - node:setPhysicsBody(body); - layer:addChild(node); + addPhysicsComponent(node, body) + layer:addChild(node) local vec = { @@ -786,61 +943,72 @@ local function PhysicsDemoPump() cc.p(VisibleRect:leftTop().x + 148, VisibleRect:leftTop().y-161), cc.p(VisibleRect:leftBottom().x + 148, VisibleRect:leftBottom().y + 20), cc.p(VisibleRect:leftBottom().x + 102, VisibleRect:leftBottom().y + 20) - }; + } - local world = cc.Director:getInstance():getRunningScene():getPhysicsWorld(); + local world = cc.Director:getInstance():getRunningScene():getPhysicsWorld() -- small gear - local sgear = cc.Node:create(); - local sgearB = cc.PhysicsBody:createCircle(44); - sgear:setPhysicsBody(sgearB); - sgear:setPosition(cc.p(VisibleRect:leftBottom().x + 125, VisibleRect:leftBottom().y)); - layer:addChild(sgear); - sgearB:setCategoryBitmask(4); - sgearB:setCollisionBitmask(4); - sgearB:setTag(1); - world:addJoint(cc.PhysicsJointPin:construct(body, sgearB, cc.p(sgear:getPosition()))); + local sgear = cc.Node:create() + local sgearB = cc.PhysicsBody:createCircle(44) + addPhysicsComponent(sgear, sgearB) + sgear:setPosition(cc.p(VisibleRect:leftBottom().x + 125, VisibleRect:leftBottom().y)) + layer:addChild(sgear) + sgearB:setCategoryBitmask(4) + sgearB:setCollisionBitmask(4) + sgearB:setTag(1) + world:addJoint(cc.PhysicsJointPin:construct(body, sgearB, cc.p(sgear:getPosition()))) -- big gear - local bgear = cc.Node:create(); - local bgearB = cc.PhysicsBody:createCircle(100); - bgear:setPhysicsBody(bgearB); - bgear:setPosition(cc.p(VisibleRect:leftBottom().x + 275, VisibleRect:leftBottom().y)); - layer:addChild(bgear); - bgearB:setCategoryBitmask(4); - world:addJoint(cc.PhysicsJointPin:construct(body, bgearB, cc.p(bgear:getPosition()))); + local bgear = cc.Node:create() + local bgearB = cc.PhysicsBody:createCircle(100) + addPhysicsComponent(bgear, bgearB) + bgear:setPosition(cc.p(VisibleRect:leftBottom().x + 275, VisibleRect:leftBottom().y)) + layer:addChild(bgear) + bgearB:setCategoryBitmask(4) + world:addJoint(cc.PhysicsJointPin:construct(body, bgearB, cc.p(bgear:getPosition()))) -- pump - local pump = cc.Node:create(); - local center = cc.PhysicsShape:getPolyonCenter(vec); - pump:setPosition(center); - local pumpB = cc.PhysicsBody:createPolygon(vec, cc.PHYSICSBODY_MATERIAL_DEFAULT, cc.p(-center.x, -center.y)); - pump:setPhysicsBody(pumpB); - layer:addChild(pump); - pumpB:setCategoryBitmask(2); - pumpB:setGravityEnable(false); - world:addJoint(cc.PhysicsJointDistance:construct(pumpB, sgearB, cc.p(0, 0), cc.p(0, -44))); + local pump = cc.Node:create() + local center = cc.PhysicsShape:getPolyonCenter(vec) + pump:setPosition(center) + local pumpB = cc.PhysicsBody:createPolygon(vec, + cc.PHYSICSBODY_MATERIAL_DEFAULT, + cc.p(-center.x, -center.y)) + addPhysicsComponent(pump, pumpB) + layer:addChild(pump) + pumpB:setCategoryBitmask(2) + pumpB:setGravityEnable(false) + world:addJoint(cc.PhysicsJointDistance:construct(pumpB, sgearB, cc.p(0, 0), cc.p(0, -44))) -- plugger - local seg = {cc.p(VisibleRect:leftTop().x + 75, VisibleRect:leftTop().y-120), cc.p(VisibleRect:leftBottom().x + 75, VisibleRect:leftBottom().y-100)}; - local segCenter = cc.p((seg[2].x + seg[1].x)/2, (seg[2].y + seg[1].y)/2); - seg[2] = cc.p(seg[2].x - segCenter.x, seg[2].y - segCenter.y); - seg[1] = cc.p(seg[1].x - segCenter.x, seg[1].y - segCenter.y); - local plugger = cc.Node:create(); - local pluggerB = cc.PhysicsBody:createEdgeSegment(seg[1], seg[2], cc.PhysicsMaterial(0.01, 0.0, 0.5), 20); - pluggerB:setDynamic(true); - pluggerB:setMass(30); - pluggerB:setMoment(100000); - plugger:setPhysicsBody(pluggerB); - plugger:setPosition(segCenter); - layer:addChild(plugger); - pluggerB:setCategoryBitmask(2); - sgearB:setCollisionBitmask(5); - world:addJoint(cc.PhysicsJointPin:construct(body, pluggerB, cc.p(VisibleRect:leftBottom().x + 75, VisibleRect:leftBottom().y-90))); - world:addJoint(cc.PhysicsJointDistance:construct(pluggerB, sgearB, - pluggerB:world2Local(cc.p(0,0)), cc.p(44, 0))); + local seg = {cc.p(VisibleRect:leftTop().x + 75, VisibleRect:leftTop().y-120), + cc.p(VisibleRect:leftBottom().x + 75, VisibleRect:leftBottom().y-100)} + local segCenter = cc.p((seg[2].x + seg[1].x)/2, (seg[2].y + seg[1].y)/2) + seg[2] = cc.p(seg[2].x - segCenter.x, seg[2].y - segCenter.y) + seg[1] = cc.p(seg[1].x - segCenter.x, seg[1].y - segCenter.y) + local plugger = cc.Node:create() + local pluggerB = cc.PhysicsBody:createEdgeSegment(seg[1], + seg[2], + cc.PhysicsMaterial(0.01, 0.0, 0.5), + 20) + pluggerB:setDynamic(true) + pluggerB:setMass(30) + pluggerB:setMoment(100000) + addPhysicsComponent(plugger, pluggerB) + plugger:setPosition(segCenter) + layer:addChild(plugger) + pluggerB:setCategoryBitmask(2) + sgearB:setCollisionBitmask(5) + world:addJoint(cc.PhysicsJointPin:construct(body, + pluggerB, + cc.p(VisibleRect:leftBottom().x + 75, + VisibleRect:leftBottom().y-90))) + world:addJoint(cc.PhysicsJointDistance:construct(pluggerB, + sgearB, + pluggerB:world2Local(cc.p(0,0)), + cc.p(44, 0))) end initWithLayer(layer, onEnter) @@ -854,83 +1022,90 @@ local function PhysicsDemoSlice() local layer = cc.Layer:create() local function onEnter() layer:toggleDebug() - local sliceTag = 1; + local sliceTag = 1 local function clipPoly(shape, normal, distance) - local body = shape:getBody(); - local count = shape:getPointsCount(); + local body = shape:getBody() + local count = shape:getPointsCount() local points = {} local j = count - 1 for i in range(0, count-1) do - local a = body:local2World(shape:getPoint(j)); - local aDist = cc.pDot(a, normal) - distance; + local a = body:local2World(shape:getPoint(j)) + local aDist = cc.pDot(a, normal) - distance if aDist < 0.0 then - points[#points + 1] = a; + points[#points + 1] = a end - local b = body:local2World(shape:getPoint(i)); - local bDist = cc.pDot(b, normal) - distance; + local b = body:local2World(shape:getPoint(i)) + local bDist = cc.pDot(b, normal) - distance if aDist*bDist < 0.0 then - local t = math.abs(aDist)/(math.abs(aDist) + math.abs(bDist)); - points[#points + 1] = cc.pLerp(a, b, t); + local t = math.abs(aDist)/(math.abs(aDist) + math.abs(bDist)) + points[#points + 1] = cc.pLerp(a, b, t) end j = i end - local center = cc.PhysicsShape:getPolyonCenter(points); - local node = cc.Node:create(); - local polyon = cc.PhysicsBody:createPolygon(points, cc.PHYSICSBODY_MATERIAL_DEFAULT, cc.p(-center.x, -center.y)); - node:setPosition(center); - node:setPhysicsBody(polyon); - polyon:setVelocity(body:getVelocityAtWorldPoint(center)); - polyon:setAngularVelocity(body:getAngularVelocity()); - polyon.tag = sliceTag; - layer:addChild(node); + local center = cc.PhysicsShape:getPolyonCenter(points) + local node = cc.Node:create() + local polyon = cc.PhysicsBody:createPolygon(points, + cc.PHYSICSBODY_MATERIAL_DEFAULT, + cc.p(-center.x, -center.y)) + node:setPosition(center) + addPhysicsComponent(node, polyon) + polyon:setVelocity(body:getVelocityAtWorldPoint(center)) + polyon:setAngularVelocity(body:getAngularVelocity()) + polyon.tag = sliceTag + layer:addChild(node) end local function slice(world, info) if info.shape:getBody().tag ~= sliceTag then - return true; + return true end if not info.shape:containsPoint(info.start) and not info.shape:containsPoint(info.ended) then - local normal = cc.p(info.ended.x - info.start.x, info.ended.y - info.start.y); - normal = cc.pNormalize(cc.pPerp(normal)); - local dist = cc.pDot(info.start, normal); + local normal = cc.p(info.ended.x - info.start.x, info.ended.y - info.start.y) + normal = cc.pNormalize(cc.pPerp(normal)) + local dist = cc.pDot(info.start, normal) - clipPoly(info.shape, normal, dist); - clipPoly(info.shape, cc.p(-normal.x, -normal.y), -dist); + clipPoly(info.shape, normal, dist) + clipPoly(info.shape, cc.p(-normal.x, -normal.y), -dist) - info.shape:getBody():removeFromWorld(); + info.shape:getBody():removeFromWorld() end - return true; + return true end local function onTouchEnded(touch, event) - cc.Director:getInstance():getRunningScene():getPhysicsWorld():rayCast(slice, touch:getStartLocation(), touch:getLocation()); + cc.Director:getInstance():getRunningScene():getPhysicsWorld():rayCast(slice, + touch:getStartLocation(), + touch:getLocation()) end - local touchListener = cc.EventListenerTouchOneByOne:create(); - touchListener:registerScriptHandler(function() return true end, cc.Handler.EVENT_TOUCH_BEGAN); - touchListener:registerScriptHandler(onTouchEnded, cc.Handler.EVENT_TOUCH_ENDED); + local touchListener = cc.EventListenerTouchOneByOne:create() + touchListener:registerScriptHandler(function() return true end, cc.Handler.EVENT_TOUCH_BEGAN) + touchListener:registerScriptHandler(onTouchEnded, cc.Handler.EVENT_TOUCH_ENDED) local eventDispatcher = layer:getEventDispatcher() - eventDispatcher:addEventListenerWithSceneGraphPriority(touchListener, layer); + eventDispatcher:addEventListenerWithSceneGraphPriority(touchListener, layer) - local ground = cc.Node:create(); - ground:setPhysicsBody(cc.PhysicsBody:createEdgeSegment(cc.p(VisibleRect:leftBottom().x, VisibleRect:leftBottom().y + 50), - cc.p(VisibleRect:rightBottom().x, VisibleRect:rightBottom().y + 50))); - layer:addChild(ground); + local ground = cc.Node:create() + addPhysicsComponent(ground, + cc.PhysicsBody:createEdgeSegment(cc.p(VisibleRect:leftBottom().x, + VisibleRect:leftBottom().y + 50), + cc.p(VisibleRect:rightBottom().x, + VisibleRect:rightBottom().y + 50))) + layer:addChild(ground) - local box = cc.Node:create(); - local points = {cc.p(-100, -100), cc.p(-100, 100), cc.p(100, 100), cc.p(100, -100)}; - box:setPhysicsBody(cc.PhysicsBody:createPolygon(points)); - box:setPosition(VisibleRect:center()); - box:getPhysicsBody().tag = sliceTag; - layer:addChild(box); + local box = cc.Node:create() + local points = {cc.p(-100, -100), cc.p(-100, 100), cc.p(100, 100), cc.p(100, -100)} + addPhysicsComponent(box, cc.PhysicsBody:createPolygon(points)) + box:setPosition(VisibleRect:center()) + box:getComponent(PHYSICS_COMPONENT_NAME):getPhysicsBody().tag = sliceTag + layer:addChild(box) end initWithLayer(layer, onEnter) @@ -944,17 +1119,19 @@ end local function PhysicsDemoBug3988() local layer = cc.Layer:create() local function onEnter() - layer:toggleDebug(); - cc.Director:getInstance():getRunningScene():getPhysicsWorld():setGravity(cc.p(0, 0)); + layer:toggleDebug() + cc.Director:getInstance():getRunningScene():getPhysicsWorld():setGravity(cc.p(0, 0)) - local ball = cc.Sprite:create("Images/YellowSquare.png"); - ball:setPosition(cc.p(VisibleRect:center().x-100, VisibleRect:center().y)); - ball:setRotation(30.0); - layer:addChild(ball); + local ball = cc.Sprite:create("Images/YellowSquare.png") + ball:setPosition(cc.p(VisibleRect:center().x-100, VisibleRect:center().y)) + ball:setRotation(30.0) + layer:addChild(ball) - local physicsBall = makeBox(cc.p(VisibleRect:center().x+100, VisibleRect:center().y), cc.size(100, 100)); - physicsBall:setRotation(30.0); - layer:addChild(physicsBall); + local physicsBall = makeBox(cc.p(VisibleRect:center().x+100, + VisibleRect:center().y), + cc.size(100, 100)) + physicsBall:setRotation(30.0) + layer:addChild(physicsBall) end initWithLayer(layer, onEnter) @@ -967,123 +1144,134 @@ end local function PhysicsContactTest() local layer = cc.Layer:create() local function onEnter() - cc.Director:getInstance():getRunningScene():getPhysicsWorld():setGravity(cc.p(0, 0)); - local s = cc.size(VisibleRect:getVisibleRect().width, VisibleRect:getVisibleRect().height); + cc.Director:getInstance():getRunningScene():getPhysicsWorld():setGravity(cc.p(0, 0)) + local s = cc.size(VisibleRect:getVisibleRect().width, VisibleRect:getVisibleRect().height) - layer.yellowBoxNum = 50; - layer.blueBoxNum = 50; - layer.yellowTriangleNum = 50; - layer.blueTriangleNum = 50; + layer.yellowBoxNum = 50 + layer.blueBoxNum = 50 + layer.yellowTriangleNum = 50 + layer.blueTriangleNum = 50 local function onContactBegin(contact) - local a = contact:getShapeA():getBody(); - local b = contact:getShapeB():getBody(); - local body = (a:getCategoryBitmask() == 4 or a:getCategoryBitmask() == 8) and a or b; + local a = contact:getShapeA():getBody() + local b = contact:getShapeB():getBody() + local body = (a:getCategoryBitmask() == 4 or a:getCategoryBitmask() == 8) and a or b - assert(body:getCategoryBitmask() == 4 or body:getCategoryBitmask() == 8, "physics contact fail"); + assert(body:getCategoryBitmask() == 4 or body:getCategoryBitmask() == 8, "physics contact fail") - return true; + return true end local function resetTest() - layer:removeChildByTag(10); - local root = cc.Node:create(); - root:setTag(10); - layer:addChild(root); + layer:removeChildByTag(10) + local root = cc.Node:create() + root:setTag(10) + layer:addChild(root) - local s = cc.size(VisibleRect:getVisibleRect().width, VisibleRect:getVisibleRect().height); + local s = cc.size(VisibleRect:getVisibleRect().width, VisibleRect:getVisibleRect().height) - local label = cc.Label:createWithTTF(tostring(layer.yellowBoxNum), s_arialPath, 32); - root:addChild(label, 1); - label:setAnchorPoint(cc.p(0.5, 0.5)); - label:setPosition(cc.p(s.width/2, s.height-50)); + local label = cc.Label:createWithTTF(tostring(layer.yellowBoxNum), s_arialPath, 32) + root:addChild(label, 1) + label:setAnchorPoint(cc.p(0.5, 0.5)) + label:setPosition(cc.p(s.width/2, s.height-50)) - label = cc.Label:createWithTTF(tostring(layer.blueBoxNum), s_arialPath, 32); - root:addChild(label, 1); - label:setAnchorPoint(cc.p(0.5, 0.5)); - label:setPosition(cc.p(s.width/2, s.height-90)); + label = cc.Label:createWithTTF(tostring(layer.blueBoxNum), s_arialPath, 32) + root:addChild(label, 1) + label:setAnchorPoint(cc.p(0.5, 0.5)) + label:setPosition(cc.p(s.width/2, s.height-90)) - label = cc.Label:createWithTTF(tostring(layer.yellowTriangleNum), s_arialPath, 32); - root:addChild(label, 1); - label:setAnchorPoint(cc.p(0.5, 0.5)); - label:setPosition(cc.p(s.width/2, s.height-130)); + label = cc.Label:createWithTTF(tostring(layer.yellowTriangleNum), s_arialPath, 32) + root:addChild(label, 1) + label:setAnchorPoint(cc.p(0.5, 0.5)) + label:setPosition(cc.p(s.width/2, s.height-130)) - label = cc.Label:createWithTTF(tostring(layer.blueTriangleNum), s_arialPath, 32); - root:addChild(label, 1); - label:setAnchorPoint(cc.p(0.5, 0.5)); - label:setPosition(cc.p(s.width/2, s.height-170)); + label = cc.Label:createWithTTF(tostring(layer.blueTriangleNum), s_arialPath, 32) + root:addChild(label, 1) + label:setAnchorPoint(cc.p(0.5, 0.5)) + label:setPosition(cc.p(s.width/2, s.height-170)) - local wall = cc.Node:create(); - wall:setPhysicsBody(cc.PhysicsBody:createEdgeBox(s, cc.PhysicsMaterial(0.1, 1, 0.0))); - wall:setPosition(VisibleRect:center()); - root:addChild(wall); + local wall = cc.Node:create() + addPhysicsComponent(wall, cc.PhysicsBody:createEdgeBox(s, cc.PhysicsMaterial(0.1, 1, 0.0))) + wall:setPosition(VisibleRect:center()) + root:addChild(wall) -- yellow box, will collide with itself and blue box. for i = 1, layer.yellowBoxNum do - local size = cc.size(10 + math.random()*10, 10 + math.random()*10); - local winSize = cc.size(VisibleRect:getVisibleRect().width, VisibleRect:getVisibleRect().height); - local position = cc.p(winSize.width - size.width, winSize.height - size.height); - position.x = position.x * math.random(); - position.y = position.y * math.random(); - position = cc.p(VisibleRect:leftBottom().x + position.x + size.width/2, VisibleRect:leftBottom().y + position.y + size.height/2); - local velocity = cc.p((math.random() - 0.5)*200, (math.random() - 0.5)*200); - local box = makeBox(position, size, 1, cc.PhysicsMaterial(0.1, 1, 0.0)); - box:getPhysicsBody():setVelocity(velocity); - box:getPhysicsBody():setCategoryBitmask(1); -- 0001 - box:getPhysicsBody():setContactTestBitmask(4); -- 0100 - box:getPhysicsBody():setCollisionBitmask(3); -- 0011 - root:addChild(box); + local size = cc.size(10 + math.random()*10, 10 + math.random()*10) + local winSize = cc.size(VisibleRect:getVisibleRect().width, + VisibleRect:getVisibleRect().height) + local position = cc.p(winSize.width - size.width, winSize.height - size.height) + position.x = position.x * math.random() + position.y = position.y * math.random() + position = cc.p(VisibleRect:leftBottom().x + position.x + size.width/2, + VisibleRect:leftBottom().y + position.y + size.height/2) + local velocity = cc.p((math.random() - 0.5)*200, (math.random() - 0.5)*200) + local box = makeBox(position, size, 1, cc.PhysicsMaterial(0.1, 1, 0.0)) + local boxPhysicsBody = box:getComponent(PHYSICS_COMPONENT_NAME):getPhysicsBody() + boxPhysicsBody:setVelocity(velocity) + boxPhysicsBody:setCategoryBitmask(1) -- 0001 + boxPhysicsBody:setContactTestBitmask(4) -- 0100 + boxPhysicsBody:setCollisionBitmask(3) -- 0011 + root:addChild(box) end -- blue box, will collide with blue box. for i = 1, layer.blueBoxNum do - local size = cc.size(10 + math.random()*10, 10 + math.random()*10); - local winSize = cc.size(VisibleRect:getVisibleRect().width, VisibleRect:getVisibleRect().height); - local position = cc.p(winSize.width - size.width, winSize.height - size.height); - position.x = position.x * math.random(); - position.y = position.y * math.random(); - position = cc.p(VisibleRect:leftBottom().x + position.x + size.width/2, VisibleRect:leftBottom().y + position.y + size.height/2); - local velocity = cc.p((math.random() - 0.5)*200, (math.random() - 0.5)*200); - local box = makeBox(position, size, 2, cc.PhysicsMaterial(0.1, 1, 0.0)); - box:getPhysicsBody():setVelocity(velocity); - box:getPhysicsBody():setCategoryBitmask(2); -- 0010 - box:getPhysicsBody():setContactTestBitmask(8); -- 1000 - box:getPhysicsBody():setCollisionBitmask(1); -- 0001 - root:addChild(box); + local size = cc.size(10 + math.random()*10, 10 + math.random()*10) + local winSize = cc.size(VisibleRect:getVisibleRect().width, VisibleRect:getVisibleRect().height) + local position = cc.p(winSize.width - size.width, winSize.height - size.height) + position.x = position.x * math.random() + position.y = position.y * math.random() + position = cc.p(VisibleRect:leftBottom().x + position.x + size.width/2, + VisibleRect:leftBottom().y + position.y + size.height/2) + local velocity = cc.p((math.random() - 0.5)*200, (math.random() - 0.5)*200) + local box = makeBox(position, size, 2, cc.PhysicsMaterial(0.1, 1, 0.0)) + local boxPhysicsBody = box:getComponent(PHYSICS_COMPONENT_NAME):getPhysicsBody() + boxPhysicsBody:setVelocity(velocity) + boxPhysicsBody:setCategoryBitmask(2) -- 0010 + boxPhysicsBody:setContactTestBitmask(8) -- 1000 + boxPhysicsBody:setCollisionBitmask(1) -- 0001 + root:addChild(box) end -- yellow triangle, will collide with itself and blue box. for i = 1, layer.yellowTriangleNum do - local size = cc.size(10 + math.random()*10, 10 + math.random()*10); - local winSize = cc.size(VisibleRect:getVisibleRect().width, VisibleRect:getVisibleRect().height); - local position = cc.p(winSize.width - size.width, winSize.height - size.height); - position.x = position.x * math.random(); - position.y = position.y * math.random(); - position = cc.p(VisibleRect:leftBottom().x + position.x + size.width/2, VisibleRect:leftBottom().y + position.y + size.height/2); - local velocity = cc.p((math.random() - 0.5)*200, (math.random() - 0.5)*200); - local triangle = makeTriangle(position, size, 1, cc.PhysicsMaterial(0.1, 1, 0.0)); - triangle:getPhysicsBody():setVelocity(velocity); - triangle:getPhysicsBody():setCategoryBitmask(4); -- 0100 - triangle:getPhysicsBody():setContactTestBitmask(1); -- 0001 - triangle:getPhysicsBody():setCollisionBitmask(6); -- 0110 - root:addChild(triangle); + local size = cc.size(10 + math.random()*10, 10 + math.random()*10) + local winSize = cc.size(VisibleRect:getVisibleRect().width, + VisibleRect:getVisibleRect().height) + local position = cc.p(winSize.width - size.width, winSize.height - size.height) + position.x = position.x * math.random() + position.y = position.y * math.random() + position = cc.p(VisibleRect:leftBottom().x + position.x + size.width/2, + VisibleRect:leftBottom().y + position.y + size.height/2) + local velocity = cc.p((math.random() - 0.5)*200, (math.random() - 0.5)*200) + local triangle = makeTriangle(position, size, 1, cc.PhysicsMaterial(0.1, 1, 0.0)) + local trianglePhysicsBody = triangle:getComponent(PHYSICS_COMPONENT_NAME):getPhysicsBody() + trianglePhysicsBody:setVelocity(velocity) + trianglePhysicsBody:setCategoryBitmask(4) -- 0100 + trianglePhysicsBody:setContactTestBitmask(1) -- 0001 + trianglePhysicsBody:setCollisionBitmask(6) -- 0110 + root:addChild(triangle) end -- blue triangle, will collide with yellow box. for i = 1, layer.blueTriangleNum do - local size = cc.size(10 + math.random()*10, 10 + math.random()*10); - local winSize = cc.size(VisibleRect:getVisibleRect().width, VisibleRect:getVisibleRect().height); - local position = cc.p(winSize.width - size.width, winSize.height - size.height); - position.x = position.x * math.random(); - position.y = position.y * math.random(); - position = cc.p(VisibleRect:leftBottom().x + position.x + size.width/2, VisibleRect:leftBottom().y + position.y + size.height/2); - local velocity = cc.p((math.random() - 0.5)*200, (math.random() - 0.5)*200); - local triangle = makeTriangle(position, size, 2, cc.PhysicsMaterial(0.1, 1, 0.0)); - triangle:getPhysicsBody():setVelocity(velocity); - triangle:getPhysicsBody():setCategoryBitmask(8); -- 1000 - triangle:getPhysicsBody():setContactTestBitmask(2); -- 0010 - triangle:getPhysicsBody():setCollisionBitmask(1); -- 0001 - root:addChild(triangle); + local size = cc.size(10 + math.random()*10, 10 + math.random()*10) + local winSize = cc.size(VisibleRect:getVisibleRect().width, + VisibleRect:getVisibleRect().height) + local position = cc.p(winSize.width - size.width, winSize.height - size.height) + position.x = position.x * math.random() + position.y = position.y * math.random() + position = cc.p(VisibleRect:leftBottom().x + position.x + size.width/2, + VisibleRect:leftBottom().y + position.y + size.height/2) + local velocity = cc.p((math.random() - 0.5)*200, (math.random() - 0.5)*200) + local triangle = makeTriangle(position, size, 2, cc.PhysicsMaterial(0.1, 1, 0.0)) + local trianglePhysicsBody = triangle:getComponent(PHYSICS_COMPONENT_NAME):getPhysicsBody() + trianglePhysicsBody:setVelocity(velocity) + trianglePhysicsBody:setCategoryBitmask(8) -- 1000 + trianglePhysicsBody:setContactTestBitmask(2) -- 0010 + trianglePhysicsBody:setCollisionBitmask(1) -- 0001 + root:addChild(triangle) end end @@ -1112,93 +1300,93 @@ local function PhysicsContactTest() layer.blueTriangleNum = layer.blueTriangleNum + 50 end - resetTest(); + resetTest() end - cc.MenuItemFont:setFontSize(65); - local decrease1 = cc.MenuItemFont:create(" - "); - decrease1:setColor(cc.c3b(0,200,20)); - local increase1 = cc.MenuItemFont:create(" + "); - increase1:setColor(cc.c3b(0,200,20)); - decrease1:setTag(1); - increase1:setTag(1); - decrease1:registerScriptTapHandler(onDecrease); - increase1:registerScriptTapHandler(onIncrease); + cc.MenuItemFont:setFontSize(65) + local decrease1 = cc.MenuItemFont:create(" - ") + decrease1:setColor(cc.c3b(0,200,20)) + local increase1 = cc.MenuItemFont:create(" + ") + increase1:setColor(cc.c3b(0,200,20)) + decrease1:setTag(1) + increase1:setTag(1) + decrease1:registerScriptTapHandler(onDecrease) + increase1:registerScriptTapHandler(onIncrease) - local menu1 = cc.Menu:create(decrease1, increase1); - menu1:alignItemsHorizontally(); - menu1:setPosition(cc.p(s.width/2, s.height-50)); - layer:addChild(menu1, 1); + local menu1 = cc.Menu:create(decrease1, increase1) + menu1:alignItemsHorizontally() + menu1:setPosition(cc.p(s.width/2, s.height-50)) + layer:addChild(menu1, 1) - local label = cc.Label:createWithTTF("yellow box", s_arialPath, 32); - layer:addChild(label, 1); - label:setAnchorPoint(cc.p(0.5, 0.5)); - label:setPosition(cc.p(s.width/2 - 150, s.height-50)); + local label = cc.Label:createWithTTF("yellow box", s_arialPath, 32) + layer:addChild(label, 1) + label:setAnchorPoint(cc.p(0.5, 0.5)) + label:setPosition(cc.p(s.width/2 - 150, s.height-50)) - local decrease2 = cc.MenuItemFont:create(" - "); - decrease2:setColor(cc.c3b(0,200,20)); - local increase2 = cc.MenuItemFont:create(" + "); - increase2:setColor(cc.c3b(0,200,20)); - decrease2:setTag(2); - increase2:setTag(2); - decrease2:registerScriptTapHandler(onDecrease); - increase2:registerScriptTapHandler(onIncrease); + local decrease2 = cc.MenuItemFont:create(" - ") + decrease2:setColor(cc.c3b(0,200,20)) + local increase2 = cc.MenuItemFont:create(" + ") + increase2:setColor(cc.c3b(0,200,20)) + decrease2:setTag(2) + increase2:setTag(2) + decrease2:registerScriptTapHandler(onDecrease) + increase2:registerScriptTapHandler(onIncrease) - local menu2 = cc.Menu:create(decrease2, increase2); - menu2:alignItemsHorizontally(); - menu2:setPosition(cc.p(s.width/2, s.height-90)); - layer:addChild(menu2, 1); + local menu2 = cc.Menu:create(decrease2, increase2) + menu2:alignItemsHorizontally() + menu2:setPosition(cc.p(s.width/2, s.height-90)) + layer:addChild(menu2, 1) - label = cc.Label:createWithTTF("blue box", s_arialPath, 32); - layer:addChild(label, 1); - label:setAnchorPoint(cc.p(0.5, 0.5)); - label:setPosition(cc.p(s.width/2 - 150, s.height-90)); + label = cc.Label:createWithTTF("blue box", s_arialPath, 32) + layer:addChild(label, 1) + label:setAnchorPoint(cc.p(0.5, 0.5)) + label:setPosition(cc.p(s.width/2 - 150, s.height-90)) - local decrease3 = cc.MenuItemFont:create(" - "); - decrease3:setColor(cc.c3b(0,200,20)); - local increase3 = cc.MenuItemFont:create(" + "); - increase3:setColor(cc.c3b(0,200,20)); - decrease3:setTag(3); - increase3:setTag(3); - decrease3:registerScriptTapHandler(onDecrease); - increase3:registerScriptTapHandler(onIncrease); + local decrease3 = cc.MenuItemFont:create(" - ") + decrease3:setColor(cc.c3b(0,200,20)) + local increase3 = cc.MenuItemFont:create(" + ") + increase3:setColor(cc.c3b(0,200,20)) + decrease3:setTag(3) + increase3:setTag(3) + decrease3:registerScriptTapHandler(onDecrease) + increase3:registerScriptTapHandler(onIncrease) - local menu3 = cc.Menu:create(decrease3, increase3); - menu3:alignItemsHorizontally(); - menu3:setPosition(cc.p(s.width/2, s.height-130)); - layer:addChild(menu3, 1); + local menu3 = cc.Menu:create(decrease3, increase3) + menu3:alignItemsHorizontally() + menu3:setPosition(cc.p(s.width/2, s.height-130)) + layer:addChild(menu3, 1) - label = cc.Label:createWithTTF("yellow triangle", s_arialPath, 32); - layer:addChild(label, 1); - label:setAnchorPoint(cc.p(0.5, 0.5)); - label:setPosition(cc.p(s.width/2 - 150, s.height-130)); + label = cc.Label:createWithTTF("yellow triangle", s_arialPath, 32) + layer:addChild(label, 1) + label:setAnchorPoint(cc.p(0.5, 0.5)) + label:setPosition(cc.p(s.width/2 - 150, s.height-130)) - local decrease4 = cc.MenuItemFont:create(" - "); - decrease4:setColor(cc.c3b(0,200,20)); - local increase4 = cc.MenuItemFont:create(" + "); - increase4:setColor(cc.c3b(0,200,20)); - decrease4:setTag(4); - increase4:setTag(4); - decrease4:registerScriptTapHandler(onDecrease); - increase4:registerScriptTapHandler(onIncrease); + local decrease4 = cc.MenuItemFont:create(" - ") + decrease4:setColor(cc.c3b(0,200,20)) + local increase4 = cc.MenuItemFont:create(" + ") + increase4:setColor(cc.c3b(0,200,20)) + decrease4:setTag(4) + increase4:setTag(4) + decrease4:registerScriptTapHandler(onDecrease) + increase4:registerScriptTapHandler(onIncrease) - local menu4 = cc.Menu:create(decrease4, increase4); - menu4:alignItemsHorizontally(); - menu4:setPosition(cc.p(s.width/2, s.height-170)); - layer:addChild(menu4, 1); + local menu4 = cc.Menu:create(decrease4, increase4) + menu4:alignItemsHorizontally() + menu4:setPosition(cc.p(s.width/2, s.height-170)) + layer:addChild(menu4, 1) - label = cc.Label:createWithTTF("blue triangle", s_arialPath, 32); - layer:addChild(label, 1); - label:setAnchorPoint(cc.p(0.5, 0.5)); - label:setPosition(cc.p(s.width/2 - 150, s.height-170)); + label = cc.Label:createWithTTF("blue triangle", s_arialPath, 32) + layer:addChild(label, 1) + label:setAnchorPoint(cc.p(0.5, 0.5)) + label:setPosition(cc.p(s.width/2 - 150, s.height-170)) - local contactListener = cc.EventListenerPhysicsContact:create(); - contactListener:registerScriptHandler(onContactBegin, cc.Handler.EVENT_PHYSICS_CONTACT_BEGIN); + local contactListener = cc.EventListenerPhysicsContact:create() + contactListener:registerScriptHandler(onContactBegin, cc.Handler.EVENT_PHYSICS_CONTACT_BEGIN) local eventDispatcher = layer:getEventDispatcher() - eventDispatcher:addEventListenerWithSceneGraphPriority(contactListener, layer); + eventDispatcher:addEventListenerWithSceneGraphPriority(contactListener, layer) - resetTest(); + resetTest() end initWithLayer(layer, onEnter) @@ -1212,7 +1400,7 @@ local function PhysicsPositionRotationTest() local function onEnter() layer:toggleDebug() - cc.Director:getInstance():getRunningScene():getPhysicsWorld():setGravity(cc.p(0, 0)); + cc.Director:getInstance():getRunningScene():getPhysicsWorld():setGravity(cc.p(0, 0)) local touchListener = cc.EventListenerTouchOneByOne:create() touchListener:registerScriptHandler(onTouchBegan, cc.Handler.EVENT_TOUCH_BEGAN) @@ -1221,43 +1409,49 @@ local function PhysicsPositionRotationTest() local eventDispatcher = layer:getEventDispatcher() eventDispatcher:addEventListenerWithSceneGraphPriority(touchListener, layer) - local wall = cc.Node:create(); - wall:setPhysicsBody(cc.PhysicsBody:createEdgeBox(cc.size(VisibleRect:getVisibleRect().width, VisibleRect:getVisibleRect().height))); - wall:setPosition(VisibleRect:center()); - layer:addChild(wall); + local wall = cc.Node:create() + addPhysicsComponent(wall, + cc.PhysicsBody:createEdgeBox(VisibleRect:getVisibleRect())) + wall:setPosition(VisibleRect:center()) + layer:addChild(wall) -- anchor test - local anchorNode = cc.Sprite:create("Images/YellowSquare.png"); - anchorNode:setAnchorPoint(cc.p(0.1, 0.9)); - anchorNode:setPosition(100, 100); - anchorNode:setScale(0.25); - anchorNode:setPhysicsBody(cc.PhysicsBody:createBox(cc.size(anchorNode:getContentSize().width*anchorNode:getScale(), anchorNode:getContentSize().height*anchorNode:getScale()))); - anchorNode:getPhysicsBody():setTag(DRAG_BODYS_TAG); - layer:addChild(anchorNode); + local anchorNode = cc.Sprite:create("Images/YellowSquare.png") + anchorNode:setAnchorPoint(cc.p(0.1, 0.9)) + anchorNode:setPosition(100, 100) + anchorNode:setScale(0.25) + addPhysicsComponent(anchorNode, + cc.PhysicsBody:createBox(anchorNode:getContentSize())) + anchorNode:getComponent(PHYSICS_COMPONENT_NAME):getPhysicsBody():setTag(DRAG_BODYS_TAG) + layer:addChild(anchorNode) --parent test - local parent = cc.Sprite:create("Images/YellowSquare.png"); - parent:setPosition(200, 100); - parent:setScale(0.25); - parent:setPhysicsBody(cc.PhysicsBody:createBox(cc.size(anchorNode:getContentSize().width*anchorNode:getScale(), anchorNode:getContentSize().height*anchorNode:getScale()))); - parent:getPhysicsBody():setTag(DRAG_BODYS_TAG); - layer:addChild(parent); + local parent = cc.Sprite:create("Images/YellowSquare.png") + parent:setPosition(200, 100) + parent:setScale(0.25) + local parentPhysicsBody = cc.PhysicsBody:createBox(anchorNode:getContentSize()) + addPhysicsComponent(parent, parentPhysicsBody) + parentPhysicsBody:setTag(DRAG_BODYS_TAG) + layer:addChild(parent) - local leftBall = cc.Sprite:create("Images/ball.png"); - leftBall:setPosition(-30, 0); - leftBall:setScale(2); - leftBall:setPhysicsBody(cc.PhysicsBody:createCircle(leftBall:getContentSize().width)); - leftBall:getPhysicsBody():setTag(DRAG_BODYS_TAG); - parent:addChild(leftBall); + local leftBall = cc.Sprite:create("Images/ball.png") + leftBall:setPosition(-30, 0) + leftBall:setScale(2) + addPhysicsComponent(leftBall, cc.PhysicsBody:createCircle(leftBall:getContentSize().width / 2)) + leftBall:getComponent(PHYSICS_COMPONENT_NAME):getPhysicsBody():setTag(DRAG_BODYS_TAG) + parent:addChild(leftBall) -- offset position rotation test - local offsetPosNode = cc.Sprite:create("Images/YellowSquare.png"); - offsetPosNode:setPosition(100, 200); - offsetPosNode:setPhysicsBody(cc.PhysicsBody:createBox(cc.size(offsetPosNode:getContentSize().width/2, offsetPosNode:getContentSize().height/2))); - offsetPosNode:getPhysicsBody():setPositionOffset(cc.p(-offsetPosNode:getContentSize().width/2, -offsetPosNode:getContentSize().height/2)); - offsetPosNode:getPhysicsBody():setRotationOffset(45); - offsetPosNode:getPhysicsBody():setTag(DRAG_BODYS_TAG); - layer:addChild(offsetPosNode); + local offsetPosNode = cc.Sprite:create("Images/YellowSquare.png") + offsetPosNode:setPosition(100, 200) + local offsetPosNodePhysicsBody = cc.PhysicsBody:createBox(cc.size(offsetPosNode:getContentSize().width/2, + offsetPosNode:getContentSize().height/2)) + addPhysicsComponent(offsetPosNode, offsetPosNodePhysicsBody) + offsetPosNodePhysicsBody:setPositionOffset(cc.p(-offsetPosNode:getContentSize().width/2, + -offsetPosNode:getContentSize().height/2)) + offsetPosNodePhysicsBody:setRotationOffset(45) + offsetPosNodePhysicsBody:setTag(DRAG_BODYS_TAG) + layer:addChild(offsetPosNode) end initWithLayer(layer, onEnter) @@ -1266,6 +1460,274 @@ local function PhysicsPositionRotationTest() return layer end +local function PhysicsSetGravityEnableTest() + local layer = cc.Layer:create() + local function onEnter() + + local touchListener = cc.EventListenerTouchOneByOne:create() + touchListener:registerScriptHandler(onTouchBegan, cc.Handler.EVENT_TOUCH_BEGAN) + touchListener:registerScriptHandler(onTouchMoved, cc.Handler.EVENT_TOUCH_MOVED) + touchListener:registerScriptHandler(onTouchEnded, cc.Handler.EVENT_TOUCH_ENDED) + local eventDispatcher = layer:getEventDispatcher() + eventDispatcher:addEventListenerWithSceneGraphPriority(touchListener, layer) + + local wall = cc.Node:create() + addPhysicsComponent(wall, + cc.PhysicsBody:createEdgeBox(cc.size(VisibleRect:getVisibleRect().width, + VisibleRect:getVisibleRect().height), + cc.PhysicsMaterial(0.1, 1.0, 0.0))) + wall:setPosition(VisibleRect:center()); + layer:addChild(wall) + + local commonBox = makeBox(cc.p(100, 100), cc.size(50, 50), 1) + commonBox:getComponent(PHYSICS_COMPONENT_NAME):getPhysicsBody():setTag(DRAG_BODYS_TAG) + layer:addChild(commonBox) + + local box = makeBox(cc.p(200, 100), cc.size(50, 50), 2) + local boxBody = box:getComponent(PHYSICS_COMPONENT_NAME):getPhysicsBody() + boxBody:setMass(20) + boxBody:setTag(DRAG_BODYS_TAG) + boxBody:setGravityEnable(false) + layer:addChild(box) + + local ball = makeBall(layer,cc.p(200,200),50) + ball:setTag(2) + local ballBody = ball:getComponent(PHYSICS_COMPONENT_NAME):getPhysicsBody() + ballBody:setTag(DRAG_BODYS_TAG) + ballBody:setGravityEnable(false) + ballBody:setMass(50) + layer:addChild(ball) + + local function onScheduleOnce() + cclog("onScheduleOnce") + local ball = layer:getChildByTag(2) + ball:getComponent(PHYSICS_COMPONENT_NAME):getPhysicsBody():setMass(200) + cc.Director:getInstance():getRunningScene():getPhysicsWorld():setGravity(cc.p(0, 98)) + end + --layer:scheduleOnce(onScheduleOnce,1.0) + local action = cc.Sequence:create(cc.DelayTime:create(1.0), + cc.CallFunc:create(onScheduleOnce)) + layer:runAction(action) + end + + initWithLayer(layer, onEnter) + Helper.titleLabel:setString("Set Gravity Enable Test") + Helper.subtitleLabel:setString("only yellow box drop down") + return layer +end + +local function PhysicsDemoBug5482() + local layer = cc.Layer:create() + local function onEnter() + layer:toggleDebug() + local _bodyInA = false + + local touchListener = cc.EventListenerTouchOneByOne:create() + touchListener:registerScriptHandler(onTouchBegan, cc.Handler.EVENT_TOUCH_BEGAN) + touchListener:registerScriptHandler(onTouchMoved, cc.Handler.EVENT_TOUCH_MOVED) + touchListener:registerScriptHandler(onTouchEnded, cc.Handler.EVENT_TOUCH_ENDED) + local eventDispatcher = layer:getEventDispatcher() + eventDispatcher:addEventListenerWithSceneGraphPriority(touchListener, layer) + + -- wall + local wall = cc.Node:create() + addPhysicsComponent(wall, + cc.PhysicsBody:createEdgeBox(cc.size(VisibleRect:getVisibleRect().width, + VisibleRect:getVisibleRect().height), + cc.PhysicsMaterial(0.1, 1.0, 0.0))) + wall:setPosition(VisibleRect:center()); + layer:addChild(wall) + + local _nodeA = cc.Sprite:create("Images/YellowSquare.png") + _nodeA:setPosition(cc.p(VisibleRect:center().x-150,100)) + addPhysicsComponent(_nodeA,nil) + layer:addChild(_nodeA) + + local _nodeB = cc.Sprite:create("Images/YellowSquare.png") + _nodeB:setPosition(cc.p(VisibleRect:center().x+150,100)) + addPhysicsComponent(_nodeB,nil) + layer:addChild(_nodeB) + + local _body = cc.PhysicsBody:createBox(_nodeA:getContentSize()) + _body:setTag(DRAG_BODYS_TAG) + _body:retain() + + local function changeBodyCallback(sender) + local node = nil + if _bodyInA then + node = _nodeB + cclog("_nodeB") + else + node = _nodeA + cclog("_nodeA") + end + node:getComponent(PHYSICS_COMPONENT_NAME):setPhysicsBody(_body) + _bodyInA = not _bodyInA + end + + cc.MenuItemFont:setFontSize(18) + local _button = cc.MenuItemFont:create("Set Body To A"); + _button:registerScriptTapHandler(changeBodyCallback) + + local menu = cc.Menu:create(_button) + layer:addChild(menu) + end + + initWithLayer(layer, onEnter) + Helper.titleLabel:setString("bug 5482: setPhysicsBodyTest") + Helper.subtitleLabel:setString("change physics body to the other.") + return layer +end + +local function PhysicsDemoBug5482() + local layer = cc.Layer:create() + local function onEnter() + cc.Director:getInstance():getRunningScene():getPhysicsWorld():setDebugDrawMask(cc.PhysicsWorld.DEBUGDRAW_ALL) + cc.Director:getInstance():getRunningScene():getPhysicsWorld():setGravity(cc.p(0, 0)) + + local function addBall() + local ball = cc.Sprite:create("Images/ball.png") + ball:setPosition(cc.p(100,100)) + addPhysicsComponent(ball,cc.PhysicsBody:createCircle(ball:getContentSize().width/2, cc.PhysicsMaterial(0.1, 1, 0.0))) + ball:getComponent(PHYSICS_COMPONENT_NAME):getPhysicsBody():setTag(DRAG_BODYS_TAG) + ball:getComponent(PHYSICS_COMPONENT_NAME):getPhysicsBody():setVelocity(cc.p(1000,20)) + layer:addChild(ball) + end + + local function update(delta) + for i=1,3 do + cc.Director:getInstance():getRunningScene():getPhysicsWorld():step(1/180.0) + end + end + + local function updateStart(delta) + addBall() + cc.Director:getInstance():getRunningScene():getPhysicsWorld():setAutoStep(false) + layer:scheduleUpdateWithPriorityLua(update, 0) + end + + -- wall + local wall = cc.Node:create() + addPhysicsComponent(wall, + cc.PhysicsBody:createEdgeBox(cc.size(VisibleRect:getVisibleRect().width, + VisibleRect:getVisibleRect().height), + cc.PhysicsMaterial(0.1, 1.0, 0.0))) + wall:setPosition(VisibleRect:center()); + layer:addChild(wall) + + addBall() + layer:runAction(cc.Sequence:create(cc.DelayTime:create(2.0), + cc.CallFunc:create(updateStart))) + + end + + initWithLayer(layer, onEnter) + Helper.titleLabel:setString("Fixed Update Test") + Helper.subtitleLabel:setString("The secend ball should not run across the wall") + return layer +end + +local function PhysicsTransformTest() + local layer = cc.Layer:create() + local function onEnter() + layer:toggleDebug() + cc.Director:getInstance():getRunningScene():getPhysicsWorld():setGravity(cc.p(0,0)) + + local touchListener = cc.EventListenerTouchOneByOne:create() + touchListener:registerScriptHandler(onTouchBegan, cc.Handler.EVENT_TOUCH_BEGAN) + local eventDispatcher = layer:getEventDispatcher() + eventDispatcher:addEventListenerWithSceneGraphPriority(touchListener, layer) + + local _rootLayer = cc.Layer:create() + layer:addChild(_rootLayer) + + local wall = cc.Node:create() + addPhysicsComponent(wall, + cc.PhysicsBody:createEdgeBox(cc.size(VisibleRect:getVisibleRect().width, + VisibleRect:getVisibleRect().height), + cc.PhysicsMaterial(0.1, 1.0, 0.0))) + wall:setPosition(VisibleRect:center()); + _rootLayer:addChild(wall) + + local _parentSprite = cc.Sprite:create("Images/YellowSquare.png") + _parentSprite:setPosition(cc.p(200,100)) + _parentSprite:setScale(0.25) + addPhysicsComponent(_parentSprite,cc.PhysicsBody:createBox(_parentSprite:getContentSize(),cc.PhysicsMaterial(0.1, 1.0, 0.0))) + _parentSprite:getComponent(PHYSICS_COMPONENT_NAME):getPhysicsBody():setTag(DRAG_BODYS_TAG) + _parentSprite:setTag(1) + _rootLayer:addChild(_parentSprite) + + local leftBall = cc.Sprite:create("Images/ball.png") + leftBall:setPosition(cc.p(-30,0)) + leftBall:setScale(2) + addPhysicsComponent(leftBall,cc.PhysicsBody:createCircle(leftBall:getContentSize().width/2,cc.PhysicsMaterial(0.1,1.0,0.0))) + leftBall:getComponent(PHYSICS_COMPONENT_NAME):getPhysicsBody():setTag(DRAG_BODYS_TAG) + _parentSprite:addChild(leftBall) + + local scaleTo = cc.ScaleTo:create(2.0,0.5) + local scaleBack = cc.ScaleTo:create(2.0,1.0) + _parentSprite:runAction(cc.RepeatForever:create(cc.Sequence:create(scaleTo,scaleBack))) + + local normal = cc.Sprite:create("Images/YellowSquare.png") + normal:setPosition(cc.p(300,100)) + normal:setScale(0.25,0.5) + addPhysicsComponent(normal,cc.PhysicsBody:createBox(normal:getContentSize()),cc.PhysicsMaterial(0.1,1.0,0.0)) + normal:getComponent(PHYSICS_COMPONENT_NAME):getPhysicsBody():setTag(DRAG_BODYS_TAG) + _rootLayer:addChild(normal) + + local bullet = cc.Sprite:create("Images/ball.png") + bullet:setPosition(cc.p(200,200)) + addPhysicsComponent(bullet,cc.PhysicsBody:createCircle(bullet:getContentSize().width/2,cc.PhysicsMaterial(0.1,1.0,0.0))) + bullet:getComponent(PHYSICS_COMPONENT_NAME):getPhysicsBody():setVelocity(cc.p(100,100)) + _rootLayer:addChild(bullet) + + local move = cc.MoveBy:create(2.0,cc.p(100,100)) + local move2 = cc.MoveBy:create(2.0,cc.p(-200,0)) + local move3 = cc.MoveBy:create(2.0,cc.p(100,-100)) + local scale = cc.ScaleTo:create(3.0,0.3) + local scale2 = cc.ScaleTo:create(3.0,1.0) + local rotate = cc.RotateBy:create(6.0,360) + + _rootLayer:runAction(cc.RepeatForever:create(cc.Sequence:create(move,move2,move3))) + _rootLayer:runAction(cc.RepeatForever:create(cc.Sequence:create(scale,scale2))) + _rootLayer:runAction(cc.RepeatForever:create(cc.Sequence:create(rotate))) + end + + initWithLayer(layer, onEnter) + Helper.titleLabel:setString("Reorder issue #9959") + Helper.subtitleLabel:setString("Test Scale9Sprite run scale/move/rotation action in physics scene") + return layer +end + +local function PhysicsIssue9959() + local layer = cc.Layer:create() + local function onEnter() + local origin = cc.Director:getInstance():getVisibleOrigin() + local visibleSize = cc.Director:getInstance():getVisibleSize() + + local scale9Sprite1 = ccui.Scale9Sprite:create("Images/ball.png") + scale9Sprite1:setPosition(cc.p(origin.x+visibleSize.width/2,origin.y+visibleSize.height/2)) + layer:addChild(scale9Sprite1) + scale9Sprite1:runAction(cc.RepeatForever:create(cc.Sequence:create(cc.MoveBy:create(2.0,cc.p(100.0,0.0)), + cc.MoveBy:create(2.0,cc.p(-100,0.0))))) + + local scale9Sprite2 = ccui.Scale9Sprite:create("Images/ball.png") + scale9Sprite2:setPosition(cc.p(origin.x+visibleSize.width/2,origin.y+visibleSize.height/2+50)) + layer:addChild(scale9Sprite2) + scale9Sprite2:runAction(cc.RepeatForever:create(cc.Sequence:create(cc.ScaleTo:create(2.0,1.5), + cc.ScaleTo:create(2.0,1.0)))) + + local scale9Sprite3 = ccui.Scale9Sprite:create("Images/ball.png") + scale9Sprite3:setPosition(cc.p(origin.x+visibleSize.width/2,origin.y+visibleSize.height/2-50)) + layer:addChild(scale9Sprite3) + scale9Sprite3:runAction(cc.RepeatForever:create(cc.Sequence:create(cc.RotateBy:create(2.0,360)))) + end + + initWithLayer(layer, onEnter) + Helper.titleLabel:setString("Physics transform test") + return layer +end + function PhysicsTest() cclog("PhysicsTest") local scene = cc.Scene:createWithPhysics() @@ -1285,6 +1747,11 @@ function PhysicsTest() PhysicsDemoBug3988, PhysicsContactTest, PhysicsPositionRotationTest, + PhysicsSetGravityEnableTest, + PhysicsDemoBug5482, + PhysicsFixedUpdate, + PhysicsTransformTest, + PhysicsIssue9959 } scene:addChild(Helper.createFunctionTable[1]()) diff --git a/tools/bindings-generator b/tools/bindings-generator index 9509466075..cdbc488081 160000 --- a/tools/bindings-generator +++ b/tools/bindings-generator @@ -1 +1 @@ -Subproject commit 9509466075e038f7c93b2a8e20a394fef9a702ea +Subproject commit cdbc488081568657b5b08e7ac97970806de04e3b diff --git a/tools/cocos2d-console b/tools/cocos2d-console index 597bba8f77..eaa08cff0d 160000 --- a/tools/cocos2d-console +++ b/tools/cocos2d-console @@ -1 +1 @@ -Subproject commit 597bba8f777aaa8c40872b791594fc7f847a339e +Subproject commit eaa08cff0d6a21577ce8431a5f800e4f8fcc5e7e diff --git a/tools/simulator/frameworks/runtime-src/proj.ios_mac/mac/SimulatorApp.mm b/tools/simulator/frameworks/runtime-src/proj.ios_mac/mac/SimulatorApp.mm index 6d91ad8139..67470ca27f 100755 --- a/tools/simulator/frameworks/runtime-src/proj.ios_mac/mac/SimulatorApp.mm +++ b/tools/simulator/frameworks/runtime-src/proj.ios_mac/mac/SimulatorApp.mm @@ -204,11 +204,35 @@ static void glfwDropFunc(GLFWwindow *window, int count, const char **files) } // set project directory as search root path - FileUtils::getInstance()->setDefaultResourceRootPath(tmpConfig.getProjectDir()); - + string solutionDir = tmpConfig.getProjectDir(); + if (!solutionDir.empty()) + { + for (int i = 0; i < solutionDir.size(); ++i) + { + if (solutionDir[i] == '\\') + { + solutionDir[i] = '/'; + } + } + int nPos = -1; + if (solutionDir[solutionDir.length() - 1] == '/') + nPos = solutionDir.rfind('/', solutionDir.length() - 2); + else + nPos = solutionDir.rfind('/'); + if (nPos > 0) + solutionDir = solutionDir.substr(0, nPos + 1); + FileUtils::getInstance()->setDefaultResourceRootPath(solutionDir); + FileUtils::getInstance()->addSearchPath(solutionDir); + FileUtils::getInstance()->addSearchPath(tmpConfig.getProjectDir()); + } + else + { + FileUtils::getInstance()->setDefaultResourceRootPath(tmpConfig.getProjectDir()); + } + // parse config.json auto parser = ConfigParser::getInstance(); - auto configPath = tmpConfig.getProjectDir().append(CONFIG_FILE); + auto configPath = solutionDir.append(CONFIG_FILE); parser->readConfig(configPath); // set information diff --git a/tools/simulator/frameworks/runtime-src/proj.win32/SimulatorWin.cpp b/tools/simulator/frameworks/runtime-src/proj.win32/SimulatorWin.cpp index 16bf32bb20..45086dfe2d 100644 --- a/tools/simulator/frameworks/runtime-src/proj.win32/SimulatorWin.cpp +++ b/tools/simulator/frameworks/runtime-src/proj.win32/SimulatorWin.cpp @@ -719,11 +719,35 @@ void SimulatorWin::parseCocosProjectConfig(ProjectConfig &config) } // set project directory as search root path - FileUtils::getInstance()->setDefaultResourceRootPath(tmpConfig.getProjectDir().c_str()); + string solutionDir = tmpConfig.getProjectDir(); + if (!solutionDir.empty()) + { + for (int i = 0; i < solutionDir.size(); ++i) + { + if (solutionDir[i] == '\\') + { + solutionDir[i] = '/'; + } + } + int nPos = -1; + if (solutionDir[solutionDir.length() - 1] == '/') + nPos = solutionDir.rfind('/', solutionDir.length() - 2); + else + nPos = solutionDir.rfind('/'); + if (nPos > 0) + solutionDir = solutionDir.substr(0, nPos + 1); + FileUtils::getInstance()->setDefaultResourceRootPath(solutionDir); + FileUtils::getInstance()->addSearchPath(solutionDir); + FileUtils::getInstance()->addSearchPath(tmpConfig.getProjectDir().c_str()); + } + else + { + FileUtils::getInstance()->setDefaultResourceRootPath(tmpConfig.getProjectDir().c_str()); + } // parse config.json auto parser = ConfigParser::getInstance(); - auto configPath = tmpConfig.getProjectDir().append(CONFIG_FILE); + auto configPath = solutionDir.append(CONFIG_FILE); parser->readConfig(configPath); // set information diff --git a/tools/simulator/frameworks/runtime-src/proj.win32/game.rc b/tools/simulator/frameworks/runtime-src/proj.win32/game.rc index ee1ca41456..4733633d7b 100755 --- a/tools/simulator/frameworks/runtime-src/proj.win32/game.rc +++ b/tools/simulator/frameworks/runtime-src/proj.win32/game.rc @@ -64,7 +64,7 @@ STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSM CAPTION "About Simulator" FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN - CTEXT "Version 3.7 (20150227)",IDC_ABOUT_VERSION,35,70,173,17 + CTEXT "Version 3.8 (20150227)",IDC_ABOUT_VERSION,35,70,173,17 CTEXT "Cocos Simulator",IDC_ABOUT_TITLE,35,49,173,17 CTEXT "Copyright (C) 2015. All rights reserved.",IDC_STATIC,35,94,173,17 ICON "GLFW_ICON",IDC_STATIC,111,15,20,20 diff --git a/tools/tojs/cocos2dx.ini b/tools/tojs/cocos2dx.ini index 612e9e6aa8..c1500ee27a 100644 --- a/tools/tojs/cocos2dx.ini +++ b/tools/tojs/cocos2dx.ini @@ -29,7 +29,7 @@ headers = %(cocosdir)s/cocos/cocos2d.h %(cocosdir)s/cocos/audio/include/SimpleAu classes = New.* Sprite SpriteBatchNode SpriteFrame SpriteFrameCache Scene Node.* Director Layer.* Menu.* Touch .*Action.* Move.* Rotate.* Blink.* Tint.* Sequence Repeat.* Fade.* Ease.* Scale.* Transition.* Spawn ReverseTime Animate AnimationFrame Animation AnimationCache Flip.* Delay.* Skew.* Jump.* Place.* Show.* Progress.* PointArray ToggleVisibility.* RemoveSelf Hide Particle.* Label.* Atlas.* TextureCache.* Texture2D Cardinal.* CatmullRom.* ParallaxNode TileMap.* TMX.* CallFunc CallFuncN RenderTexture GridAction Grid3DAction Grid3D TiledGrid3D GridBase$ .+Grid Shaky3D Waves3D FlipX3D FlipY3D Lens3D Ripple3D PageTurn3D ShakyTiles3D ShatteredTiles3D WavesTiles3D JumpTiles3D Speed ActionManager Set SimpleAudioEngine Scheduler Orbit.* Follow.* Bezier.* CardinalSpline.* Camera.* DrawNode Liquid$ Waves$ ShuffleTiles$ TurnOffTiles$ Split.* Twirl$ FileUtils$ GLProgram GLProgramCache Application ClippingNode MotionStreak TextFieldTTF GLViewProtocol GLView Component ComponentContainer __NodeRGBA __LayerRGBA SAXParser Event(?!.*(Physics).*).* Device Configuration ProtectedNode GLProgramState Image .*Light$ AsyncTaskPool Properties Material Technique RenderState Pass -classes_need_extend = Node __NodeRGBA Layer.* Sprite SpriteBatchNode SpriteFrame Menu MenuItem.* Scene DrawNode Component .*Action.* GridBase Grid3D TiledGrid3D MotionStreak ParticleBatchNode ParticleSystem TextFieldTTF RenderTexture TileMapAtlas TMXLayer TMXTiledMap TMXMapInfo TransitionScene ProgressTimer ParallaxNode Label.* GLProgram +classes_need_extend = Node __NodeRGBA Layer.* Sprite SpriteBatchNode SpriteFrame Menu MenuItem.* Scene DrawNode Component .*Action.* GridBase Grid3D TiledGrid3D MotionStreak ParticleBatchNode ParticleSystem TextFieldTTF RenderTexture TileMapAtlas TMXLayer TMXTiledMap TMXMapInfo TransitionScene ProgressTimer ParallaxNode Label.* GLProgram Move.* Rotate.* Blink.* Tint.* Sequence Repeat.* Fade.* Ease.* Scale.* Transition.* Spawn ReverseTime Animate AnimationFrame Animation AnimationCache Flip.* Delay.* Skew.* Jump.* Place.* Show.* Progress.* Orbit.* Follow.* Bezier.* Hide CallFunc CallFuncN # what should we skip? in the format ClassName::[function function] # ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also diff --git a/tools/tolua/cocos2dx_physics.ini b/tools/tolua/cocos2dx_physics.ini index 6a763b9d9d..ef1bede544 100644 --- a/tools/tolua/cocos2dx_physics.ini +++ b/tools/tolua/cocos2dx_physics.ini @@ -29,7 +29,7 @@ headers = %(cocosdir)s/cocos/cocos2d.h # what classes to produce code for. You can use regular expressions here. When testing the regular # expression, it will be enclosed in "^$", like this: "^Menu*$". -classes = Event(.*(Physics).*) Physics.* +classes = Event(.*(Physics).*) Physics.* ComponentPhysics2d # what should we skip? in the format ClassName::[function function] # ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also @@ -46,7 +46,9 @@ skip = PhysicsBody::[getJoints createPolygon createEdgeChain createEdgePolygon], PhysicsShapeEdgePolygon::[create ^getPoints$], PhysicsShapeEdgeChain::[create ^getPoints$], PhysicsWorld::[getScene queryPoint queryRect rayCast], - PhysicsContact::[getData setData] + PhysicsContact::[getData setData], + PhysicsManager::[PhysicsManager update], + ComponentPhysics2d::[beforeSimulation afterSimulation] rename_functions = diff --git a/web b/web index 31263de3f6..64c6935933 160000 --- a/web +++ b/web @@ -1 +1 @@ -Subproject commit 31263de3f661cdf42760884f162c56af0824ed0d +Subproject commit 64c6935933ce468aaadcfa9d2b30de3fe1b7550d