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