From 19c96632b556461d0e3ef90bad55307b5839bb35 Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 29 May 2012 16:21:23 +0800 Subject: [PATCH] fixed #1176: Changed linebreak symbol to UNIX format ('\n'),replaced 'tab' with four spaces. --- Box2D/Android.mk | 120 ++-- CocosDenshion/android/Android.mk | 38 +- HelloLua/Classes/AppDelegate.cpp | 12 +- HelloLua/proj.android/jni/Android.mk | 46 +- HelloLua/proj.android/jni/Application.mk | 4 +- HelloLua/proj.android/jni/helloworld/main.cpp | 4 +- HelloWorld/proj.android/jni/Android.mk | 40 +- HelloWorld/proj.android/jni/Application.mk | 2 +- chipmunk/Android.mk | 90 +-- cocos2dx/Android.mk | 438 ++++++------ cocos2dx/extensions/CCBReader/CCBReader.h | 4 +- .../extensions/CCBReader/CCBReader_v1.cpp | 192 +++--- .../extensions/CCBReader/CCBReader_v2.cpp | 190 +++--- cocos2dx/platform/CCImageCommon_cpp.h | 118 ++-- js/JSBindings/ScriptingCore.cpp | 456 ++++++------- js/JSBindings/ScriptingCore.h | 222 +++--- js/JSBindings/cocos2d_manual_bindings.cpp | 646 +++++++++--------- .../LuaCocos2d.cpp.REMOVED.git-id | 2 +- lua/proj.android/jni/Android.mk | 74 +- .../Templates/1033/Classes/AppDelegate.cpp | 174 ++--- .../Templates/1033/Classes/AppDelegate.h | 76 +-- .../1033/Classes/HelloWorldScene.cpp | 194 +++--- .../Templates/1033/Classes/HelloWorldScene.h | 66 +- .../Templates/1033/proj.win32/main.cpp | 80 +-- .../Templates/1033/proj.win32/main.h | 26 +- .../Templates/1033/proj.win32/resource.h | 44 +- .../Classes/AppDelegate.cpp | 12 +- testjs/Classes/AppDelegate.cpp | 170 ++--- testjs/Classes/AppDelegate.h | 94 +-- testjs/Classes/simple_class.cpp | 28 +- testjs/Classes/simple_class.h | 74 +- testjs/proj.android/jni/Android.mk | 38 +- testjs/proj.android/jni/Application.mk | 2 +- testjs/proj.ios/AppController.h | 2 +- testjs/proj.ios/AppController.mm | 4 +- testjs/proj.ios/RootViewController.mm | 4 +- testjs/proj.win32/main.cpp | 80 +-- testjs/proj.win32/main.h | 26 +- testjs/proj.win32/resource.h | 40 +- tests/proj.android/jni/Android.mk | 52 +- tests/proj.android/jni/Application.mk | 4 +- .../CocosBuilderTest/CocosBuilderTest.cpp | 2 +- .../template/android/jni/Android.mk | 22 +- .../template/android/jni/Application.mk | 4 +- .../android/jni/LuaProjectTemplate/Android.mk | 62 +- .../android/jni/LuaProjectTemplate/main.cpp | 2 +- 46 files changed, 2040 insertions(+), 2040 deletions(-) diff --git a/Box2D/Android.mk b/Box2D/Android.mk index fe3faa08bf..e289b24bee 100644 --- a/Box2D/Android.mk +++ b/Box2D/Android.mk @@ -1,60 +1,60 @@ -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := box2d_static - -LOCAL_MODULE_FILENAME := libbox2d - -LOCAL_SRC_FILES := \ -Collision/Shapes/b2ChainShape.cpp \ -Collision/Shapes/b2CircleShape.cpp \ -Collision/Shapes/b2EdgeShape.cpp \ -Collision/Shapes/b2PolygonShape.cpp \ -Collision/b2BroadPhase.cpp \ -Collision/b2CollideCircle.cpp \ -Collision/b2CollideEdge.cpp \ -Collision/b2CollidePolygon.cpp \ -Collision/b2Collision.cpp \ -Collision/b2Distance.cpp \ -Collision/b2DynamicTree.cpp \ -Collision/b2TimeOfImpact.cpp \ -Common/b2BlockAllocator.cpp \ -Common/b2Draw.cpp \ -Common/b2Math.cpp \ -Common/b2Settings.cpp \ -Common/b2StackAllocator.cpp \ -Common/b2Timer.cpp \ -Dynamics/Contacts/b2ChainAndCircleContact.cpp \ -Dynamics/Contacts/b2ChainAndPolygonContact.cpp \ -Dynamics/Contacts/b2CircleContact.cpp \ -Dynamics/Contacts/b2Contact.cpp \ -Dynamics/Contacts/b2ContactSolver.cpp \ -Dynamics/Contacts/b2EdgeAndCircleContact.cpp \ -Dynamics/Contacts/b2EdgeAndPolygonContact.cpp \ -Dynamics/Contacts/b2PolygonAndCircleContact.cpp \ -Dynamics/Contacts/b2PolygonContact.cpp \ -Dynamics/Joints/b2DistanceJoint.cpp \ -Dynamics/Joints/b2FrictionJoint.cpp \ -Dynamics/Joints/b2GearJoint.cpp \ -Dynamics/Joints/b2Joint.cpp \ -Dynamics/Joints/b2MouseJoint.cpp \ -Dynamics/Joints/b2PrismaticJoint.cpp \ -Dynamics/Joints/b2PulleyJoint.cpp \ -Dynamics/Joints/b2RevoluteJoint.cpp \ -Dynamics/Joints/b2RopeJoint.cpp \ -Dynamics/Joints/b2WeldJoint.cpp \ -Dynamics/Joints/b2WheelJoint.cpp \ -Dynamics/b2Body.cpp \ -Dynamics/b2ContactManager.cpp \ -Dynamics/b2Fixture.cpp \ -Dynamics/b2Island.cpp \ -Dynamics/b2World.cpp \ -Dynamics/b2WorldCallbacks.cpp \ -Rope/b2Rope.cpp - -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/.. - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/.. - -include $(BUILD_STATIC_LIBRARY) +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) + +LOCAL_MODULE := box2d_static + +LOCAL_MODULE_FILENAME := libbox2d + +LOCAL_SRC_FILES := \ +Collision/Shapes/b2ChainShape.cpp \ +Collision/Shapes/b2CircleShape.cpp \ +Collision/Shapes/b2EdgeShape.cpp \ +Collision/Shapes/b2PolygonShape.cpp \ +Collision/b2BroadPhase.cpp \ +Collision/b2CollideCircle.cpp \ +Collision/b2CollideEdge.cpp \ +Collision/b2CollidePolygon.cpp \ +Collision/b2Collision.cpp \ +Collision/b2Distance.cpp \ +Collision/b2DynamicTree.cpp \ +Collision/b2TimeOfImpact.cpp \ +Common/b2BlockAllocator.cpp \ +Common/b2Draw.cpp \ +Common/b2Math.cpp \ +Common/b2Settings.cpp \ +Common/b2StackAllocator.cpp \ +Common/b2Timer.cpp \ +Dynamics/Contacts/b2ChainAndCircleContact.cpp \ +Dynamics/Contacts/b2ChainAndPolygonContact.cpp \ +Dynamics/Contacts/b2CircleContact.cpp \ +Dynamics/Contacts/b2Contact.cpp \ +Dynamics/Contacts/b2ContactSolver.cpp \ +Dynamics/Contacts/b2EdgeAndCircleContact.cpp \ +Dynamics/Contacts/b2EdgeAndPolygonContact.cpp \ +Dynamics/Contacts/b2PolygonAndCircleContact.cpp \ +Dynamics/Contacts/b2PolygonContact.cpp \ +Dynamics/Joints/b2DistanceJoint.cpp \ +Dynamics/Joints/b2FrictionJoint.cpp \ +Dynamics/Joints/b2GearJoint.cpp \ +Dynamics/Joints/b2Joint.cpp \ +Dynamics/Joints/b2MouseJoint.cpp \ +Dynamics/Joints/b2PrismaticJoint.cpp \ +Dynamics/Joints/b2PulleyJoint.cpp \ +Dynamics/Joints/b2RevoluteJoint.cpp \ +Dynamics/Joints/b2RopeJoint.cpp \ +Dynamics/Joints/b2WeldJoint.cpp \ +Dynamics/Joints/b2WheelJoint.cpp \ +Dynamics/b2Body.cpp \ +Dynamics/b2ContactManager.cpp \ +Dynamics/b2Fixture.cpp \ +Dynamics/b2Island.cpp \ +Dynamics/b2World.cpp \ +Dynamics/b2WorldCallbacks.cpp \ +Rope/b2Rope.cpp + +LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/.. + +LOCAL_C_INCLUDES := $(LOCAL_PATH)/.. + +include $(BUILD_STATIC_LIBRARY) diff --git a/CocosDenshion/android/Android.mk b/CocosDenshion/android/Android.mk index 0b6649e1e7..7e0c5b48f1 100644 --- a/CocosDenshion/android/Android.mk +++ b/CocosDenshion/android/Android.mk @@ -1,21 +1,21 @@ -LOCAL_PATH := $(call my-dir) -include $(CLEAR_VARS) - -LOCAL_MODULE := cocosdenshion_static - -LOCAL_MODULE_FILENAME := libcocosdenshion - -LOCAL_SRC_FILES := SimpleAudioEngine.cpp \ -jni/SimpleAudioEngineJni.cpp - -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../include - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/../include \ - $(LOCAL_PATH)/../../cocos2dx/include \ +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_MODULE := cocosdenshion_static + +LOCAL_MODULE_FILENAME := libcocosdenshion + +LOCAL_SRC_FILES := SimpleAudioEngine.cpp \ +jni/SimpleAudioEngineJni.cpp + +LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../include + +LOCAL_C_INCLUDES := $(LOCAL_PATH)/../include \ + $(LOCAL_PATH)/../../cocos2dx/include \ $(LOCAL_PATH)/../../cocos2dx/platform \ - $(LOCAL_PATH)/../../cocos2dx/platform/android \ - $(LOCAL_PATH)/../../cocos2dx/platform/android/jni - -LOCAL_LDLIBS := -llog - + $(LOCAL_PATH)/../../cocos2dx/platform/android \ + $(LOCAL_PATH)/../../cocos2dx/platform/android/jni + +LOCAL_LDLIBS := -llog + include $(BUILD_STATIC_LIBRARY) diff --git a/HelloLua/Classes/AppDelegate.cpp b/HelloLua/Classes/AppDelegate.cpp index 3fa9228bd9..6201bf0da8 100644 --- a/HelloLua/Classes/AppDelegate.cpp +++ b/HelloLua/Classes/AppDelegate.cpp @@ -41,12 +41,12 @@ bool AppDelegate::applicationDidFinishLaunching() CCScriptEngineProtocol* pEngine = CCLuaEngine::engine(); CCScriptEngineManager::sharedManager()->setScriptEngine(pEngine); -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) - CCString* pstrFileContent = CCString::stringWithContentsOfFile("hello.lua"); - if (pstrFileContent) - { - pEngine->executeString(pstrFileContent->getCString()); - } +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) + CCString* pstrFileContent = CCString::stringWithContentsOfFile("hello.lua"); + if (pstrFileContent) + { + pEngine->executeString(pstrFileContent->getCString()); + } #else std::string path = CCFileUtils::fullPathFromRelativePath("hello.lua"); pEngine->addSearchPath(path.substr(0, path.find_last_of("/")).c_str()); diff --git a/HelloLua/proj.android/jni/Android.mk b/HelloLua/proj.android/jni/Android.mk index 7144854a1b..a8417a9224 100644 --- a/HelloLua/proj.android/jni/Android.mk +++ b/HelloLua/proj.android/jni/Android.mk @@ -1,26 +1,26 @@ -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := game_shared - -LOCAL_MODULE_FILENAME := libgame - -LOCAL_SRC_FILES := helloworld/main.cpp \ - ../../Classes/AppDelegate.cpp \ - ../../../lua/cocos2dx_support/CCLuaEngine.cpp \ - ../../../lua/cocos2dx_support/Cocos2dxLuaLoader.cpp \ - ../../../lua/cocos2dx_support/LuaCocos2d.cpp \ - ../../../lua/cocos2dx_support/tolua_fix.c - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes - +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) + +LOCAL_MODULE := game_shared + +LOCAL_MODULE_FILENAME := libgame + +LOCAL_SRC_FILES := helloworld/main.cpp \ + ../../Classes/AppDelegate.cpp \ + ../../../lua/cocos2dx_support/CCLuaEngine.cpp \ + ../../../lua/cocos2dx_support/Cocos2dxLuaLoader.cpp \ + ../../../lua/cocos2dx_support/LuaCocos2d.cpp \ + ../../../lua/cocos2dx_support/tolua_fix.c + +LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes + LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static LOCAL_WHOLE_STATIC_LIBRARIES += cocosdenshion_static LOCAL_WHOLE_STATIC_LIBRARIES += cocos_lua_static - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,cocos2dx) -$(call import-module,CocosDenshion/android) -$(call import-module,lua/proj.android/jni) + +include $(BUILD_SHARED_LIBRARY) + +$(call import-module,cocos2dx) +$(call import-module,CocosDenshion/android) +$(call import-module,lua/proj.android/jni) diff --git a/HelloLua/proj.android/jni/Application.mk b/HelloLua/proj.android/jni/Application.mk index cb24aada5f..f5e25d70ef 100644 --- a/HelloLua/proj.android/jni/Application.mk +++ b/HelloLua/proj.android/jni/Application.mk @@ -1,3 +1,3 @@ APP_STL := gnustl_static -APP_CPPFLAGS := -frtti -APP_CPPFLAGS += -fexceptions +APP_CPPFLAGS := -frtti +APP_CPPFLAGS += -fexceptions diff --git a/HelloLua/proj.android/jni/helloworld/main.cpp b/HelloLua/proj.android/jni/helloworld/main.cpp index 39957ab36c..e4d222db90 100644 --- a/HelloLua/proj.android/jni/helloworld/main.cpp +++ b/HelloLua/proj.android/jni/helloworld/main.cpp @@ -34,8 +34,8 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi } else { - ccDrawInit(); - ccGLInvalidateStateCache(); + ccDrawInit(); + ccGLInvalidateStateCache(); CCShaderCache::sharedShaderCache()->reloadDefaultShaders(); CCTextureCache::reloadAllTextures(); diff --git a/HelloWorld/proj.android/jni/Android.mk b/HelloWorld/proj.android/jni/Android.mk index aedf61112c..a14b4fa135 100644 --- a/HelloWorld/proj.android/jni/Android.mk +++ b/HelloWorld/proj.android/jni/Android.mk @@ -1,20 +1,20 @@ -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := helloworld_shared - -LOCAL_MODULE_FILENAME := libhelloworld - -LOCAL_SRC_FILES := helloworld/main.cpp \ - ../../Classes/AppDelegate.cpp \ - ../../Classes/HelloWorldScene.cpp - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes - -LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,cocos2dx) - +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) + +LOCAL_MODULE := helloworld_shared + +LOCAL_MODULE_FILENAME := libhelloworld + +LOCAL_SRC_FILES := helloworld/main.cpp \ + ../../Classes/AppDelegate.cpp \ + ../../Classes/HelloWorldScene.cpp + +LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes + +LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static + +include $(BUILD_SHARED_LIBRARY) + +$(call import-module,cocos2dx) + diff --git a/HelloWorld/proj.android/jni/Application.mk b/HelloWorld/proj.android/jni/Application.mk index 0ba4ae3a9c..22d424dab7 100644 --- a/HelloWorld/proj.android/jni/Application.mk +++ b/HelloWorld/proj.android/jni/Application.mk @@ -1,2 +1,2 @@ -APP_STL := gnustl_static +APP_STL := gnustl_static APP_CPPFLAGS := -frtti \ No newline at end of file diff --git a/chipmunk/Android.mk b/chipmunk/Android.mk index 771d02dfc5..bf22594183 100644 --- a/chipmunk/Android.mk +++ b/chipmunk/Android.mk @@ -1,45 +1,45 @@ -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := chipmunk_static - -LOCAL_MODULE_FILENAME := libchipmunk - -LOCAL_SRC_FILES := \ -src/chipmunk.c \ -src/constraints/cpConstraint.c \ -src/constraints/cpDampedRotarySpring.c \ -src/constraints/cpDampedSpring.c \ -src/constraints/cpGearJoint.c \ -src/constraints/cpGrooveJoint.c \ -src/constraints/cpPinJoint.c \ -src/constraints/cpPivotJoint.c \ -src/constraints/cpRatchetJoint.c \ -src/constraints/cpRotaryLimitJoint.c \ -src/constraints/cpSimpleMotor.c \ -src/constraints/cpSlideJoint.c \ -src/cpArbiter.c \ -src/cpArray.c \ -src/cpBB.c \ -src/cpBBTree.c \ -src/cpBody.c \ -src/cpCollision.c \ -src/cpHashSet.c \ -src/cpPolyShape.c \ -src/cpShape.c \ -src/cpSpace.c \ -src/cpSpaceComponent.c \ -src/cpSpaceHash.c \ -src/cpSpaceQuery.c \ -src/cpSpaceStep.c \ -src/cpSpatialIndex.c \ -src/cpSweep1D.c \ -src/cpVect.c - -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include/chipmunk - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/include/chipmunk -LOCAL_CFLAGS := -std=c99 - -include $(BUILD_STATIC_LIBRARY) +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) + +LOCAL_MODULE := chipmunk_static + +LOCAL_MODULE_FILENAME := libchipmunk + +LOCAL_SRC_FILES := \ +src/chipmunk.c \ +src/constraints/cpConstraint.c \ +src/constraints/cpDampedRotarySpring.c \ +src/constraints/cpDampedSpring.c \ +src/constraints/cpGearJoint.c \ +src/constraints/cpGrooveJoint.c \ +src/constraints/cpPinJoint.c \ +src/constraints/cpPivotJoint.c \ +src/constraints/cpRatchetJoint.c \ +src/constraints/cpRotaryLimitJoint.c \ +src/constraints/cpSimpleMotor.c \ +src/constraints/cpSlideJoint.c \ +src/cpArbiter.c \ +src/cpArray.c \ +src/cpBB.c \ +src/cpBBTree.c \ +src/cpBody.c \ +src/cpCollision.c \ +src/cpHashSet.c \ +src/cpPolyShape.c \ +src/cpShape.c \ +src/cpSpace.c \ +src/cpSpaceComponent.c \ +src/cpSpaceHash.c \ +src/cpSpaceQuery.c \ +src/cpSpaceStep.c \ +src/cpSpatialIndex.c \ +src/cpSweep1D.c \ +src/cpVect.c + +LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include/chipmunk + +LOCAL_C_INCLUDES := $(LOCAL_PATH)/include/chipmunk +LOCAL_CFLAGS := -std=c99 + +include $(BUILD_STATIC_LIBRARY) diff --git a/cocos2dx/Android.mk b/cocos2dx/Android.mk index 5c8db2a0ba..f73df4fca2 100644 --- a/cocos2dx/Android.mk +++ b/cocos2dx/Android.mk @@ -1,222 +1,222 @@ -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := cocos2dx_static - -LOCAL_MODULE_FILENAME := libcocos2d - -LOCAL_SRC_FILES := \ -CCConfiguration.cpp \ -CCDrawingPrimitives.cpp \ -CCScheduler.cpp \ -CCCamera.cpp \ -actions/CCAction.cpp \ -actions/CCActionCamera.cpp \ -actions/CCActionEase.cpp \ -actions/CCActionGrid.cpp \ -actions/CCActionGrid3D.cpp \ -actions/CCActionInstant.cpp \ -actions/CCActionInterval.cpp \ -actions/CCActionManager.cpp \ -actions/CCActionPageTurn3D.cpp \ -actions/CCActionProgressTimer.cpp \ -actions/CCActionTiledGrid.cpp \ -actions/CCActionTween.cpp \ -base_nodes/CCAtlasNode.cpp \ -base_nodes/CCNode.cpp \ -cocoa/CCAffineTransform.cpp \ -cocoa/CCGeometry.cpp \ -cocoa/CCAutoreleasePool.cpp \ -cocoa/CCData.cpp \ -cocoa/CCDictionary.cpp \ -cocoa/CCNS.cpp \ -cocoa/CCObject.cpp \ -cocoa/CCSet.cpp \ -cocoa/CCString.cpp \ -cocoa/CCZone.cpp \ -cocoa/CCArray.cpp \ -cocos2d.cpp \ -CCDirector.cpp \ -effects/CCGrabber.cpp \ -effects/CCGrid.cpp \ -extensions/CCNotificationCenter/CCNotificationCenter.cpp \ -extensions/CCControlExtension/CCControl.cpp \ -extensions/CCControlExtension/CCControlButton.cpp \ -extensions/CCControlExtension/CCControlColourPicker.cpp \ -extensions/CCControlExtension/CCControlHuePicker.cpp \ -extensions/CCControlExtension/CCControlSaturationBrightnessPicker.cpp \ -extensions/CCControlExtension/CCControlSlider.cpp \ -extensions/CCControlExtension/CCControlSwitch.cpp \ -extensions/CCControlExtension/CCControlUtils.cpp \ -extensions/CCControlExtension/CCInvocation.cpp \ -extensions/CCControlExtension/CCMenuPassive.cpp \ -extensions/CCControlExtension/CCScale9Sprite.cpp \ -extensions/CCControlExtension/CCSpacer.cpp \ -extensions/CCListView/CCListView.cpp \ -extensions/CCListView/CCListViewCell.cpp \ +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) + +LOCAL_MODULE := cocos2dx_static + +LOCAL_MODULE_FILENAME := libcocos2d + +LOCAL_SRC_FILES := \ +CCConfiguration.cpp \ +CCDrawingPrimitives.cpp \ +CCScheduler.cpp \ +CCCamera.cpp \ +actions/CCAction.cpp \ +actions/CCActionCamera.cpp \ +actions/CCActionEase.cpp \ +actions/CCActionGrid.cpp \ +actions/CCActionGrid3D.cpp \ +actions/CCActionInstant.cpp \ +actions/CCActionInterval.cpp \ +actions/CCActionManager.cpp \ +actions/CCActionPageTurn3D.cpp \ +actions/CCActionProgressTimer.cpp \ +actions/CCActionTiledGrid.cpp \ +actions/CCActionTween.cpp \ +base_nodes/CCAtlasNode.cpp \ +base_nodes/CCNode.cpp \ +cocoa/CCAffineTransform.cpp \ +cocoa/CCGeometry.cpp \ +cocoa/CCAutoreleasePool.cpp \ +cocoa/CCData.cpp \ +cocoa/CCDictionary.cpp \ +cocoa/CCNS.cpp \ +cocoa/CCObject.cpp \ +cocoa/CCSet.cpp \ +cocoa/CCString.cpp \ +cocoa/CCZone.cpp \ +cocoa/CCArray.cpp \ +cocos2d.cpp \ +CCDirector.cpp \ +effects/CCGrabber.cpp \ +effects/CCGrid.cpp \ +extensions/CCNotificationCenter/CCNotificationCenter.cpp \ +extensions/CCControlExtension/CCControl.cpp \ +extensions/CCControlExtension/CCControlButton.cpp \ +extensions/CCControlExtension/CCControlColourPicker.cpp \ +extensions/CCControlExtension/CCControlHuePicker.cpp \ +extensions/CCControlExtension/CCControlSaturationBrightnessPicker.cpp \ +extensions/CCControlExtension/CCControlSlider.cpp \ +extensions/CCControlExtension/CCControlSwitch.cpp \ +extensions/CCControlExtension/CCControlUtils.cpp \ +extensions/CCControlExtension/CCInvocation.cpp \ +extensions/CCControlExtension/CCMenuPassive.cpp \ +extensions/CCControlExtension/CCScale9Sprite.cpp \ +extensions/CCControlExtension/CCSpacer.cpp \ +extensions/CCListView/CCListView.cpp \ +extensions/CCListView/CCListViewCell.cpp \ extensions/CCTextureWatcher/CCTextureWatcher.cpp \ extensions/CCBReader/CCBCustomClass.cpp \ -extensions/CCBReader/CCBReader_v2.cpp \ -kazmath/src/aabb.c \ -kazmath/src/mat3.c \ -kazmath/src/mat4.c \ -kazmath/src/neon_matrix_impl.c \ -kazmath/src/plane.c \ -kazmath/src/quaternion.c \ -kazmath/src/ray2.c \ -kazmath/src/utility.c \ -kazmath/src/vec2.c \ -kazmath/src/vec3.c \ -kazmath/src/vec4.c \ -kazmath/src/GL/mat4stack.c \ -kazmath/src/GL/matrix.c \ -keypad_dispatcher/CCKeypadDelegate.cpp \ -keypad_dispatcher/CCKeypadDispatcher.cpp \ -label_nodes/CCLabelAtlas.cpp \ -label_nodes/CCLabelBMFont.cpp \ -label_nodes/CCLabelTTF.cpp \ -layers_scenes_transitions_nodes/CCLayer.cpp \ -layers_scenes_transitions_nodes/CCScene.cpp \ -layers_scenes_transitions_nodes/CCTransitionPageTurn.cpp \ -layers_scenes_transitions_nodes/CCTransition.cpp \ -layers_scenes_transitions_nodes/CCTransitionProgress.cpp \ -menu_nodes/CCMenu.cpp \ -menu_nodes/CCMenuItem.cpp \ -misc_nodes/CCMotionStreak.cpp \ -misc_nodes/CCProgressTimer.cpp \ -misc_nodes/CCRenderTexture.cpp \ -particle_nodes/CCParticleExamples.cpp \ -particle_nodes/CCParticleSystem.cpp \ -particle_nodes/CCParticleBatchNode.cpp \ -particle_nodes/CCParticleSystemQuad.cpp \ -platform/CCSAXParser.cpp \ -platform/CCThread.cpp \ -platform/platform.cpp \ -platform/CCEGLViewProtocol.cpp \ -platform/android/CCEGLView.cpp \ -platform/android/CCAccelerometer.cpp \ -platform/android/CCApplication.cpp \ -platform/android/CCCommon.cpp \ -platform/android/CCFileUtils.cpp \ -platform/android/CCImage.cpp \ -platform/android/jni/JniHelper.cpp \ -platform/android/jni/IMEJni.cpp \ -platform/android/jni/MessageJni.cpp \ -platform/android/jni/SensorJni.cpp \ -platform/android/jni/SystemInfoJni.cpp \ -platform/android/jni/TouchesJni.cpp \ -script_support/CCScriptSupport.cpp \ -shaders/ccShaders.cpp \ -shaders/CCGLProgram.cpp \ -shaders/ccGLStateCache.cpp \ -shaders/CCShaderCache.cpp \ -sprite_nodes/CCAnimation.cpp \ -sprite_nodes/CCAnimationCache.cpp \ -sprite_nodes/CCSprite.cpp \ -sprite_nodes/CCSpriteBatchNode.cpp \ -sprite_nodes/CCSpriteFrame.cpp \ -sprite_nodes/CCSpriteFrameCache.cpp \ -support/CCProfiling.cpp \ -support/CCPointExtension.cpp \ -support/TransformUtils.cpp \ -support/CCUserDefault.cpp \ -support/base64.cpp \ -support/ccUtils.cpp \ -support/CCVertex.cpp \ -support/image_support/TGAlib.cpp \ -support/zip_support/ZipUtils.cpp \ -support/zip_support/ioapi.cpp \ -support/zip_support/unzip.cpp \ -text_input_node/CCIMEDispatcher.cpp \ -text_input_node/CCTextFieldTTF.cpp \ -textures/CCTexture2D.cpp \ -textures/CCTextureAtlas.cpp \ -textures/CCTextureCache.cpp \ -textures/CCTexturePVR.cpp \ -tileMap_parallax_nodes/CCParallaxNode.cpp \ -tileMap_parallax_nodes/CCTMXLayer.cpp \ -tileMap_parallax_nodes/CCTMXObjectGroup.cpp \ -tileMap_parallax_nodes/CCTMXTiledMap.cpp \ -tileMap_parallax_nodes/CCTMXXMLParser.cpp \ -tileMap_parallax_nodes/CCTileMapAtlas.cpp \ -touch_dispatcher/CCTouchDispatcher.cpp \ -touch_dispatcher/CCTouchHandler.cpp - -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/ \ - $(LOCAL_PATH)/actions \ - $(LOCAL_PATH)/base_nodes \ - $(LOCAL_PATH)/cocoa \ - $(LOCAL_PATH)/effects \ - $(LOCAL_PATH)/extensions \ - $(LOCAL_PATH)/include \ - $(LOCAL_PATH)/kazmath/include \ - $(LOCAL_PATH)/keypad_dispatcher \ - $(LOCAL_PATH)/label_nodes \ - $(LOCAL_PATH)/layers_scenes_transitions_nodes \ - $(LOCAL_PATH)/menu_nodes \ - $(LOCAL_PATH)/misc_nodes \ - $(LOCAL_PATH)/particle_nodes \ - $(LOCAL_PATH)/platform \ - $(LOCAL_PATH)/platform/android \ - $(LOCAL_PATH)/script_support \ - $(LOCAL_PATH)/shaders \ - $(LOCAL_PATH)/sprite_nodes \ - $(LOCAL_PATH)/support \ - $(LOCAL_PATH)/text_input_node \ - $(LOCAL_PATH)/textures \ - $(LOCAL_PATH)/tileMap_parallax_nodes \ - $(LOCAL_PATH)/touch_dispatcher - - -LOCAL_EXPORT_LDLIBS := -llog\ - -lz \ - -lGLESv2 - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/ \ - $(LOCAL_PATH)/actions \ - $(LOCAL_PATH)/base_nodes \ - $(LOCAL_PATH)/cocoa \ - $(LOCAL_PATH)/effects \ - $(LOCAL_PATH)/extensions \ - $(LOCAL_PATH)/include \ - $(LOCAL_PATH)/kazmath/include \ - $(LOCAL_PATH)/keypad_dispatcher \ - $(LOCAL_PATH)/label_nodes \ - $(LOCAL_PATH)/layers_scenes_transitions_nodes \ - $(LOCAL_PATH)/menu_nodes \ - $(LOCAL_PATH)/misc_nodes \ - $(LOCAL_PATH)/particle_nodes \ - $(LOCAL_PATH)/platform \ - $(LOCAL_PATH)/platform/android \ - $(LOCAL_PATH)/script_support \ - $(LOCAL_PATH)/shaders \ - $(LOCAL_PATH)/sprite_nodes \ - $(LOCAL_PATH)/support \ - $(LOCAL_PATH)/text_input_node \ - $(LOCAL_PATH)/textures \ - $(LOCAL_PATH)/tileMap_parallax_nodes \ - $(LOCAL_PATH)/touch_dispatcher - - -LOCAL_LDLIBS := -lGLESv2 \ - -lEGL \ - -llog \ - -lz - -LOCAL_WHOLE_STATIC_LIBRARIES := cocos_libpng_static -LOCAL_WHOLE_STATIC_LIBRARIES += cocos_jpeg_static -LOCAL_WHOLE_STATIC_LIBRARIES += cocos_libxml2_static -LOCAL_WHOLE_STATIC_LIBRARIES += cocos_libtiff_static +extensions/CCBReader/CCBReader_v2.cpp \ +kazmath/src/aabb.c \ +kazmath/src/mat3.c \ +kazmath/src/mat4.c \ +kazmath/src/neon_matrix_impl.c \ +kazmath/src/plane.c \ +kazmath/src/quaternion.c \ +kazmath/src/ray2.c \ +kazmath/src/utility.c \ +kazmath/src/vec2.c \ +kazmath/src/vec3.c \ +kazmath/src/vec4.c \ +kazmath/src/GL/mat4stack.c \ +kazmath/src/GL/matrix.c \ +keypad_dispatcher/CCKeypadDelegate.cpp \ +keypad_dispatcher/CCKeypadDispatcher.cpp \ +label_nodes/CCLabelAtlas.cpp \ +label_nodes/CCLabelBMFont.cpp \ +label_nodes/CCLabelTTF.cpp \ +layers_scenes_transitions_nodes/CCLayer.cpp \ +layers_scenes_transitions_nodes/CCScene.cpp \ +layers_scenes_transitions_nodes/CCTransitionPageTurn.cpp \ +layers_scenes_transitions_nodes/CCTransition.cpp \ +layers_scenes_transitions_nodes/CCTransitionProgress.cpp \ +menu_nodes/CCMenu.cpp \ +menu_nodes/CCMenuItem.cpp \ +misc_nodes/CCMotionStreak.cpp \ +misc_nodes/CCProgressTimer.cpp \ +misc_nodes/CCRenderTexture.cpp \ +particle_nodes/CCParticleExamples.cpp \ +particle_nodes/CCParticleSystem.cpp \ +particle_nodes/CCParticleBatchNode.cpp \ +particle_nodes/CCParticleSystemQuad.cpp \ +platform/CCSAXParser.cpp \ +platform/CCThread.cpp \ +platform/platform.cpp \ +platform/CCEGLViewProtocol.cpp \ +platform/android/CCEGLView.cpp \ +platform/android/CCAccelerometer.cpp \ +platform/android/CCApplication.cpp \ +platform/android/CCCommon.cpp \ +platform/android/CCFileUtils.cpp \ +platform/android/CCImage.cpp \ +platform/android/jni/JniHelper.cpp \ +platform/android/jni/IMEJni.cpp \ +platform/android/jni/MessageJni.cpp \ +platform/android/jni/SensorJni.cpp \ +platform/android/jni/SystemInfoJni.cpp \ +platform/android/jni/TouchesJni.cpp \ +script_support/CCScriptSupport.cpp \ +shaders/ccShaders.cpp \ +shaders/CCGLProgram.cpp \ +shaders/ccGLStateCache.cpp \ +shaders/CCShaderCache.cpp \ +sprite_nodes/CCAnimation.cpp \ +sprite_nodes/CCAnimationCache.cpp \ +sprite_nodes/CCSprite.cpp \ +sprite_nodes/CCSpriteBatchNode.cpp \ +sprite_nodes/CCSpriteFrame.cpp \ +sprite_nodes/CCSpriteFrameCache.cpp \ +support/CCProfiling.cpp \ +support/CCPointExtension.cpp \ +support/TransformUtils.cpp \ +support/CCUserDefault.cpp \ +support/base64.cpp \ +support/ccUtils.cpp \ +support/CCVertex.cpp \ +support/image_support/TGAlib.cpp \ +support/zip_support/ZipUtils.cpp \ +support/zip_support/ioapi.cpp \ +support/zip_support/unzip.cpp \ +text_input_node/CCIMEDispatcher.cpp \ +text_input_node/CCTextFieldTTF.cpp \ +textures/CCTexture2D.cpp \ +textures/CCTextureAtlas.cpp \ +textures/CCTextureCache.cpp \ +textures/CCTexturePVR.cpp \ +tileMap_parallax_nodes/CCParallaxNode.cpp \ +tileMap_parallax_nodes/CCTMXLayer.cpp \ +tileMap_parallax_nodes/CCTMXObjectGroup.cpp \ +tileMap_parallax_nodes/CCTMXTiledMap.cpp \ +tileMap_parallax_nodes/CCTMXXMLParser.cpp \ +tileMap_parallax_nodes/CCTileMapAtlas.cpp \ +touch_dispatcher/CCTouchDispatcher.cpp \ +touch_dispatcher/CCTouchHandler.cpp + +LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/ \ + $(LOCAL_PATH)/actions \ + $(LOCAL_PATH)/base_nodes \ + $(LOCAL_PATH)/cocoa \ + $(LOCAL_PATH)/effects \ + $(LOCAL_PATH)/extensions \ + $(LOCAL_PATH)/include \ + $(LOCAL_PATH)/kazmath/include \ + $(LOCAL_PATH)/keypad_dispatcher \ + $(LOCAL_PATH)/label_nodes \ + $(LOCAL_PATH)/layers_scenes_transitions_nodes \ + $(LOCAL_PATH)/menu_nodes \ + $(LOCAL_PATH)/misc_nodes \ + $(LOCAL_PATH)/particle_nodes \ + $(LOCAL_PATH)/platform \ + $(LOCAL_PATH)/platform/android \ + $(LOCAL_PATH)/script_support \ + $(LOCAL_PATH)/shaders \ + $(LOCAL_PATH)/sprite_nodes \ + $(LOCAL_PATH)/support \ + $(LOCAL_PATH)/text_input_node \ + $(LOCAL_PATH)/textures \ + $(LOCAL_PATH)/tileMap_parallax_nodes \ + $(LOCAL_PATH)/touch_dispatcher + + +LOCAL_EXPORT_LDLIBS := -llog\ + -lz \ + -lGLESv2 + +LOCAL_C_INCLUDES := $(LOCAL_PATH)/ \ + $(LOCAL_PATH)/actions \ + $(LOCAL_PATH)/base_nodes \ + $(LOCAL_PATH)/cocoa \ + $(LOCAL_PATH)/effects \ + $(LOCAL_PATH)/extensions \ + $(LOCAL_PATH)/include \ + $(LOCAL_PATH)/kazmath/include \ + $(LOCAL_PATH)/keypad_dispatcher \ + $(LOCAL_PATH)/label_nodes \ + $(LOCAL_PATH)/layers_scenes_transitions_nodes \ + $(LOCAL_PATH)/menu_nodes \ + $(LOCAL_PATH)/misc_nodes \ + $(LOCAL_PATH)/particle_nodes \ + $(LOCAL_PATH)/platform \ + $(LOCAL_PATH)/platform/android \ + $(LOCAL_PATH)/script_support \ + $(LOCAL_PATH)/shaders \ + $(LOCAL_PATH)/sprite_nodes \ + $(LOCAL_PATH)/support \ + $(LOCAL_PATH)/text_input_node \ + $(LOCAL_PATH)/textures \ + $(LOCAL_PATH)/tileMap_parallax_nodes \ + $(LOCAL_PATH)/touch_dispatcher + + +LOCAL_LDLIBS := -lGLESv2 \ + -lEGL \ + -llog \ + -lz + +LOCAL_WHOLE_STATIC_LIBRARIES := cocos_libpng_static +LOCAL_WHOLE_STATIC_LIBRARIES += cocos_jpeg_static +LOCAL_WHOLE_STATIC_LIBRARIES += cocos_libxml2_static +LOCAL_WHOLE_STATIC_LIBRARIES += cocos_libtiff_static + + +# define the macro to compile through support/zip_support/ioapi.c +LOCAL_CFLAGS := -DUSE_FILE32API + +include $(BUILD_STATIC_LIBRARY) + +$(call import-module,libjpeg) +$(call import-module,libpng) +$(call import-module,libxml2) +$(call import-module,libtiff) - -# define the macro to compile through support/zip_support/ioapi.c -LOCAL_CFLAGS := -DUSE_FILE32API - -include $(BUILD_STATIC_LIBRARY) - -$(call import-module,libjpeg) -$(call import-module,libpng) -$(call import-module,libxml2) -$(call import-module,libtiff) - diff --git a/cocos2dx/extensions/CCBReader/CCBReader.h b/cocos2dx/extensions/CCBReader/CCBReader.h index fd7560bf19..19a804b4d3 100644 --- a/cocos2dx/extensions/CCBReader/CCBReader.h +++ b/cocos2dx/extensions/CCBReader/CCBReader.h @@ -51,7 +51,7 @@ private: static CCNode* ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extraProps, const char* assetsDir, CCNode* owner, CCNode* root); - // read different types of values from dict + // read different types of values from dict static int intValFromDict(CCDictionary* dict, const std::string key); @@ -73,7 +73,7 @@ private: const std::string key); private: - // set properties + // set properties static void setExtraProp(CCObject* prop, const char* key, int tag, CCDictionary* dict); diff --git a/cocos2dx/extensions/CCBReader/CCBReader_v1.cpp b/cocos2dx/extensions/CCBReader/CCBReader_v1.cpp index 0cea9e4a3c..daaca0b9c4 100644 --- a/cocos2dx/extensions/CCBReader/CCBReader_v1.cpp +++ b/cocos2dx/extensions/CCBReader/CCBReader_v1.cpp @@ -33,31 +33,31 @@ USING_NS_CC_EXT; int CCBReader::intValFromDict(CCDictionary* dict, const std::string key) { - CCString* valueString = (CCString*) dict->objectForKey(key.c_str()); - return valueString->intValue(); + CCString* valueString = (CCString*) dict->objectForKey(key.c_str()); + return valueString->intValue(); } float CCBReader::floatValFromDict(CCDictionary* dict, const std::string key) { - CCString* valueString = (CCString*) dict->objectForKey(key.c_str()); + CCString* valueString = (CCString*) dict->objectForKey(key.c_str()); return valueString->floatValue(); } bool CCBReader::boolValFromDict(CCDictionary* dict, const std::string key) { - CCString* valueString = (CCString*) dict->objectForKey(key.c_str()); + CCString* valueString = (CCString*) dict->objectForKey(key.c_str()); return (bool) valueString->intValue(); } CCPoint CCBReader::pointValFromDict(CCDictionary* dict, const std::string key) { - CCArray* arr = (CCArray*)dict->objectForKey(key.c_str()); - + CCArray* arr = (CCArray*)dict->objectForKey(key.c_str()); + if (!arr) - { - return ccp(0,0); - } - + { + return ccp(0,0); + } + float x = ((CCString*)arr->objectAtIndex(0))->floatValue(); float y = ((CCString*)arr->objectAtIndex(1))->floatValue(); return ccp(x, y); @@ -65,13 +65,13 @@ CCPoint CCBReader::pointValFromDict(CCDictionary* dict, const std::string key) CCSize CCBReader::sizeValFromDict(CCDictionary* dict, const std::string key) { - CCArray* arr = (CCArray*) dict->objectForKey(key.c_str()); - + CCArray* arr = (CCArray*) dict->objectForKey(key.c_str()); + if (!arr) - { - return CCSize(0, 0); - } - + { + return CCSize(0, 0); + } + float w = ((CCString*)arr->objectAtIndex(0))->floatValue(); float h = ((CCString*)arr->objectAtIndex(1))->floatValue(); return CCSize(w, h); @@ -79,39 +79,39 @@ CCSize CCBReader::sizeValFromDict(CCDictionary* dict, const std::string key) ccColor3B CCBReader::ccColor3ValFromDict(CCDictionary* dict, const std::string key) { - CCArray* arr = (CCArray*) dict->objectForKey(key.c_str()); - + CCArray* arr = (CCArray*) dict->objectForKey(key.c_str()); + int r = ((CCString*)arr->objectAtIndex(0))->intValue(); int g = ((CCString*)arr->objectAtIndex(1))->intValue(); int b = ((CCString*)arr->objectAtIndex(2))->intValue(); - + return ccc3(r, g, b); } ccColor4F CCBReader::ccColor4fValFromDict(CCDictionary* dict, const std::string key) { - CCArray* arr = (CCArray*) dict->objectForKey(key.c_str()); - + CCArray* arr = (CCArray*) dict->objectForKey(key.c_str()); + ccColor4F color; color.r = ((CCString*)arr->objectAtIndex(0))->floatValue(); color.g = ((CCString*)arr->objectAtIndex(1))->floatValue(); color.b = ((CCString*)arr->objectAtIndex(2))->floatValue(); color.a = ((CCString*)arr->objectAtIndex(3))->floatValue(); - + return color; } ccBlendFunc CCBReader::blendFuncValFromDict(CCDictionary* dict, const std::string key) { - CCArray* arr = (CCArray*) dict->objectForKey(key.c_str()); - + CCArray* arr = (CCArray*) dict->objectForKey(key.c_str()); + int src = ((CCString*)arr->objectAtIndex(0))->intValue(); int dst = ((CCString*)arr->objectAtIndex(1))->intValue(); - + ccBlendFunc blendFunc; blendFunc.src = src; blendFunc.dst = dst; - + return blendFunc; } @@ -119,10 +119,10 @@ ccBlendFunc CCBReader::blendFuncValFromDict(CCDictionary* dict, const std::strin void CCBReader::setExtraProp(CCObject* prop, const char* key, int tag, CCDictionary* dict) { - std::string tagString; - tagString += tag; + std::string tagString; + tagString += tag; CCDictionary* props = (CCDictionary*) dict->objectForKey(tagString.c_str()); - + if (!props) { props = new CCDictionary(); @@ -140,7 +140,7 @@ void CCBReader::setPropsForMenuItem(CCMenuItem* node, CCDictionary* props, CCDic setExtraProp((CCDictionary*) props->objectForKey("selector"), "selector", node->getTag(), extraProps); setExtraProp((CCDictionary*) props->objectForKey("target"), "target", node->getTag(), extraProps); CCString* spriteFramesFile = (CCString*) props->objectForKey("spriteFramesFile"); - + if (spriteFramesFile) { setExtraProp(spriteFramesFile, "spriteSheetFile", node->getTag(), extraProps); @@ -193,7 +193,7 @@ void CCBReader::setPropsForLabelBMFont(CCLabelBMFont* node, CCDictionary* props, { node->setOpacity(intValFromDict(props, "opacity")); node->setColor(ccColor3ValFromDict(props, "color")); - + if (extraProps) { setExtraProp(props->objectForKey("fontFile"), "fontFile", node->getTag(), extraProps); @@ -221,7 +221,7 @@ void CCBReader::setPropsForParticleSystem(CCParticleSystem* node, CCDictionary* node->setEndSpin(intValFromDict(props, "endSpin")); node->setEndSpinVar(intValFromDict(props, "endSpinVar")); } - + node->setStartColor(ccColor4fValFromDict(props, "startColor")); node->setStartColorVar(ccColor4fValFromDict(props, "startColorVar")); node->setEndColor(ccColor4fValFromDict(props, "endColor")); @@ -286,12 +286,12 @@ void CCBReader::setPropsForSprite(CCSprite* node, CCDictionary* props, CCDiction node->setFlipX(boolValFromDict(props, "flipX")); node->setFlipY(boolValFromDict(props, "flipY")); node->setBlendFunc(blendFuncValFromDict(props, "blendFunc")); - + if (extraProps) { setExtraProp(props->objectForKey("spriteFile"), "spriteFile", node->getTag(), extraProps); CCString* spriteFramesFile = (CCString*) props->objectForKey("spriteFramesFile"); - + if (spriteFramesFile) { setExtraProp(spriteFramesFile, "spriteSheetFile", node->getTag(), extraProps); @@ -301,17 +301,17 @@ void CCBReader::setPropsForSprite(CCSprite* node, CCDictionary* props, CCDiction void CCBReader::setPropsForNode(CCNode* node, CCDictionary* props, CCDictionary* extraProps) { - CCPoint position = pointValFromDict(props, "position"); - node->setPosition(position); + CCPoint position = pointValFromDict(props, "position"); + node->setPosition(position); if (dynamic_cast(node) == NULL && dynamic_cast(node) == NULL && dynamic_cast(node) == NULL) { - CCSize size = sizeValFromDict(props, "contentSize"); - //node->setContentSize(size); + CCSize size = sizeValFromDict(props, "contentSize"); + //node->setContentSize(size); } - + node->setScaleX(floatValFromDict(props, "scaleX")); node->setScaleY(floatValFromDict(props, "scaleY")); node->setAnchorPoint(pointValFromDict(props, "anchorPoint")); @@ -330,20 +330,20 @@ void CCBReader::setPropsForNode(CCNode* node, CCDictionary* props, CCDictionary* setExtraProp((CCDictionary*) props->objectForKey("customClass"), "customClass", node->getTag(), extraProps); setExtraProp((CCDictionary*) props->objectForKey("memberVarAssignmentType"), "memberVarAssignmentType", node->getTag(), extraProps); - setExtraProp((CCDictionary*) props->objectForKey("memberVarAssignmentName"), "memberVarAssignmentName", node->getTag(), extraProps); + setExtraProp((CCDictionary*) props->objectForKey("memberVarAssignmentName"), "memberVarAssignmentName", node->getTag(), extraProps); setExtraProp((CCDictionary*) props->objectForKey("lockedScaleRatio"), "lockedScaleRatio", node->getTag(), extraProps); // Expanded nodes bool isExpanded; CCString* isExpandedObj = (CCString*) props->objectForKey("isExpanded"); - + if (isExpandedObj) { - isExpanded = !isExpandedObj->m_sString.empty(); - } else { - isExpanded = true; - } - - setExtraProp(isExpandedObj, "isExpanded", node->getTag(), extraProps); + isExpanded = !isExpandedObj->m_sString.empty(); + } else { + isExpanded = true; + } + + setExtraProp(isExpandedObj, "isExpanded", node->getTag(), extraProps); } else { @@ -355,38 +355,38 @@ void CCBReader::setPropsForNode(CCNode* node, CCDictionary* props, CCDictionary* CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extraProps, const char* assetsDir, CCNode* owner, CCNode* root) { - CCString* className = (CCString*) dict->objectForKey("class"); + CCString* className = (CCString*) dict->objectForKey("class"); CCDictionary* props = (CCDictionary*) dict->objectForKey("properties"); CCArray* children = (CCArray*) dict->objectForKey("children"); CCString* customClass = (CCString*)props->objectForKey("customClass"); - + if (extraProps) customClass = NULL; CCNode* node = NULL; - if (className->m_sString.compare("CCParticleSystem") == 0) + if (className->m_sString.compare("CCParticleSystem") == 0) { CCString* spriteFile = new CCString(assetsDir); - spriteFile->m_sString += ((CCString*)props->objectForKey("spriteFile"))->m_sString; - + spriteFile->m_sString += ((CCString*)props->objectForKey("spriteFile"))->m_sString; + CCParticleSystem* sys = new CCParticleSystemQuad(); - sys->initWithTotalParticles(2048); + sys->initWithTotalParticles(2048); sys->setTexture(CCTextureCache::sharedTextureCache()->addImage(spriteFile->m_sString.c_str())); - delete spriteFile; + delete spriteFile; node = (CCNode*)sys; - + setPropsForNode((CCNode*)node, (CCDictionary*) props, extraProps); setPropsForParticleSystem((CCParticleSystem*) node, (CCDictionary*) props, extraProps); } else if (className->m_sString.compare("CCMenuItemImage") == 0) { CCString* spriteFileNormal = new CCString(assetsDir); - spriteFileNormal->m_sString += ((CCString*)props->objectForKey("spriteFileNormal"))->getCString(); + spriteFileNormal->m_sString += ((CCString*)props->objectForKey("spriteFileNormal"))->getCString(); CCString* spriteFileSelected = new CCString(assetsDir); - spriteFileSelected->m_sString += ((CCString*)props->objectForKey("spriteFileSelected"))->getCString(); + spriteFileSelected->m_sString += ((CCString*)props->objectForKey("spriteFileSelected"))->getCString(); CCString* spriteFileDisabled = new CCString(assetsDir); - spriteFileDisabled->m_sString += ((CCString*)props->objectForKey("spriteFileDisabled"))->getCString(); + spriteFileDisabled->m_sString += ((CCString*)props->objectForKey("spriteFileDisabled"))->getCString(); CCSprite* spriteNormal = NULL; CCSprite* spriteSelected = NULL; @@ -394,12 +394,12 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr CCString* spriteSheetFile = (CCString*)props->objectForKey("spriteFramesFile"); if (spriteSheetFile && !spriteSheetFile->length()) { - spriteSheetFile->m_sString.insert(0, assetsDir); - } + spriteSheetFile->m_sString.insert(0, assetsDir); + } if (spriteSheetFile && !spriteSheetFile->length()) { - CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile(spriteSheetFile->m_sString.c_str()); + CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile(spriteSheetFile->m_sString.c_str()); spriteNormal = CCSprite::spriteWithSpriteFrameName(((CCString*)props->objectForKey("spriteFileNormal"))->getCString()); spriteSelected = CCSprite::spriteWithSpriteFrameName(((CCString*)props->objectForKey("spriteFileSelected"))->getCString()); @@ -412,16 +412,16 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr spriteSelected = CCSprite::spriteWithFile(spriteFileSelected->m_sString.c_str()); spriteDisabled = CCSprite::spriteWithFile(spriteFileDisabled->m_sString.c_str()); } - - //deallocate + + //deallocate CC_SAFE_DELETE(spriteFileNormal); CC_SAFE_DELETE(spriteFileSelected); CC_SAFE_DELETE(spriteFileDisabled); if (!spriteNormal) spriteNormal = CCSprite::spriteWithFile("missing-texture.png"); if (!spriteSelected) spriteSelected = CCSprite::spriteWithFile("missing-texture.png"); - if (!spriteDisabled) spriteDisabled = CCSprite::spriteWithFile("missing-texture.png"); - + if (!spriteDisabled) spriteDisabled = CCSprite::spriteWithFile("missing-texture.png"); + CCNode *target = NULL ; if ( extraProps == NULL ) { @@ -446,7 +446,7 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr target = NULL ; } - node = (CCNode*)CCMenuItemImage::itemWithNormalSprite((CCNode*) spriteNormal, (CCNode*) spriteSelected, (CCNode*) spriteDisabled, target, sel); + node = (CCNode*)CCMenuItemImage::itemWithNormalSprite((CCNode*) spriteNormal, (CCNode*) spriteSelected, (CCNode*) spriteDisabled, target, sel); setPropsForNode(node, (CCDictionary*) props, extraProps); setPropsForMenuItem((CCMenuItem*) node, (CCDictionary*) props, extraProps); @@ -455,38 +455,38 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr else if (className->m_sString.compare("CCMenu") == 0) { node = (CCNode*)CCMenu::menuWithItems(NULL); - setPropsForNode(node, (CCDictionary*) props, extraProps); + setPropsForNode(node, (CCDictionary*) props, extraProps); setPropsForLayer((CCLayer*) node, (CCDictionary*) props, extraProps); setPropsForMenu((CCMenu*)node, (CCDictionary*) props, extraProps); } - else if (className->m_sString.compare("CCLabelBMFont") == 0) + else if (className->m_sString.compare("CCLabelBMFont") == 0) { CCString* fontFile = new CCString(assetsDir); - fontFile->m_sString += ((CCString*)props->objectForKey("fontFile"))->m_sString; + fontFile->m_sString += ((CCString*)props->objectForKey("fontFile"))->m_sString; CCString* stringText = ((CCString*)props->objectForKey("string")); - + node = (CCNode*)CCLabelBMFont::labelWithString(stringText->m_sString.c_str(), fontFile->m_sString.c_str() ); - - delete fontFile; - fontFile = 0; - + + delete fontFile; + fontFile = 0; + if (!node) node = (CCNode*)CCLabelBMFont::labelWithString(stringText->m_sString.c_str(), "missing-font.fnt"); setPropsForNode(node, (CCDictionary*) props, extraProps); - setPropsForLabelBMFont((CCLabelBMFont*) node, (CCDictionary*) props, extraProps); + setPropsForLabelBMFont((CCLabelBMFont*) node, (CCDictionary*) props, extraProps); } - else if (className->m_sString.compare("CCSprite") == 0) + else if (className->m_sString.compare("CCSprite") == 0) { CCString* spriteFile = new CCString(assetsDir); - spriteFile->m_sString += ((CCString*)props->objectForKey("spriteFile"))->m_sString; + spriteFile->m_sString += ((CCString*)props->objectForKey("spriteFile"))->m_sString; CCString* spriteSheetFile = (CCString*)props->objectForKey("spriteFramesFile"); - + if (spriteSheetFile && !spriteSheetFile->length()) - { - spriteSheetFile->m_sString.insert(0, assetsDir); - } + { + spriteSheetFile->m_sString.insert(0, assetsDir); + } if (spriteSheetFile && !spriteSheetFile->length()) { @@ -499,7 +499,7 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr printf("spriteFile->m_string.cstr is %s\n", spriteFile->m_sString.c_str()) ; node = (CCNode*)CCSprite::spriteWithFile(spriteFile->m_sString.c_str()); } - + CC_SAFE_RELEASE_NULL(spriteFile); if (!node) node = (CCNode*)CCSprite::spriteWithFile("missing-texture.png"); @@ -515,7 +515,7 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr if (dynamic_cast(node) == NULL) { CCLOG("WARNING! %s is not subclass of CCNode", customClass); - delete node; + delete node; node = NULL; } } @@ -538,7 +538,7 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr if (dynamic_cast(node) == NULL) { CCLOG("WARNING! %s is not subclass of CCNode", customClass); - delete node; + delete node; node = NULL; } } @@ -558,7 +558,7 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr if (dynamic_cast(node) == NULL) { CCLOG("WARNING! %s is not subclass of CCNode", customClass); - delete node; + delete node; node = NULL; } } @@ -579,7 +579,7 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr if (dynamic_cast(node) == NULL) { CCLOG("WARNING! %s is not subclass of CCNode", customClass); - delete node; + delete node; node = NULL; } } @@ -587,12 +587,12 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr { node = (CCNode*)CCNode::node(); } - + setPropsForNode(node, (CCDictionary*) props, extraProps); } else { - CCLOG("WARNING! Class of type %@ couldn't be found", className); + CCLOG("WARNING! Class of type %@ couldn't be found", className); return NULL; } @@ -604,14 +604,14 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr CCDictionary* childDict = (CCDictionary*) children->objectAtIndex(i); CCNode* child = ccObjectFromDictionary(childDict, extraProps, assetsDir, owner, root); int zOrder = intValFromDict((CCDictionary*) childDict->objectForKey("properties"), "zOrder"); - + if (child && node) { node->addChild(child, zOrder); } else { - CCLOG("WARNING! Failed to add child to node"); + CCLOG("WARNING! Failed to add child to node"); } } @@ -660,12 +660,12 @@ CCNode* CCBReader::nodeGraphFromDictionary(CCDictionary* dict, const char* assetsDir, CCNode* owner) { - if (!dict) + if (!dict) { CCLOG("WARNING! Trying to load invalid file type"); return NULL; } - + CCString* fileType = (CCString*) dict->objectForKey("fileType"); int fileVersion = ((CCString*) dict->objectForKey("fileVersion"))->intValue(); @@ -686,8 +686,8 @@ CCNode* CCBReader::nodeGraphFromDictionary(CCDictionary* dict, CCNode* CCBReader::nodeGraphFromFile(const char* file, CCNode* owner) { - CCLOG("CCBReader path is: %s", file); - std::string ccbFilePath(file); + CCLOG("CCBReader path is: %s", file); + std::string ccbFilePath(file); std::string ccbFileDir; // find ccbFileDir before "/" or "\" @@ -700,8 +700,8 @@ CCNode* CCBReader::nodeGraphFromFile(const char* file, CCNode* owner) } CCDictionary* dict = CCDictionary::dictionaryWithContentsOfFileThreadSafe(ccbFilePath.c_str()); - CCAssert(dict != NULL, "CCBReader: file not found"); + CCAssert(dict != NULL, "CCBReader: file not found"); - return nodeGraphFromDictionary(dict, NULL, ccbFileDir.c_str(), owner); + return nodeGraphFromDictionary(dict, NULL, ccbFileDir.c_str(), owner); } diff --git a/cocos2dx/extensions/CCBReader/CCBReader_v2.cpp b/cocos2dx/extensions/CCBReader/CCBReader_v2.cpp index f82b7dbbd9..e04be27088 100644 --- a/cocos2dx/extensions/CCBReader/CCBReader_v2.cpp +++ b/cocos2dx/extensions/CCBReader/CCBReader_v2.cpp @@ -33,31 +33,31 @@ USING_NS_CC_EXT; int CCBReader::intValFromDict(CCDictionary* dict, const std::string key) { - CCString* valueString = (CCString*) dict->objectForKey(key.c_str()); - return valueString? valueString->intValue() : 0; + CCString* valueString = (CCString*) dict->objectForKey(key.c_str()); + return valueString? valueString->intValue() : 0; } float CCBReader::floatValFromDict(CCDictionary* dict, const std::string key) { - CCString* valueString = (CCString*) dict->objectForKey(key.c_str()); + CCString* valueString = (CCString*) dict->objectForKey(key.c_str()); return valueString? valueString->floatValue() : 0; } bool CCBReader::boolValFromDict(CCDictionary* dict, const std::string key) { - CCString* valueString = (CCString*) dict->objectForKey(key.c_str()); + CCString* valueString = (CCString*) dict->objectForKey(key.c_str()); return valueString? ((bool)(valueString->intValue())) : false; } CCPoint CCBReader::pointValFromDict(CCDictionary* dict, const std::string key) { - CCArray* arr = (CCArray*)dict->objectForKey(key.c_str()); - + CCArray* arr = (CCArray*)dict->objectForKey(key.c_str()); + if (!arr) - { - return ccp(0,0); - } - + { + return ccp(0,0); + } + float x = ((CCString*)arr->objectAtIndex(0))->floatValue(); float y = ((CCString*)arr->objectAtIndex(1))->floatValue(); return ccp(x, y); @@ -65,13 +65,13 @@ CCPoint CCBReader::pointValFromDict(CCDictionary* dict, const std::string key) CCSize CCBReader::sizeValFromDict(CCDictionary* dict, const std::string key) { - CCArray* arr = (CCArray*) dict->objectForKey(key.c_str()); - + CCArray* arr = (CCArray*) dict->objectForKey(key.c_str()); + if (!arr) - { - return CCSize(0, 0); - } - + { + return CCSize(0, 0); + } + float w = ((CCString*)arr->objectAtIndex(0))->floatValue(); float h = ((CCString*)arr->objectAtIndex(1))->floatValue(); return CCSize(w, h); @@ -79,39 +79,39 @@ CCSize CCBReader::sizeValFromDict(CCDictionary* dict, const std::string key) ccColor3B CCBReader::ccColor3ValFromDict(CCDictionary* dict, const std::string key) { - CCArray* arr = (CCArray*) dict->objectForKey(key.c_str()); - + CCArray* arr = (CCArray*) dict->objectForKey(key.c_str()); + int r = ((CCString*)arr->objectAtIndex(0))->intValue(); int g = ((CCString*)arr->objectAtIndex(1))->intValue(); int b = ((CCString*)arr->objectAtIndex(2))->intValue(); - + return ccc3(r, g, b); } ccColor4F CCBReader::ccColor4fValFromDict(CCDictionary* dict, const std::string key) { - CCArray* arr = (CCArray*) dict->objectForKey(key.c_str()); - + CCArray* arr = (CCArray*) dict->objectForKey(key.c_str()); + ccColor4F color; color.r = ((CCString*)arr->objectAtIndex(0))->floatValue(); color.g = ((CCString*)arr->objectAtIndex(1))->floatValue(); color.b = ((CCString*)arr->objectAtIndex(2))->floatValue(); color.a = ((CCString*)arr->objectAtIndex(3))->floatValue(); - + return color; } ccBlendFunc CCBReader::blendFuncValFromDict(CCDictionary* dict, const std::string key) { - CCArray* arr = (CCArray*) dict->objectForKey(key.c_str()); - + CCArray* arr = (CCArray*) dict->objectForKey(key.c_str()); + int src = ((CCString*)arr->objectAtIndex(0))->intValue(); int dst = ((CCString*)arr->objectAtIndex(1))->intValue(); - + ccBlendFunc blendFunc; blendFunc.src = src; blendFunc.dst = dst; - + return blendFunc; } @@ -119,10 +119,10 @@ ccBlendFunc CCBReader::blendFuncValFromDict(CCDictionary* dict, const std::strin void CCBReader::setExtraProp(CCObject* prop, const char* key, int tag, CCDictionary* dict) { - std::string tagString; - tagString += tag; + std::string tagString; + tagString += tag; CCDictionary* props = (CCDictionary*) dict->objectForKey(tagString.c_str()); - + if (!props) { props = new CCDictionary(); @@ -140,7 +140,7 @@ void CCBReader::setPropsForMenuItem(CCMenuItem* node, CCDictionary* props, CCDic setExtraProp((CCDictionary*) props->objectForKey("selector"), "selector", node->getTag(), extraProps); setExtraProp((CCDictionary*) props->objectForKey("target"), "target", node->getTag(), extraProps); CCString* spriteFramesFile = (CCString*) props->objectForKey("spriteFramesFile"); - + if (spriteFramesFile) { setExtraProp(spriteFramesFile, "spriteSheetFile", node->getTag(), extraProps); @@ -193,7 +193,7 @@ void CCBReader::setPropsForLabelBMFont(CCLabelBMFont* node, CCDictionary* props, { node->setOpacity(intValFromDict(props, "opacity")); node->setColor(ccColor3ValFromDict(props, "color")); - + if (extraProps) { setExtraProp(props->objectForKey("fontFile"), "fontFile", node->getTag(), extraProps); @@ -221,7 +221,7 @@ void CCBReader::setPropsForParticleSystem(CCParticleSystem* node, CCDictionary* node->setEndSpin(intValFromDict(props, "endSpin")); node->setEndSpinVar(intValFromDict(props, "endSpinVar")); } - + node->setStartColor(ccColor4fValFromDict(props, "startColor")); node->setStartColorVar(ccColor4fValFromDict(props, "startColorVar")); node->setEndColor(ccColor4fValFromDict(props, "endColor")); @@ -286,12 +286,12 @@ void CCBReader::setPropsForSprite(CCSprite* node, CCDictionary* props, CCDiction node->setFlipX(boolValFromDict(props, "flipX")); node->setFlipY(boolValFromDict(props, "flipY")); node->setBlendFunc(blendFuncValFromDict(props, "blendFunc")); - + if (extraProps) { setExtraProp(props->objectForKey("spriteFile"), "spriteFile", node->getTag(), extraProps); CCString* spriteFramesFile = (CCString*) props->objectForKey("spriteFramesFile"); - + if (spriteFramesFile) { setExtraProp(spriteFramesFile, "spriteSheetFile", node->getTag(), extraProps); @@ -301,7 +301,7 @@ void CCBReader::setPropsForSprite(CCSprite* node, CCDictionary* props, CCDiction void CCBReader::setPropsForNode(CCNode* node, CCDictionary* props, CCDictionary* extraProps) { - CCPoint position = pointValFromDict(props, "position"); + CCPoint position = pointValFromDict(props, "position"); int refPointType = intValFromDict(props, "refPointType"); if (refPointType == kInvalidRelativePosition) @@ -369,10 +369,10 @@ void CCBReader::setPropsForNode(CCNode* node, CCDictionary* props, CCDictionary* dynamic_cast(node) == NULL && dynamic_cast(node) == NULL) { - CCSize size = sizeValFromDict(props, "contentSize"); - //node->setContentSize(size); + CCSize size = sizeValFromDict(props, "contentSize"); + //node->setContentSize(size); } - + node->setScaleX(floatValFromDict(props, "scaleX")); node->setScaleY(floatValFromDict(props, "scaleY")); node->setAnchorPoint(pointValFromDict(props, "anchorPoint")); @@ -391,20 +391,20 @@ void CCBReader::setPropsForNode(CCNode* node, CCDictionary* props, CCDictionary* setExtraProp((CCDictionary*) props->objectForKey("customClass"), "customClass", node->getTag(), extraProps); setExtraProp((CCDictionary*) props->objectForKey("memberVarAssignmentType"), "memberVarAssignmentType", node->getTag(), extraProps); - setExtraProp((CCDictionary*) props->objectForKey("memberVarAssignmentName"), "memberVarAssignmentName", node->getTag(), extraProps); + setExtraProp((CCDictionary*) props->objectForKey("memberVarAssignmentName"), "memberVarAssignmentName", node->getTag(), extraProps); setExtraProp((CCDictionary*) props->objectForKey("lockedScaleRatio"), "lockedScaleRatio", node->getTag(), extraProps); // Expanded nodes bool isExpanded; CCString* isExpandedObj = (CCString*) props->objectForKey("isExpanded"); - + if (isExpandedObj) { - isExpanded = !isExpandedObj->m_sString.empty(); - } else { - isExpanded = true; - } - - setExtraProp(isExpandedObj, "isExpanded", node->getTag(), extraProps); + isExpanded = !isExpandedObj->m_sString.empty(); + } else { + isExpanded = true; + } + + setExtraProp(isExpandedObj, "isExpanded", node->getTag(), extraProps); } else { @@ -416,38 +416,38 @@ void CCBReader::setPropsForNode(CCNode* node, CCDictionary* props, CCDictionary* CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extraProps, const char* assetsDir, CCNode* owner, CCNode* root) { - CCString* className = (CCString*) dict->objectForKey("class"); + CCString* className = (CCString*) dict->objectForKey("class"); CCDictionary* props = (CCDictionary*) dict->objectForKey("properties"); CCArray* children = (CCArray*) dict->objectForKey("children"); CCString* customClass = (CCString*)props->objectForKey("customClass"); - + if (extraProps) customClass = NULL; CCNode* node = NULL; - if (className->m_sString.compare("CCParticleSystem") == 0) + if (className->m_sString.compare("CCParticleSystem") == 0) { CCString* spriteFile = new CCString(assetsDir); - spriteFile->m_sString += ((CCString*)props->objectForKey("spriteFile"))->m_sString; - + spriteFile->m_sString += ((CCString*)props->objectForKey("spriteFile"))->m_sString; + CCParticleSystem* sys = new CCParticleSystemQuad(); - sys->initWithTotalParticles(2048); + sys->initWithTotalParticles(2048); sys->setTexture(CCTextureCache::sharedTextureCache()->addImage(spriteFile->m_sString.c_str())); - delete spriteFile; + delete spriteFile; node = (CCNode*)sys; - + setPropsForNode((CCNode*)node, (CCDictionary*) props, extraProps); setPropsForParticleSystem((CCParticleSystem*) node, (CCDictionary*) props, extraProps); } else if (className->m_sString.compare("CCMenuItemImage") == 0) { CCString* spriteFileNormal = new CCString(assetsDir); - spriteFileNormal->m_sString += ((CCString*)props->objectForKey("spriteFileNormal"))->getCString(); + spriteFileNormal->m_sString += ((CCString*)props->objectForKey("spriteFileNormal"))->getCString(); CCString* spriteFileSelected = new CCString(assetsDir); - spriteFileSelected->m_sString += ((CCString*)props->objectForKey("spriteFileSelected"))->getCString(); + spriteFileSelected->m_sString += ((CCString*)props->objectForKey("spriteFileSelected"))->getCString(); CCString* spriteFileDisabled = new CCString(assetsDir); - spriteFileDisabled->m_sString += ((CCString*)props->objectForKey("spriteFileDisabled"))->getCString(); + spriteFileDisabled->m_sString += ((CCString*)props->objectForKey("spriteFileDisabled"))->getCString(); CCSprite* spriteNormal = NULL; CCSprite* spriteSelected = NULL; @@ -455,12 +455,12 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr CCString* spriteSheetFile = (CCString*)props->objectForKey("spriteFramesFile"); if (spriteSheetFile && !spriteSheetFile->length()) { - spriteSheetFile->m_sString.insert(0, assetsDir); - } + spriteSheetFile->m_sString.insert(0, assetsDir); + } if (spriteSheetFile && !spriteSheetFile->length()) { - CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile(spriteSheetFile->m_sString.c_str()); + CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile(spriteSheetFile->m_sString.c_str()); spriteNormal = CCSprite::spriteWithSpriteFrameName(((CCString*)props->objectForKey("spriteFileNormal"))->getCString()); spriteSelected = CCSprite::spriteWithSpriteFrameName(((CCString*)props->objectForKey("spriteFileSelected"))->getCString()); @@ -473,16 +473,16 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr spriteSelected = CCSprite::spriteWithFile(spriteFileSelected->m_sString.c_str()); spriteDisabled = CCSprite::spriteWithFile(spriteFileDisabled->m_sString.c_str()); } - - //deallocate + + //deallocate CC_SAFE_DELETE(spriteFileNormal); CC_SAFE_DELETE(spriteFileSelected); CC_SAFE_DELETE(spriteFileDisabled); if (!spriteNormal) spriteNormal = CCSprite::spriteWithFile("missing-texture.png"); if (!spriteSelected) spriteSelected = CCSprite::spriteWithFile("missing-texture.png"); - if (!spriteDisabled) spriteDisabled = CCSprite::spriteWithFile("missing-texture.png"); - + if (!spriteDisabled) spriteDisabled = CCSprite::spriteWithFile("missing-texture.png"); + CCNode *target = NULL ; if ( extraProps == NULL ) { @@ -507,7 +507,7 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr target = NULL ; } - node = (CCNode*)CCMenuItemImage::itemWithNormalSprite((CCNode*) spriteNormal, (CCNode*) spriteSelected, (CCNode*) spriteDisabled, target, sel); + node = (CCNode*)CCMenuItemImage::itemWithNormalSprite((CCNode*) spriteNormal, (CCNode*) spriteSelected, (CCNode*) spriteDisabled, target, sel); setPropsForNode(node, (CCDictionary*) props, extraProps); setPropsForMenuItem((CCMenuItem*) node, (CCDictionary*) props, extraProps); @@ -516,38 +516,38 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr else if (className->m_sString.compare("CCMenu") == 0) { node = (CCNode*)CCMenu::menuWithItems(NULL); - setPropsForNode(node, (CCDictionary*) props, extraProps); + setPropsForNode(node, (CCDictionary*) props, extraProps); setPropsForLayer((CCLayer*) node, (CCDictionary*) props, extraProps); setPropsForMenu((CCMenu*)node, (CCDictionary*) props, extraProps); } - else if (className->m_sString.compare("CCLabelBMFont") == 0) + else if (className->m_sString.compare("CCLabelBMFont") == 0) { CCString* fontFile = new CCString(assetsDir); - fontFile->m_sString += ((CCString*)props->objectForKey("fontFile"))->m_sString; + fontFile->m_sString += ((CCString*)props->objectForKey("fontFile"))->m_sString; CCString* stringText = ((CCString*)props->objectForKey("string")); - + node = (CCNode*)CCLabelBMFont::labelWithString(stringText->m_sString.c_str(), fontFile->m_sString.c_str() ); - - delete fontFile; - fontFile = 0; - + + delete fontFile; + fontFile = 0; + if (!node) node = (CCNode*)CCLabelBMFont::labelWithString(stringText->m_sString.c_str(), "missing-font.fnt"); setPropsForNode(node, (CCDictionary*) props, extraProps); - setPropsForLabelBMFont((CCLabelBMFont*) node, (CCDictionary*) props, extraProps); + setPropsForLabelBMFont((CCLabelBMFont*) node, (CCDictionary*) props, extraProps); } - else if (className->m_sString.compare("CCSprite") == 0) + else if (className->m_sString.compare("CCSprite") == 0) { CCString* spriteFile = new CCString(assetsDir); - spriteFile->m_sString += ((CCString*)props->objectForKey("spriteFile"))->m_sString; + spriteFile->m_sString += ((CCString*)props->objectForKey("spriteFile"))->m_sString; CCString* spriteSheetFile = (CCString*)props->objectForKey("spriteFramesFile"); - + if (spriteSheetFile && !spriteSheetFile->length()) - { - spriteSheetFile->m_sString.insert(0, assetsDir); - } + { + spriteSheetFile->m_sString.insert(0, assetsDir); + } if (spriteSheetFile && !spriteSheetFile->length()) { @@ -560,7 +560,7 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr printf("spriteFile->m_string.cstr is %s\n", spriteFile->m_sString.c_str()) ; node = (CCNode*)CCSprite::spriteWithFile(spriteFile->m_sString.c_str()); } - + CC_SAFE_RELEASE_NULL(spriteFile); if (!node) node = (CCNode*)CCSprite::spriteWithFile("missing-texture.png"); @@ -576,7 +576,7 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr if (dynamic_cast(node) == NULL) { CCLOG("WARNING! %s is not subclass of CCNode", customClass); - delete node; + delete node; node = NULL; } } @@ -599,7 +599,7 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr if (dynamic_cast(node) == NULL) { CCLOG("WARNING! %s is not subclass of CCNode", customClass); - delete node; + delete node; node = NULL; } } @@ -619,7 +619,7 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr if (dynamic_cast(node) == NULL) { CCLOG("WARNING! %s is not subclass of CCNode", customClass); - delete node; + delete node; node = NULL; } } @@ -640,7 +640,7 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr if (dynamic_cast(node) == NULL) { CCLOG("WARNING! %s is not subclass of CCNode", customClass); - delete node; + delete node; node = NULL; } } @@ -648,12 +648,12 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr { node = (CCNode*)CCNode::node(); } - + setPropsForNode(node, (CCDictionary*) props, extraProps); } else { - CCLOG("WARNING! Class of type %@ couldn't be found", className); + CCLOG("WARNING! Class of type %@ couldn't be found", className); return NULL; } @@ -665,14 +665,14 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr CCDictionary* childDict = (CCDictionary*) children->objectAtIndex(i); CCNode* child = ccObjectFromDictionary(childDict, extraProps, assetsDir, owner, root); int zOrder = intValFromDict((CCDictionary*) childDict->objectForKey("properties"), "zOrder"); - + if (child && node) { node->addChild(child, zOrder); } else { - CCLOG("WARNING! Failed to add child to node"); + CCLOG("WARNING! Failed to add child to node"); } } @@ -721,12 +721,12 @@ CCNode* CCBReader::nodeGraphFromDictionary(CCDictionary* dict, const char* assetsDir, CCNode* owner) { - if (!dict) + if (!dict) { CCLOG("WARNING! Trying to load invalid file type"); return NULL; } - + CCString* fileType = (CCString*) dict->objectForKey("fileType"); int fileVersion = ((CCString*) dict->objectForKey("fileVersion"))->intValue(); @@ -747,8 +747,8 @@ CCNode* CCBReader::nodeGraphFromDictionary(CCDictionary* dict, CCNode* CCBReader::nodeGraphFromFile(const char* file, CCNode* owner) { - CCLOG("CCBReader path is: %s", file); - std::string ccbFilePath(file); + CCLOG("CCBReader path is: %s", file); + std::string ccbFilePath(file); std::string ccbFileDir; // find ccbFileDir before "/" or "\" @@ -761,8 +761,8 @@ CCNode* CCBReader::nodeGraphFromFile(const char* file, CCNode* owner) } CCDictionary* dict = CCDictionary::dictionaryWithContentsOfFileThreadSafe(ccbFilePath.c_str()); - CCAssert(dict != NULL, "CCBReader: file not found"); + CCAssert(dict != NULL, "CCBReader: file not found"); - return nodeGraphFromDictionary(dict, NULL, ccbFileDir.c_str(), owner); + return nodeGraphFromDictionary(dict, NULL, ccbFileDir.c_str(), owner); } diff --git a/cocos2dx/platform/CCImageCommon_cpp.h b/cocos2dx/platform/CCImageCommon_cpp.h index df1255c3d2..3ebd41c6a4 100644 --- a/cocos2dx/platform/CCImageCommon_cpp.h +++ b/cocos2dx/platform/CCImageCommon_cpp.h @@ -392,19 +392,19 @@ out: static tmsize_t _tiffReadProc(thandle_t fd, void* buf, tmsize_t size) { tImageSource* isource = (tImageSource*)fd; - uint8* ma; - uint64 mb; - unsigned long n; - unsigned long o; - tmsize_t p; - ma=(uint8*)buf; - mb=size; - p=0; - while (mb>0) - { - n=0x80000000UL; - if ((uint64)n>mb) - n=(unsigned long)mb; + uint8* ma; + uint64 mb; + unsigned long n; + unsigned long o; + tmsize_t p; + ma=(uint8*)buf; + mb=size; + p=0; + while (mb>0) + { + n=0x80000000UL; + if ((uint64)n>mb) + n=(unsigned long)mb; if((int)(isource->offset + n) <= isource->size) @@ -418,15 +418,15 @@ static tmsize_t _tiffReadProc(thandle_t fd, void* buf, tmsize_t size) return 0; } - ma+=o; - mb-=o; - p+=o; - if (o!=n) + ma+=o; + mb-=o; + p+=o; + if (o!=n) { - break; + break; } - } - return p; + } + return p; } static tmsize_t _tiffWriteProc(thandle_t fd, void* buf, tmsize_t size) @@ -434,7 +434,7 @@ static tmsize_t _tiffWriteProc(thandle_t fd, void* buf, tmsize_t size) CC_UNUSED_PARAM(fd); CC_UNUSED_PARAM(buf); CC_UNUSED_PARAM(size); - return 0; + return 0; } @@ -444,7 +444,7 @@ static uint64 _tiffSeekProc(thandle_t fd, uint64 off, int whence) uint64 ret = -1; do { - if (whence == SEEK_SET) + if (whence == SEEK_SET) { CC_BREAK_IF(off > isource->size-1); ret = isource->offset = (uint32)off; @@ -481,19 +481,19 @@ static int _tiffCloseProc(thandle_t fd) return 0; } -static int _tiffMapProc(thandle_t fd, void** pbase, toff_t* psize) -{ - CC_UNUSED_PARAM(fd); - CC_UNUSED_PARAM(pbase); - CC_UNUSED_PARAM(psize); - return 0; -} - -static void _tiffUnmapProc(thandle_t fd, void* base, toff_t size) -{ - CC_UNUSED_PARAM(fd); - CC_UNUSED_PARAM(base); - CC_UNUSED_PARAM(size); +static int _tiffMapProc(thandle_t fd, void** pbase, toff_t* psize) +{ + CC_UNUSED_PARAM(fd); + CC_UNUSED_PARAM(pbase); + CC_UNUSED_PARAM(psize); + return 0; +} + +static void _tiffUnmapProc(thandle_t fd, void* base, toff_t size) +{ + CC_UNUSED_PARAM(fd); + CC_UNUSED_PARAM(base); + CC_UNUSED_PARAM(size); } bool CCImage::_initWithTiffData(void* pData, int nDataLen) @@ -515,25 +515,25 @@ bool CCImage::_initWithTiffData(void* pData, int nDataLen) CC_BREAK_IF(NULL == tif); - uint32 w, h; - uint16 bitsPerSample, samplePerPixel, planarConfig, extraSample; - size_t npixels; - - TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &w); - TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &h); - TIFFGetField(tif, TIFFTAG_BITSPERSAMPLE, &bitsPerSample); - TIFFGetField(tif, TIFFTAG_SAMPLESPERPIXEL, &samplePerPixel); - TIFFGetField(tif, TIFFTAG_PLANARCONFIG, &planarConfig); - - npixels = w * h; - - m_bHasAlpha = true; - m_nWidth = w; - m_nHeight = h; - m_nBitsPerComponent = 8; - - m_pData = new unsigned char[npixels * sizeof (uint32)]; - + uint32 w, h; + uint16 bitsPerSample, samplePerPixel, planarConfig, extraSample; + size_t npixels; + + TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &w); + TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &h); + TIFFGetField(tif, TIFFTAG_BITSPERSAMPLE, &bitsPerSample); + TIFFGetField(tif, TIFFTAG_SAMPLESPERPIXEL, &samplePerPixel); + TIFFGetField(tif, TIFFTAG_PLANARCONFIG, &planarConfig); + + npixels = w * h; + + m_bHasAlpha = true; + m_nWidth = w; + m_nHeight = h; + m_nBitsPerComponent = 8; + + m_pData = new unsigned char[npixels * sizeof (uint32)]; + uint32* raster = (uint32*) _TIFFmalloc(npixels * sizeof (uint32)); if (raster != NULL) { @@ -550,15 +550,15 @@ bool CCImage::_initWithTiffData(void* pData, int nDataLen) src[j + 2], src[j + 3] ); } */ - m_bPreMulti = true; - + m_bPreMulti = true; + memcpy(m_pData, raster, npixels*sizeof (uint32)); } _TIFFfree(raster); - } - - + } + + TIFFClose(tif); bRet = true; diff --git a/js/JSBindings/ScriptingCore.cpp b/js/JSBindings/ScriptingCore.cpp index 3dbd714c86..33a78b4e72 100644 --- a/js/JSBindings/ScriptingCore.cpp +++ b/js/JSBindings/ScriptingCore.cpp @@ -16,254 +16,254 @@ using namespace cocos2d; static JSClass global_class = { - "global", JSCLASS_GLOBAL_FLAGS, - JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub, - JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub, - JSCLASS_NO_OPTIONAL_MEMBERS + "global", JSCLASS_GLOBAL_FLAGS, + JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub, + JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub, + JSCLASS_NO_OPTIONAL_MEMBERS }; ScriptingCore::ScriptingCore() { - this->rt = JS_NewRuntime(8 * 1024 * 1024); - this->cx = JS_NewContext(rt, 8192); - JS_SetOptions(this->cx, JSOPTION_VAROBJFIX); - JS_SetVersion(this->cx, JSVERSION_LATEST); - JS_SetErrorReporter(this->cx, ScriptingCore::reportError); - global = JS_NewCompartmentAndGlobalObject(cx, &global_class, NULL); - if (!JS_InitStandardClasses(cx, global)) { - CCLog("js error"); - } - // create the cocos namespace - JSObject *cocos = JS_NewObject(cx, NULL, NULL, NULL); - jsval cocosVal = OBJECT_TO_JSVAL(cocos); - JS_SetProperty(cx, global, "cocos", &cocosVal); + this->rt = JS_NewRuntime(8 * 1024 * 1024); + this->cx = JS_NewContext(rt, 8192); + JS_SetOptions(this->cx, JSOPTION_VAROBJFIX); + JS_SetVersion(this->cx, JSVERSION_LATEST); + JS_SetErrorReporter(this->cx, ScriptingCore::reportError); + global = JS_NewCompartmentAndGlobalObject(cx, &global_class, NULL); + if (!JS_InitStandardClasses(cx, global)) { + CCLog("js error"); + } + // create the cocos namespace + JSObject *cocos = JS_NewObject(cx, NULL, NULL, NULL); + jsval cocosVal = OBJECT_TO_JSVAL(cocos); + JS_SetProperty(cx, global, "cocos", &cocosVal); - // register the internal classes - S_CCPoint::jsCreateClass(this->cx, cocos, "Point"); - S_CCSize::jsCreateClass(this->cx, cocos, "Size"); - S_CCRect::jsCreateClass(this->cx, cocos, "Rect"); - S__ccGridSize::jsCreateClass(this->cx, cocos, "GridSize"); - S_CCSet::jsCreateClass(this->cx, cocos, "Set"); - S_CCTouch::jsCreateClass(this->cx, cocos, "Touch"); - S_CCDirector::jsCreateClass(this->cx, cocos, "Director"); - S_CCNode::jsCreateClass(this->cx, cocos, "Node"); - S_CCTextureAtlas::jsCreateClass(this->cx, cocos, "TextureAtlas"); - S_CCSpriteBatchNode::jsCreateClass(this->cx, cocos, "SpriteBatchNode"); - S_CCScene::jsCreateClass(this->cx, cocos, "Scene"); - S_CCLayer::jsCreateClass(this->cx, cocos, "Layer"); - S_CCSprite::jsCreateClass(this->cx, cocos, "Sprite"); - S_CCRenderTexture::jsCreateClass(this->cx, cocos, "RenderTexture"); - S_CCMenu::jsCreateClass(this->cx, cocos, "Menu"); - S_CCMenuItem::jsCreateClass(this->cx, cocos, "MenuItem"); - S_CCMenuItemLabel::jsCreateClass(this->cx, cocos, "MenuItemLabel"); - S_CCMenuItemSprite::jsCreateClass(this->cx, cocos, "MenuItemSprite"); - S_CCMenuItemImage::jsCreateClass(this->cx, cocos, "MenuItemImage"); - S_CCSpriteFrame::jsCreateClass(this->cx, cocos, "SpriteFrame"); - S_CCSpriteFrameCache::jsCreateClass(this->cx, cocos, "SpriteFrameCache"); - S_CCAnimation::jsCreateClass(this->cx, cocos, "Animation"); - S_CCAction::jsCreateClass(this->cx, cocos, "Action"); - S_CCActionInterval::jsCreateClass(this->cx, cocos, "ActionInterval"); - S_CCFiniteTimeAction::jsCreateClass(this->cx, cocos, "FiniteTimeAction"); - S_CCActionInstant::jsCreateClass(this->cx, cocos, "ActionInstant"); - S_CCDelayTime::jsCreateClass(this->cx, cocos, "DelayTime"); - S_CCAnimate::jsCreateClass(this->cx, cocos, "Animate"); - S_CCMoveTo::jsCreateClass(this->cx, cocos, "MoveTo"); - S_CCMoveBy::jsCreateClass(this->cx, cocos, "MoveBy"); - S_CCRotateBy::jsCreateClass(this->cx, cocos, "RotateBy"); - S_CCRotateTo::jsCreateClass(this->cx, cocos, "RotateTo"); - S_CCActionEase::jsCreateClass(this->cx, cocos, "ActionEase"); - S_CCEaseRateAction::jsCreateClass(this->cx, cocos, "EaseRateAction"); - S_CCEaseIn::jsCreateClass(this->cx, cocos, "EaseIn"); - S_CCEaseOut::jsCreateClass(this->cx, cocos, "EaseOut"); - S_CCEaseInOut::jsCreateClass(this->cx, cocos, "EaseInOut"); - S_CCEaseBackInOut::jsCreateClass(this->cx, cocos, "EaseBackInOut"); - S_CCEaseBackOut::jsCreateClass(this->cx, cocos, "EaseBackOut"); - S_CCEaseElasticIn::jsCreateClass(this->cx, cocos, "EaseElasticIn"); - S_CCEaseElastic::jsCreateClass(this->cx, cocos, "EaseElastic"); - S_CCEaseElasticOut::jsCreateClass(this->cx, cocos, "EaseElasticOut"); - S_CCEaseElasticInOut::jsCreateClass(this->cx, cocos, "EaseElasticInOut"); - S_CCEaseBounce::jsCreateClass(this->cx, cocos, "EaseBounce"); - S_CCEaseBounceIn::jsCreateClass(this->cx, cocos, "EaseBounceIn"); - S_CCEaseBounceInOut::jsCreateClass(this->cx, cocos, "EaseBounceInOut"); - S_CCEaseBackIn::jsCreateClass(this->cx, cocos, "EaseBackIn"); - S_CCEaseBounceOut::jsCreateClass(this->cx, cocos, "EaseBounceOut"); - S_CCEaseExponentialIn::jsCreateClass(this->cx, cocos, "EaseExponentialIn"); - S_CCEaseExponentialOut::jsCreateClass(this->cx, cocos, "EaseExponentialOut"); - S_CCEaseExponentialInOut::jsCreateClass(this->cx, cocos, "EaseExponentialInOut"); - S_CCEaseSineIn::jsCreateClass(this->cx, cocos, "EaseSineIn"); - S_CCEaseSineOut::jsCreateClass(this->cx, cocos, "EaseSineOut"); - S_CCEaseSineInOut::jsCreateClass(this->cx, cocos, "EaseSineInOut"); - S_CCRepeatForever::jsCreateClass(this->cx, cocos, "RepeatForever"); - S_CCSequence::jsCreateClass(this->cx, cocos, "Sequence"); - S_CCLabelTTF::jsCreateClass(this->cx, cocos, "LabelTTF"); - S_CCParticleSystem::jsCreateClass(this->cx, cocos, "ParticleSystem"); - S_CCFileUtils::jsCreateClass(this->cx, cocos, "FileUtils"); - S_CCTexture2D::jsCreateClass(this->cx, cocos, "Texture2D"); - S_CCTextureCache::jsCreateClass(this->cx, cocos, "TextureCache"); - S_CCParallaxNode::jsCreateClass(this->cx, cocos, "ParallaxNode"); - S_CCTintBy::jsCreateClass(this->cx, cocos, "TintBy"); - S_CCTintTo::jsCreateClass(this->cx, cocos, "TintTo"); - S_CCLayerColor::jsCreateClass(this->cx, cocos, "LayerColor"); - S_CCBlink::jsCreateClass(this->cx, cocos, "Blink"); - S_CCSpeed::jsCreateClass(this->cx, cocos, "Speed"); - S_CCGridAction::jsCreateClass(this->cx, cocos, "GridAction"); - S_CCGrid3DAction::jsCreateClass(this->cx, cocos, "Grid3DAction"); - S_CCWaves3D::jsCreateClass(this->cx, cocos, "Waves3D"); - S_CCTransitionScene::jsCreateClass(this->cx, cocos, "TransitionScene"); - S_CCTransitionSceneOriented::jsCreateClass(this->cx, cocos, "TransitionSceneOriented"); - S_CCTransitionRotoZoom::jsCreateClass(this->cx, cocos, "TransitionRotoZoom"); - S_CCTransitionFadeDown::jsCreateClass(this->cx, cocos, "TransitionFadeDown"); - S_CCTransitionJumpZoom::jsCreateClass(this->cx, cocos, "TransitionJumpZoom"); - S_CCTransitionMoveInL::jsCreateClass(this->cx, cocos, "TransitionMoveInL"); - S_CCTransitionMoveInR::jsCreateClass(this->cx, cocos, "TransitionMoveInR"); - S_CCTransitionMoveInT::jsCreateClass(this->cx, cocos, "TransitionMoveInT"); - S_CCTransitionMoveInB::jsCreateClass(this->cx, cocos, "TransitionMoveInB"); - S_CCTransitionSlideInL::jsCreateClass(this->cx, cocos, "TransitionSlideInL"); - S_CCTransitionSlideInR::jsCreateClass(this->cx, cocos, "TransitionSlideInR"); - S_CCTransitionSlideInB::jsCreateClass(this->cx, cocos, "TransitionSlideInB"); - S_CCTransitionSlideInT::jsCreateClass(this->cx, cocos, "TransitionSlideInT"); - S_CCTransitionShrinkGrow::jsCreateClass(this->cx, cocos, "TransitionShrinkGrow"); - S_CCTransitionFlipX::jsCreateClass(this->cx, cocos, "TransitionFlipX"); - S_CCTransitionFlipY::jsCreateClass(this->cx, cocos, "TransitionFlipY"); - S_CCTransitionFlipAngular::jsCreateClass(this->cx, cocos, "TransitionFlipAngular"); - S_CCTransitionZoomFlipX::jsCreateClass(this->cx, cocos, "TransitionZoomFlipX"); - S_CCTransitionZoomFlipY::jsCreateClass(this->cx, cocos, "TransitionZoomFlipY"); - S_CCTransitionZoomFlipAngular::jsCreateClass(this->cx, cocos, "TransitionZoomFlipAngular"); - S_CCTransitionFade::jsCreateClass(this->cx, cocos, "TransitionFade"); - S_CCTransitionCrossFade::jsCreateClass(this->cx, cocos, "TransitionCrossFade"); - S_CCTransitionTurnOffTiles::jsCreateClass(this->cx, cocos, "TransitionTurnOffTiles"); - S_CCTransitionSplitCols::jsCreateClass(this->cx, cocos, "TransitionSplitCols"); - S_CCTransitionSplitRows::jsCreateClass(this->cx, cocos, "TransitionSplitRows"); - S_CCTransitionFadeTR::jsCreateClass(this->cx, cocos, "TransitionFadeTR"); - S_CCTransitionFadeBL::jsCreateClass(this->cx, cocos, "TransitionFadeBL"); - S_CCTransitionFadeUp::jsCreateClass(this->cx, cocos, "TransitionFadeUp"); - S_CCFadeOutBLTiles::jsCreateClass(this->cx, cocos, "FadeOutBLTiles"); - S_CCProgressFromTo::jsCreateClass(this->cx, cocos, "ProgressFromTo"); - S_CCFadeOutUpTiles::jsCreateClass(this->cx, cocos, "FadeOutUpTiles"); - S_CCAnimationCache::jsCreateClass(this->cx, cocos, "AnimationCache"); - S_CCPlace::jsCreateClass(this->cx, cocos, "Place"); - S_CCLabelBMFont::jsCreateClass(this->cx, cocos, "LabelBMFont"); - S_CCReverseTime::jsCreateClass(this->cx, cocos, "ReverseTime"); - S_CCFadeOutTRTiles::jsCreateClass(this->cx, cocos, "FadeOutTRTiles"); - S_CCCamera::jsCreateClass(this->cx, cocos, "Camera"); - S_CCProgressTo::jsCreateClass(this->cx, cocos, "ProgressTo"); - S_CCWavesTiles3D::jsCreateClass(this->cx, cocos, "WavesTiles3D"); - S_CCMotionStreak::jsCreateClass(this->cx, cocos, "MotionStreak"); - S_CCTransitionProgressRadialCCW::jsCreateClass(this->cx, cocos, "TransitionRadialProgressCCW"); - S_CCFadeOutDownTiles::jsCreateClass(this->cx, cocos, "FadeOutDownTiles"); - S_CCTurnOffTiles::jsCreateClass(this->cx, cocos, "TurnOffTiles"); - S_CCDeccelAmplitude::jsCreateClass(this->cx, cocos, "DeccelAmplitude"); - S_CCProgressTimer::jsCreateClass(this->cx, cocos, "ProgressTimer"); - S_CCReuseGrid::jsCreateClass(this->cx, cocos, "ReuseGrid"); - S_CCStopGrid::jsCreateClass(this->cx, cocos, "StopGrid"); - S_CCTwirl::jsCreateClass(this->cx, cocos, "Twirl"); - S_CCShakyTiles3D::jsCreateClass(this->cx, cocos, "ShakyTiles3D"); - S_CCTransitionProgressRadialCW::jsCreateClass(this->cx, cocos, "TransitionProgressRadialCW"); - S_CCAtlasNode::jsCreateClass(this->cx, cocos, "AtlasNode"); - S_CCWaves::jsCreateClass(this->cx, cocos, "Waves"); - S_CCShow::jsCreateClass(this->cx, cocos, "Show"); - S_CCOrbitCamera::jsCreateClass(this->cx, cocos, "OrbitCamera"); - S_CCShatteredTiles3D::jsCreateClass(this->cx, cocos, "ShatteredTiles3D"); - S_CCHide::jsCreateClass(this->cx, cocos, "Hide"); - S_CCToggleVisibility::jsCreateClass(this->cx, cocos, "ToggleVisibility"); - S_CCActionCamera::jsCreateClass(this->cx, cocos, "ActionCamera"); - S_CCShuffleTiles::jsCreateClass(this->cx, cocos, "ShuffleTiles"); - S_CCLayerGradient::jsCreateClass(this->cx, cocos, "LayerGradient"); - S_CCFlipX::jsCreateClass(this->cx, cocos, "FlipX"); - S_CCRepeat::jsCreateClass(this->cx, cocos, "Repeat"); - S_CCFlipY::jsCreateClass(this->cx, cocos, "FlipY"); - S_CCBezierBy::jsCreateClass(this->cx, cocos, "BezierBy"); - S_CCPageTurn3D::jsCreateClass(this->cx, cocos, "PageTurn3D"); - S_CCLens3D::jsCreateClass(this->cx, cocos, "Lens3D"); - S_CCRipple3D::jsCreateClass(this->cx, cocos, "Ripple3D"); - S_CCApplication::jsCreateClass(this->cx, cocos, "Application"); - S_CCFlipX3D::jsCreateClass(this->cx, cocos, "FlipX3D"); - S_CCJumpTo::jsCreateClass(this->cx, cocos, "JumpTo"); - S_CCTransitionPageTurn::jsCreateClass(this->cx, cocos, "TransitionPageTurn"); - S_CCFlipY3D::jsCreateClass(this->cx, cocos, "FlipY3D"); - S_CCLiquid::jsCreateClass(this->cx, cocos, "Liquid"); - S_CCTiledGrid3DAction::jsCreateClass(this->cx, cocos, "TiledGrid3DAction"); - S_CCJumpBy::jsCreateClass(this->cx, cocos, "JumpBy"); - S_CCFollow::jsCreateClass(this->cx, cocos, "Follow"); - S_CCSkewBy::jsCreateClass(this->cx, cocos, "SkewBy"); - S_CCAccelDeccelAmplitude::jsCreateClass(this->cx, cocos, "AccelDeccelAmplitude"); - S_CCLabelAtlas::jsCreateClass(this->cx, cocos, "LabelAtlas"); - S_CCAccelAmplitude::jsCreateClass(this->cx, cocos, "AccelAmplitude"); - S_CCSkewTo::jsCreateClass(this->cx, cocos, "SkewTo"); - S_CCShaky3D::jsCreateClass(this->cx, cocos, "Shaky3D"); - S_CCSplitCols::jsCreateClass(this->cx, cocos, "SplitCols"); - S_CCFadeOut::jsCreateClass(this->cx, cocos, "FadeOut"); - S_CCTileMapAtlas::jsCreateClass(this->cx, cocos, "TileMapAtlas"); - S_CCFadeTo::jsCreateClass(this->cx, cocos, "FadeTo"); - S_CCJumpTiles3D::jsCreateClass(this->cx, cocos, "JumpTiles3D"); - S_CCFadeIn::jsCreateClass(this->cx, cocos, "FadeIn"); - S_CCSplitRows::jsCreateClass(this->cx, cocos, "SplitRows"); - S_CCScaleBy::jsCreateClass(this->cx, cocos, "ScaleBy"); - S_CCScaleTo::jsCreateClass(this->cx, cocos, "ScaleTo"); - S_CCBezierTo::jsCreateClass(this->cx, cocos, "BezierTo"); - S_CCTMXTiledMap::jsCreateClass(this->cx, cocos, "TMXTiledMap"); - S_CCTMXLayer::jsCreateClass(this->cx, cocos, "TMXLayer"); + // register the internal classes + S_CCPoint::jsCreateClass(this->cx, cocos, "Point"); + S_CCSize::jsCreateClass(this->cx, cocos, "Size"); + S_CCRect::jsCreateClass(this->cx, cocos, "Rect"); + S__ccGridSize::jsCreateClass(this->cx, cocos, "GridSize"); + S_CCSet::jsCreateClass(this->cx, cocos, "Set"); + S_CCTouch::jsCreateClass(this->cx, cocos, "Touch"); + S_CCDirector::jsCreateClass(this->cx, cocos, "Director"); + S_CCNode::jsCreateClass(this->cx, cocos, "Node"); + S_CCTextureAtlas::jsCreateClass(this->cx, cocos, "TextureAtlas"); + S_CCSpriteBatchNode::jsCreateClass(this->cx, cocos, "SpriteBatchNode"); + S_CCScene::jsCreateClass(this->cx, cocos, "Scene"); + S_CCLayer::jsCreateClass(this->cx, cocos, "Layer"); + S_CCSprite::jsCreateClass(this->cx, cocos, "Sprite"); + S_CCRenderTexture::jsCreateClass(this->cx, cocos, "RenderTexture"); + S_CCMenu::jsCreateClass(this->cx, cocos, "Menu"); + S_CCMenuItem::jsCreateClass(this->cx, cocos, "MenuItem"); + S_CCMenuItemLabel::jsCreateClass(this->cx, cocos, "MenuItemLabel"); + S_CCMenuItemSprite::jsCreateClass(this->cx, cocos, "MenuItemSprite"); + S_CCMenuItemImage::jsCreateClass(this->cx, cocos, "MenuItemImage"); + S_CCSpriteFrame::jsCreateClass(this->cx, cocos, "SpriteFrame"); + S_CCSpriteFrameCache::jsCreateClass(this->cx, cocos, "SpriteFrameCache"); + S_CCAnimation::jsCreateClass(this->cx, cocos, "Animation"); + S_CCAction::jsCreateClass(this->cx, cocos, "Action"); + S_CCActionInterval::jsCreateClass(this->cx, cocos, "ActionInterval"); + S_CCFiniteTimeAction::jsCreateClass(this->cx, cocos, "FiniteTimeAction"); + S_CCActionInstant::jsCreateClass(this->cx, cocos, "ActionInstant"); + S_CCDelayTime::jsCreateClass(this->cx, cocos, "DelayTime"); + S_CCAnimate::jsCreateClass(this->cx, cocos, "Animate"); + S_CCMoveTo::jsCreateClass(this->cx, cocos, "MoveTo"); + S_CCMoveBy::jsCreateClass(this->cx, cocos, "MoveBy"); + S_CCRotateBy::jsCreateClass(this->cx, cocos, "RotateBy"); + S_CCRotateTo::jsCreateClass(this->cx, cocos, "RotateTo"); + S_CCActionEase::jsCreateClass(this->cx, cocos, "ActionEase"); + S_CCEaseRateAction::jsCreateClass(this->cx, cocos, "EaseRateAction"); + S_CCEaseIn::jsCreateClass(this->cx, cocos, "EaseIn"); + S_CCEaseOut::jsCreateClass(this->cx, cocos, "EaseOut"); + S_CCEaseInOut::jsCreateClass(this->cx, cocos, "EaseInOut"); + S_CCEaseBackInOut::jsCreateClass(this->cx, cocos, "EaseBackInOut"); + S_CCEaseBackOut::jsCreateClass(this->cx, cocos, "EaseBackOut"); + S_CCEaseElasticIn::jsCreateClass(this->cx, cocos, "EaseElasticIn"); + S_CCEaseElastic::jsCreateClass(this->cx, cocos, "EaseElastic"); + S_CCEaseElasticOut::jsCreateClass(this->cx, cocos, "EaseElasticOut"); + S_CCEaseElasticInOut::jsCreateClass(this->cx, cocos, "EaseElasticInOut"); + S_CCEaseBounce::jsCreateClass(this->cx, cocos, "EaseBounce"); + S_CCEaseBounceIn::jsCreateClass(this->cx, cocos, "EaseBounceIn"); + S_CCEaseBounceInOut::jsCreateClass(this->cx, cocos, "EaseBounceInOut"); + S_CCEaseBackIn::jsCreateClass(this->cx, cocos, "EaseBackIn"); + S_CCEaseBounceOut::jsCreateClass(this->cx, cocos, "EaseBounceOut"); + S_CCEaseExponentialIn::jsCreateClass(this->cx, cocos, "EaseExponentialIn"); + S_CCEaseExponentialOut::jsCreateClass(this->cx, cocos, "EaseExponentialOut"); + S_CCEaseExponentialInOut::jsCreateClass(this->cx, cocos, "EaseExponentialInOut"); + S_CCEaseSineIn::jsCreateClass(this->cx, cocos, "EaseSineIn"); + S_CCEaseSineOut::jsCreateClass(this->cx, cocos, "EaseSineOut"); + S_CCEaseSineInOut::jsCreateClass(this->cx, cocos, "EaseSineInOut"); + S_CCRepeatForever::jsCreateClass(this->cx, cocos, "RepeatForever"); + S_CCSequence::jsCreateClass(this->cx, cocos, "Sequence"); + S_CCLabelTTF::jsCreateClass(this->cx, cocos, "LabelTTF"); + S_CCParticleSystem::jsCreateClass(this->cx, cocos, "ParticleSystem"); + S_CCFileUtils::jsCreateClass(this->cx, cocos, "FileUtils"); + S_CCTexture2D::jsCreateClass(this->cx, cocos, "Texture2D"); + S_CCTextureCache::jsCreateClass(this->cx, cocos, "TextureCache"); + S_CCParallaxNode::jsCreateClass(this->cx, cocos, "ParallaxNode"); + S_CCTintBy::jsCreateClass(this->cx, cocos, "TintBy"); + S_CCTintTo::jsCreateClass(this->cx, cocos, "TintTo"); + S_CCLayerColor::jsCreateClass(this->cx, cocos, "LayerColor"); + S_CCBlink::jsCreateClass(this->cx, cocos, "Blink"); + S_CCSpeed::jsCreateClass(this->cx, cocos, "Speed"); + S_CCGridAction::jsCreateClass(this->cx, cocos, "GridAction"); + S_CCGrid3DAction::jsCreateClass(this->cx, cocos, "Grid3DAction"); + S_CCWaves3D::jsCreateClass(this->cx, cocos, "Waves3D"); + S_CCTransitionScene::jsCreateClass(this->cx, cocos, "TransitionScene"); + S_CCTransitionSceneOriented::jsCreateClass(this->cx, cocos, "TransitionSceneOriented"); + S_CCTransitionRotoZoom::jsCreateClass(this->cx, cocos, "TransitionRotoZoom"); + S_CCTransitionFadeDown::jsCreateClass(this->cx, cocos, "TransitionFadeDown"); + S_CCTransitionJumpZoom::jsCreateClass(this->cx, cocos, "TransitionJumpZoom"); + S_CCTransitionMoveInL::jsCreateClass(this->cx, cocos, "TransitionMoveInL"); + S_CCTransitionMoveInR::jsCreateClass(this->cx, cocos, "TransitionMoveInR"); + S_CCTransitionMoveInT::jsCreateClass(this->cx, cocos, "TransitionMoveInT"); + S_CCTransitionMoveInB::jsCreateClass(this->cx, cocos, "TransitionMoveInB"); + S_CCTransitionSlideInL::jsCreateClass(this->cx, cocos, "TransitionSlideInL"); + S_CCTransitionSlideInR::jsCreateClass(this->cx, cocos, "TransitionSlideInR"); + S_CCTransitionSlideInB::jsCreateClass(this->cx, cocos, "TransitionSlideInB"); + S_CCTransitionSlideInT::jsCreateClass(this->cx, cocos, "TransitionSlideInT"); + S_CCTransitionShrinkGrow::jsCreateClass(this->cx, cocos, "TransitionShrinkGrow"); + S_CCTransitionFlipX::jsCreateClass(this->cx, cocos, "TransitionFlipX"); + S_CCTransitionFlipY::jsCreateClass(this->cx, cocos, "TransitionFlipY"); + S_CCTransitionFlipAngular::jsCreateClass(this->cx, cocos, "TransitionFlipAngular"); + S_CCTransitionZoomFlipX::jsCreateClass(this->cx, cocos, "TransitionZoomFlipX"); + S_CCTransitionZoomFlipY::jsCreateClass(this->cx, cocos, "TransitionZoomFlipY"); + S_CCTransitionZoomFlipAngular::jsCreateClass(this->cx, cocos, "TransitionZoomFlipAngular"); + S_CCTransitionFade::jsCreateClass(this->cx, cocos, "TransitionFade"); + S_CCTransitionCrossFade::jsCreateClass(this->cx, cocos, "TransitionCrossFade"); + S_CCTransitionTurnOffTiles::jsCreateClass(this->cx, cocos, "TransitionTurnOffTiles"); + S_CCTransitionSplitCols::jsCreateClass(this->cx, cocos, "TransitionSplitCols"); + S_CCTransitionSplitRows::jsCreateClass(this->cx, cocos, "TransitionSplitRows"); + S_CCTransitionFadeTR::jsCreateClass(this->cx, cocos, "TransitionFadeTR"); + S_CCTransitionFadeBL::jsCreateClass(this->cx, cocos, "TransitionFadeBL"); + S_CCTransitionFadeUp::jsCreateClass(this->cx, cocos, "TransitionFadeUp"); + S_CCFadeOutBLTiles::jsCreateClass(this->cx, cocos, "FadeOutBLTiles"); + S_CCProgressFromTo::jsCreateClass(this->cx, cocos, "ProgressFromTo"); + S_CCFadeOutUpTiles::jsCreateClass(this->cx, cocos, "FadeOutUpTiles"); + S_CCAnimationCache::jsCreateClass(this->cx, cocos, "AnimationCache"); + S_CCPlace::jsCreateClass(this->cx, cocos, "Place"); + S_CCLabelBMFont::jsCreateClass(this->cx, cocos, "LabelBMFont"); + S_CCReverseTime::jsCreateClass(this->cx, cocos, "ReverseTime"); + S_CCFadeOutTRTiles::jsCreateClass(this->cx, cocos, "FadeOutTRTiles"); + S_CCCamera::jsCreateClass(this->cx, cocos, "Camera"); + S_CCProgressTo::jsCreateClass(this->cx, cocos, "ProgressTo"); + S_CCWavesTiles3D::jsCreateClass(this->cx, cocos, "WavesTiles3D"); + S_CCMotionStreak::jsCreateClass(this->cx, cocos, "MotionStreak"); + S_CCTransitionProgressRadialCCW::jsCreateClass(this->cx, cocos, "TransitionRadialProgressCCW"); + S_CCFadeOutDownTiles::jsCreateClass(this->cx, cocos, "FadeOutDownTiles"); + S_CCTurnOffTiles::jsCreateClass(this->cx, cocos, "TurnOffTiles"); + S_CCDeccelAmplitude::jsCreateClass(this->cx, cocos, "DeccelAmplitude"); + S_CCProgressTimer::jsCreateClass(this->cx, cocos, "ProgressTimer"); + S_CCReuseGrid::jsCreateClass(this->cx, cocos, "ReuseGrid"); + S_CCStopGrid::jsCreateClass(this->cx, cocos, "StopGrid"); + S_CCTwirl::jsCreateClass(this->cx, cocos, "Twirl"); + S_CCShakyTiles3D::jsCreateClass(this->cx, cocos, "ShakyTiles3D"); + S_CCTransitionProgressRadialCW::jsCreateClass(this->cx, cocos, "TransitionProgressRadialCW"); + S_CCAtlasNode::jsCreateClass(this->cx, cocos, "AtlasNode"); + S_CCWaves::jsCreateClass(this->cx, cocos, "Waves"); + S_CCShow::jsCreateClass(this->cx, cocos, "Show"); + S_CCOrbitCamera::jsCreateClass(this->cx, cocos, "OrbitCamera"); + S_CCShatteredTiles3D::jsCreateClass(this->cx, cocos, "ShatteredTiles3D"); + S_CCHide::jsCreateClass(this->cx, cocos, "Hide"); + S_CCToggleVisibility::jsCreateClass(this->cx, cocos, "ToggleVisibility"); + S_CCActionCamera::jsCreateClass(this->cx, cocos, "ActionCamera"); + S_CCShuffleTiles::jsCreateClass(this->cx, cocos, "ShuffleTiles"); + S_CCLayerGradient::jsCreateClass(this->cx, cocos, "LayerGradient"); + S_CCFlipX::jsCreateClass(this->cx, cocos, "FlipX"); + S_CCRepeat::jsCreateClass(this->cx, cocos, "Repeat"); + S_CCFlipY::jsCreateClass(this->cx, cocos, "FlipY"); + S_CCBezierBy::jsCreateClass(this->cx, cocos, "BezierBy"); + S_CCPageTurn3D::jsCreateClass(this->cx, cocos, "PageTurn3D"); + S_CCLens3D::jsCreateClass(this->cx, cocos, "Lens3D"); + S_CCRipple3D::jsCreateClass(this->cx, cocos, "Ripple3D"); + S_CCApplication::jsCreateClass(this->cx, cocos, "Application"); + S_CCFlipX3D::jsCreateClass(this->cx, cocos, "FlipX3D"); + S_CCJumpTo::jsCreateClass(this->cx, cocos, "JumpTo"); + S_CCTransitionPageTurn::jsCreateClass(this->cx, cocos, "TransitionPageTurn"); + S_CCFlipY3D::jsCreateClass(this->cx, cocos, "FlipY3D"); + S_CCLiquid::jsCreateClass(this->cx, cocos, "Liquid"); + S_CCTiledGrid3DAction::jsCreateClass(this->cx, cocos, "TiledGrid3DAction"); + S_CCJumpBy::jsCreateClass(this->cx, cocos, "JumpBy"); + S_CCFollow::jsCreateClass(this->cx, cocos, "Follow"); + S_CCSkewBy::jsCreateClass(this->cx, cocos, "SkewBy"); + S_CCAccelDeccelAmplitude::jsCreateClass(this->cx, cocos, "AccelDeccelAmplitude"); + S_CCLabelAtlas::jsCreateClass(this->cx, cocos, "LabelAtlas"); + S_CCAccelAmplitude::jsCreateClass(this->cx, cocos, "AccelAmplitude"); + S_CCSkewTo::jsCreateClass(this->cx, cocos, "SkewTo"); + S_CCShaky3D::jsCreateClass(this->cx, cocos, "Shaky3D"); + S_CCSplitCols::jsCreateClass(this->cx, cocos, "SplitCols"); + S_CCFadeOut::jsCreateClass(this->cx, cocos, "FadeOut"); + S_CCTileMapAtlas::jsCreateClass(this->cx, cocos, "TileMapAtlas"); + S_CCFadeTo::jsCreateClass(this->cx, cocos, "FadeTo"); + S_CCJumpTiles3D::jsCreateClass(this->cx, cocos, "JumpTiles3D"); + S_CCFadeIn::jsCreateClass(this->cx, cocos, "FadeIn"); + S_CCSplitRows::jsCreateClass(this->cx, cocos, "SplitRows"); + S_CCScaleBy::jsCreateClass(this->cx, cocos, "ScaleBy"); + S_CCScaleTo::jsCreateClass(this->cx, cocos, "ScaleTo"); + S_CCBezierTo::jsCreateClass(this->cx, cocos, "BezierTo"); + S_CCTMXTiledMap::jsCreateClass(this->cx, cocos, "TMXTiledMap"); + S_CCTMXLayer::jsCreateClass(this->cx, cocos, "TMXLayer"); - S_SimpleAudioEngine::jsCreateClass(this->cx, cocos, "SimpleAudioEngine"); + S_SimpleAudioEngine::jsCreateClass(this->cx, cocos, "SimpleAudioEngine"); - // register some global functions - JS_DefineFunction(this->cx, global, "require", ScriptingCore::executeScript, 0, JSPROP_READONLY | JSPROP_PERMANENT); - JS_DefineFunction(this->cx, cocos, "log", ScriptingCore::log, 0, JSPROP_READONLY | JSPROP_PERMANENT); - JS_DefineFunction(this->cx, cocos, "executeScript", ScriptingCore::executeScript, 1, JSPROP_READONLY | JSPROP_PERMANENT); - JS_DefineFunction(this->cx, cocos, "addGCRootObject", ScriptingCore::addRootJS, 1, JSPROP_READONLY | JSPROP_PERMANENT); - JS_DefineFunction(this->cx, cocos, "removeGCRootObject", ScriptingCore::removeRootJS, 1, JSPROP_READONLY | JSPROP_PERMANENT); - JS_DefineFunction(this->cx, cocos, "forceGC", ScriptingCore::forceGC, 0, JSPROP_READONLY | JSPROP_PERMANENT); + // register some global functions + JS_DefineFunction(this->cx, global, "require", ScriptingCore::executeScript, 0, JSPROP_READONLY | JSPROP_PERMANENT); + JS_DefineFunction(this->cx, cocos, "log", ScriptingCore::log, 0, JSPROP_READONLY | JSPROP_PERMANENT); + JS_DefineFunction(this->cx, cocos, "executeScript", ScriptingCore::executeScript, 1, JSPROP_READONLY | JSPROP_PERMANENT); + JS_DefineFunction(this->cx, cocos, "addGCRootObject", ScriptingCore::addRootJS, 1, JSPROP_READONLY | JSPROP_PERMANENT); + JS_DefineFunction(this->cx, cocos, "removeGCRootObject", ScriptingCore::removeRootJS, 1, JSPROP_READONLY | JSPROP_PERMANENT); + JS_DefineFunction(this->cx, cocos, "forceGC", ScriptingCore::forceGC, 0, JSPROP_READONLY | JSPROP_PERMANENT); } bool ScriptingCore::evalString(const char *string, jsval *outVal) { - jsval rval; - JSString *str; - JSBool ok; - const char *filename = "noname"; - uint32_t lineno = 0; - if (outVal == NULL) { - outVal = &rval; - } - ok = JS_EvaluateScript(cx, global, string, strlen(string), filename, lineno, outVal); - if (ok == JS_FALSE) { - CCLog("error evaluating script:\n%s", string); - } - str = JS_ValueToString(cx, rval); - return ok; + jsval rval; + JSString *str; + JSBool ok; + const char *filename = "noname"; + uint32_t lineno = 0; + if (outVal == NULL) { + outVal = &rval; + } + ok = JS_EvaluateScript(cx, global, string, strlen(string), filename, lineno, outVal); + if (ok == JS_FALSE) { + CCLog("error evaluating script:\n%s", string); + } + str = JS_ValueToString(cx, rval); + return ok; } void ScriptingCore::runScript(const char *path) { #ifdef DEBUG - /** - * dpath should point to the parent directory of the "JS" folder. If this is - * set to "" (as it is now) then it will take the scripts from the app bundle. - * By setting the absolute path you can iterate the development only by - * modifying those scripts and reloading from the simulator (no recompiling/ - * relaunching) - */ -// std::string dpath("/Users/rabarca/Desktop/testjs/testjs/"); - std::string dpath(""); - dpath += path; - const char *realPath = CCFileUtils::fullPathFromRelativePath(dpath.c_str()); + /** + * dpath should point to the parent directory of the "JS" folder. If this is + * set to "" (as it is now) then it will take the scripts from the app bundle. + * By setting the absolute path you can iterate the development only by + * modifying those scripts and reloading from the simulator (no recompiling/ + * relaunching) + */ +// std::string dpath("/Users/rabarca/Desktop/testjs/testjs/"); + std::string dpath(""); + dpath += path; + const char *realPath = CCFileUtils::fullPathFromRelativePath(dpath.c_str()); #else - const char *realPath = CCFileUtils::fullPathFromRelativePath(path); + const char *realPath = CCFileUtils::fullPathFromRelativePath(path); #endif - const char* content = CCString::stringWithContentsOfFile(realPath)->getCString(); - if (content && strlen(content) > 0) { - JSBool ok; - jsval rval; - ok = JS_EvaluateScript(this->cx, this->global, (char *)content, strlen(content), path, 1, &rval); - if (ok == JS_FALSE) { - CCLog("error evaluating script:\n%s", content); - } - } + const char* content = CCString::stringWithContentsOfFile(realPath)->getCString(); + if (content && strlen(content) > 0) { + JSBool ok; + jsval rval; + ok = JS_EvaluateScript(this->cx, this->global, (char *)content, strlen(content), path, 1, &rval); + if (ok == JS_FALSE) { + CCLog("error evaluating script:\n%s", content); + } + } } ScriptingCore::~ScriptingCore() { - JS_DestroyContext(cx); - JS_DestroyRuntime(rt); - JS_ShutDown(); + JS_DestroyContext(cx); + JS_DestroyRuntime(rt); + JS_ShutDown(); } diff --git a/js/JSBindings/ScriptingCore.h b/js/JSBindings/ScriptingCore.h index 1aa5a5155c..8a58ac5681 100644 --- a/js/JSBindings/ScriptingCore.h +++ b/js/JSBindings/ScriptingCore.h @@ -14,129 +14,129 @@ class ScriptingCore { - JSRuntime *rt; - JSContext *cx; - JSObject *global; + JSRuntime *rt; + JSContext *cx; + JSObject *global; - ScriptingCore(); + ScriptingCore(); public: - ~ScriptingCore(); + ~ScriptingCore(); - static ScriptingCore & getInstance() { - static ScriptingCore instance; - return instance; - }; + static ScriptingCore & getInstance() { + static ScriptingCore instance; + return instance; + }; - /** - * will eval the specified string - * @param string The string with the javascript code to be evaluated - * @param outVal The jsval that will hold the return value of the evaluation. - * Can be NULL. - */ - bool evalString(const char *string, jsval *outVal); + /** + * will eval the specified string + * @param string The string with the javascript code to be evaluated + * @param outVal The jsval that will hold the return value of the evaluation. + * Can be NULL. + */ + bool evalString(const char *string, jsval *outVal); - /** - * will run the specified string - * @param string The path of the script to be run - */ - void runScript(const char *path); + /** + * will run the specified string + * @param string The path of the script to be run + */ + void runScript(const char *path); - /** - * @return the global context - */ - JSContext* getGlobalContext() { - return cx; - }; + /** + * @return the global context + */ + JSContext* getGlobalContext() { + return cx; + }; - /** - * @param cx - * @param message - * @param report - */ - static void reportError(JSContext *cx, const char *message, JSErrorReport *report) - { - fprintf(stderr, "%s:%u:%s\n", - report->filename ? report->filename : "", - (unsigned int) report->lineno, - message); - }; + /** + * @param cx + * @param message + * @param report + */ + static void reportError(JSContext *cx, const char *message, JSErrorReport *report) + { + fprintf(stderr, "%s:%u:%s\n", + report->filename ? report->filename : "", + (unsigned int) report->lineno, + message); + }; - /** - * Log something using CCLog - * @param cx - * @param argc - * @param vp - */ - static JSBool log(JSContext *cx, uint32_t argc, jsval *vp) - { - if (argc > 0) { - JSString *string = NULL; - JS_ConvertArguments(cx, argc, JS_ARGV(cx, vp), "S", &string); - if (string) { - char *cstr = JS_EncodeString(cx, string); - cocos2d::CCLog(cstr); - } - } - return JS_TRUE; - }; + /** + * Log something using CCLog + * @param cx + * @param argc + * @param vp + */ + static JSBool log(JSContext *cx, uint32_t argc, jsval *vp) + { + if (argc > 0) { + JSString *string = NULL; + JS_ConvertArguments(cx, argc, JS_ARGV(cx, vp), "S", &string); + if (string) { + char *cstr = JS_EncodeString(cx, string); + cocos2d::CCLog(cstr); + } + } + return JS_TRUE; + }; - /** - * run a script from script :) - */ - static JSBool executeScript(JSContext *cx, uint32_t argc, jsval *vp) - { - if (argc == 1) { - JSString *string; - if (JS_ConvertArguments(cx, argc, JS_ARGV(cx, vp), "S", &string) == JS_TRUE) { - ScriptingCore::getInstance().runScript(JS_EncodeString(cx, string)); - } - } - return JS_TRUE; - }; + /** + * run a script from script :) + */ + static JSBool executeScript(JSContext *cx, uint32_t argc, jsval *vp) + { + if (argc == 1) { + JSString *string; + if (JS_ConvertArguments(cx, argc, JS_ARGV(cx, vp), "S", &string) == JS_TRUE) { + ScriptingCore::getInstance().runScript(JS_EncodeString(cx, string)); + } + } + return JS_TRUE; + }; - /** - * Register an object as a member of the GC's root set, preventing - * them from being GC'ed - */ - static JSBool addRootJS(JSContext *cx, uint32_t argc, jsval *vp) - { - if (argc == 1) { - JSObject *o = NULL; - if (JS_ConvertArguments(cx, argc, JS_ARGV(cx, vp), "o", &o) == JS_TRUE) { - if (JS_AddObjectRoot(cx, &o) == JS_FALSE) { - cocos2d::CCLog("something went wrong when setting an object to the root"); - } - } - } - return JS_TRUE; - }; + /** + * Register an object as a member of the GC's root set, preventing + * them from being GC'ed + */ + static JSBool addRootJS(JSContext *cx, uint32_t argc, jsval *vp) + { + if (argc == 1) { + JSObject *o = NULL; + if (JS_ConvertArguments(cx, argc, JS_ARGV(cx, vp), "o", &o) == JS_TRUE) { + if (JS_AddObjectRoot(cx, &o) == JS_FALSE) { + cocos2d::CCLog("something went wrong when setting an object to the root"); + } + } + } + return JS_TRUE; + }; - /** - * removes an object from the GC's root, allowing them to be GC'ed if no - * longer referenced. - */ - static JSBool removeRootJS(JSContext *cx, uint32_t argc, jsval *vp) - { - if (argc == 1) { - JSObject *o = NULL; - if (JS_ConvertArguments(cx, argc, JS_ARGV(cx, vp), "o", &o) == JS_TRUE) { - JS_RemoveObjectRoot(cx, &o); - } - } - return JS_TRUE; - }; + /** + * removes an object from the GC's root, allowing them to be GC'ed if no + * longer referenced. + */ + static JSBool removeRootJS(JSContext *cx, uint32_t argc, jsval *vp) + { + if (argc == 1) { + JSObject *o = NULL; + if (JS_ConvertArguments(cx, argc, JS_ARGV(cx, vp), "o", &o) == JS_TRUE) { + JS_RemoveObjectRoot(cx, &o); + } + } + return JS_TRUE; + }; - /** - * Force a cycle of GC - * @param cx - * @param argc - * @param vp - */ - static JSBool forceGC(JSContext *cx, uint32_t argc, jsval *vp) - { - JS_GC(cx); - return JS_TRUE; - }; + /** + * Force a cycle of GC + * @param cx + * @param argc + * @param vp + */ + static JSBool forceGC(JSContext *cx, uint32_t argc, jsval *vp) + { + JS_GC(cx); + return JS_TRUE; + }; }; #endif diff --git a/js/JSBindings/cocos2d_manual_bindings.cpp b/js/JSBindings/cocos2d_manual_bindings.cpp index b0318ad5c7..e8a4ca5877 100644 --- a/js/JSBindings/cocos2d_manual_bindings.cpp +++ b/js/JSBindings/cocos2d_manual_bindings.cpp @@ -1,379 +1,379 @@ #include "cocos2d_generated.hpp" JSBool S_CCNode::jsaddChild(JSContext *cx, uint32_t argc, jsval *vp) { - JSObject* obj = (JSObject *)JS_THIS_OBJECT(cx, vp); - S_CCNode* self = NULL; JSGET_PTRSHELL(S_CCNode, self, obj); - if (self == NULL) return JS_FALSE; - if (argc >= 1) { - JSObject *arg0; - int zorder = 0; - int tag = 0; - JS_ConvertArguments(cx, 1, JS_ARGV(cx, vp), "o/ii", &arg0, &zorder, &tag); - CCNode* narg0; JSGET_PTRSHELL(CCNode, narg0, arg0); - // call the proper method - if (argc == 1) { - self->addChild(narg0); - } else if (argc == 2) { - self->addChild(narg0, zorder); - } else { - self->addChild(narg0, zorder, tag); - } + JSObject* obj = (JSObject *)JS_THIS_OBJECT(cx, vp); + S_CCNode* self = NULL; JSGET_PTRSHELL(S_CCNode, self, obj); + if (self == NULL) return JS_FALSE; + if (argc >= 1) { + JSObject *arg0; + int zorder = 0; + int tag = 0; + JS_ConvertArguments(cx, 1, JS_ARGV(cx, vp), "o/ii", &arg0, &zorder, &tag); + CCNode* narg0; JSGET_PTRSHELL(CCNode, narg0, arg0); + // call the proper method + if (argc == 1) { + self->addChild(narg0); + } else if (argc == 2) { + self->addChild(narg0, zorder); + } else { + self->addChild(narg0, zorder, tag); + } - JS_SET_RVAL(cx, vp, JSVAL_TRUE); - return JS_TRUE; - } - JS_SET_RVAL(cx, vp, JSVAL_TRUE); - return JS_TRUE; + JS_SET_RVAL(cx, vp, JSVAL_TRUE); + return JS_TRUE; + } + JS_SET_RVAL(cx, vp, JSVAL_TRUE); + return JS_TRUE; } JSBool S_CCMenuItemSprite::jsinitWithNormalSprite(JSContext *cx, uint32_t argc, jsval *vp) { - JSObject* obj = (JSObject *)JS_THIS_OBJECT(cx, vp); - S_CCMenuItemSprite* self = NULL; JSGET_PTRSHELL(S_CCMenuItemSprite, self, obj); - if (self == NULL) return JS_FALSE; - if (argc >= 2) { - JSObject *arg0; - JSObject *arg1; - JSObject *arg2 = NULL; - JS_ConvertArguments(cx, 5, JS_ARGV(cx, vp), "oo/o", &arg0, &arg1, &arg2); - CCNode* narg0; JSGET_PTRSHELL(CCNode, narg0, arg0); - CCNode* narg1; JSGET_PTRSHELL(CCNode, narg1, arg1); - CCNode* narg2 = NULL; if (argc == 3) JSGET_PTRSHELL(CCNode, narg2, arg2); - bool ret = self->initWithNormalSprite(narg0, narg1, narg2, self, menu_selector(S_CCMenuItemSprite::menuAction)); - JS_SET_RVAL(cx, vp, BOOLEAN_TO_JSVAL(ret)); - - return JS_TRUE; - } - JS_SET_RVAL(cx, vp, JSVAL_TRUE); - return JS_TRUE; + JSObject* obj = (JSObject *)JS_THIS_OBJECT(cx, vp); + S_CCMenuItemSprite* self = NULL; JSGET_PTRSHELL(S_CCMenuItemSprite, self, obj); + if (self == NULL) return JS_FALSE; + if (argc >= 2) { + JSObject *arg0; + JSObject *arg1; + JSObject *arg2 = NULL; + JS_ConvertArguments(cx, 5, JS_ARGV(cx, vp), "oo/o", &arg0, &arg1, &arg2); + CCNode* narg0; JSGET_PTRSHELL(CCNode, narg0, arg0); + CCNode* narg1; JSGET_PTRSHELL(CCNode, narg1, arg1); + CCNode* narg2 = NULL; if (argc == 3) JSGET_PTRSHELL(CCNode, narg2, arg2); + bool ret = self->initWithNormalSprite(narg0, narg1, narg2, self, menu_selector(S_CCMenuItemSprite::menuAction)); + JS_SET_RVAL(cx, vp, BOOLEAN_TO_JSVAL(ret)); + + return JS_TRUE; + } + JS_SET_RVAL(cx, vp, JSVAL_TRUE); + return JS_TRUE; } JSBool S_CCMenuItemImage::jsinitWithNormalImage(JSContext *cx, uint32_t argc, jsval *vp) { - JSObject* obj = (JSObject *)JS_THIS_OBJECT(cx, vp); - S_CCMenuItemImage* self = NULL; JSGET_PTRSHELL(S_CCMenuItemImage, self, obj); - if (self == NULL) return JS_FALSE; - if (argc >= 2) { - JSString *arg0; - JSString *arg1; - JSString *arg2 = NULL; - JS_ConvertArguments(cx, argc, JS_ARGV(cx, vp), "SS/S", &arg0, &arg1, &arg2); - char *narg0 = JS_EncodeString(cx, arg0); - char *narg1 = JS_EncodeString(cx, arg1); - char *narg2 = (arg2) ? JS_EncodeString(cx, arg2) : NULL; - bool ret = self->initWithNormalImage(narg0, narg1, narg2, self, menu_selector(S_CCMenuItemImage::menuAction)); - JS_SET_RVAL(cx, vp, BOOLEAN_TO_JSVAL(ret)); - - return JS_TRUE; - } - JS_SET_RVAL(cx, vp, JSVAL_TRUE); - return JS_TRUE; + JSObject* obj = (JSObject *)JS_THIS_OBJECT(cx, vp); + S_CCMenuItemImage* self = NULL; JSGET_PTRSHELL(S_CCMenuItemImage, self, obj); + if (self == NULL) return JS_FALSE; + if (argc >= 2) { + JSString *arg0; + JSString *arg1; + JSString *arg2 = NULL; + JS_ConvertArguments(cx, argc, JS_ARGV(cx, vp), "SS/S", &arg0, &arg1, &arg2); + char *narg0 = JS_EncodeString(cx, arg0); + char *narg1 = JS_EncodeString(cx, arg1); + char *narg2 = (arg2) ? JS_EncodeString(cx, arg2) : NULL; + bool ret = self->initWithNormalImage(narg0, narg1, narg2, self, menu_selector(S_CCMenuItemImage::menuAction)); + JS_SET_RVAL(cx, vp, BOOLEAN_TO_JSVAL(ret)); + + return JS_TRUE; + } + JS_SET_RVAL(cx, vp, JSVAL_TRUE); + return JS_TRUE; } JSBool S_CCSequence::jsactions(JSContext *cx, uint32_t argc, jsval *vp) { - // just like CCSequence::actions - if (argc > 0) { - jsval* argv = JS_ARGV(cx, vp); - // get first element - S_CCSequence* prev; - JSGET_PTRSHELL(S_CCSequence, prev, JSVAL_TO_OBJECT(argv[0])); - for (int i=1; i < argc; i++) { - CCFiniteTimeAction *next; JSGET_PTRSHELL(CCFiniteTimeAction, next, JSVAL_TO_OBJECT(argv[i])); - prev = (S_CCSequence *)CCSequence::actionOneTwo(prev, next); - } - // wrap prev in an action - // temporary because it's just a wrapper for an autoreleased object - // or worst case, it's an already binded object (if it's just one item in the array) - pointerShell_t* pt = (pointerShell_t *)JS_malloc(cx, sizeof(pointerShell_t)); - pt->flags = kPointerTemporary; - pt->data = prev; - JSObject* out = JS_NewObject(cx, S_CCSequence::jsClass, S_CCSequence::jsObject, NULL); - prev->jsObject = out; - JS_SetPrivate(out, pt); - JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(out)); - return JS_TRUE; - } - JS_ReportError(cx, "must call with at least one element"); - return JS_FALSE; + // just like CCSequence::actions + if (argc > 0) { + jsval* argv = JS_ARGV(cx, vp); + // get first element + S_CCSequence* prev; + JSGET_PTRSHELL(S_CCSequence, prev, JSVAL_TO_OBJECT(argv[0])); + for (int i=1; i < argc; i++) { + CCFiniteTimeAction *next; JSGET_PTRSHELL(CCFiniteTimeAction, next, JSVAL_TO_OBJECT(argv[i])); + prev = (S_CCSequence *)CCSequence::actionOneTwo(prev, next); + } + // wrap prev in an action + // temporary because it's just a wrapper for an autoreleased object + // or worst case, it's an already binded object (if it's just one item in the array) + pointerShell_t* pt = (pointerShell_t *)JS_malloc(cx, sizeof(pointerShell_t)); + pt->flags = kPointerTemporary; + pt->data = prev; + JSObject* out = JS_NewObject(cx, S_CCSequence::jsClass, S_CCSequence::jsObject, NULL); + prev->jsObject = out; + JS_SetPrivate(out, pt); + JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(out)); + return JS_TRUE; + } + JS_ReportError(cx, "must call with at least one element"); + return JS_FALSE; } JSBool S_CCParticleSystem::jsparticleWithFile(JSContext *cx, uint32_t argc, jsval *vp) { - if (argc == 1) { - JSString *arg0; - JS_ConvertArguments(cx, 1, JS_ARGV(cx, vp), "S", &arg0); - char *narg0 = JS_EncodeString(cx, arg0); - CCParticleSystem* ret = CCParticleSystemQuad::particleWithFile(narg0); - if (ret == NULL) { - JS_SET_RVAL(cx, vp, JSVAL_NULL); - return JS_TRUE; - } - do { - JSObject *tmp = JS_NewObject(cx, S_CCParticleSystem::jsClass, S_CCParticleSystem::jsObject, NULL); - pointerShell_t *pt = (pointerShell_t *)JS_malloc(cx, sizeof(pointerShell_t)); - pt->flags = kPointerTemporary; - pt->data = (void *)ret; - JS_SetPrivate(tmp, pt); - JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(tmp)); - } while (0); - - return JS_TRUE; - } - JS_SET_RVAL(cx, vp, JSVAL_TRUE); - return JS_TRUE; + if (argc == 1) { + JSString *arg0; + JS_ConvertArguments(cx, 1, JS_ARGV(cx, vp), "S", &arg0); + char *narg0 = JS_EncodeString(cx, arg0); + CCParticleSystem* ret = CCParticleSystemQuad::particleWithFile(narg0); + if (ret == NULL) { + JS_SET_RVAL(cx, vp, JSVAL_NULL); + return JS_TRUE; + } + do { + JSObject *tmp = JS_NewObject(cx, S_CCParticleSystem::jsClass, S_CCParticleSystem::jsObject, NULL); + pointerShell_t *pt = (pointerShell_t *)JS_malloc(cx, sizeof(pointerShell_t)); + pt->flags = kPointerTemporary; + pt->data = (void *)ret; + JS_SetPrivate(tmp, pt); + JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(tmp)); + } while (0); + + return JS_TRUE; + } + JS_SET_RVAL(cx, vp, JSVAL_TRUE); + return JS_TRUE; } JSBool S_CCFileUtils::jsgetFileData(JSContext *cx, uint32_t argc, jsval *vp) { - if (argc == 2) { - JSString *arg0; - JSString *arg1; - unsigned long len; - JS_ConvertArguments(cx, 2, JS_ARGV(cx, vp), "SS", &arg0, &arg1); - char *narg0 = JS_EncodeString(cx, arg0); - char *narg1 = JS_EncodeString(cx, arg1); - unsigned char *ret = CCFileUtils::getFileData(narg0, narg1, &len); - if (ret == NULL) { - JS_SET_RVAL(cx, vp, JSVAL_NULL); - return JS_TRUE; - } - JSString *str = JS_NewStringCopyN(cx, (const char *)ret, len); - JS_SET_RVAL(cx, vp, STRING_TO_JSVAL(str)); - return JS_TRUE; - } - JS_SET_RVAL(cx, vp, JSVAL_TRUE); - return JS_TRUE; + if (argc == 2) { + JSString *arg0; + JSString *arg1; + unsigned long len; + JS_ConvertArguments(cx, 2, JS_ARGV(cx, vp), "SS", &arg0, &arg1); + char *narg0 = JS_EncodeString(cx, arg0); + char *narg1 = JS_EncodeString(cx, arg1); + unsigned char *ret = CCFileUtils::getFileData(narg0, narg1, &len); + if (ret == NULL) { + JS_SET_RVAL(cx, vp, JSVAL_NULL); + return JS_TRUE; + } + JSString *str = JS_NewStringCopyN(cx, (const char *)ret, len); + JS_SET_RVAL(cx, vp, STRING_TO_JSVAL(str)); + return JS_TRUE; + } + JS_SET_RVAL(cx, vp, JSVAL_TRUE); + return JS_TRUE; } JSBool S_CCFileUtils::jsfullPathFromRelativePath(JSContext *cx, uint32_t argc, jsval *vp) { - if (argc == 1) { - JSString *arg0; - JS_ConvertArguments(cx, 1, JS_ARGV(cx, vp), "S", &arg0); - char *narg0 = JS_EncodeString(cx, arg0); - const char *ret = CCFileUtils::fullPathFromRelativePath(narg0); - if (ret == NULL) { - JS_SET_RVAL(cx, vp, JSVAL_NULL); - return JS_TRUE; - } - JSString *str = JS_NewStringCopyN(cx, ret, strlen(ret)); - JS_SET_RVAL(cx, vp, STRING_TO_JSVAL(str)); - return JS_TRUE; - } - JS_SET_RVAL(cx, vp, JSVAL_TRUE); - return JS_TRUE; + if (argc == 1) { + JSString *arg0; + JS_ConvertArguments(cx, 1, JS_ARGV(cx, vp), "S", &arg0); + char *narg0 = JS_EncodeString(cx, arg0); + const char *ret = CCFileUtils::fullPathFromRelativePath(narg0); + if (ret == NULL) { + JS_SET_RVAL(cx, vp, JSVAL_NULL); + return JS_TRUE; + } + JSString *str = JS_NewStringCopyN(cx, ret, strlen(ret)); + JS_SET_RVAL(cx, vp, STRING_TO_JSVAL(str)); + return JS_TRUE; + } + JS_SET_RVAL(cx, vp, JSVAL_TRUE); + return JS_TRUE; } JSBool S_CCFileUtils::jsfullPathFromRelativeFile(JSContext *cx, uint32_t argc, jsval *vp) { - if (argc == 2) { - JSString *arg0; - JSString *arg1; - JS_ConvertArguments(cx, 2, JS_ARGV(cx, vp), "SS", &arg0, &arg1); - char *narg0 = JS_EncodeString(cx, arg0); - char *narg1 = JS_EncodeString(cx, arg1); - const char *ret = CCFileUtils::fullPathFromRelativeFile(narg0, narg1); - if (ret == NULL) { - JS_SET_RVAL(cx, vp, JSVAL_NULL); - return JS_TRUE; - } - JSString *str = JS_NewStringCopyN(cx, ret, strlen(ret)); - JS_SET_RVAL(cx, vp, STRING_TO_JSVAL(str)); - return JS_TRUE; - - return JS_TRUE; - } - JS_SET_RVAL(cx, vp, JSVAL_TRUE); - return JS_TRUE; + if (argc == 2) { + JSString *arg0; + JSString *arg1; + JS_ConvertArguments(cx, 2, JS_ARGV(cx, vp), "SS", &arg0, &arg1); + char *narg0 = JS_EncodeString(cx, arg0); + char *narg1 = JS_EncodeString(cx, arg1); + const char *ret = CCFileUtils::fullPathFromRelativeFile(narg0, narg1); + if (ret == NULL) { + JS_SET_RVAL(cx, vp, JSVAL_NULL); + return JS_TRUE; + } + JSString *str = JS_NewStringCopyN(cx, ret, strlen(ret)); + JS_SET_RVAL(cx, vp, STRING_TO_JSVAL(str)); + return JS_TRUE; + + return JS_TRUE; + } + JS_SET_RVAL(cx, vp, JSVAL_TRUE); + return JS_TRUE; } JSBool S_CCLabelTTF::jslabelWithString(JSContext *cx, uint32_t argc, jsval *vp) { - if (argc == 5) { - JSString *arg0; - JSObject *arg1; - int arg2; - JSString *arg3; - double arg4; - JS_ConvertArguments(cx, 5, JS_ARGV(cx, vp), "SoiSd", &arg0, &arg1, &arg2, &arg3, &arg4); - char *narg0 = JS_EncodeString(cx, arg0); - CCSize* narg1; JSGET_PTRSHELL(CCSize, narg1, arg1); - char *narg3 = JS_EncodeString(cx, arg3); - CCLabelTTF *ret = CCLabelTTF::labelWithString(narg0, *narg1, (CCTextAlignment)arg2, narg3, arg4); - if (ret == NULL) { - JS_SET_RVAL(cx, vp, JSVAL_NULL); - return JS_TRUE; - } - do { - JSObject *tmp = JS_NewObject(cx, S_CCLabelTTF::jsClass, S_CCLabelTTF::jsObject, NULL); - pointerShell_t *pt = (pointerShell_t *)JS_malloc(cx, sizeof(pointerShell_t)); - pt->flags = kPointerTemporary; - pt->data = (void *)ret; - JS_SetPrivate(tmp, pt); - JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(tmp)); - } while (0); - return JS_TRUE; - } - JS_SET_RVAL(cx, vp, JSVAL_TRUE); - return JS_TRUE; + if (argc == 5) { + JSString *arg0; + JSObject *arg1; + int arg2; + JSString *arg3; + double arg4; + JS_ConvertArguments(cx, 5, JS_ARGV(cx, vp), "SoiSd", &arg0, &arg1, &arg2, &arg3, &arg4); + char *narg0 = JS_EncodeString(cx, arg0); + CCSize* narg1; JSGET_PTRSHELL(CCSize, narg1, arg1); + char *narg3 = JS_EncodeString(cx, arg3); + CCLabelTTF *ret = CCLabelTTF::labelWithString(narg0, *narg1, (CCTextAlignment)arg2, narg3, arg4); + if (ret == NULL) { + JS_SET_RVAL(cx, vp, JSVAL_NULL); + return JS_TRUE; + } + do { + JSObject *tmp = JS_NewObject(cx, S_CCLabelTTF::jsClass, S_CCLabelTTF::jsObject, NULL); + pointerShell_t *pt = (pointerShell_t *)JS_malloc(cx, sizeof(pointerShell_t)); + pt->flags = kPointerTemporary; + pt->data = (void *)ret; + JS_SetPrivate(tmp, pt); + JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(tmp)); + } while (0); + return JS_TRUE; + } + JS_SET_RVAL(cx, vp, JSVAL_TRUE); + return JS_TRUE; } JSBool S_CCLabelTTF::jsinitWithString(JSContext *cx, uint32_t argc, jsval *vp) { - JSObject* obj = (JSObject *)JS_THIS_OBJECT(cx, vp); - S_CCLabelTTF* self = NULL; JSGET_PTRSHELL(S_CCLabelTTF, self, obj); - if (self == NULL) return JS_FALSE; - if (argc == 5) { - JSString *arg0; - JSObject *arg1; - int arg2; - JSString *arg3; - double arg4; - JS_ConvertArguments(cx, 5, JS_ARGV(cx, vp), "SoiSd", &arg0, &arg1, &arg2, &arg3, &arg4); - char *narg0 = JS_EncodeString(cx, arg0); - CCSize* narg1; JSGET_PTRSHELL(CCSize, narg1, arg1); - char *narg3 = JS_EncodeString(cx, arg3); - bool ret = self->initWithString(narg0, *narg1, (CCTextAlignment)arg2, narg3, arg4); - JS_SET_RVAL(cx, vp, BOOLEAN_TO_JSVAL(ret)); - - return JS_TRUE; - } - JS_SET_RVAL(cx, vp, JSVAL_TRUE); - return JS_TRUE; + JSObject* obj = (JSObject *)JS_THIS_OBJECT(cx, vp); + S_CCLabelTTF* self = NULL; JSGET_PTRSHELL(S_CCLabelTTF, self, obj); + if (self == NULL) return JS_FALSE; + if (argc == 5) { + JSString *arg0; + JSObject *arg1; + int arg2; + JSString *arg3; + double arg4; + JS_ConvertArguments(cx, 5, JS_ARGV(cx, vp), "SoiSd", &arg0, &arg1, &arg2, &arg3, &arg4); + char *narg0 = JS_EncodeString(cx, arg0); + CCSize* narg1; JSGET_PTRSHELL(CCSize, narg1, arg1); + char *narg3 = JS_EncodeString(cx, arg3); + bool ret = self->initWithString(narg0, *narg1, (CCTextAlignment)arg2, narg3, arg4); + JS_SET_RVAL(cx, vp, BOOLEAN_TO_JSVAL(ret)); + + return JS_TRUE; + } + JS_SET_RVAL(cx, vp, JSVAL_TRUE); + return JS_TRUE; } JSBool S_CCMenuItem::jsinit(JSContext *cx, uint32_t argc, jsval *vp) { - JSObject* obj = (JSObject *)JS_THIS_OBJECT(cx, vp); - S_CCMenuItem* self = NULL; JSGET_PTRSHELL(S_CCMenuItem, self, obj); - if (self == NULL) return JS_FALSE; - if (argc == 0) { - bool ret = self->initWithTarget(self, menu_selector(S_CCMenuItem::menuAction)); - JS_SET_RVAL(cx, vp, BOOLEAN_TO_JSVAL(ret)); - - return JS_TRUE; - } - JS_SET_RVAL(cx, vp, JSVAL_TRUE); - return JS_TRUE; + JSObject* obj = (JSObject *)JS_THIS_OBJECT(cx, vp); + S_CCMenuItem* self = NULL; JSGET_PTRSHELL(S_CCMenuItem, self, obj); + if (self == NULL) return JS_FALSE; + if (argc == 0) { + bool ret = self->initWithTarget(self, menu_selector(S_CCMenuItem::menuAction)); + JS_SET_RVAL(cx, vp, BOOLEAN_TO_JSVAL(ret)); + + return JS_TRUE; + } + JS_SET_RVAL(cx, vp, JSVAL_TRUE); + return JS_TRUE; } JSBool S_CCRenderTexture::jsrenderTextureWithWidthAndHeight(JSContext *cx, uint32_t argc, jsval *vp) { - if (argc == 2) { - int arg0; - int arg1; - JS_ConvertArguments(cx, 2, JS_ARGV(cx, vp), "ii", &arg0, &arg1); - CCRenderTexture* ret = CCRenderTexture::renderTextureWithWidthAndHeight(arg0, arg1); - do { - JSObject *tmp = JS_NewObject(cx, S_CCRenderTexture::jsClass, S_CCRenderTexture::jsObject, NULL); - pointerShell_t *pt = (pointerShell_t *)JS_malloc(cx, sizeof(pointerShell_t)); - pt->flags = kPointerTemporary; - pt->data = (void *)ret; - JS_SetPrivate(tmp, pt); - JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(tmp)); - } while (0); - - return JS_TRUE; - } - JS_SET_RVAL(cx, vp, JSVAL_TRUE); - return JS_TRUE; + if (argc == 2) { + int arg0; + int arg1; + JS_ConvertArguments(cx, 2, JS_ARGV(cx, vp), "ii", &arg0, &arg1); + CCRenderTexture* ret = CCRenderTexture::renderTextureWithWidthAndHeight(arg0, arg1); + do { + JSObject *tmp = JS_NewObject(cx, S_CCRenderTexture::jsClass, S_CCRenderTexture::jsObject, NULL); + pointerShell_t *pt = (pointerShell_t *)JS_malloc(cx, sizeof(pointerShell_t)); + pt->flags = kPointerTemporary; + pt->data = (void *)ret; + JS_SetPrivate(tmp, pt); + JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(tmp)); + } while (0); + + return JS_TRUE; + } + JS_SET_RVAL(cx, vp, JSVAL_TRUE); + return JS_TRUE; } JSBool S_CCRenderTexture::jsinitWithWidthAndHeight(JSContext *cx, uint32_t argc, jsval *vp) { - JSObject* obj = (JSObject *)JS_THIS_OBJECT(cx, vp); - S_CCRenderTexture* self = NULL; JSGET_PTRSHELL(S_CCRenderTexture, self, obj); - if (self == NULL) return JS_FALSE; - if (argc == 2) { - int arg0; - int arg1; - JS_ConvertArguments(cx, 2, JS_ARGV(cx, vp), "ii", &arg0, &arg1); - bool ret = self->initWithWidthAndHeight(arg0, arg1, kCCTexture2DPixelFormat_RGBA8888); - JS_SET_RVAL(cx, vp, BOOLEAN_TO_JSVAL(ret)); - - return JS_TRUE; - } - JS_SET_RVAL(cx, vp, JSVAL_TRUE); - return JS_TRUE; + JSObject* obj = (JSObject *)JS_THIS_OBJECT(cx, vp); + S_CCRenderTexture* self = NULL; JSGET_PTRSHELL(S_CCRenderTexture, self, obj); + if (self == NULL) return JS_FALSE; + if (argc == 2) { + int arg0; + int arg1; + JS_ConvertArguments(cx, 2, JS_ARGV(cx, vp), "ii", &arg0, &arg1); + bool ret = self->initWithWidthAndHeight(arg0, arg1, kCCTexture2DPixelFormat_RGBA8888); + JS_SET_RVAL(cx, vp, BOOLEAN_TO_JSVAL(ret)); + + return JS_TRUE; + } + JS_SET_RVAL(cx, vp, JSVAL_TRUE); + return JS_TRUE; } JSBool S_CCMenuItemLabel::jsitemWithLabel(JSContext *cx, uint32_t argc, jsval *vp) { - JSObject* obj = (JSObject *)JS_THIS_OBJECT(cx, vp); - S_CCRenderTexture* self = NULL; JSGET_PTRSHELL(S_CCRenderTexture, self, obj); - if (self == NULL) return JS_FALSE; - if (argc == 1) { - JSObject *arg0; - JS_ConvertArguments(cx, 1, JS_ARGV(cx, vp), "o", &arg0); - CCNode* narg0; JSGET_PTRSHELL(CCNode, narg0, arg0); - CCMenuItemLabel *ret = CCMenuItemLabel::itemWithLabel(narg0, self, menu_selector(S_CCMenuItemLabel::menuAction)); - if (ret == NULL) { - JS_SET_RVAL(cx, vp, JSVAL_NULL); - return JS_TRUE; - } - do { - JSObject *tmp = JS_NewObject(cx, S_CCMenuItemLabel::jsClass, S_CCMenuItemLabel::jsObject, NULL); - pointerShell_t *pt = (pointerShell_t *)JS_malloc(cx, sizeof(pointerShell_t)); - pt->flags = kPointerTemporary; - pt->data = (void *)ret; - JS_SetPrivate(tmp, pt); - JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(tmp)); - } while(0); - - return JS_TRUE; - } - JS_SET_RVAL(cx, vp, JSVAL_TRUE); - return JS_TRUE; + JSObject* obj = (JSObject *)JS_THIS_OBJECT(cx, vp); + S_CCRenderTexture* self = NULL; JSGET_PTRSHELL(S_CCRenderTexture, self, obj); + if (self == NULL) return JS_FALSE; + if (argc == 1) { + JSObject *arg0; + JS_ConvertArguments(cx, 1, JS_ARGV(cx, vp), "o", &arg0); + CCNode* narg0; JSGET_PTRSHELL(CCNode, narg0, arg0); + CCMenuItemLabel *ret = CCMenuItemLabel::itemWithLabel(narg0, self, menu_selector(S_CCMenuItemLabel::menuAction)); + if (ret == NULL) { + JS_SET_RVAL(cx, vp, JSVAL_NULL); + return JS_TRUE; + } + do { + JSObject *tmp = JS_NewObject(cx, S_CCMenuItemLabel::jsClass, S_CCMenuItemLabel::jsObject, NULL); + pointerShell_t *pt = (pointerShell_t *)JS_malloc(cx, sizeof(pointerShell_t)); + pt->flags = kPointerTemporary; + pt->data = (void *)ret; + JS_SetPrivate(tmp, pt); + JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(tmp)); + } while(0); + + return JS_TRUE; + } + JS_SET_RVAL(cx, vp, JSVAL_TRUE); + return JS_TRUE; } JSBool S_CCMenuItemLabel::jsinitWithLabel(JSContext *cx, uint32_t argc, jsval *vp) { - JSObject* obj = (JSObject *)JS_THIS_OBJECT(cx, vp); - S_CCMenuItemLabel* self = NULL; JSGET_PTRSHELL(S_CCMenuItemLabel, self, obj); - if (self == NULL) return JS_FALSE; - if (argc == 1) { - JSObject *arg0; - JS_ConvertArguments(cx, 1, JS_ARGV(cx, vp), "o", &arg0); - CCNode* narg0; JSGET_PTRSHELL(CCNode, narg0, arg0); - bool ret = self->initWithLabel(narg0, self, menu_selector(S_CCMenuItemLabel::menuAction)); - JS_SET_RVAL(cx, vp, BOOLEAN_TO_JSVAL(ret)); - - return JS_TRUE; - } - JS_SET_RVAL(cx, vp, JSVAL_TRUE); - return JS_TRUE; + JSObject* obj = (JSObject *)JS_THIS_OBJECT(cx, vp); + S_CCMenuItemLabel* self = NULL; JSGET_PTRSHELL(S_CCMenuItemLabel, self, obj); + if (self == NULL) return JS_FALSE; + if (argc == 1) { + JSObject *arg0; + JS_ConvertArguments(cx, 1, JS_ARGV(cx, vp), "o", &arg0); + CCNode* narg0; JSGET_PTRSHELL(CCNode, narg0, arg0); + bool ret = self->initWithLabel(narg0, self, menu_selector(S_CCMenuItemLabel::menuAction)); + JS_SET_RVAL(cx, vp, BOOLEAN_TO_JSVAL(ret)); + + return JS_TRUE; + } + JS_SET_RVAL(cx, vp, JSVAL_TRUE); + return JS_TRUE; } JSBool S_CCApplication::jsgetCurrentLanguage(JSContext *cx, uint32_t argc, jsval *vp) { - JSObject* obj = (JSObject *)JS_THIS_OBJECT(cx, vp); - CCApplication* self = NULL; JSGET_PTRSHELL(CCApplication, self, obj); - if (self == NULL) return JS_FALSE; - jsval result; JS_NewNumberValue(cx, self->getCurrentLanguage(), &result); - JS_SET_RVAL(cx, vp, result); - return JS_TRUE; + JSObject* obj = (JSObject *)JS_THIS_OBJECT(cx, vp); + CCApplication* self = NULL; JSGET_PTRSHELL(CCApplication, self, obj); + if (self == NULL) return JS_FALSE; + jsval result; JS_NewNumberValue(cx, self->getCurrentLanguage(), &result); + JS_SET_RVAL(cx, vp, result); + return JS_TRUE; } JSBool S_CCUserDefault::jsgetStringForKey(JSContext *cx, uint32_t argc, jsval *vp) { - JSObject* obj = (JSObject *)JS_THIS_OBJECT(cx, vp); - S_CCUserDefault* self = NULL; JSGET_PTRSHELL(S_CCUserDefault, self, obj); - if (self == NULL) return JS_FALSE; - if (argc == 2) { - JSString *arg0; - JSString *arg1; - JS_ConvertArguments(cx, 2, JS_ARGV(cx, vp), "SS", &arg0, &arg1); - char *narg0 = JS_EncodeString(cx, arg0); - std::string narg1(JS_EncodeString(cx, arg1)); - std::string ret = self->getStringForKey(narg0, narg1); - JSString *jsret = JS_NewStringCopyZ(cx, ret.c_str()); - JS_SET_RVAL(cx, vp, STRING_TO_JSVAL(jsret)); - return JS_TRUE; - } - JS_SET_RVAL(cx, vp, JSVAL_TRUE); - return JS_TRUE; + JSObject* obj = (JSObject *)JS_THIS_OBJECT(cx, vp); + S_CCUserDefault* self = NULL; JSGET_PTRSHELL(S_CCUserDefault, self, obj); + if (self == NULL) return JS_FALSE; + if (argc == 2) { + JSString *arg0; + JSString *arg1; + JS_ConvertArguments(cx, 2, JS_ARGV(cx, vp), "SS", &arg0, &arg1); + char *narg0 = JS_EncodeString(cx, arg0); + std::string narg1(JS_EncodeString(cx, arg1)); + std::string ret = self->getStringForKey(narg0, narg1); + JSString *jsret = JS_NewStringCopyZ(cx, ret.c_str()); + JS_SET_RVAL(cx, vp, STRING_TO_JSVAL(jsret)); + return JS_TRUE; + } + JS_SET_RVAL(cx, vp, JSVAL_TRUE); + return JS_TRUE; } JSBool S_CCUserDefault::jssetStringForKey(JSContext *cx, uint32_t argc, jsval *vp) { - JSObject* obj = (JSObject *)JS_THIS_OBJECT(cx, vp); - S_CCUserDefault* self = NULL; JSGET_PTRSHELL(S_CCUserDefault, self, obj); - if (self == NULL) return JS_FALSE; - if (argc == 2) { - JSString *arg0; - JSString *arg1; - JS_ConvertArguments(cx, 2, JS_ARGV(cx, vp), "SS", &arg0, &arg1); - char *narg0 = JS_EncodeString(cx, arg0); - std::string narg1(JS_EncodeString(cx, arg1)); - self->setStringForKey(narg0, narg1); - - JS_SET_RVAL(cx, vp, JSVAL_TRUE); - return JS_TRUE; - } - JS_SET_RVAL(cx, vp, JSVAL_TRUE); - return JS_TRUE; + JSObject* obj = (JSObject *)JS_THIS_OBJECT(cx, vp); + S_CCUserDefault* self = NULL; JSGET_PTRSHELL(S_CCUserDefault, self, obj); + if (self == NULL) return JS_FALSE; + if (argc == 2) { + JSString *arg0; + JSString *arg1; + JS_ConvertArguments(cx, 2, JS_ARGV(cx, vp), "SS", &arg0, &arg1); + char *narg0 = JS_EncodeString(cx, arg0); + std::string narg1(JS_EncodeString(cx, arg1)); + self->setStringForKey(narg0, narg1); + + JS_SET_RVAL(cx, vp, JSVAL_TRUE); + return JS_TRUE; + } + JS_SET_RVAL(cx, vp, JSVAL_TRUE); + return JS_TRUE; } diff --git a/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id b/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id index 071a7526ac..2d1624912e 100644 --- a/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id +++ b/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id @@ -1 +1 @@ -215941887bb3ecde65ca64e6e1b5ddaacded6a7c \ No newline at end of file +5a1155c9dcd8585864efa8080d8fd42059f9ea52 \ No newline at end of file diff --git a/lua/proj.android/jni/Android.mk b/lua/proj.android/jni/Android.mk index 34739f5758..2d249968c6 100644 --- a/lua/proj.android/jni/Android.mk +++ b/lua/proj.android/jni/Android.mk @@ -7,46 +7,46 @@ LOCAL_MODULE_FILENAME := liblua LOCAL_SRC_FILES :=../../lua/lapi.c \ ../../lua/lauxlib.c \ - ../../lua/lbaselib.c \ - ../../lua/lcode.c \ - ../../lua/ldblib.c \ - ../../lua/ldebug.c \ - ../../lua/ldo.c \ - ../../lua/ldump.c \ - ../../lua/lfunc.c \ - ../../lua/lgc.c \ - ../../lua/linit.c \ - ../../lua/liolib.c \ - ../../lua/llex.c \ - ../../lua/lmathlib.c \ - ../../lua/lmem.c \ - ../../lua/loadlib.c \ - ../../lua/lobject.c \ - ../../lua/lopcodes.c \ - ../../lua/loslib.c \ - ../../lua/lparser.c \ - ../../lua/lstate.c \ - ../../lua/lstring.c \ - ../../lua/lstrlib.c \ - ../../lua/ltable.c \ - ../../lua/ltablib.c \ - ../../lua/ltm.c \ - ../../lua/lua.c \ - ../../lua/lundump.c \ - ../../lua/lvm.c \ - ../../lua/lzio.c \ - ../../lua/print.c \ - ../../tolua/tolua_event.c \ - ../../tolua/tolua_is.c \ - ../../tolua/tolua_map.c \ - ../../tolua/tolua_push.c \ - ../../tolua/tolua_to.c - + ../../lua/lbaselib.c \ + ../../lua/lcode.c \ + ../../lua/ldblib.c \ + ../../lua/ldebug.c \ + ../../lua/ldo.c \ + ../../lua/ldump.c \ + ../../lua/lfunc.c \ + ../../lua/lgc.c \ + ../../lua/linit.c \ + ../../lua/liolib.c \ + ../../lua/llex.c \ + ../../lua/lmathlib.c \ + ../../lua/lmem.c \ + ../../lua/loadlib.c \ + ../../lua/lobject.c \ + ../../lua/lopcodes.c \ + ../../lua/loslib.c \ + ../../lua/lparser.c \ + ../../lua/lstate.c \ + ../../lua/lstring.c \ + ../../lua/lstrlib.c \ + ../../lua/ltable.c \ + ../../lua/ltablib.c \ + ../../lua/ltm.c \ + ../../lua/lua.c \ + ../../lua/lundump.c \ + ../../lua/lvm.c \ + ../../lua/lzio.c \ + ../../lua/print.c \ + ../../tolua/tolua_event.c \ + ../../tolua/tolua_is.c \ + ../../tolua/tolua_map.c \ + ../../tolua/tolua_push.c \ + ../../tolua/tolua_to.c + LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../lua \ $(LOCAL_PATH)/../../tolua \ $(LOCAL_PATH)/../../cocos2dx_support - - + + LOCAL_C_INCLUDES := $(LOCAL_PATH)/ \ $(LOCAL_PATH)/../../lua diff --git a/template/msvc/CCAppWiz.win32/Templates/1033/Classes/AppDelegate.cpp b/template/msvc/CCAppWiz.win32/Templates/1033/Classes/AppDelegate.cpp index 3c29270c50..2d57ea041f 100644 --- a/template/msvc/CCAppWiz.win32/Templates/1033/Classes/AppDelegate.cpp +++ b/template/msvc/CCAppWiz.win32/Templates/1033/Classes/AppDelegate.cpp @@ -1,87 +1,87 @@ -#include "cocos2d.h" -#include "CCEGLView.h" -#include "AppDelegate.h" -[! if CC_USE_LUA] -#include "CCLuaEngine.h" -[! else] -#include "HelloWorldScene.h" -[! endif] -[! if CC_USE_COCOS_DENSHION_SIMPLE_AUDIO_ENGINE] -#include "SimpleAudioEngine.h" - -using namespace CocosDenshion; -[! endif] - -USING_NS_CC; - -AppDelegate::AppDelegate() -{ -} - -AppDelegate::~AppDelegate() -{ -[! if CC_USE_COCOS_DENSHION_SIMPLE_AUDIO_ENGINE] - SimpleAudioEngine::end(); -[! endif] -} - -bool AppDelegate::applicationDidFinishLaunching() -{ - // initialize director - CCDirector *pDirector = CCDirector::sharedDirector(); - pDirector->setOpenGLView(&CCEGLView::sharedOpenGLView()); - - // enable High Resource Mode(2x, such as iphone4) and maintains low resource on other devices. -// pDirector->enableRetinaDisplay(true); - - // turn on display FPS - pDirector->setDisplayStats(true); - - // set FPS. the default value is 1.0/60 if you don't call this - pDirector->setAnimationInterval(1.0 / 60); - -[! if CC_USE_LUA] - // register lua engine - CCScriptEngineProtocol* pEngine = CCLuaEngine::engine(); - CCScriptEngineManager::sharedManager()->setScriptEngine(pEngine); - -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) - CCString* pstrFileContent = CCString::stringWithContentsOfFile("hello.lua"); - if (pstrFileContent) - { - pEngine->executeString(pstrFileContent->getCString()); - } -#else - std::string path = CCFileUtils::fullPathFromRelativePath("hello.lua"); - pEngine->addSearchPath(path.substr(0, path.find_last_of("/")).c_str()); - pEngine->executeScriptFile(path.c_str()); -#endif -[! else] - // create a scene. it's an autorelease object - CCScene *pScene = HelloWorld::scene(); - - // run - pDirector->runWithScene(pScene); -[! endif] - return true; -} - -// This function will be called when the app is inactive. When comes a phone call,it's be invoked too -void AppDelegate::applicationDidEnterBackground() -{ - CCDirector::sharedDirector()->pause(); -[! if CC_USE_COCOS_DENSHION_SIMPLE_AUDIO_ENGINE] - - SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic(); -[! endif] -} - -// this function will be called when the app is active again -void AppDelegate::applicationWillEnterForeground() -{ - CCDirector::sharedDirector()->resume(); -[! if CC_USE_COCOS_DENSHION_SIMPLE_AUDIO_ENGINE] - - SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic(); -[! endif] -} +#include "cocos2d.h" +#include "CCEGLView.h" +#include "AppDelegate.h" +[! if CC_USE_LUA] +#include "CCLuaEngine.h" +[! else] +#include "HelloWorldScene.h" +[! endif] +[! if CC_USE_COCOS_DENSHION_SIMPLE_AUDIO_ENGINE] +#include "SimpleAudioEngine.h" + +using namespace CocosDenshion; +[! endif] + +USING_NS_CC; + +AppDelegate::AppDelegate() +{ +} + +AppDelegate::~AppDelegate() +{ +[! if CC_USE_COCOS_DENSHION_SIMPLE_AUDIO_ENGINE] + SimpleAudioEngine::end(); +[! endif] +} + +bool AppDelegate::applicationDidFinishLaunching() +{ + // initialize director + CCDirector *pDirector = CCDirector::sharedDirector(); + pDirector->setOpenGLView(&CCEGLView::sharedOpenGLView()); + + // enable High Resource Mode(2x, such as iphone4) and maintains low resource on other devices. +// pDirector->enableRetinaDisplay(true); + + // turn on display FPS + pDirector->setDisplayStats(true); + + // set FPS. the default value is 1.0/60 if you don't call this + pDirector->setAnimationInterval(1.0 / 60); + +[! if CC_USE_LUA] + // register lua engine + CCScriptEngineProtocol* pEngine = CCLuaEngine::engine(); + CCScriptEngineManager::sharedManager()->setScriptEngine(pEngine); + +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) + CCString* pstrFileContent = CCString::stringWithContentsOfFile("hello.lua"); + if (pstrFileContent) + { + pEngine->executeString(pstrFileContent->getCString()); + } +#else + std::string path = CCFileUtils::fullPathFromRelativePath("hello.lua"); + pEngine->addSearchPath(path.substr(0, path.find_last_of("/")).c_str()); + pEngine->executeScriptFile(path.c_str()); +#endif +[! else] + // create a scene. it's an autorelease object + CCScene *pScene = HelloWorld::scene(); + + // run + pDirector->runWithScene(pScene); +[! endif] + return true; +} + +// This function will be called when the app is inactive. When comes a phone call,it's be invoked too +void AppDelegate::applicationDidEnterBackground() +{ + CCDirector::sharedDirector()->pause(); +[! if CC_USE_COCOS_DENSHION_SIMPLE_AUDIO_ENGINE] + + SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic(); +[! endif] +} + +// this function will be called when the app is active again +void AppDelegate::applicationWillEnterForeground() +{ + CCDirector::sharedDirector()->resume(); +[! if CC_USE_COCOS_DENSHION_SIMPLE_AUDIO_ENGINE] + + SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic(); +[! endif] +} diff --git a/template/msvc/CCAppWiz.win32/Templates/1033/Classes/AppDelegate.h b/template/msvc/CCAppWiz.win32/Templates/1033/Classes/AppDelegate.h index f2d35bace9..65dfe75bfe 100644 --- a/template/msvc/CCAppWiz.win32/Templates/1033/Classes/AppDelegate.h +++ b/template/msvc/CCAppWiz.win32/Templates/1033/Classes/AppDelegate.h @@ -1,38 +1,38 @@ -#ifndef __APP_DELEGATE_H__ -#define __APP_DELEGATE_H__ - -#include "CCApplication.h" - -/** -@brief The cocos2d Application. - -The reason for implement as private inheritance is to hide some interface call by CCDirector. -*/ -class AppDelegate : private cocos2d::CCApplication -{ -public: - AppDelegate(); - virtual ~AppDelegate(); - - /** - @brief Implement CCDirector and CCScene init code here. - @return true Initialize success, app continue. - @return false Initialize failed, app terminate. - */ - virtual bool applicationDidFinishLaunching(); - - /** - @brief The function be called when the application enter background - @param the pointer of the application - */ - virtual void applicationDidEnterBackground(); - - /** - @brief The function be called when the application enter foreground - @param the pointer of the application - */ - virtual void applicationWillEnterForeground(); -}; - -#endif // __APP_DELEGATE_H__ - +#ifndef __APP_DELEGATE_H__ +#define __APP_DELEGATE_H__ + +#include "CCApplication.h" + +/** +@brief The cocos2d Application. + +The reason for implement as private inheritance is to hide some interface call by CCDirector. +*/ +class AppDelegate : private cocos2d::CCApplication +{ +public: + AppDelegate(); + virtual ~AppDelegate(); + + /** + @brief Implement CCDirector and CCScene init code here. + @return true Initialize success, app continue. + @return false Initialize failed, app terminate. + */ + virtual bool applicationDidFinishLaunching(); + + /** + @brief The function be called when the application enter background + @param the pointer of the application + */ + virtual void applicationDidEnterBackground(); + + /** + @brief The function be called when the application enter foreground + @param the pointer of the application + */ + virtual void applicationWillEnterForeground(); +}; + +#endif // __APP_DELEGATE_H__ + diff --git a/template/msvc/CCAppWiz.win32/Templates/1033/Classes/HelloWorldScene.cpp b/template/msvc/CCAppWiz.win32/Templates/1033/Classes/HelloWorldScene.cpp index f789b7bb1a..e85e95e66a 100644 --- a/template/msvc/CCAppWiz.win32/Templates/1033/Classes/HelloWorldScene.cpp +++ b/template/msvc/CCAppWiz.win32/Templates/1033/Classes/HelloWorldScene.cpp @@ -1,97 +1,97 @@ -#include "HelloWorldScene.h" - -using namespace cocos2d; - -CCScene* HelloWorld::scene() -{ - CCScene * scene = NULL; - do - { - // 'scene' is an autorelease object - scene = CCScene::node(); - CC_BREAK_IF(! scene); - - // 'layer' is an autorelease object - HelloWorld *layer = HelloWorld::node(); - CC_BREAK_IF(! layer); - - // add layer as a child to scene - scene->addChild(layer); - } while (0); - - // return the scene - return scene; -} - -// on "init" you need to initialize your instance -bool HelloWorld::init() -{ - bool bRet = false; - do - { - ////////////////////////////////////////////////////////////////////////// - // super init first - ////////////////////////////////////////////////////////////////////////// - - CC_BREAK_IF(! CCLayer::init()); - - ////////////////////////////////////////////////////////////////////////// - // add your codes below... - ////////////////////////////////////////////////////////////////////////// - - // 1. Add a menu item with "X" image, which is clicked to quit the program. - - // Create a "close" menu item with close icon, it's an auto release object. - CCMenuItemImage *pCloseItem = CCMenuItemImage::itemWithNormalImage( - "CloseNormal.png", - "CloseSelected.png", - this, - menu_selector(HelloWorld::menuCloseCallback)); - CC_BREAK_IF(! pCloseItem); - - // Place the menu item bottom-right conner. - pCloseItem->setPosition(ccp(CCDirector::sharedDirector()->getWinSize().width - 20, 20)); - - // Create a menu with the "close" menu item, it's an auto release object. - CCMenu* pMenu = CCMenu::menuWithItems(pCloseItem, NULL); - pMenu->setPosition(CCPointZero); - CC_BREAK_IF(! pMenu); - - // Add the menu to HelloWorld layer as a child layer. - this->addChild(pMenu, 1); - - // 2. Add a label shows "Hello World". - - // Create a label and initialize with string "Hello World". - CCLabelTTF* pLabel = CCLabelTTF::labelWithString("Hello World", "Arial", 24); - CC_BREAK_IF(! pLabel); - - // Get window size and place the label upper. - CCSize size = CCDirector::sharedDirector()->getWinSize(); - pLabel->setPosition(ccp(size.width / 2, size.height - 50)); - - // Add the label to HelloWorld layer as a child layer. - this->addChild(pLabel, 1); - - // 3. Add add a splash screen, show the cocos2d splash image. - CCSprite* pSprite = CCSprite::spriteWithFile("HelloWorld.png"); - CC_BREAK_IF(! pSprite); - - // Place the sprite on the center of the screen - pSprite->setPosition(ccp(size.width/2, size.height/2)); - - // Add the sprite to HelloWorld layer as a child layer. - this->addChild(pSprite, 0); - - bRet = true; - } while (0); - - return bRet; -} - -void HelloWorld::menuCloseCallback(CCObject* pSender) -{ - // "close" menu item clicked - CCDirector::sharedDirector()->end(); -} - +#include "HelloWorldScene.h" + +using namespace cocos2d; + +CCScene* HelloWorld::scene() +{ + CCScene * scene = NULL; + do + { + // 'scene' is an autorelease object + scene = CCScene::node(); + CC_BREAK_IF(! scene); + + // 'layer' is an autorelease object + HelloWorld *layer = HelloWorld::node(); + CC_BREAK_IF(! layer); + + // add layer as a child to scene + scene->addChild(layer); + } while (0); + + // return the scene + return scene; +} + +// on "init" you need to initialize your instance +bool HelloWorld::init() +{ + bool bRet = false; + do + { + ////////////////////////////////////////////////////////////////////////// + // super init first + ////////////////////////////////////////////////////////////////////////// + + CC_BREAK_IF(! CCLayer::init()); + + ////////////////////////////////////////////////////////////////////////// + // add your codes below... + ////////////////////////////////////////////////////////////////////////// + + // 1. Add a menu item with "X" image, which is clicked to quit the program. + + // Create a "close" menu item with close icon, it's an auto release object. + CCMenuItemImage *pCloseItem = CCMenuItemImage::itemWithNormalImage( + "CloseNormal.png", + "CloseSelected.png", + this, + menu_selector(HelloWorld::menuCloseCallback)); + CC_BREAK_IF(! pCloseItem); + + // Place the menu item bottom-right conner. + pCloseItem->setPosition(ccp(CCDirector::sharedDirector()->getWinSize().width - 20, 20)); + + // Create a menu with the "close" menu item, it's an auto release object. + CCMenu* pMenu = CCMenu::menuWithItems(pCloseItem, NULL); + pMenu->setPosition(CCPointZero); + CC_BREAK_IF(! pMenu); + + // Add the menu to HelloWorld layer as a child layer. + this->addChild(pMenu, 1); + + // 2. Add a label shows "Hello World". + + // Create a label and initialize with string "Hello World". + CCLabelTTF* pLabel = CCLabelTTF::labelWithString("Hello World", "Arial", 24); + CC_BREAK_IF(! pLabel); + + // Get window size and place the label upper. + CCSize size = CCDirector::sharedDirector()->getWinSize(); + pLabel->setPosition(ccp(size.width / 2, size.height - 50)); + + // Add the label to HelloWorld layer as a child layer. + this->addChild(pLabel, 1); + + // 3. Add add a splash screen, show the cocos2d splash image. + CCSprite* pSprite = CCSprite::spriteWithFile("HelloWorld.png"); + CC_BREAK_IF(! pSprite); + + // Place the sprite on the center of the screen + pSprite->setPosition(ccp(size.width/2, size.height/2)); + + // Add the sprite to HelloWorld layer as a child layer. + this->addChild(pSprite, 0); + + bRet = true; + } while (0); + + return bRet; +} + +void HelloWorld::menuCloseCallback(CCObject* pSender) +{ + // "close" menu item clicked + CCDirector::sharedDirector()->end(); +} + diff --git a/template/msvc/CCAppWiz.win32/Templates/1033/Classes/HelloWorldScene.h b/template/msvc/CCAppWiz.win32/Templates/1033/Classes/HelloWorldScene.h index 0f45161148..aebea7b637 100644 --- a/template/msvc/CCAppWiz.win32/Templates/1033/Classes/HelloWorldScene.h +++ b/template/msvc/CCAppWiz.win32/Templates/1033/Classes/HelloWorldScene.h @@ -1,34 +1,34 @@ -#ifndef __HELLOWORLD_SCENE_H__ -#define __HELLOWORLD_SCENE_H__ - -#include "cocos2d.h" -[! if CC_USE_BOX2D] - -#include "Box2D/Box2D.h" -[! endif] -[! if CC_USE_CHIPMUNK] - -#include "chipmunk.h" -[! endif] -[! if CC_USE_COCOS_DENSHION_SIMPLE_AUDIO_ENGINE] - -#include "SimpleAudioEngine.h" -[! endif] - -class HelloWorld : public cocos2d::CCLayer -{ -public: - // Here's a difference. Method 'init' in cocos2d-x returns bool, instead of returning 'id' in cocos2d-iphone - virtual bool init(); - - // there's no 'id' in cpp, so we recommand to return the exactly class pointer - static cocos2d::CCScene* scene(); - - // a selector callback - virtual void menuCloseCallback(CCObject* pSender); - - // implement the "static node()" method manually - LAYER_NODE_FUNC(HelloWorld); -}; - +#ifndef __HELLOWORLD_SCENE_H__ +#define __HELLOWORLD_SCENE_H__ + +#include "cocos2d.h" +[! if CC_USE_BOX2D] + +#include "Box2D/Box2D.h" +[! endif] +[! if CC_USE_CHIPMUNK] + +#include "chipmunk.h" +[! endif] +[! if CC_USE_COCOS_DENSHION_SIMPLE_AUDIO_ENGINE] + +#include "SimpleAudioEngine.h" +[! endif] + +class HelloWorld : public cocos2d::CCLayer +{ +public: + // Here's a difference. Method 'init' in cocos2d-x returns bool, instead of returning 'id' in cocos2d-iphone + virtual bool init(); + + // there's no 'id' in cpp, so we recommand to return the exactly class pointer + static cocos2d::CCScene* scene(); + + // a selector callback + virtual void menuCloseCallback(CCObject* pSender); + + // implement the "static node()" method manually + LAYER_NODE_FUNC(HelloWorld); +}; + #endif // __HELLOWORLD_SCENE_H__ \ No newline at end of file diff --git a/template/msvc/CCAppWiz.win32/Templates/1033/proj.win32/main.cpp b/template/msvc/CCAppWiz.win32/Templates/1033/proj.win32/main.cpp index 9f97c90f99..f284ee7201 100644 --- a/template/msvc/CCAppWiz.win32/Templates/1033/proj.win32/main.cpp +++ b/template/msvc/CCAppWiz.win32/Templates/1033/proj.win32/main.cpp @@ -1,40 +1,40 @@ -#include "main.h" -#include "AppDelegate.h" -#include "CCEGLView.h" - -USING_NS_CC; - -// uncomment below line, open debug console -// #define USE_WIN32_CONSOLE - -int APIENTRY _tWinMain(HINSTANCE hInstance, - HINSTANCE hPrevInstance, - LPTSTR lpCmdLine, - int nCmdShow) -{ - UNREFERENCED_PARAMETER(hPrevInstance); - UNREFERENCED_PARAMETER(lpCmdLine); - -#ifdef USE_WIN32_CONSOLE - AllocConsole(); - freopen("CONIN$", "r", stdin); - freopen("CONOUT$", "w", stdout); - freopen("CONOUT$", "w", stderr); -#endif - - // create the application instance - AppDelegate app; - CCEGLView& eglView = CCEGLView::sharedOpenGLView(); - eglView.setViewName("Hello World"); - eglView.setFrameSize(480, 320); - // set the design resolution screen size, if you want to use Design Resoulution scaled to current screen, please uncomment next line. - // eglView.setDesignResolutionSize(480, 320); - - int ret = CCApplication::sharedApplication().run(); - -#ifdef USE_WIN32_CONSOLE - FreeConsole(); -#endif - - return ret; -} +#include "main.h" +#include "AppDelegate.h" +#include "CCEGLView.h" + +USING_NS_CC; + +// uncomment below line, open debug console +// #define USE_WIN32_CONSOLE + +int APIENTRY _tWinMain(HINSTANCE hInstance, + HINSTANCE hPrevInstance, + LPTSTR lpCmdLine, + int nCmdShow) +{ + UNREFERENCED_PARAMETER(hPrevInstance); + UNREFERENCED_PARAMETER(lpCmdLine); + +#ifdef USE_WIN32_CONSOLE + AllocConsole(); + freopen("CONIN$", "r", stdin); + freopen("CONOUT$", "w", stdout); + freopen("CONOUT$", "w", stderr); +#endif + + // create the application instance + AppDelegate app; + CCEGLView& eglView = CCEGLView::sharedOpenGLView(); + eglView.setViewName("Hello World"); + eglView.setFrameSize(480, 320); + // set the design resolution screen size, if you want to use Design Resoulution scaled to current screen, please uncomment next line. + // eglView.setDesignResolutionSize(480, 320); + + int ret = CCApplication::sharedApplication().run(); + +#ifdef USE_WIN32_CONSOLE + FreeConsole(); +#endif + + return ret; +} diff --git a/template/msvc/CCAppWiz.win32/Templates/1033/proj.win32/main.h b/template/msvc/CCAppWiz.win32/Templates/1033/proj.win32/main.h index 45b862cc00..abe1c3a007 100644 --- a/template/msvc/CCAppWiz.win32/Templates/1033/proj.win32/main.h +++ b/template/msvc/CCAppWiz.win32/Templates/1033/proj.win32/main.h @@ -1,13 +1,13 @@ -#ifndef __MAIN_H__ -#define __MAIN_H__ - -#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers - -// Windows Header Files: -#include -#include - -// C RunTime Header Files -#include "CCStdC.h" - -#endif // __WINMAIN_H__ +#ifndef __MAIN_H__ +#define __MAIN_H__ + +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers + +// Windows Header Files: +#include +#include + +// C RunTime Header Files +#include "CCStdC.h" + +#endif // __WINMAIN_H__ diff --git a/template/msvc/CCAppWiz.win32/Templates/1033/proj.win32/resource.h b/template/msvc/CCAppWiz.win32/Templates/1033/proj.win32/resource.h index 4132eda4e2..58684d7c8a 100644 --- a/template/msvc/CCAppWiz.win32/Templates/1033/proj.win32/resource.h +++ b/template/msvc/CCAppWiz.win32/Templates/1033/proj.win32/resource.h @@ -1,22 +1,22 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by [!output PROJECT_NAME].RC -// - -[!if WTL_COM_SERVER] -#define IDS_PROJNAME 100 -#define IDR_[!output UPPERCASE_SAFE_PROJECT_NAME] 100 -[!endif] - -#define ID_FILE_NEW_WINDOW 32771 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 201 -#define _APS_NEXT_CONTROL_VALUE 1000 -#define _APS_NEXT_SYMED_VALUE 101 -#define _APS_NEXT_COMMAND_VALUE 32775 -#endif -#endif +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by [!output PROJECT_NAME].RC +// + +[!if WTL_COM_SERVER] +#define IDS_PROJNAME 100 +#define IDR_[!output UPPERCASE_SAFE_PROJECT_NAME] 100 +[!endif] + +#define ID_FILE_NEW_WINDOW 32771 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 201 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_SYMED_VALUE 101 +#define _APS_NEXT_COMMAND_VALUE 32775 +#endif +#endif diff --git a/template/xcode4/cocos2dx_lua.xctemplate/Classes/AppDelegate.cpp b/template/xcode4/cocos2dx_lua.xctemplate/Classes/AppDelegate.cpp index 7649a5ff8e..fa0a03eff9 100644 --- a/template/xcode4/cocos2dx_lua.xctemplate/Classes/AppDelegate.cpp +++ b/template/xcode4/cocos2dx_lua.xctemplate/Classes/AppDelegate.cpp @@ -42,12 +42,12 @@ bool AppDelegate::applicationDidFinishLaunching() CCScriptEngineProtocol* pEngine = CCLuaEngine::engine(); CCScriptEngineManager::sharedManager()->setScriptEngine(pEngine); -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) - CCString* pstrFileContent = CCString::stringWithContentsOfFile("hello.lua"); - if (pstrFileContent) - { - pEngine->executeString(pstrFileContent->getCString()); - } +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) + CCString* pstrFileContent = CCString::stringWithContentsOfFile("hello.lua"); + if (pstrFileContent) + { + pEngine->executeString(pstrFileContent->getCString()); + } #else string path = CCFileUtils::fullPathFromRelativePath("hello.lua"); pEngine->addSearchPath(path.substr(0, path.find_last_of("/")).c_str()); diff --git a/testjs/Classes/AppDelegate.cpp b/testjs/Classes/AppDelegate.cpp index c7be9078bf..38dc2e91c1 100644 --- a/testjs/Classes/AppDelegate.cpp +++ b/testjs/Classes/AppDelegate.cpp @@ -1,85 +1,85 @@ -// -// testjsAppDelegate.cpp -// testjs -// -// Created by Rolando Abarca on 3/19/12. -// Copyright __MyCompanyName__ 2012. All rights reserved. -// - -#include "AppDelegate.h" - -#include "cocos2d.h" -#include "simple_native_generated.hpp" - -USING_NS_CC; - -AppDelegate::AppDelegate() -{ - -} - -AppDelegate::~AppDelegate() -{ - -} - -bool AppDelegate::applicationDidFinishLaunching() -{ - // initialize director - CCDirector *pDirector = CCDirector::sharedDirector(); - pDirector->setOpenGLView(&CCEGLView::sharedOpenGLView()); - - // enable High Resource Mode(2x, such as iphone4) and maintains low resource on other devices. - // pDirector->enableRetinaDisplay(true); - - // sets landscape mode - // pDirector->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft); - - // turn on display FPS - pDirector->setDisplayStats(true); - - // set FPS. the default value is 1.0/60 if you don't call this - pDirector->setAnimationInterval(1.0 / 60); - - // add our generated bindings - /* - JSContext *cx = ScriptingCore::getInstance().getGlobalContext(); - JSObject *obj = JS_GetGlobalObject(cx); - // since we pass the global object as the second argument, so these classes - // will also be "global" much like properties added to "window" or "document" - // in a browser - S_SimpleNativeClass::jsCreateClass(cx, obj, "SimpleNativeClass"); - S_AnotherClass::jsCreateClass(cx, obj, "AnotherClass"); - register_enums_simple_native_generated(obj); - ScriptingCore::getInstance().runScript("Javascript/1to1/test_bindings.js"); - */ - - // run the main script - ScriptingCore::getInstance().runScript("JS/1to1/test_actions.js"); -// ScriptingCore::getInstance().runScript("JS/1to1/test_ease_actions.js"); -// ScriptingCore::getInstance().runScript("JS/1to1/test_particles.js"); -// ScriptingCore::getInstance().runScript("JS/1to1/test_layer.js"); -// ScriptingCore::getInstance().runScript("JS/1to1/test_sound.js"); -// ScriptingCore::getInstance().runScript("JS/1to1/test_transitions.js"); -// ScriptingCore::getInstance().runScript("JS/1to1/test_require.js"); - - return true; -} - -// This function will be called when the app is inactive. When comes a phone call,it's be invoked too -void AppDelegate::applicationDidEnterBackground() -{ - CCDirector::sharedDirector()->pause(); - - // if you use SimpleAudioEngine, it must be pause - // SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic(); -} - -// this function will be called when the app is active again -void AppDelegate::applicationWillEnterForeground() -{ - CCDirector::sharedDirector()->resume(); - - // if you use SimpleAudioEngine, it must resume here - // SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic(); -} +// +// testjsAppDelegate.cpp +// testjs +// +// Created by Rolando Abarca on 3/19/12. +// Copyright __MyCompanyName__ 2012. All rights reserved. +// + +#include "AppDelegate.h" + +#include "cocos2d.h" +#include "simple_native_generated.hpp" + +USING_NS_CC; + +AppDelegate::AppDelegate() +{ + +} + +AppDelegate::~AppDelegate() +{ + +} + +bool AppDelegate::applicationDidFinishLaunching() +{ + // initialize director + CCDirector *pDirector = CCDirector::sharedDirector(); + pDirector->setOpenGLView(&CCEGLView::sharedOpenGLView()); + + // enable High Resource Mode(2x, such as iphone4) and maintains low resource on other devices. + // pDirector->enableRetinaDisplay(true); + + // sets landscape mode + // pDirector->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft); + + // turn on display FPS + pDirector->setDisplayStats(true); + + // set FPS. the default value is 1.0/60 if you don't call this + pDirector->setAnimationInterval(1.0 / 60); + + // add our generated bindings + /* + JSContext *cx = ScriptingCore::getInstance().getGlobalContext(); + JSObject *obj = JS_GetGlobalObject(cx); + // since we pass the global object as the second argument, so these classes + // will also be "global" much like properties added to "window" or "document" + // in a browser + S_SimpleNativeClass::jsCreateClass(cx, obj, "SimpleNativeClass"); + S_AnotherClass::jsCreateClass(cx, obj, "AnotherClass"); + register_enums_simple_native_generated(obj); + ScriptingCore::getInstance().runScript("Javascript/1to1/test_bindings.js"); + */ + + // run the main script + ScriptingCore::getInstance().runScript("JS/1to1/test_actions.js"); +// ScriptingCore::getInstance().runScript("JS/1to1/test_ease_actions.js"); +// ScriptingCore::getInstance().runScript("JS/1to1/test_particles.js"); +// ScriptingCore::getInstance().runScript("JS/1to1/test_layer.js"); +// ScriptingCore::getInstance().runScript("JS/1to1/test_sound.js"); +// ScriptingCore::getInstance().runScript("JS/1to1/test_transitions.js"); +// ScriptingCore::getInstance().runScript("JS/1to1/test_require.js"); + + return true; +} + +// This function will be called when the app is inactive. When comes a phone call,it's be invoked too +void AppDelegate::applicationDidEnterBackground() +{ + CCDirector::sharedDirector()->pause(); + + // if you use SimpleAudioEngine, it must be pause + // SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic(); +} + +// this function will be called when the app is active again +void AppDelegate::applicationWillEnterForeground() +{ + CCDirector::sharedDirector()->resume(); + + // if you use SimpleAudioEngine, it must resume here + // SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic(); +} diff --git a/testjs/Classes/AppDelegate.h b/testjs/Classes/AppDelegate.h index 2f481f8165..e6047ffe91 100644 --- a/testjs/Classes/AppDelegate.h +++ b/testjs/Classes/AppDelegate.h @@ -1,47 +1,47 @@ -// -// testjsAppDelegate.h -// testjs -// -// Created by Rolando Abarca on 3/19/12. -// Copyright __MyCompanyName__ 2012. All rights reserved. -// - -#ifndef _APP_DELEGATE_H_ -#define _APP_DELEGATE_H_ - -#include "CCApplication.h" -#include "ScriptingCore.h" - -/** -@brief The cocos2d Application. - -The reason for implement as private inheritance is to hide some interface call by CCDirector. -*/ -class AppDelegate : private cocos2d::CCApplication -{ -public: - AppDelegate(); - virtual ~AppDelegate(); - - /** - @brief Implement CCDirector and CCScene init code here. - @return true Initialize success, app continue. - @return false Initialize failed, app terminate. - */ - virtual bool applicationDidFinishLaunching(); - - /** - @brief The function be called when the application enter background - @param the pointer of the application - */ - virtual void applicationDidEnterBackground(); - - /** - @brief The function be called when the application enter foreground - @param the pointer of the application - */ - virtual void applicationWillEnterForeground(); -}; - -#endif // _APP_DELEGATE_H_ - +// +// testjsAppDelegate.h +// testjs +// +// Created by Rolando Abarca on 3/19/12. +// Copyright __MyCompanyName__ 2012. All rights reserved. +// + +#ifndef _APP_DELEGATE_H_ +#define _APP_DELEGATE_H_ + +#include "CCApplication.h" +#include "ScriptingCore.h" + +/** +@brief The cocos2d Application. + +The reason for implement as private inheritance is to hide some interface call by CCDirector. +*/ +class AppDelegate : private cocos2d::CCApplication +{ +public: + AppDelegate(); + virtual ~AppDelegate(); + + /** + @brief Implement CCDirector and CCScene init code here. + @return true Initialize success, app continue. + @return false Initialize failed, app terminate. + */ + virtual bool applicationDidFinishLaunching(); + + /** + @brief The function be called when the application enter background + @param the pointer of the application + */ + virtual void applicationDidEnterBackground(); + + /** + @brief The function be called when the application enter foreground + @param the pointer of the application + */ + virtual void applicationWillEnterForeground(); +}; + +#endif // _APP_DELEGATE_H_ + diff --git a/testjs/Classes/simple_class.cpp b/testjs/Classes/simple_class.cpp index 3bf0f1c9ef..e4308bd910 100644 --- a/testjs/Classes/simple_class.cpp +++ b/testjs/Classes/simple_class.cpp @@ -7,10 +7,10 @@ SimpleNativeClass::SimpleNativeClass() { - // just set some fields - m_someField = 0; - m_someOtherField = 10; - m_anotherMoreComplexField = NULL; + // just set some fields + m_someField = 0; + m_someOtherField = 10; + m_anotherMoreComplexField = NULL; } // empty destructor @@ -21,25 +21,25 @@ SimpleNativeClass::~SimpleNativeClass() // just a very simple function :) int SimpleNativeClass::doSomeProcessing(std::string arg1, std::string arg2) { - return arg1.length() + arg2.length(); + return arg1.length() + arg2.length(); } void SimpleNativeClass::setAnotherMoreComplexField(const char *str) { - if (m_anotherMoreComplexField) { - free(m_anotherMoreComplexField); - } - size_t len = strlen(str); - m_anotherMoreComplexField = (char *)malloc(len); - memcpy(m_anotherMoreComplexField, str, len); + if (m_anotherMoreComplexField) { + free(m_anotherMoreComplexField); + } + size_t len = strlen(str); + m_anotherMoreComplexField = (char *)malloc(len); + memcpy(m_anotherMoreComplexField, str, len); } namespace SomeNamespace { AnotherClass::AnotherClass() { - justOneField = 1313; - aPublicField = 1337; + justOneField = 1313; + aPublicField = 1337; } // empty destructor AnotherClass::~AnotherClass() @@ -47,6 +47,6 @@ AnotherClass::~AnotherClass() } void AnotherClass::doSomethingSimple() { - fprintf(stderr, "just doing something simple\n"); + fprintf(stderr, "just doing something simple\n"); } }; diff --git a/testjs/Classes/simple_class.h b/testjs/Classes/simple_class.h index 62214ac9f4..8f33b5ad7e 100644 --- a/testjs/Classes/simple_class.h +++ b/testjs/Classes/simple_class.h @@ -6,57 +6,57 @@ class SimpleNativeClass { protected: - int m_someField; - int m_someOtherField; - char* m_anotherMoreComplexField; + int m_someField; + int m_someOtherField; + char* m_anotherMoreComplexField; public: - SimpleNativeClass(); - ~SimpleNativeClass(); + SimpleNativeClass(); + ~SimpleNativeClass(); - // these methods are simple, can be defined inline - int getSomeField() { - return m_someField; - }; - int getSomeOtherField() { - return m_someOtherField; - }; - char *getAnotherMoreComplexField() { - return m_anotherMoreComplexField; - } - void setSomeField(int f) { - m_someField = f; - } - void setSomeOtherField(int f) { - m_someOtherField = f; - } - void setAnotherMoreComplexField(const char *str); + // these methods are simple, can be defined inline + int getSomeField() { + return m_someField; + }; + int getSomeOtherField() { + return m_someOtherField; + }; + char *getAnotherMoreComplexField() { + return m_anotherMoreComplexField; + } + void setSomeField(int f) { + m_someField = f; + } + void setSomeOtherField(int f) { + m_someOtherField = f; + } + void setAnotherMoreComplexField(const char *str); - // std::string not working yet! - int doSomeProcessing(std::string arg1, std::string arg2); + // std::string not working yet! + int doSomeProcessing(std::string arg1, std::string arg2); }; namespace SomeNamespace { class AnotherClass { protected: - int justOneField; + int justOneField; public: - int aPublicField; + int aPublicField; - AnotherClass(); - ~AnotherClass(); + AnotherClass(); + ~AnotherClass(); - // also simple methods, can be defined inline - int getJustOneField() { - return justOneField; - } - // wrong setter - won't work (needs ONLY one parameter in order to work) - void setJustOneField() { - justOneField = 999; - } + // also simple methods, can be defined inline + int getJustOneField() { + return justOneField; + } + // wrong setter - won't work (needs ONLY one parameter in order to work) + void setJustOneField() { + justOneField = 999; + } - void doSomethingSimple(); + void doSomethingSimple(); }; }; diff --git a/testjs/proj.android/jni/Android.mk b/testjs/proj.android/jni/Android.mk index d9cdbb6303..8c5afa3441 100644 --- a/testjs/proj.android/jni/Android.mk +++ b/testjs/proj.android/jni/Android.mk @@ -1,29 +1,29 @@ -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := test_js_shared - -LOCAL_MODULE_FILENAME := libtestjs - -LOCAL_SRC_FILES := helloworld/main.cpp \ +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) + +LOCAL_MODULE := test_js_shared + +LOCAL_MODULE_FILENAME := libtestjs + +LOCAL_SRC_FILES := helloworld/main.cpp \ ../../Classes/AppDelegate.cpp \ ../../Classes/simple_class.cpp \ ../../Classes/simple_native_generated.cpp \ ../../../js/JSBindings/cocos_denshion_generated.cpp \ ../../../js/JSBindings/cocos2d_generated.cpp \ ../../../js/JSBindings/cocos2d_manual_bindings.cpp \ - ../../../js/JSBindings/ScriptingCore.cpp - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes - + ../../../js/JSBindings/ScriptingCore.cpp + +LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes + LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static LOCAL_WHOLE_STATIC_LIBRARIES += cocos_spidermonkey_static -LOCAL_WHOLE_STATIC_LIBRARIES += cocosdenshion_static - -include $(BUILD_SHARED_LIBRARY) - +LOCAL_WHOLE_STATIC_LIBRARIES += cocosdenshion_static + +include $(BUILD_SHARED_LIBRARY) + $(call import-module,cocos2dx) $(call import-module,CocosDenshion/android) -$(call import-module,spidermonkey-android) - +$(call import-module,spidermonkey-android) + diff --git a/testjs/proj.android/jni/Application.mk b/testjs/proj.android/jni/Application.mk index 0ba4ae3a9c..22d424dab7 100644 --- a/testjs/proj.android/jni/Application.mk +++ b/testjs/proj.android/jni/Application.mk @@ -1,2 +1,2 @@ -APP_STL := gnustl_static +APP_STL := gnustl_static APP_CPPFLAGS := -frtti \ No newline at end of file diff --git a/testjs/proj.ios/AppController.h b/testjs/proj.ios/AppController.h index e301334d85..10287bd13f 100644 --- a/testjs/proj.ios/AppController.h +++ b/testjs/proj.ios/AppController.h @@ -10,7 +10,7 @@ @interface AppController : NSObject { UIWindow *window; - RootViewController *viewController; + RootViewController *viewController; } @end diff --git a/testjs/proj.ios/AppController.mm b/testjs/proj.ios/AppController.mm index 0f397bf831..187e55ed48 100644 --- a/testjs/proj.ios/AppController.mm +++ b/testjs/proj.ios/AppController.mm @@ -56,14 +56,14 @@ static AppDelegate s_sharedApplication; Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. */ - cocos2d::CCDirector::sharedDirector()->pause(); + cocos2d::CCDirector::sharedDirector()->pause(); } - (void)applicationDidBecomeActive:(UIApplication *)application { /* Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. */ - cocos2d::CCDirector::sharedDirector()->resume(); + cocos2d::CCDirector::sharedDirector()->resume(); } - (void)applicationDidEnterBackground:(UIApplication *)application { diff --git a/testjs/proj.ios/RootViewController.mm b/testjs/proj.ios/RootViewController.mm index 2bfb6f241c..9dda5a1846 100644 --- a/testjs/proj.ios/RootViewController.mm +++ b/testjs/proj.ios/RootViewController.mm @@ -36,10 +36,10 @@ */ // Override to allow orientations other than the default landscape orientation. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { - return UIInterfaceOrientationIsLandscape( interfaceOrientation ); + return UIInterfaceOrientationIsLandscape( interfaceOrientation ); // switch to this line if you want to set portrait view -// return UIInterfaceOrientationIsPortrait( interfaceOrientation ); +// return UIInterfaceOrientationIsPortrait( interfaceOrientation ); } - (void)didReceiveMemoryWarning { diff --git a/testjs/proj.win32/main.cpp b/testjs/proj.win32/main.cpp index 9f97c90f99..f284ee7201 100644 --- a/testjs/proj.win32/main.cpp +++ b/testjs/proj.win32/main.cpp @@ -1,40 +1,40 @@ -#include "main.h" -#include "AppDelegate.h" -#include "CCEGLView.h" - -USING_NS_CC; - -// uncomment below line, open debug console -// #define USE_WIN32_CONSOLE - -int APIENTRY _tWinMain(HINSTANCE hInstance, - HINSTANCE hPrevInstance, - LPTSTR lpCmdLine, - int nCmdShow) -{ - UNREFERENCED_PARAMETER(hPrevInstance); - UNREFERENCED_PARAMETER(lpCmdLine); - -#ifdef USE_WIN32_CONSOLE - AllocConsole(); - freopen("CONIN$", "r", stdin); - freopen("CONOUT$", "w", stdout); - freopen("CONOUT$", "w", stderr); -#endif - - // create the application instance - AppDelegate app; - CCEGLView& eglView = CCEGLView::sharedOpenGLView(); - eglView.setViewName("Hello World"); - eglView.setFrameSize(480, 320); - // set the design resolution screen size, if you want to use Design Resoulution scaled to current screen, please uncomment next line. - // eglView.setDesignResolutionSize(480, 320); - - int ret = CCApplication::sharedApplication().run(); - -#ifdef USE_WIN32_CONSOLE - FreeConsole(); -#endif - - return ret; -} +#include "main.h" +#include "AppDelegate.h" +#include "CCEGLView.h" + +USING_NS_CC; + +// uncomment below line, open debug console +// #define USE_WIN32_CONSOLE + +int APIENTRY _tWinMain(HINSTANCE hInstance, + HINSTANCE hPrevInstance, + LPTSTR lpCmdLine, + int nCmdShow) +{ + UNREFERENCED_PARAMETER(hPrevInstance); + UNREFERENCED_PARAMETER(lpCmdLine); + +#ifdef USE_WIN32_CONSOLE + AllocConsole(); + freopen("CONIN$", "r", stdin); + freopen("CONOUT$", "w", stdout); + freopen("CONOUT$", "w", stderr); +#endif + + // create the application instance + AppDelegate app; + CCEGLView& eglView = CCEGLView::sharedOpenGLView(); + eglView.setViewName("Hello World"); + eglView.setFrameSize(480, 320); + // set the design resolution screen size, if you want to use Design Resoulution scaled to current screen, please uncomment next line. + // eglView.setDesignResolutionSize(480, 320); + + int ret = CCApplication::sharedApplication().run(); + +#ifdef USE_WIN32_CONSOLE + FreeConsole(); +#endif + + return ret; +} diff --git a/testjs/proj.win32/main.h b/testjs/proj.win32/main.h index 45b862cc00..abe1c3a007 100644 --- a/testjs/proj.win32/main.h +++ b/testjs/proj.win32/main.h @@ -1,13 +1,13 @@ -#ifndef __MAIN_H__ -#define __MAIN_H__ - -#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers - -// Windows Header Files: -#include -#include - -// C RunTime Header Files -#include "CCStdC.h" - -#endif // __WINMAIN_H__ +#ifndef __MAIN_H__ +#define __MAIN_H__ + +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers + +// Windows Header Files: +#include +#include + +// C RunTime Header Files +#include "CCStdC.h" + +#endif // __WINMAIN_H__ diff --git a/testjs/proj.win32/resource.h b/testjs/proj.win32/resource.h index 04067c8f95..a4cfa38af8 100644 --- a/testjs/proj.win32/resource.h +++ b/testjs/proj.win32/resource.h @@ -1,20 +1,20 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by testjs.RC -// - -#define IDS_PROJNAME 100 -#define IDR_TESTJS 100 - -#define ID_FILE_NEW_WINDOW 32771 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 201 -#define _APS_NEXT_CONTROL_VALUE 1000 -#define _APS_NEXT_SYMED_VALUE 101 -#define _APS_NEXT_COMMAND_VALUE 32775 -#endif -#endif +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by testjs.RC +// + +#define IDS_PROJNAME 100 +#define IDR_TESTJS 100 + +#define ID_FILE_NEW_WINDOW 32771 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 201 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_SYMED_VALUE 101 +#define _APS_NEXT_COMMAND_VALUE 32775 +#endif +#endif diff --git a/tests/proj.android/jni/Android.mk b/tests/proj.android/jni/Android.mk index af5fbb2e97..ee1baa0f98 100644 --- a/tests/proj.android/jni/Android.mk +++ b/tests/proj.android/jni/Android.mk @@ -1,26 +1,26 @@ -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := cocos_tests_android - -LOCAL_MODULE_FILENAME := libtests - -LOCAL_SRC_FILES := tests/main.cpp - -LOCAL_STATIC_LIBRARIES := curl_static_prebuilt - -LOCAL_WHOLE_STATIC_LIBRARIES := cocos_tests_common -LOCAL_WHOLE_STATIC_LIBRARIES += cocos2dx_static -LOCAL_WHOLE_STATIC_LIBRARIES += cocosdenshion_static -LOCAL_WHOLE_STATIC_LIBRARIES += box2d_static -LOCAL_WHOLE_STATIC_LIBRARIES += chipmunk_static - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,tests) -$(call import-module,cocos2dx) -$(call import-module,cocos2dx/platform/third_party/android/prebuilt/libcurl) -$(call import-module,CocosDenshion/android) -$(call import-module,Box2D) -$(call import-module,chipmunk) +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) + +LOCAL_MODULE := cocos_tests_android + +LOCAL_MODULE_FILENAME := libtests + +LOCAL_SRC_FILES := tests/main.cpp + +LOCAL_STATIC_LIBRARIES := curl_static_prebuilt + +LOCAL_WHOLE_STATIC_LIBRARIES := cocos_tests_common +LOCAL_WHOLE_STATIC_LIBRARIES += cocos2dx_static +LOCAL_WHOLE_STATIC_LIBRARIES += cocosdenshion_static +LOCAL_WHOLE_STATIC_LIBRARIES += box2d_static +LOCAL_WHOLE_STATIC_LIBRARIES += chipmunk_static + +include $(BUILD_SHARED_LIBRARY) + +$(call import-module,tests) +$(call import-module,cocos2dx) +$(call import-module,cocos2dx/platform/third_party/android/prebuilt/libcurl) +$(call import-module,CocosDenshion/android) +$(call import-module,Box2D) +$(call import-module,chipmunk) diff --git a/tests/proj.android/jni/Application.mk b/tests/proj.android/jni/Application.mk index 8787d5227b..cf42fcc70e 100644 --- a/tests/proj.android/jni/Application.mk +++ b/tests/proj.android/jni/Application.mk @@ -1,2 +1,2 @@ -APP_STL := gnustl_static -APP_CPPFLAGS := -frtti +APP_STL := gnustl_static +APP_CPPFLAGS := -frtti diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/CocosBuilderTest.cpp b/tests/tests/ExtensionsTest/CocosBuilderTest/CocosBuilderTest.cpp index 2e7bab8b24..0469bbbb03 100644 --- a/tests/tests/ExtensionsTest/CocosBuilderTest/CocosBuilderTest.cpp +++ b/tests/tests/ExtensionsTest/CocosBuilderTest/CocosBuilderTest.cpp @@ -36,7 +36,7 @@ void CocosBuilderTestScene::runThisTest() HelloCocosBuilder::createInstance); CCNode* node = CCBReader::nodeGraphFromFile("CocosBuilder_v2/example_relativeposition.ccb"); - this->addChild(node) ; + this->addChild(node) ; CCDirector::sharedDirector()->replaceScene(this); } diff --git a/tools/lua_project_generator/template/android/jni/Android.mk b/tools/lua_project_generator/template/android/jni/Android.mk index 8df30f893b..910cd6be86 100644 --- a/tools/lua_project_generator/template/android/jni/Android.mk +++ b/tools/lua_project_generator/template/android/jni/Android.mk @@ -1,11 +1,11 @@ -LOCAL_PATH := $(call my-dir) -include $(CLEAR_VARS) - -subdirs := $(addprefix $(LOCAL_PATH)/../../../,$(addsuffix /Android.mk, \ - cocos2dx \ - CocosDenshion/android \ - lua/proj.android/jni \ - )) -subdirs += $(LOCAL_PATH)/LuaProjectTemplate/Android.mk - -include $(subdirs) +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + +subdirs := $(addprefix $(LOCAL_PATH)/../../../,$(addsuffix /Android.mk, \ + cocos2dx \ + CocosDenshion/android \ + lua/proj.android/jni \ + )) +subdirs += $(LOCAL_PATH)/LuaProjectTemplate/Android.mk + +include $(subdirs) diff --git a/tools/lua_project_generator/template/android/jni/Application.mk b/tools/lua_project_generator/template/android/jni/Application.mk index ffaaa6b6e3..a79179b9fb 100644 --- a/tools/lua_project_generator/template/android/jni/Application.mk +++ b/tools/lua_project_generator/template/android/jni/Application.mk @@ -1,3 +1,3 @@ -# it is needed for ndk-r5 -APP_STL := stlport_static +# it is needed for ndk-r5 +APP_STL := stlport_static APP_MODULES := cocos2d cocosdenshion lua game \ No newline at end of file diff --git a/tools/lua_project_generator/template/android/jni/LuaProjectTemplate/Android.mk b/tools/lua_project_generator/template/android/jni/LuaProjectTemplate/Android.mk index eacc52e456..bf354ba8a9 100644 --- a/tools/lua_project_generator/template/android/jni/LuaProjectTemplate/Android.mk +++ b/tools/lua_project_generator/template/android/jni/LuaProjectTemplate/Android.mk @@ -1,33 +1,33 @@ -LOCAL_PATH := $(call my-dir) -include $(CLEAR_VARS) -LOCAL_MODULE := game - -LOCAL_SRC_FILES := main.cpp \ -../../../Classes/AppDelegate.cpp \ -../../../../lua/cocos2dx_support/LuaEngineImpl.cpp \ -../../../../lua/cocos2dx_support/Cocos2dxLuaLoader.cpp \ -../../../../lua/cocos2dx_support/LuaCocos2d.cpp \ -../../../../lua/cocos2dx_support/LuaEngine.cpp \ -../../../../lua/CocosDenshion_support/LuaSimpleAudioEngine.cpp - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../../../cocos2dx \ - $(LOCAL_PATH)/../../../../cocos2dx/platform \ - $(LOCAL_PATH)/../../../../cocos2dx/include \ - $(LOCAL_PATH)/../../../../cocos2dx/lua_support \ - $(LOCAL_PATH)/../../../../CocosDenshion/include \ - $(LOCAL_PATH)/../../../Classes \ - $(LOCAL_PATH)/../../../../lua/lua \ - $(LOCAL_PATH)/../../../../lua/tolua \ - $(LOCAL_PATH)/../../../../lua/cocos2dx_support \ - $(LOCAL_PATH)/../../../../lua/CocosDenshion_support -# it is used for ndk-r5 -# if you build with ndk-r4, comment it -# because the new Windows toolchain doesn't support Cygwin's drive -# mapping (i.e /cygdrive/c/ instead of C:/) +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) +LOCAL_MODULE := game + +LOCAL_SRC_FILES := main.cpp \ +../../../Classes/AppDelegate.cpp \ +../../../../lua/cocos2dx_support/LuaEngineImpl.cpp \ +../../../../lua/cocos2dx_support/Cocos2dxLuaLoader.cpp \ +../../../../lua/cocos2dx_support/LuaCocos2d.cpp \ +../../../../lua/cocos2dx_support/LuaEngine.cpp \ +../../../../lua/CocosDenshion_support/LuaSimpleAudioEngine.cpp + +LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../../../cocos2dx \ + $(LOCAL_PATH)/../../../../cocos2dx/platform \ + $(LOCAL_PATH)/../../../../cocos2dx/include \ + $(LOCAL_PATH)/../../../../cocos2dx/lua_support \ + $(LOCAL_PATH)/../../../../CocosDenshion/include \ + $(LOCAL_PATH)/../../../Classes \ + $(LOCAL_PATH)/../../../../lua/lua \ + $(LOCAL_PATH)/../../../../lua/tolua \ + $(LOCAL_PATH)/../../../../lua/cocos2dx_support \ + $(LOCAL_PATH)/../../../../lua/CocosDenshion_support +# it is used for ndk-r5 +# if you build with ndk-r4, comment it +# because the new Windows toolchain doesn't support Cygwin's drive +# mapping (i.e /cygdrive/c/ instead of C:/) LOCAL_LDLIBS := -L$(call host-path, $(LOCAL_PATH)/../../libs/armeabi) \ - -L$(call host-path, $(LOCAL_PATH)/../../../../cocos2dx/platform/third_party/android/libraries) -lcurl \ - -lcocos2d \ - -lcocosdenshion \ - -llua - + -L$(call host-path, $(LOCAL_PATH)/../../../../cocos2dx/platform/third_party/android/libraries) -lcurl \ + -lcocos2d \ + -lcocosdenshion \ + -llua + include $(BUILD_SHARED_LIBRARY) \ No newline at end of file diff --git a/tools/lua_project_generator/template/android/jni/LuaProjectTemplate/main.cpp b/tools/lua_project_generator/template/android/jni/LuaProjectTemplate/main.cpp index e1d0daff5f..8246e103a2 100644 --- a/tools/lua_project_generator/template/android/jni/LuaProjectTemplate/main.cpp +++ b/tools/lua_project_generator/template/android/jni/LuaProjectTemplate/main.cpp @@ -26,7 +26,7 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi } else { - ccDrawInit(); + ccDrawInit(); ccGLInvalidateStateCache(); CCShaderCache::sharedShaderCache()->reloadDefaultShaders();