Add js-tests

This commit is contained in:
WenhaiLin 2015-04-16 18:07:35 +08:00
parent 1f491cf656
commit e50b14b7fb
243 changed files with 61781 additions and 0 deletions

View File

@ -53,11 +53,22 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libjscocos2d.Windows", "..\
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libjscocos2d.WindowsPhone", "..\cocos\scripting\js-bindings\proj.win8.1-universal\libjscocos2d\libjscocos2d.WindowsPhone\libjscocos2d.WindowsPhone.vcxproj", "{CA082EC4-17CE-430B-8207-D1E947A5D1E9}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "js-tests", "js-tests", "{616DCDB6-4727-422A-9CD8-50F27228B237}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "js-tests.Shared", "..\tests\js-tests\project\proj.win8.1-universal\App.Shared\js-tests.Shared.vcxitems", "{AE6763F6-1549-441E-AFB5-377BE1C776DC}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "js-tests.Windows", "..\tests\js-tests\project\proj.win8.1-universal\App.Windows\js-tests.Windows.vcxproj", "{70914FC8-7709-4CD6-B86B-C63FDE5478DB}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "js-tests.WindowsPhone", "..\tests\js-tests\project\proj.win8.1-universal\App.WindowsPhone\js-tests.WindowsPhone.vcxproj", "{94874B5B-398F-448A-A366-35A35DC1DB9C}"
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
..\tests\js-tests\project\proj.win8.1-universal\App.Shared\js-tests.Shared.vcxitems*{ae6763f6-1549-441e-afb5-377be1c776dc}*SharedItemsImports = 9
..\tests\js-tests\project\proj.win8.1-universal\App.Shared\js-tests.Shared.vcxitems*{94874b5b-398f-448a-a366-35a35dc1db9c}*SharedItemsImports = 4
..\cocos\2d\libcocos2d_8_1\libcocos2d_8_1\libcocos2d_8_1.Shared\libcocos2d_8_1.Shared.vcxitems*{9335005f-678e-4e8e-9b84-50037216aec8}*SharedItemsImports = 4
..\tests\cpp-tests\proj.win8.1-universal\cpp-tests.Shared\cpp-tests.Shared.vcxitems*{15247c71-5289-4913-b88f-e253cc353720}*SharedItemsImports = 4
..\tests\cpp-empty-test\proj.win8.1-universal\HelloCpp.Shared\HelloCpp.Shared.vcxitems*{a3ad93e4-0b2f-4c58-9181-69bed2e42e3e}*SharedItemsImports = 9
..\tests\js-tests\project\proj.win8.1-universal\App.Shared\js-tests.Shared.vcxitems*{70914fc8-7709-4cd6-b86b-c63fde5478db}*SharedItemsImports = 4
..\cocos\editor-support\spine\proj.win8.1-universal\libSpine.Shared\libSpine.Shared.vcxitems*{cc1da216-a80d-4be4-b309-acb6af313aff}*SharedItemsImports = 4
..\external\Box2D\proj.win8.1-universal\libbox2d.Shared\libbox2d.Shared.vcxitems*{4a3c6ba8-c227-498b-aa21-40bda27b461f}*SharedItemsImports = 9
..\tests\cpp-empty-test\proj.win8.1-universal\HelloCpp.Shared\HelloCpp.Shared.vcxitems*{79a8fcda-4b12-4dd1-b676-ff148d651638}*SharedItemsImports = 4
@ -235,6 +246,38 @@ Global
{CA082EC4-17CE-430B-8207-D1E947A5D1E9}.Release|Win32.ActiveCfg = Release|Win32
{CA082EC4-17CE-430B-8207-D1E947A5D1E9}.Release|Win32.Build.0 = Release|Win32
{CA082EC4-17CE-430B-8207-D1E947A5D1E9}.Release|x64.ActiveCfg = Release|Win32
{70914FC8-7709-4CD6-B86B-C63FDE5478DB}.Debug|ARM.ActiveCfg = Debug|ARM
{70914FC8-7709-4CD6-B86B-C63FDE5478DB}.Debug|ARM.Build.0 = Debug|ARM
{70914FC8-7709-4CD6-B86B-C63FDE5478DB}.Debug|ARM.Deploy.0 = Debug|ARM
{70914FC8-7709-4CD6-B86B-C63FDE5478DB}.Debug|Win32.ActiveCfg = Debug|Win32
{70914FC8-7709-4CD6-B86B-C63FDE5478DB}.Debug|Win32.Build.0 = Debug|Win32
{70914FC8-7709-4CD6-B86B-C63FDE5478DB}.Debug|Win32.Deploy.0 = Debug|Win32
{70914FC8-7709-4CD6-B86B-C63FDE5478DB}.Debug|x64.ActiveCfg = Debug|x64
{70914FC8-7709-4CD6-B86B-C63FDE5478DB}.Debug|x64.Build.0 = Debug|x64
{70914FC8-7709-4CD6-B86B-C63FDE5478DB}.Debug|x64.Deploy.0 = Debug|x64
{70914FC8-7709-4CD6-B86B-C63FDE5478DB}.Release|ARM.ActiveCfg = Release|ARM
{70914FC8-7709-4CD6-B86B-C63FDE5478DB}.Release|ARM.Build.0 = Release|ARM
{70914FC8-7709-4CD6-B86B-C63FDE5478DB}.Release|ARM.Deploy.0 = Release|ARM
{70914FC8-7709-4CD6-B86B-C63FDE5478DB}.Release|Win32.ActiveCfg = Release|Win32
{70914FC8-7709-4CD6-B86B-C63FDE5478DB}.Release|Win32.Build.0 = Release|Win32
{70914FC8-7709-4CD6-B86B-C63FDE5478DB}.Release|Win32.Deploy.0 = Release|Win32
{70914FC8-7709-4CD6-B86B-C63FDE5478DB}.Release|x64.ActiveCfg = Release|x64
{70914FC8-7709-4CD6-B86B-C63FDE5478DB}.Release|x64.Build.0 = Release|x64
{70914FC8-7709-4CD6-B86B-C63FDE5478DB}.Release|x64.Deploy.0 = Release|x64
{94874B5B-398F-448A-A366-35A35DC1DB9C}.Debug|ARM.ActiveCfg = Debug|ARM
{94874B5B-398F-448A-A366-35A35DC1DB9C}.Debug|ARM.Build.0 = Debug|ARM
{94874B5B-398F-448A-A366-35A35DC1DB9C}.Debug|ARM.Deploy.0 = Debug|ARM
{94874B5B-398F-448A-A366-35A35DC1DB9C}.Debug|Win32.ActiveCfg = Debug|Win32
{94874B5B-398F-448A-A366-35A35DC1DB9C}.Debug|Win32.Build.0 = Debug|Win32
{94874B5B-398F-448A-A366-35A35DC1DB9C}.Debug|Win32.Deploy.0 = Debug|Win32
{94874B5B-398F-448A-A366-35A35DC1DB9C}.Debug|x64.ActiveCfg = Debug|Win32
{94874B5B-398F-448A-A366-35A35DC1DB9C}.Release|ARM.ActiveCfg = Release|ARM
{94874B5B-398F-448A-A366-35A35DC1DB9C}.Release|ARM.Build.0 = Release|ARM
{94874B5B-398F-448A-A366-35A35DC1DB9C}.Release|ARM.Deploy.0 = Release|ARM
{94874B5B-398F-448A-A366-35A35DC1DB9C}.Release|Win32.ActiveCfg = Release|Win32
{94874B5B-398F-448A-A366-35A35DC1DB9C}.Release|Win32.Build.0 = Release|Win32
{94874B5B-398F-448A-A366-35A35DC1DB9C}.Release|Win32.Deploy.0 = Release|Win32
{94874B5B-398F-448A-A366-35A35DC1DB9C}.Release|x64.ActiveCfg = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -260,5 +303,8 @@ Global
{BEA66276-51DD-4C53-92A8-F3D1FEA50892} = {151000C9-1FF6-4190-8B3C-EC5DA3C7763D}
{BCF5546D-66A0-4998-AFD6-C5514F618930} = {151000C9-1FF6-4190-8B3C-EC5DA3C7763D}
{CA082EC4-17CE-430B-8207-D1E947A5D1E9} = {151000C9-1FF6-4190-8B3C-EC5DA3C7763D}
{AE6763F6-1549-441E-AFB5-377BE1C776DC} = {616DCDB6-4727-422A-9CD8-50F27228B237}
{70914FC8-7709-4CD6-B86B-C63FDE5478DB} = {616DCDB6-4727-422A-9CD8-50F27228B237}
{94874B5B-398F-448A-A366-35A35DC1DB9C} = {616DCDB6-4727-422A-9CD8-50F27228B237}
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,31 @@
{
"project_type": "js",
"has_native": true,
"win32_cfg": {
"project_path": "../../build",
"sln_file": "cocos2d-win32.vc2013.sln",
"project_name": "js-tests",
"build_cfg_path": "project/proj.win32"
},
"ios_cfg": {
"project_path": "../../build",
"project_file": "cocos2d_jsb_samples.xcodeproj",
"target_name": "js-tests iOS"
},
"mac_cfg": {
"project_path": "../../build",
"project_file": "cocos2d_jsb_samples.xcodeproj",
"target_name": "js-tests Mac"
},
"android_cfg": {
"project_path": "project/proj.android"
},
"linux_cfg": {
"project_path": "project/proj.linux",
"project_name": "js-tests",
"cmake_path": "../../",
"build_dir": "../../build/linux-build",
"build_result_dir": "js-tests"
},
"engine_dir": "../../"
}

View File

@ -0,0 +1,79 @@
#/****************************************************************************
# Copyright (c) 2015 Chukong Technologies Inc.
#
# http://www.cocos2d-x.org
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
# ****************************************************************************/
set(APP_NAME js-tests)
if(WIN32)
else()
set(PLATFORM_SRC
project/proj.linux/main.cpp
)
endif()
set(SAMPLE_SRC
project/Classes/AppDelegate.cpp
project/Classes/js_DrawNode3D_bindings.cpp
project/Classes/js_Effect3D_bindings.cpp
${PLATFORM_SRC}
)
include_directories(
project/Classes
../../cocos/scripting/js-bindings/auto
../../cocos/scripting/js-bindings/manual
../../cocos/base
../../cocos/editor-support
../../cocos/audio/include
../../external/spidermonkey/include/${PLATFORM_FOLDER}
../../external/chipmunk/include/chipmunk
)
# add the executable
add_executable(${APP_NAME}
${SAMPLE_SRC}
)
target_link_libraries(${APP_NAME}
jsbindings
cocos2d
)
set(APP_BIN_DIR "${CMAKE_BINARY_DIR}/bin/${APP_NAME}")
set_target_properties(${APP_NAME} PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${APP_BIN_DIR}")
pre_build(${APP_NAME}
COMMAND ${CMAKE_COMMAND} -E remove_directory ${APP_BIN_DIR}/script
COMMAND ${CMAKE_COMMAND} -E remove_directory ${APP_BIN_DIR}/res
COMMAND ${CMAKE_COMMAND} -E remove_directory ${APP_BIN_DIR}/src
COMMAND ${CMAKE_COMMAND} -E remove ${APP_BIN_DIR}/*.js
COMMAND ${CMAKE_COMMAND} -E remove ${APP_BIN_DIR}/*.json
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/../cpp-tests/Resources ${APP_BIN_DIR}/res
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/src ${APP_BIN_DIR}/src
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/../../cocos/scripting/js-bindings/script ${APP_BIN_DIR}/script
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/main.js ${APP_BIN_DIR}/main.js
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/project.json ${APP_BIN_DIR}/project.json
)

127
tests/js-tests/main.js Normal file
View File

@ -0,0 +1,127 @@
/****************************************************************************
Copyright (c) 2010-2012 cocos2d-x.org
Copyright (c) 2008-2010 Ricardo Quesada
Copyright (c) 2011 Zynga Inc.
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
/**
* A brief explanation for "project.json":
* Here is the content of project.json file, this is the global configuration for your game, you can modify it to customize some behavior.
* The detail of each field is under it.
{
"debugMode" : 1,
// "debugMode" possible values :
// 0 - No message will be printed.
// 1 - cc.error, cc.assert, cc.warn, cc.log will print in console.
// 2 - cc.error, cc.assert, cc.warn will print in console.
// 3 - cc.error, cc.assert will print in console.
// 4 - cc.error, cc.assert, cc.warn, cc.log will print on canvas, available only on web.
// 5 - cc.error, cc.assert, cc.warn will print on canvas, available only on web.
// 6 - cc.error, cc.assert will print on canvas, available only on web.
"showFPS" : true,
// Left bottom corner fps information will show when "showFPS" equals true, otherwise it will be hide.
"frameRate" : 60,
// "frameRate" set the wanted frame rate for your game, but the real fps depends on your game implementation and the running environment.
"id" : "gameCanvas",
// "gameCanvas" sets the id of your canvas element on the web page, it's useful only on web.
"renderMode" : 0,
// "renderMode" sets the renderer type, only useful on web :
// 0 - Automatically chosen by engine
// 1 - Forced to use canvas renderer
// 2 - Forced to use WebGL renderer, but this will be ignored on mobile browsers
"engineDir" : "../../frameworks/cocos2d-html5/",
// In debug mode, if you use the whole engine to develop your game, you should specify its relative path with "engineDir",
// but if you are using a single engine file, you can ignore it.
"modules" : ["cocos2d", "extensions", "external"],
// "modules" defines which modules you will need in your game, it's useful only on web,
// using this can greatly reduce your game's resource size, and the cocos console tool can package your game with only the modules you set.
// For details about modules definitions, you can refer to "../../frameworks/cocos2d-html5/modulesConfig.json".
"plugin": {
"facebook": {
"appId" : "1426774790893461",
"xfbml" : true,
"version" : "v2.0"
}
},
// "plugin" is used by plugin-x for its settings, if you don't use it, you can ignore it.
"jsList" : [
]
// "jsList" sets the list of js files in your game.
}
*
*/
if(cc.sys){
var scene3SearchPaths = cc.sys.localStorage.getItem("Scene3SearchPaths");
if (scene3SearchPaths)
jsb.fileUtils.setSearchPaths(JSON.parse(scene3SearchPaths));
}
cc.game.onStart = function(){
cc.view.enableRetina(false);
if (cc.sys.isNative) {
var resolutionPolicy = (cc.sys.os == cc.sys.OS_WP8 || cc.sys.os == cc.sys.OS_WINRT) ? cc.ResolutionPolicy.SHOW_ALL : cc.ResolutionPolicy.FIXED_HEIGHT;
cc.view.setDesignResolutionSize(800, 450, resolutionPolicy);
cc.view.resizeWithBrowserSize(true);
var searchPaths = jsb.fileUtils.getSearchPaths();
searchPaths.push('script');
searchPaths.push('src');
var paths = [
'res',
'res/scenetest',
'res/scenetest/ArmatureComponentTest',
'res/scenetest/AttributeComponentTest',
'res/scenetest/BackgroundComponentTest',
'res/scenetest/EffectComponentTest',
'res/scenetest/LoadSceneEdtiorFileTest',
'res/scenetest/ParticleComponentTest',
'res/scenetest/SpriteComponentTest',
'res/scenetest/TmxMapComponentTest',
'res/scenetest/UIComponentTest',
'res/scenetest/TriggerTest'
];
for (var i = 0; i < paths.length; i++) {
searchPaths.push(paths[i]);
}
jsb.fileUtils.setSearchPaths(searchPaths);
}
cc.LoaderScene.preload(g_resources, function () {
if(window.sideIndexBar && typeof sideIndexBar.start === 'function'){
sideIndexBar.start();
}else{
var scene = new cc.Scene();
scene.addChild(new TestController());
cc.director.runScene(scene);
}
}, this);
};
cc.game.run();

186
tests/js-tests/project.json Normal file
View File

@ -0,0 +1,186 @@
{
"debugMode" : 1,
"showFPS" : true,
"frameRate" : 60,
"id" : "gameCanvas",
"renderMode" : 0,
"engineDir" : "../../frameworks/cocos2d-html5/",
"modules" : ["cocos2d", "extensions", "external"],
"plugin": {
"facebook": {
"appId" : "1426774790893461",
"xfbml" : true,
"version" : "v2.0"
}
},
"jsList" : [
"src/BaseTestLayer/BaseTestLayer.js",
"src/tests_resources.js",
"src/tests-main.js",
"src/PathTest/PathTest.js",
"src/LoaderTest/LoaderTest.js",
"src/BakeLayerTest/BakeLayerTest.js",
"src/TouchesTest/Ball.js",
"src/TouchesTest/Paddle.js",
"src/TouchesTest/TouchesTest.js",
"src/SchedulerTest/SchedulerTest.js",
"src/ClickAndMoveTest/ClickAndMoveTest.js",
"src/MenuTest/MenuTest.js",
"src/ActionsTest/ActionsTest.js",
"src/TileMapTest/TileMapTest.js",
"src/TransitionsTest/TransitionsTest.js",
"src/DrawPrimitivesTest/DrawPrimitivesTest.js",
"src/ParticleTest/ParticleTest.js",
"src/ProgressActionsTest/ProgressActionsTest.js",
"src/LayerTest/LayerTest.js",
"src/SceneTest/SceneTest.js",
"src/SpineTest/SpineTest.js",
"src/SpriteTest/SpriteTest.js",
"src/Sprite3DTest/Sprite3DTest.js",
"src/LightTest/LightTest.js",
"src/BillBoardTest/BillBoardTest.js",
"src/Camera3DTest/Camera3DTest.js",
"src/TextureCacheTest/TextureCacheTest.js",
"src/CocosDenshionTest/CocosDenshionTest.js",
"src/CocosNodeTest/CocosNodeTest.js",
"src/RotateWorldTest/RotateWorldTest.js",
"src/RenderTextureTest/RenderTextureTest.js",
"src/IntervalTest/IntervalTest.js",
"src/ActionManagerTest/ActionManagerTest.js",
"src/EaseActionsTest/EaseActionsTest.js",
"src/ParallaxTest/ParallaxTest.js",
"src/PerformanceTest/PerformanceTest.js",
"src/PerformanceTest/PerformanceSpriteTest.js",
"src/PerformanceTest/PerformanceSpriteTest2.js",
"src/PerformanceTest/PerformanceParticleTest.js",
"src/PerformanceTest/PerformanceNodeChildrenTest.js",
"src/PerformanceTest/PerformanceTextureTest.js",
"src/PerformanceTest/PerformanceAnimationTest.js",
"src/PerformanceTest/PerformanceVirtualMachineTest.js",
"src/PerformanceTest/seedrandom.js",
"src/FontTest/FontTest.js",
"src/PerformanceTest/PerformanceTouchesTest.js",
"src/LabelTest/LabelTest.js",
"src/CurrentLanguageTest/CurrentLanguageTest.js",
"src/TextInputTest/TextInputTest.js",
"src/NewEventManagerTest/NewEventManagerTest.js",
"src/EventTest/EventTest.js",
"src/UnitTest/UnitTest.js",
"src/SysTest/SysTest.js",
"src/SysTest/ScriptTestTempFile.js",
"src/EffectsTest/EffectsTest.js",
"src/EffectsAdvancedTest/EffectsAdvancedTest.js",
"src/MotionStreakTest/MotionStreakTest.js",
"src/ClippingNodeTest/ClippingNodeTest.js",
"src/OpenGLTest/OpenGLTest.js",
"src/FacebookTest/FacebookTest.js",
"src/FacebookTest/FacebookShareTest.js",
"src/FacebookTest/FacebookUserTest.js",
"src/FacebookTest/FacebookTestsManager.js",
"src/ExtensionsTest/ExtensionsTest.js",
"src/ExtensionsTest/AssetsManagerTest/AssetsManagerTest.js",
"src/ExtensionsTest/ControlExtensionTest/CCControlSceneManager.js",
"src/ExtensionsTest/ControlExtensionTest/CCControlScene.js",
"src/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.js",
"src/ExtensionsTest/ControlExtensionTest/CCControlSwitchTest/CCControlSwitchTest.js",
"src/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.js",
"src/ExtensionsTest/ControlExtensionTest/CCControlStepperTest/CCControlStepperTest.js",
"src/ExtensionsTest/ControlExtensionTest/CCControlPotentiometerTest/CCControlPotentiometerTest.js",
"src/ExtensionsTest/ControlExtensionTest/CCControlColourPickerTest/CCControlColourPickerTest.js",
"src/ExtensionsTest/TableViewTest/TableViewTestScene.js",
"src/ExtensionsTest/CocosBuilderTest/CocosBuilderTest.js",
"src/ExtensionsTest/CocosBuilderTest/TestHeader/TestHeaderLayer.js",
"src/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.js",
"src/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayer.js",
"src/ExtensionsTest/CocosBuilderTest/SpriteTest/SpriteTestLayer.js",
"src/ExtensionsTest/CocosBuilderTest/MenuTest/MenuTestLayer.js",
"src/ExtensionsTest/CocosBuilderTest/LabelTest/LabelTestLayer.js",
"src/ExtensionsTest/CocosBuilderTest/ParticleSystemTest/ParticleSystemTestLayer.js",
"src/ExtensionsTest/CocosBuilderTest/ScrollViewTest/ScrollViewTestLayer.js",
"src/ExtensionsTest/CocosBuilderTest/AnimationsTest/AnimationsTestLayer.js",
"src/ExtensionsTest/CocosBuilderTest/TimelineCallbackTest/TimelineCallbackTestLayer.js",
"src/ExtensionsTest/CCPoolTest/CCPoolTest.js",
"src/ExtensionsTest/EditBoxTest/EditBoxTest.js",
"src/ExtensionsTest/S9SpriteTest/S9SpriteTest.js",
"src/ExtensionsTest/NetworkTest/WebSocketTest.js",
"src/ExtensionsTest/NetworkTest/SocketIOTest.js",
"src/ExtensionsTest/PluginXTest/PluginXTest.js",
"src/ExtensionsTest/PluginXTest/PluginXTestsManager.js",
"src/ExtensionsTest/PluginXTest/IOSIAPTest.js",
"src/ExtensionsTest/PluginXTest/AnalyticsTest.js",
"src/CocoStudioTest/ArmatureTest/ArmatureTest.js",
"src/CocoStudioTest/ComponentsTest/ComponentsTestScene.js",
"src/CocoStudioTest/ComponentsTest/EnemyController.js",
"src/CocoStudioTest/ComponentsTest/GameOverScene.js",
"src/CocoStudioTest/ComponentsTest/PlayerController.js",
"src/CocoStudioTest/ComponentsTest/ProjectileController.js",
"src/CocoStudioTest/ComponentsTest/SceneController.js",
"src/CocoStudioTest/GUITest/UISceneTest.js",
"src/CocoStudioTest/GUITest/UIBaseLayer.js",
"src/CocoStudioTest/GUITest/UIButtonTest/UIButtonTest.js",
"src/CocoStudioTest/GUITest/UICheckBoxTest/UICheckBoxTest.js",
"src/CocoStudioTest/GUITest/UIImageViewTest/UIImageViewTest.js",
"src/CocoStudioTest/GUITest/UITextTest/UITextTest.js",
"src/CocoStudioTest/GUITest/UITextAtlasTest/UITextAtlasTest.js",
"src/CocoStudioTest/GUITest/UITextBMFontTest/UITextBMFontTest.js",
"src/CocoStudioTest/GUITest/UILoadingBarTest/UILoadingBarTest.js",
"src/CocoStudioTest/GUITest/UISliderTest/UISliderTest.js",
"src/CocoStudioTest/GUITest/UITextFieldTest/UITextFieldTest.js",
"src/CocoStudioTest/GUITest/UINodeContainerTest/UINodeContainerTest.js",
"src/CocoStudioTest/GUITest/UILayoutTest/UILayoutTest.js",
"src/CocoStudioTest/GUITest/UIListViewTest/UIListViewTest.js",
"src/CocoStudioTest/GUITest/UIPageViewTest/UIPageViewTest.js",
"src/CocoStudioTest/GUITest/UIScrollViewTest/UIScrollViewTest.js",
"src/CocoStudioTest/ParserTest/ParserTest.js",
"src/CocoStudioTest/CustomTest/CustomImageView/CustomImageView.js",
"src/CocoStudioTest/CustomTest/CustomImageView/CustomImageViewReader.js",
"src/CocoStudioTest/CustomTest/CustomImageView/CustomParticleWidget.js",
"src/CocoStudioTest/CustomTest/CustomImageView/CustomParticWidgetReader.js",
"src/CocoStudioTest/CustomTest/CustomImageView/CustomReader.js",
"src/CocoStudioTest/CustomTest/CustomParticleWidgetTest/CustomParticleWidgetTest.js",
"src/CocoStudioTest/CustomTest/CustomImageScene/CustomImageScene.js",
"src/CocoStudioTest/CustomTest/CustomGUIScene.js",
"src/GUITest/UIScene.js",
"src/GUITest/UIButtonTest/UIButtonTest.js",
"src/GUITest/UICheckBoxTest/UICheckBoxTest.js",
"src/GUITest/UIFocusTest/UIFocusTest.js",
"src/GUITest/UIImageViewTest/UIImageViewTest.js",
"src/GUITest/UILabelAtlasTest/UILabelAtlasTest.js",
"src/GUITest/UILabelBMFontTest/UILabelBMFontTest.js",
"src/GUITest/UILabelTest/UILabelTest.js",
"src/GUITest/UILayoutTest/UILayoutTest.js",
"src/GUITest/UIListViewTest/UIListViewTest.js",
"src/GUITest/UILoadingBarTest/UILoadingBarTest.js",
"src/GUITest/UINodeContainerTest/UINodeContainerTest.js",
"src/GUITest/UIPageViewTest/UIPageViewTest.js",
"src/GUITest/UISceneManager.js",
"src/GUITest/UIScrollViewTest/UIScrollViewTest.js",
"src/GUITest/UISliderTest/UISliderTest.js",
"src/GUITest/UITextFieldTest/UITextFieldTest.js",
"src/GUITest/UIRichTextTest/UIRichTextTest.js",
"src/GUITest/UITextTest/UITextTest.js",
"src/CocoStudioTest/SceneTest/TriggerCode/Acts.js",
"src/CocoStudioTest/SceneTest/TriggerCode/Cons.js",
"src/CocoStudioTest/SceneTest/TriggerCode/EventDef.js",
"src/CocoStudioTest/SceneTest/SceneEditorTest.js",
"src/CocoStudioTest/CocoStudioTest.js",
"src/XHRTest/XHRTest.js",
"src/XHRTest/XHRArrayBufferTest.js",
"src/Box2dTest/Box2dTest.js",
"src/ChipmunkTest/ChipmunkTest.js",
"src/Presentation/Presentation.js",
"src/ReflectionTest/ReflectionTest.js"
]
}

View File

@ -0,0 +1,161 @@
#include "AppDelegate.h"
#include "cocos2d.h"
#include "SimpleAudioEngine.h"
#include "ScriptingCore.h"
#include "jsb_cocos2dx_auto.hpp"
#include "jsb_cocos2dx_extension_auto.hpp"
#include "jsb_cocos2dx_builder_auto.hpp"
#include "jsb_cocos2dx_spine_auto.hpp"
#include "jsb_cocos2dx_3d_auto.hpp"
#include "jsb_cocos2dx_3d_extension_auto.hpp"
#include "3d/jsb_cocos2dx_3d_manual.h"
#include "extension/jsb_cocos2dx_extension_manual.h"
#include "cocostudio/jsb_cocos2dx_studio_manual.h"
#include "jsb_cocos2dx_studio_auto.hpp"
#include "jsb_cocos2dx_ui_auto.hpp"
#include "ui/jsb_cocos2dx_ui_manual.h"
#include "spine/jsb_cocos2dx_spine_manual.h"
#include "cocos2d_specifics.hpp"
#include "cocosbuilder/cocosbuilder_specifics.hpp"
#include "chipmunk/js_bindings_chipmunk_registration.h"
#include "localstorage/js_bindings_system_registration.h"
#include "jsb_opengl_registration.h"
#include "network/XMLHTTPRequest.h"
#include "network/jsb_websocket.h"
#include "network/jsb_socketio.h"
#include "cocosbuilder/js_bindings_ccbreader.h"
#include "js_DrawNode3D_bindings.h"
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
#include "jsb_cocos2dx_pluginx_auto.hpp"
#include "jsb_pluginx_extension_registration.h"
#endif
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
#include "platform/android/CCJavascriptJavaBridge.h"
#elif (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
#include "platform/ios/JavaScriptObjCBridge.h"
#endif
#if(CC_TARGET_PLATFORM != CC_PLATFORM_WP8)
#include "js_Effect3D_bindings.h"
#endif
USING_NS_CC;
USING_NS_CC_EXT;
using namespace CocosDenshion;
AppDelegate::AppDelegate()
{
}
AppDelegate::~AppDelegate()
{
ScriptEngineManager::destroyInstance();
}
void AppDelegate::initGLContextAttrs()
{
GLContextAttrs glContextAttrs = {8, 8, 8, 8, 24, 8};
GLView::setGLContextAttrs(glContextAttrs);
}
bool AppDelegate::applicationDidFinishLaunching()
{
// initialize director
auto director = Director::getInstance();
auto glview = director->getOpenGLView();
if(!glview) {
#if(CC_TARGET_PLATFORM == CC_PLATFORM_WP8 || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
glview = cocos2d::GLViewImpl::create("js-tests");
#else
glview = cocos2d::GLViewImpl::createWithRect("js-tests", Rect(0,0,900,640));
#endif
director->setOpenGLView(glview);
}
// set FPS. the default value is 1.0/60 if you don't call this
director->setAnimationInterval(1.0 / 60);
ScriptingCore* sc = ScriptingCore::getInstance();
sc->addRegisterCallback(register_all_cocos2dx);
sc->addRegisterCallback(register_cocos2dx_js_core);
sc->addRegisterCallback(jsb_register_system);
sc->addRegisterCallback(register_all_cocos2dx_extension);
sc->addRegisterCallback(register_all_cocos2dx_extension_manual);
sc->addRegisterCallback(jsb_register_chipmunk);
sc->addRegisterCallback(JSB_register_opengl);
sc->addRegisterCallback(MinXmlHttpRequest::_js_register);
sc->addRegisterCallback(register_jsb_websocket);
sc->addRegisterCallback(register_jsb_socketio);
sc->addRegisterCallback(register_all_cocos2dx_builder);
sc->addRegisterCallback(register_CCBuilderReader);
sc->addRegisterCallback(register_all_cocos2dx_ui);
sc->addRegisterCallback(register_all_cocos2dx_ui_manual);
sc->addRegisterCallback(register_all_cocos2dx_studio);
sc->addRegisterCallback(register_all_cocos2dx_studio_manual);
sc->addRegisterCallback(register_all_cocos2dx_spine);
sc->addRegisterCallback(register_all_cocos2dx_spine_manual);
sc->addRegisterCallback(register_all_cocos2dx_3d);
sc->addRegisterCallback(register_all_cocos2dx_3d_manual);
sc->addRegisterCallback(register_all_cocos2dx_3d_extension);
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
sc->addRegisterCallback(register_all_pluginx_protocols);
sc->addRegisterCallback(register_pluginx_js_extensions);
#endif
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
sc->addRegisterCallback(JavascriptJavaBridge::_js_register);
#elif (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
sc->addRegisterCallback(JavaScriptObjCBridge::_js_register);
#endif
sc->addRegisterCallback(register_DrawNode3D_bindings);
#if(CC_TARGET_PLATFORM != CC_PLATFORM_WP8)
sc->addRegisterCallback(register_Effect3D_bindings);
#endif
sc->start();
sc->runScript("script/jsb_boot.js");
#if defined(COCOS2D_DEBUG) && (COCOS2D_DEBUG > 0)
sc->enableDebugger();
#endif
auto pEngine = ScriptingCore::getInstance();
ScriptEngineManager::getInstance()->setScriptEngine(pEngine);
ScriptingCore::getInstance()->runScript("main.js");
return true;
}
// This function will be called when the app is inactive. When comes a phone call,it's be invoked too
void AppDelegate::applicationDidEnterBackground()
{
auto director = Director::getInstance();
director->stopAnimation();
director->getEventDispatcher()->dispatchCustomEvent("game_on_hide");
SimpleAudioEngine::getInstance()->pauseBackgroundMusic();
SimpleAudioEngine::getInstance()->pauseAllEffects();
}
// this function will be called when the app is active again
void AppDelegate::applicationWillEnterForeground()
{
auto director = Director::getInstance();
director->startAnimation();
director->getEventDispatcher()->dispatchCustomEvent("game_on_show");
SimpleAudioEngine::getInstance()->resumeBackgroundMusic();
SimpleAudioEngine::getInstance()->resumeAllEffects();
}

View File

@ -0,0 +1,39 @@
#ifndef _APP_DELEGATE_H_
#define _APP_DELEGATE_H_
#include "platform/CCApplication.h"
/**
@brief The cocos2d Application.
The reason for implement as private inheritance is to hide some interface call by Director.
*/
class AppDelegate : private cocos2d::Application
{
public:
AppDelegate();
virtual ~AppDelegate();
void initGLContextAttrs() override;
/**
@brief Implement Director and Scene init code here.
@return true Initialize success, app continue.
@return false Initialize failed, app terminate.
*/
virtual bool applicationDidFinishLaunching();
/**
@brief The function be called when the application enter background
@param the pointer of the application
*/
virtual void applicationDidEnterBackground();
/**
@brief The function be called when the application enter foreground
@param the pointer of the application
*/
virtual void applicationWillEnterForeground();
};
#endif // _APP_DELEGATE_H_

View File

@ -0,0 +1,593 @@
/****************************************************************************
Copyright (c) 2014 Chukong Technologies Inc.
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "cocos2d.h"
#include "cocos2d_specifics.hpp"
#include "js_DrawNode3D_bindings.h"
NS_CC_BEGIN
/**
* Copy DrawNode for 3D geometry drawing.
*/
class DrawNode3D: public Node
{
public:
/** creates and initialize a DrawNode3D node */
static DrawNode3D* create();
/**
* Draw 3D Line
*/
void drawLine(const Vec3 &from, const Vec3 &to, const Color4F &color);
/**
* Draw 3D cube
* @param point to a vertex array who has 8 element.
* vertices[0]:Left-top-front,
* vertices[1]:Left-bottom-front,
* vertices[2]:Right-bottom-front,
* vertices[3]:Right-top-front,
* vertices[4]:Right-top-back,
* vertices[5]:Right-bottom-back,
* vertices[6]:Left-bottom-back,
* vertices[7]:Left-top-back.
* @param color
*/
void drawCube(Vec3* vertices, const Color4F &color);
/** Clear the geometry in the node's buffer. */
void clear();
/**
* @js NA
* @lua NA
*/
const BlendFunc& getBlendFunc() const;
/**
* @code
* When this function bound into js or lua,the parameter will be changed
* In js: var setBlendFunc(var src, var dst)
* @endcode
* @lua NA
*/
void setBlendFunc(const BlendFunc &blendFunc);
void onDraw(const Mat4 &transform, uint32_t flags);
// Overrides
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
CC_CONSTRUCTOR_ACCESS:
DrawNode3D();
virtual ~DrawNode3D();
virtual bool init();
protected:
struct V3F_C4B
{
Vec3 vertices;
Color4B colors;
};
void ensureCapacity(int count);
GLuint _vao;
GLuint _vbo;
int _bufferCapacity;
GLsizei _bufferCount;
V3F_C4B* _buffer;
BlendFunc _blendFunc;
CustomCommand _customCommand;
bool _dirty;
private:
CC_DISALLOW_COPY_AND_ASSIGN(DrawNode3D);
};
DrawNode3D::DrawNode3D()
: _vao(0)
, _vbo(0)
, _bufferCapacity(0)
, _bufferCount(0)
, _buffer(nullptr)
, _dirty(false)
{
_blendFunc = BlendFunc::ALPHA_PREMULTIPLIED;
}
DrawNode3D::~DrawNode3D()
{
free(_buffer);
_buffer = nullptr;
glDeleteBuffers(1, &_vbo);
_vbo = 0;
if (Configuration::getInstance()->supportsShareableVAO())
{
glDeleteVertexArrays(1, &_vao);
GL::bindVAO(0);
_vao = 0;
}
}
DrawNode3D* DrawNode3D::create()
{
DrawNode3D* ret = new (std::nothrow) DrawNode3D();
if (ret && ret->init())
{
ret->autorelease();
}
else
{
CC_SAFE_DELETE(ret);
}
return ret;
}
void DrawNode3D::ensureCapacity(int count)
{
CCASSERT(count>=0, "capacity must be >= 0");
if(_bufferCount + count > _bufferCapacity)
{
_bufferCapacity += MAX(_bufferCapacity, count);
_buffer = (V3F_C4B*)realloc(_buffer, _bufferCapacity*sizeof(V3F_C4B));
}
}
bool DrawNode3D::init()
{
_blendFunc = BlendFunc::ALPHA_PREMULTIPLIED;
setGLProgramState(GLProgramState::getOrCreateWithGLProgramName(GLProgram::SHADER_NAME_POSITION_COLOR));
ensureCapacity(512);
if (Configuration::getInstance()->supportsShareableVAO())
{
glGenVertexArrays(1, &_vao);
GL::bindVAO(_vao);
}
glGenBuffers(1, &_vbo);
glBindBuffer(GL_ARRAY_BUFFER, _vbo);
glBufferData(GL_ARRAY_BUFFER, sizeof(V3F_C4B)* _bufferCapacity, _buffer, GL_STREAM_DRAW);
glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_POSITION);
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, sizeof(V3F_C4B), (GLvoid *)offsetof(V3F_C4B, vertices));
glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_COLOR);
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(V3F_C4B), (GLvoid *)offsetof(V3F_C4B, colors));
glBindBuffer(GL_ARRAY_BUFFER, 0);
if (Configuration::getInstance()->supportsShareableVAO())
{
GL::bindVAO(0);
}
CHECK_GL_ERROR_DEBUG();
_dirty = true;
#if CC_ENABLE_CACHE_TEXTURE_DATA
// Need to listen the event only when not use batchnode, because it will use VBO
auto listener = EventListenerCustom::create(EVENT_COME_TO_FOREGROUND, [this](EventCustom* event){
/** listen the event that coming to foreground on Android */
this->init();
});
_eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
#endif
return true;
}
void DrawNode3D::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
{
_customCommand.init(_globalZOrder, transform, flags);
_customCommand.func = CC_CALLBACK_0(DrawNode3D::onDraw, this, transform, flags);
renderer->addCommand(&_customCommand);
}
void DrawNode3D::onDraw(const Mat4 &transform, uint32_t flags)
{
auto glProgram = getGLProgram();
glProgram->use();
glProgram->setUniformsForBuiltins(transform);
glEnable(GL_DEPTH_TEST);
GL::blendFunc(_blendFunc.src, _blendFunc.dst);
if (_dirty)
{
glBindBuffer(GL_ARRAY_BUFFER, _vbo);
glBufferData(GL_ARRAY_BUFFER, sizeof(V3F_C4B)*_bufferCapacity, _buffer, GL_STREAM_DRAW);
_dirty = false;
}
if (Configuration::getInstance()->supportsShareableVAO())
{
GL::bindVAO(_vao);
}
else
{
GL::enableVertexAttribs(GL::VERTEX_ATTRIB_FLAG_POS_COLOR_TEX);
glBindBuffer(GL_ARRAY_BUFFER, _vbo);
// vertex
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, sizeof(V3F_C4B), (GLvoid *)offsetof(V3F_C4B, vertices));
// color
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(V3F_C4B), (GLvoid *)offsetof(V3F_C4B, colors));
}
glDrawArrays(GL_LINES, 0, _bufferCount);
glBindBuffer(GL_ARRAY_BUFFER, 0);
CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1,_bufferCount);
glDisable(GL_DEPTH_TEST);
CHECK_GL_ERROR_DEBUG();
}
void DrawNode3D::drawLine(const Vec3 &from, const Vec3 &to, const Color4F &color)
{
unsigned int vertex_count = 2;
ensureCapacity(vertex_count);
Color4B col = Color4B(color);
V3F_C4B a = {Vec3(from.x, from.y, from.z), col};
V3F_C4B b = {Vec3(to.x, to.y, to.z), col, };
V3F_C4B *lines = (V3F_C4B *)(_buffer + _bufferCount);
lines[0] = a;
lines[1] = b;
_bufferCount += vertex_count;
_dirty = true;
}
void DrawNode3D::drawCube(Vec3* vertices, const Color4F &color)
{
// front face
drawLine(vertices[0], vertices[1], color);
drawLine(vertices[1], vertices[2], color);
drawLine(vertices[2], vertices[3], color);
drawLine(vertices[3], vertices[0], color);
// back face
drawLine(vertices[4], vertices[5], color);
drawLine(vertices[5], vertices[6], color);
drawLine(vertices[6], vertices[7], color);
drawLine(vertices[7], vertices[4], color);
// edge
drawLine(vertices[0], vertices[7], color);
drawLine(vertices[1], vertices[6], color);
drawLine(vertices[2], vertices[5], color);
drawLine(vertices[3], vertices[4], color);
}
void DrawNode3D::clear()
{
_bufferCount = 0;
_dirty = true;
}
const BlendFunc& DrawNode3D::getBlendFunc() const
{
return _blendFunc;
}
void DrawNode3D::setBlendFunc(const BlendFunc &blendFunc)
{
_blendFunc = blendFunc;
}
NS_CC_END
/**
* bindings for cc.DrawNode3D
**/
JSClass *jsb_cocos2d_DrawNode3D_class;
JSObject *jsb_cocos2d_DrawNode3D_prototype;
bool js_cocos2dx_DrawNode3D_getBlendFunc(JSContext *cx, uint32_t argc, jsval *vp)
{
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
js_proxy_t *proxy = jsb_get_js_proxy(obj);
cocos2d::DrawNode3D* cobj = (cocos2d::DrawNode3D *)(proxy ? proxy->ptr : NULL);
JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_DrawNode3D_getBlendFunc : Invalid Native Object");
if (argc == 0) {
const cocos2d::BlendFunc& ret = cobj->getBlendFunc();
jsval jsret = JSVAL_NULL;
jsret = blendfunc_to_jsval(cx, ret);
args.rval().set(jsret);
return true;
}
JS_ReportError(cx, "js_cocos2dx_DrawNode3D_getBlendFunc : wrong number of arguments: %d, was expecting %d", argc, 0);
return false;
}
bool js_cocos2dx_DrawNode3D_setBlendFunc(JSContext *cx, uint32_t argc, jsval *vp)
{
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
bool ok = true;
JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
js_proxy_t *proxy = jsb_get_js_proxy(obj);
cocos2d::DrawNode3D* cobj = (cocos2d::DrawNode3D *)(proxy ? proxy->ptr : NULL);
JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_DrawNode3D_setBlendFunc : Invalid Native Object");
if (argc == 1) {
cocos2d::BlendFunc arg0;
ok &= jsval_to_blendfunc(cx, args.get(0), &arg0);
JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_DrawNode3D_setBlendFunc : Error processing arguments");
cobj->setBlendFunc(arg0);
args.rval().setUndefined();
return true;
}
JS_ReportError(cx, "js_cocos2dx_DrawNode3D_setBlendFunc : wrong number of arguments: %d, was expecting %d", argc, 1);
return false;
}
bool js_cocos2dx_DrawNode3D_drawLine(JSContext *cx, uint32_t argc, jsval *vp)
{
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
bool ok = true;
JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
js_proxy_t *proxy = jsb_get_js_proxy(obj);
cocos2d::DrawNode3D* cobj = (cocos2d::DrawNode3D *)(proxy ? proxy->ptr : NULL);
JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_DrawNode3D_drawLine : Invalid Native Object");
if (argc == 3) {
cocos2d::Vec3 arg0;
cocos2d::Vec3 arg1;
cocos2d::Color4F arg2;
ok &= jsval_to_vector3(cx, args.get(0), &arg0);
ok &= jsval_to_vector3(cx, args.get(1), &arg1);
ok &= jsval_to_cccolor4f(cx, args.get(2), &arg2);
JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_DrawNode3D_drawLine : Error processing arguments");
cobj->drawLine(arg0, arg1, arg2);
args.rval().setUndefined();
return true;
}
JS_ReportError(cx, "js_cocos2dx_DrawNode3D_drawLine : wrong number of arguments: %d, was expecting %d", argc, 3);
return false;
}
bool js_cocos2dx_DrawNode3D_clear(JSContext *cx, uint32_t argc, jsval *vp)
{
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
js_proxy_t *proxy = jsb_get_js_proxy(obj);
cocos2d::DrawNode3D* cobj = (cocos2d::DrawNode3D *)(proxy ? proxy->ptr : NULL);
JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_DrawNode3D_clear : Invalid Native Object");
if (argc == 0) {
cobj->clear();
args.rval().setUndefined();
return true;
}
JS_ReportError(cx, "js_cocos2dx_DrawNode3D_clear : wrong number of arguments: %d, was expecting %d", argc, 0);
return false;
}
bool js_cocos2dx_DrawNode3D_onDraw(JSContext *cx, uint32_t argc, jsval *vp)
{
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
bool ok = true;
JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
js_proxy_t *proxy = jsb_get_js_proxy(obj);
cocos2d::DrawNode3D* cobj = (cocos2d::DrawNode3D *)(proxy ? proxy->ptr : NULL);
JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_DrawNode3D_onDraw : Invalid Native Object");
if (argc == 2) {
cocos2d::Mat4 arg0;
unsigned int arg1;
ok &= jsval_to_matrix(cx, args.get(0), &arg0);
ok &= jsval_to_uint32(cx, args.get(1), &arg1);
JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_DrawNode3D_onDraw : Error processing arguments");
cobj->onDraw(arg0, arg1);
args.rval().setUndefined();
return true;
}
JS_ReportError(cx, "js_cocos2dx_DrawNode3D_onDraw : wrong number of arguments: %d, was expecting %d", argc, 2);
return false;
}
bool js_cocos2dx_DrawNode3D_init(JSContext *cx, uint32_t argc, jsval *vp)
{
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
js_proxy_t *proxy = jsb_get_js_proxy(obj);
cocos2d::DrawNode3D* cobj = (cocos2d::DrawNode3D *)(proxy ? proxy->ptr : NULL);
JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_DrawNode3D_init : Invalid Native Object");
if (argc == 0) {
bool ret = cobj->init();
jsval jsret = JSVAL_NULL;
jsret = BOOLEAN_TO_JSVAL(ret);
args.rval().set(jsret);
return true;
}
JS_ReportError(cx, "js_cocos2dx_DrawNode3D_init : wrong number of arguments: %d, was expecting %d", argc, 0);
return false;
}
bool js_cocos2dx_DrawNode3D_drawCube(JSContext *cx, uint32_t argc, jsval *vp)
{
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
bool ok = true;
JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
js_proxy_t *proxy = jsb_get_js_proxy(obj);
cocos2d::DrawNode3D* cobj = (cocos2d::DrawNode3D *)(proxy ? proxy->ptr : NULL);
JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_DrawNode3D_drawCube : Invalid Native Object");
if (argc == 2) {
cocos2d::Vec3 arg0[8];
cocos2d::Color4F arg1;
JS::RootedObject jsVec3Array(cx, args.get(0).toObjectOrNull());
JSB_PRECONDITION3( jsVec3Array && JS_IsArrayObject( cx, jsVec3Array), cx, false, "augument must be an array");
uint32_t len = 0;
JS_GetArrayLength(cx, jsVec3Array, &len);
if (len != 8)
{
JS_ReportError(cx, "array length error: %d, was expecting 8", len);
}
for (uint32_t i=0; i < len; i++)
{
JS::RootedValue value(cx);
if (JS_GetElement(cx, jsVec3Array, i, &value))
{
ok &= jsval_to_vector3(cx, value, &arg0[i]);
if(!ok)
break;
}
}
ok &= jsval_to_cccolor4f(cx, args.get(1), &arg1);
JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_DrawNode3D_drawCube : Error processing arguments");
cobj->drawCube(arg0, arg1);
args.rval().setUndefined();
return true;
}
JS_ReportError(cx, "js_cocos2dx_DrawNode3D_drawCube : wrong number of arguments: %d, was expecting %d", argc, 2);
return false;
}
bool js_cocos2dx_DrawNode3D_constructor(JSContext *cx, uint32_t argc, jsval *vp)
{
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
bool ok = true;
cocos2d::DrawNode3D* cobj = new (std::nothrow) cocos2d::DrawNode3D();
cobj->init();
cocos2d::Ref *_ccobj = dynamic_cast<cocos2d::Ref *>(cobj);
if (_ccobj) {
_ccobj->autorelease();
}
TypeTest<cocos2d::DrawNode3D> t;
js_type_class_t *typeClass = nullptr;
std::string typeName = t.s_name();
auto typeMapIter = _js_global_type_map.find(typeName);
CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!");
typeClass = typeMapIter->second;
CCASSERT(typeClass, "The value is null.");
// JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto);
JS::RootedObject proto(cx, typeClass->proto.get());
JS::RootedObject parent(cx, typeClass->parentProto.get());
JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent));
args.rval().set(OBJECT_TO_JSVAL(obj));
// link the native object with the javascript object
js_proxy_t* p = jsb_new_proxy(cobj, obj);
AddNamedObjectRoot(cx, &p->obj, "cocos2d::DrawNode3D");
if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok)
ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args);
return true;
}
static bool js_is_native_obj(JSContext *cx, uint32_t argc, jsval *vp)
{
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
args.rval().setBoolean(true);
return true;
}
extern JSObject *jsb_cocos2d_Node_prototype;
void js_cocos2d_DrawNode3D_finalize(JSFreeOp *fop, JSObject *obj) {
CCLOGINFO("jsbindings: finalizing JS object %p (DrawNode3D)", obj);
}
void js_register_cocos2dx_DrawNode3D(JSContext *cx, JS::HandleObject global) {
jsb_cocos2d_DrawNode3D_class = (JSClass *)calloc(1, sizeof(JSClass));
jsb_cocos2d_DrawNode3D_class->name = "DrawNode3D";
jsb_cocos2d_DrawNode3D_class->addProperty = JS_PropertyStub;
jsb_cocos2d_DrawNode3D_class->delProperty = JS_DeletePropertyStub;
jsb_cocos2d_DrawNode3D_class->getProperty = JS_PropertyStub;
jsb_cocos2d_DrawNode3D_class->setProperty = JS_StrictPropertyStub;
jsb_cocos2d_DrawNode3D_class->enumerate = JS_EnumerateStub;
jsb_cocos2d_DrawNode3D_class->resolve = JS_ResolveStub;
jsb_cocos2d_DrawNode3D_class->convert = JS_ConvertStub;
jsb_cocos2d_DrawNode3D_class->finalize = js_cocos2d_DrawNode3D_finalize;
jsb_cocos2d_DrawNode3D_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2);
static JSPropertySpec properties[] = {
JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_PS_END
};
static JSFunctionSpec funcs[] = {
JS_FN("getBlendFunc", js_cocos2dx_DrawNode3D_getBlendFunc, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("setBlendFunc", js_cocos2dx_DrawNode3D_setBlendFunc, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("drawLine", js_cocos2dx_DrawNode3D_drawLine, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("clear", js_cocos2dx_DrawNode3D_clear, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("onDraw", js_cocos2dx_DrawNode3D_onDraw, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("init", js_cocos2dx_DrawNode3D_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("drawCube", js_cocos2dx_DrawNode3D_drawCube, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FS_END
};
static JSFunctionSpec st_funcs[] = {
JS_FS_END
};
jsb_cocos2d_DrawNode3D_prototype = JS_InitClass(
cx, global,
JS::RootedObject(cx, jsb_cocos2d_Node_prototype),
jsb_cocos2d_DrawNode3D_class,
js_cocos2dx_DrawNode3D_constructor, 0, // constructor
properties,
funcs,
NULL, // no static properties
st_funcs);
// make the class enumerable in the registered namespace
// bool found;
//FIXME: Removed in Firefox v27
// JS_SetPropertyAttributes(cx, global, "DrawNode3D", JSPROP_ENUMERATE | JSPROP_READONLY, &found);
// add the proto and JSClass to the type->js info hash table
TypeTest<cocos2d::DrawNode3D> t;
js_type_class_t *p;
std::string typeName = t.s_name();
if (_js_global_type_map.find(typeName) == _js_global_type_map.end())
{
p = (js_type_class_t *)malloc(sizeof(js_type_class_t));
p->jsclass = jsb_cocos2d_DrawNode3D_class;
p->proto = jsb_cocos2d_DrawNode3D_prototype;
p->parentProto = jsb_cocos2d_Node_prototype;
_js_global_type_map.insert(std::make_pair(typeName, p));
}
}
void register_DrawNode3D_bindings(JSContext *cx, JS::HandleObject global)
{
JS::RootedObject ccobj(cx);
get_or_create_js_obj(cx, global, "cc", &ccobj);
js_register_cocos2dx_DrawNode3D(cx, ccobj);
}

View File

@ -0,0 +1,31 @@
/****************************************************************************
Copyright (c) 2014 Chukong Technologies Inc.
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#ifndef __js_tests_bindings_h__
#define __js_tests_bindings_h__
#include "jsapi.h"
void register_DrawNode3D_bindings(JSContext *cx, JS::HandleObject global);
#endif

View File

@ -0,0 +1,777 @@
/****************************************************************************
Copyright (c) 2014 Chukong Technologies Inc.
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "js_Effect3D_bindings.h"
#include "cocos2d_specifics.hpp"
using namespace cocos2d;
class EffectSprite3D;
class Effect3D : public Ref
{
public:
virtual void draw(const Mat4 &transform) = 0;
virtual void setTarget(EffectSprite3D *sprite) = 0;
protected:
Effect3D() : _glProgramState(nullptr) {}
virtual ~Effect3D()
{
CC_SAFE_RELEASE(_glProgramState);
}
protected:
GLProgramState* _glProgramState;
};
class Effect3DOutline: public Effect3D
{
public:
static Effect3DOutline* create();
void setOutlineColor(const Vec3& color);
void setOutlineWidth(float width);
virtual void draw(const Mat4 &transform) override;
virtual void setTarget(EffectSprite3D *sprite) override;
Effect3DOutline();
virtual ~Effect3DOutline();
bool init();
protected:
Vec3 _outlineColor;
float _outlineWidth;
//weak reference
EffectSprite3D* _sprite;
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8 || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
EventListenerCustom* _backToForegroundListener;
#endif
protected:
static const std::string _vertShaderFile;
static const std::string _fragShaderFile;
static const std::string _keyInGLProgramCache;
static const std::string _vertSkinnedShaderFile;
static const std::string _fragSkinnedShaderFile;
static const std::string _keySkinnedInGLProgramCache;
static GLProgram* getOrCreateProgram(bool isSkinned = false);
};
class EffectSprite3D : public Sprite3D
{
public:
static EffectSprite3D* createFromObjFileAndTexture(const std::string& objFilePath, const std::string& textureFilePath);
static EffectSprite3D* create(const std::string& path);
void setEffect3D(Effect3D* effect);
void addEffect(Effect3DOutline* effect, ssize_t order);
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
EffectSprite3D();
virtual ~EffectSprite3D();
protected:
std::vector<std::tuple<ssize_t,Effect3D*,CustomCommand>> _effects;
Effect3D* _defaultEffect;
CustomCommand _command;
};
EffectSprite3D* EffectSprite3D::createFromObjFileAndTexture(const std::string &objFilePath, const std::string &textureFilePath)
{
auto sprite = new (std::nothrow) EffectSprite3D();
if (sprite && sprite->initWithFile(objFilePath))
{
sprite->autorelease();
if(textureFilePath.size() > 0)
sprite->setTexture(textureFilePath);
return sprite;
}
CC_SAFE_DELETE(sprite);
return nullptr;
}
EffectSprite3D* EffectSprite3D::create(const std::string &path)
{
if (path.length() < 4)
CCASSERT(false, "improper name specified when creating Sprite3D");
auto sprite = new (std::nothrow) EffectSprite3D();
if (sprite && sprite->initWithFile(path))
{
sprite->autorelease();
return sprite;
}
CC_SAFE_DELETE(sprite);
return nullptr;
}
EffectSprite3D::EffectSprite3D()
: _defaultEffect(nullptr)
{
}
EffectSprite3D::~EffectSprite3D()
{
for(auto effect : _effects)
{
CC_SAFE_RELEASE_NULL(std::get<1>(effect));
}
CC_SAFE_RELEASE(_defaultEffect);
}
void EffectSprite3D::setEffect3D(Effect3D *effect)
{
if(_defaultEffect == effect) return;
CC_SAFE_RETAIN(effect);
CC_SAFE_RELEASE(_defaultEffect);
_defaultEffect = effect;
}
static int tuple_sort( const std::tuple<ssize_t,Effect3D*,CustomCommand> &tuple1, const std::tuple<ssize_t,Effect3D*,CustomCommand> &tuple2 )
{
return std::get<0>(tuple1) < std::get<0>(tuple2);
}
void EffectSprite3D::addEffect(Effect3DOutline* effect, ssize_t order)
{
if(nullptr == effect) return;
effect->retain();
effect->setTarget(this);
_effects.push_back(std::make_tuple(order,effect,CustomCommand()));
std::sort(std::begin(_effects), std::end(_effects), tuple_sort);
}
const std::string Effect3DOutline::_vertShaderFile = "Shaders3D/OutLine.vert";
const std::string Effect3DOutline::_fragShaderFile = "Shaders3D/OutLine.frag";
const std::string Effect3DOutline::_keyInGLProgramCache = "Effect3DLibrary_Outline";
const std::string Effect3DOutline::_vertSkinnedShaderFile = "Shaders3D/SkinnedOutline.vert";
const std::string Effect3DOutline::_fragSkinnedShaderFile = "Shaders3D/OutLine.frag";
const std::string Effect3DOutline::_keySkinnedInGLProgramCache = "Effect3DLibrary_Outline";
GLProgram* Effect3DOutline::getOrCreateProgram(bool isSkinned /* = false */ )
{
if(isSkinned)
{
auto program = GLProgramCache::getInstance()->getGLProgram(_keySkinnedInGLProgramCache);
if(program == nullptr)
{
program = GLProgram::createWithFilenames(_vertSkinnedShaderFile, _fragSkinnedShaderFile);
GLProgramCache::getInstance()->addGLProgram(program, _keySkinnedInGLProgramCache);
}
return program;
}
else
{
auto program = GLProgramCache::getInstance()->getGLProgram(_keyInGLProgramCache);
if(program == nullptr)
{
program = GLProgram::createWithFilenames(_vertShaderFile, _fragShaderFile);
GLProgramCache::getInstance()->addGLProgram(program, _keyInGLProgramCache);
}
return program;
}
}
Effect3DOutline* Effect3DOutline::create()
{
Effect3DOutline* effect = new (std::nothrow) Effect3DOutline();
if(effect && effect->init())
{
effect->autorelease();
return effect;
}
else
{
CC_SAFE_DELETE(effect);
return nullptr;
}
}
bool Effect3DOutline::init()
{
return true;
}
Effect3DOutline::Effect3DOutline()
: _outlineWidth(1.0f)
, _outlineColor(1, 1, 1)
, _sprite(nullptr)
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8 || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
_backToForegroundListener = EventListenerCustom::create(EVENT_RENDERER_RECREATED,
[this](EventCustom*)
{
auto glProgram = _glProgramState->getGLProgram();
glProgram->reset();
glProgram->initWithFilenames(_vertShaderFile, _fragShaderFile);
glProgram->link();
glProgram->updateUniforms();
}
);
Director::getInstance()->getEventDispatcher()->addEventListenerWithFixedPriority(_backToForegroundListener, -1);
#endif
}
Effect3DOutline::~Effect3DOutline()
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8 || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
Director::getInstance()->getEventDispatcher()->removeEventListener(_backToForegroundListener);
#endif
}
void Effect3DOutline::setOutlineColor(const Vec3& color)
{
if(_outlineColor != color)
{
_outlineColor = color;
if(_glProgramState)
_glProgramState->setUniformVec3("OutLineColor", _outlineColor);
}
}
void Effect3DOutline::setOutlineWidth(float width)
{
if(_outlineWidth != width)
{
_outlineWidth = width;
if(_glProgramState)
_glProgramState->setUniformFloat("OutlineWidth", _outlineWidth);
}
}
void Effect3DOutline::setTarget(EffectSprite3D *sprite)
{
CCASSERT(nullptr != sprite && nullptr != sprite->getMesh(),"Error: Setting a null pointer or a null mesh EffectSprite3D to Effect3D");
if(sprite != _sprite)
{
GLProgram* glprogram;
if(!sprite->getMesh()->getSkin())
glprogram = GLProgram::createWithFilenames(_vertShaderFile, _fragShaderFile);
else
glprogram = GLProgram::createWithFilenames(_vertSkinnedShaderFile, _fragSkinnedShaderFile);
_glProgramState = GLProgramState::create(glprogram);
_glProgramState->retain();
_glProgramState->setUniformVec3("OutLineColor", _outlineColor);
_glProgramState->setUniformFloat("OutlineWidth", _outlineWidth);
_sprite = sprite;
auto mesh = sprite->getMesh();
long offset = 0;
for (auto i = 0; i < mesh->getMeshVertexAttribCount(); i++)
{
auto meshvertexattrib = mesh->getMeshVertexAttribute(i);
_glProgramState->setVertexAttribPointer(s_attributeNames[meshvertexattrib.vertexAttrib],
meshvertexattrib.size,
meshvertexattrib.type,
GL_FALSE,
mesh->getVertexSizeInBytes(),
(void*)offset);
offset += meshvertexattrib.attribSizeBytes;
}
Color4F color(_sprite->getDisplayedColor());
color.a = _sprite->getDisplayedOpacity() / 255.0f;
_glProgramState->setUniformVec4("u_color", Vec4(color.r, color.g, color.b, color.a));
}
}
static void MatrixPalleteCallBack( GLProgram* glProgram, Uniform* uniform, int paletteSize, const float* palette)
{
glUniform4fv( uniform->location, (GLsizei)paletteSize, (const float*)palette );
}
void Effect3DOutline::draw(const Mat4 &transform)
{
//draw
Color4F color(_sprite->getDisplayedColor());
color.a = _sprite->getDisplayedOpacity() / 255.0f;
_glProgramState->setUniformVec4("u_color", Vec4(color.r, color.g, color.b, color.a));
if(_sprite && _sprite->getMesh())
{
glEnable(GL_CULL_FACE);
glCullFace(GL_FRONT);
glEnable(GL_DEPTH_TEST);
auto mesh = _sprite->getMesh();
glBindBuffer(GL_ARRAY_BUFFER, mesh->getVertexBuffer());
auto skin = _sprite->getMesh()->getSkin();
if(_sprite && skin)
{
auto function = std::bind(MatrixPalleteCallBack, std::placeholders::_1, std::placeholders::_2,
skin->getMatrixPaletteSize(), (float*)skin->getMatrixPalette());
_glProgramState->setUniformCallback("u_matrixPalette", function);
}
if(_sprite)
_glProgramState->apply(transform);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mesh->getIndexBuffer());
glDrawElements(mesh->getPrimitiveType(), (GLsizei)mesh->getIndexCount(), mesh->getIndexFormat(), 0);
CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1, mesh->getIndexCount());
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glDisable(GL_DEPTH_TEST);
glCullFace(GL_BACK);
glDisable(GL_CULL_FACE);
}
}
void EffectSprite3D::draw(cocos2d::Renderer *renderer, const cocos2d::Mat4 &transform, uint32_t flags)
{
for(auto &effect : _effects)
{
if(std::get<0>(effect) >=0)
break;
CustomCommand &cc = std::get<2>(effect);
cc.func = CC_CALLBACK_0(Effect3D::draw,std::get<1>(effect),transform);
renderer->addCommand(&cc);
}
if(!_defaultEffect)
{
Sprite3D::draw(renderer, transform, flags);
}
else
{
_command.init(_globalZOrder, transform, flags);
_command.func = CC_CALLBACK_0(Effect3D::draw, _defaultEffect, transform);
renderer->addCommand(&_command);
}
for(auto &effect : _effects)
{
if(std::get<0>(effect) <=0)
continue;
CustomCommand &cc = std::get<2>(effect);
cc.func = CC_CALLBACK_0(Effect3D::draw,std::get<1>(effect),transform);
renderer->addCommand(&cc);
}
}
// js bindings
static bool js_is_native_obj(JSContext *cx, uint32_t argc, jsval *vp)
{
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
args.rval().setBoolean(true);
return true;
}
JSClass *jsb_Effect3DOutline_class;
JSObject *jsb_Effect3DOutline_prototype;
bool js_cocos2dx_Effect3DOutline_setOutlineWidth(JSContext *cx, uint32_t argc, jsval *vp)
{
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
bool ok = true;
JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
js_proxy_t *proxy = jsb_get_js_proxy(obj);
Effect3DOutline* cobj = (Effect3DOutline *)(proxy ? proxy->ptr : NULL);
JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Effect3DOutline_setOutlineWidth : Invalid Native Object");
if (argc == 1) {
double arg0;
ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0);
JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Effect3DOutline_setOutlineWidth : Error processing arguments");
cobj->setOutlineWidth(arg0);
args.rval().setUndefined();
return true;
}
JS_ReportError(cx, "js_cocos2dx_Effect3DOutline_setOutlineWidth : wrong number of arguments: %d, was expecting %d", argc, 1);
return false;
}
bool js_cocos2dx_Effect3DOutline_setOutlineColor(JSContext *cx, uint32_t argc, jsval *vp)
{
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
bool ok = true;
JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
js_proxy_t *proxy = jsb_get_js_proxy(obj);
Effect3DOutline* cobj = (Effect3DOutline *)(proxy ? proxy->ptr : NULL);
JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Effect3DOutline_setOutlineColor : Invalid Native Object");
if (argc == 1) {
cocos2d::Vec3 arg0;
ok &= jsval_to_vector3(cx, args.get(0), &arg0);
JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Effect3DOutline_setOutlineColor : Error processing arguments");
cobj->setOutlineColor(arg0);
args.rval().setUndefined();
return true;
}
JS_ReportError(cx, "js_cocos2dx_Effect3DOutline_setOutlineColor : wrong number of arguments: %d, was expecting %d", argc, 1);
return false;
}
bool js_cocos2dx_Effect3DOutline_create(JSContext *cx, uint32_t argc, jsval *vp)
{
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
if (argc == 0) {
Effect3DOutline* ret = Effect3DOutline::create();
jsval jsret = JSVAL_NULL;
do {
if (ret) {
js_proxy_t *jsProxy = js_get_or_create_proxy<Effect3DOutline>(cx, (Effect3DOutline*)ret);
jsret = OBJECT_TO_JSVAL(jsProxy->obj);
} else {
jsret = JSVAL_NULL;
}
} while (0);
args.rval().set(jsret);
return true;
}
JS_ReportError(cx, "js_cocos2dx_Effect3DOutline_create : wrong number of arguments");
return false;
}
JSObject *jsb_Effect3D_prototype;
void js_Effect3DOutline_finalize(JSFreeOp *fop, JSObject *obj) {
CCLOGINFO("jsbindings: finalizing JS object %p (Effect3DOutline)", obj);
}
bool jsb_Effect3DOutline_constructor(JSContext *cx, uint32_t argc, jsval *vp)
{
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
bool ok = true;
Effect3DOutline* cobj = new (std::nothrow) Effect3DOutline();
cobj->init();
cobj->autorelease();
TypeTest<Effect3DOutline> t;
js_type_class_t *typeClass = nullptr;
std::string typeName = t.s_name();
auto typeMapIter = _js_global_type_map.find(typeName);
CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!");
typeClass = typeMapIter->second;
CCASSERT(typeClass, "The value is null.");
// JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto);
JS::RootedObject proto(cx, typeClass->proto.get());
JS::RootedObject parent(cx, typeClass->parentProto.get());
JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent));
args.rval().set(OBJECT_TO_JSVAL(obj));
// link the native object with the javascript object
js_proxy_t* p = jsb_new_proxy(cobj, obj);
AddNamedObjectRoot(cx, &p->obj, "cocos2d::Effect3DOutline");
if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok)
ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args);
return true;
}
void js_register_cocos2dx_Effect3DOutline(JSContext *cx, JS::HandleObject global) {
jsb_Effect3DOutline_class = (JSClass *)calloc(1, sizeof(JSClass));
jsb_Effect3DOutline_class->name = "Effect3DOutline";
jsb_Effect3DOutline_class->addProperty = JS_PropertyStub;
jsb_Effect3DOutline_class->delProperty = JS_DeletePropertyStub;
jsb_Effect3DOutline_class->getProperty = JS_PropertyStub;
jsb_Effect3DOutline_class->setProperty = JS_StrictPropertyStub;
jsb_Effect3DOutline_class->enumerate = JS_EnumerateStub;
jsb_Effect3DOutline_class->resolve = JS_ResolveStub;
jsb_Effect3DOutline_class->convert = JS_ConvertStub;
jsb_Effect3DOutline_class->finalize = js_Effect3DOutline_finalize;
jsb_Effect3DOutline_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2);
static JSPropertySpec properties[] = {
JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_PS_END
};
static JSFunctionSpec funcs[] = {
JS_FN("setOutlineWidth", js_cocos2dx_Effect3DOutline_setOutlineWidth, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("setOutlineColor", js_cocos2dx_Effect3DOutline_setOutlineColor, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FS_END
};
static JSFunctionSpec st_funcs[] = {
JS_FN("create", js_cocos2dx_Effect3DOutline_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FS_END
};
jsb_Effect3DOutline_prototype = JS_InitClass(
cx, global,
JS::RootedObject(cx, jsb_Effect3D_prototype),
jsb_Effect3DOutline_class,
jsb_Effect3DOutline_constructor, 0,
properties,
funcs,
NULL, // no static properties
st_funcs);
// make the class enumerable in the registered namespace
// bool found;
//FIXME: Removed in Firefox v27
// JS_SetPropertyAttributes(cx, global, "Effect3DOutline", JSPROP_ENUMERATE | JSPROP_READONLY, &found);
// add the proto and JSClass to the type->js info hash table
TypeTest<Effect3DOutline> t;
js_type_class_t *p;
std::string typeName = t.s_name();
if (_js_global_type_map.find(typeName) == _js_global_type_map.end())
{
p = (js_type_class_t *)malloc(sizeof(js_type_class_t));
p->jsclass = jsb_Effect3DOutline_class;
p->proto = jsb_Effect3DOutline_prototype;
p->parentProto = jsb_Effect3D_prototype;
_js_global_type_map.insert(std::make_pair(typeName, p));
}
}
JSClass *jsb_EffectSprite3D_class;
JSObject *jsb_EffectSprite3D_prototype;
bool js_cocos2dx_EffectSprite3D_setEffect3D(JSContext *cx, uint32_t argc, jsval *vp)
{
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
bool ok = true;
JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
js_proxy_t *proxy = jsb_get_js_proxy(obj);
EffectSprite3D* cobj = (EffectSprite3D *)(proxy ? proxy->ptr : NULL);
JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_EffectSprite3D_setEffect3D : Invalid Native Object");
if (argc == 1) {
Effect3D* arg0;
do {
if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull();
jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (Effect3D*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object");
} while (0);
JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_EffectSprite3D_setEffect3D : Error processing arguments");
cobj->setEffect3D(arg0);
args.rval().setUndefined();
return true;
}
JS_ReportError(cx, "js_cocos2dx_EffectSprite3D_setEffect3D : wrong number of arguments: %d, was expecting %d", argc, 1);
return false;
}
bool js_cocos2dx_EffectSprite3D_addEffect(JSContext *cx, uint32_t argc, jsval *vp)
{
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
bool ok = true;
JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
js_proxy_t *proxy = jsb_get_js_proxy(obj);
EffectSprite3D* cobj = (EffectSprite3D *)(proxy ? proxy->ptr : NULL);
JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_EffectSprite3D_addEffect : Invalid Native Object");
if (argc == 2) {
Effect3DOutline* arg0;
ssize_t arg1;
do {
if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull();
jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (Effect3DOutline*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object");
} while (0);
ok &= jsval_to_ssize(cx, args.get(1), &arg1);
JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_EffectSprite3D_addEffect : Error processing arguments");
cobj->addEffect(arg0, arg1);
args.rval().setUndefined();
return true;
}
JS_ReportError(cx, "js_cocos2dx_EffectSprite3D_addEffect : wrong number of arguments: %d, was expecting %d", argc, 2);
return false;
}
bool js_cocos2dx_EffectSprite3D_createFromObjFileAndTexture(JSContext *cx, uint32_t argc, jsval *vp)
{
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
bool ok = true;
if (argc == 2) {
std::string arg0;
std::string arg1;
ok &= jsval_to_std_string(cx, args.get(0), &arg0);
ok &= jsval_to_std_string(cx, args.get(1), &arg1);
JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_EffectSprite3D_createFromObjFileAndTexture : Error processing arguments");
EffectSprite3D* ret = EffectSprite3D::createFromObjFileAndTexture(arg0, arg1);
jsval jsret = JSVAL_NULL;
do {
if (ret) {
js_proxy_t *jsProxy = js_get_or_create_proxy<EffectSprite3D>(cx, (EffectSprite3D*)ret);
jsret = OBJECT_TO_JSVAL(jsProxy->obj);
} else {
jsret = JSVAL_NULL;
}
} while (0);
args.rval().set(jsret);
return true;
}
JS_ReportError(cx, "js_cocos2dx_EffectSprite3D_createFromObjFileAndTexture : wrong number of arguments");
return false;
}
bool js_cocos2dx_EffectSprite3D_create(JSContext *cx, uint32_t argc, jsval *vp)
{
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
bool ok = true;
if (argc == 1) {
std::string arg0;
ok &= jsval_to_std_string(cx, args.get(0), &arg0);
JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_EffectSprite3D_create : Error processing arguments");
EffectSprite3D* ret = EffectSprite3D::create(arg0);
jsval jsret = JSVAL_NULL;
do {
if (ret) {
js_proxy_t *jsProxy = js_get_or_create_proxy<EffectSprite3D>(cx, (EffectSprite3D*)ret);
jsret = OBJECT_TO_JSVAL(jsProxy->obj);
} else {
jsret = JSVAL_NULL;
}
} while (0);
args.rval().set(jsret);
return true;
}
JS_ReportError(cx, "js_cocos2dx_EffectSprite3D_create : wrong number of arguments");
return false;
}
extern JSObject *jsb_cocos2d_Sprite3D_prototype;
void js_EffectSprite3D_finalize(JSFreeOp *fop, JSObject *obj) {
CCLOGINFO("jsbindings: finalizing JS object %p (EffectSprite3D)", obj);
}
bool jsb_EffectSprite3D_constructor(JSContext *cx, uint32_t argc, jsval *vp)
{
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
bool ok = true;
EffectSprite3D* cobj = new (std::nothrow) EffectSprite3D();
if(argc == 1 || argc == 2)
{
std::string path;
jsval_to_std_string(cx, args.get(0), &path);
cobj->initWithFile(path);
if(argc == 2)
{
std::string texture;
jsval_to_std_string(cx, args.get(1), &texture);
cobj->setTexture(texture);
}
}
cobj->autorelease();
TypeTest<EffectSprite3D> t;
js_type_class_t *typeClass = nullptr;
std::string typeName = t.s_name();
auto typeMapIter = _js_global_type_map.find(typeName);
CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!");
typeClass = typeMapIter->second;
CCASSERT(typeClass, "The value is null.");
// JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto);
JS::RootedObject proto(cx, typeClass->proto.get());
JS::RootedObject parent(cx, typeClass->parentProto.get());
JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent));
args.rval().set(OBJECT_TO_JSVAL(obj));
// link the native object with the javascript object
js_proxy_t* p = jsb_new_proxy(cobj, obj);
AddNamedObjectRoot(cx, &p->obj, "cocos2d::EffectSprite3D");
if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok)
ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args);
return true;
}
void js_register_cocos2dx_EffectSprite3D(JSContext *cx, JS::HandleObject global) {
jsb_EffectSprite3D_class = (JSClass *)calloc(1, sizeof(JSClass));
jsb_EffectSprite3D_class->name = "EffectSprite3D";
jsb_EffectSprite3D_class->addProperty = JS_PropertyStub;
jsb_EffectSprite3D_class->delProperty = JS_DeletePropertyStub;
jsb_EffectSprite3D_class->getProperty = JS_PropertyStub;
jsb_EffectSprite3D_class->setProperty = JS_StrictPropertyStub;
jsb_EffectSprite3D_class->enumerate = JS_EnumerateStub;
jsb_EffectSprite3D_class->resolve = JS_ResolveStub;
jsb_EffectSprite3D_class->convert = JS_ConvertStub;
jsb_EffectSprite3D_class->finalize = js_EffectSprite3D_finalize;
jsb_EffectSprite3D_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2);
static JSPropertySpec properties[] = {
JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_PS_END
};
static JSFunctionSpec funcs[] = {
JS_FN("setEffect3D", js_cocos2dx_EffectSprite3D_setEffect3D, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("addEffect", js_cocos2dx_EffectSprite3D_addEffect, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FS_END
};
static JSFunctionSpec st_funcs[] = {
JS_FN("createFromObjFileAndTexture", js_cocos2dx_EffectSprite3D_createFromObjFileAndTexture, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("create", js_cocos2dx_EffectSprite3D_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FS_END
};
jsb_EffectSprite3D_prototype = JS_InitClass(
cx, global,
JS::RootedObject(cx, jsb_cocos2d_Sprite3D_prototype),
jsb_EffectSprite3D_class,
jsb_EffectSprite3D_constructor, 1,
properties,
funcs,
NULL, // no static properties
st_funcs);
// make the class enumerable in the registered namespace
// bool found;
//FIXME: Removed in Firefox v27
// JS_SetPropertyAttributes(cx, global, "EffectSprite3D", JSPROP_ENUMERATE | JSPROP_READONLY, &found);
// add the proto and JSClass to the type->js info hash table
TypeTest<EffectSprite3D> t;
js_type_class_t *p;
std::string typeName = t.s_name();
if (_js_global_type_map.find(typeName) == _js_global_type_map.end())
{
p = (js_type_class_t *)malloc(sizeof(js_type_class_t));
p->jsclass = jsb_EffectSprite3D_class;
p->proto = jsb_EffectSprite3D_prototype;
p->parentProto = jsb_cocos2d_Sprite3D_prototype;
_js_global_type_map.insert(std::make_pair(typeName, p));
}
}
void register_Effect3D_bindings(JSContext *cx, JS::HandleObject global)
{
JS::RootedObject ccobj(cx);
get_or_create_js_obj(cx, global, "cc", &ccobj);
js_register_cocos2dx_Effect3DOutline(cx, ccobj);
js_register_cocos2dx_EffectSprite3D(cx, ccobj);
}

View File

@ -0,0 +1,31 @@
/****************************************************************************
Copyright (c) 2014 Chukong Technologies Inc.
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#ifndef __js_effect3d_bindings_h__
#define __js_effect3d_bindings_h__
#include "jsapi.h"
void register_Effect3D_bindings(JSContext *cx, JS::HandleObject global);
#endif

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>

View File

@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>JSTests</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.cdt.core.cnature</nature>
<nature>org.eclipse.cdt.core.ccnature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
</natures>
</projectDescription>

View File

@ -0,0 +1,54 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.cocos2dx.js_tests"
android:installLocation="preferExternal"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="9"/>
<uses-feature android:glEsVersion="0x00020000" />
<application android:label="@string/app_name"
android:icon="@drawable/icon">
<!-- Tell NativeActivity the name of our .so -->
<meta-data android:name="android.app.lib_name" android:value="js_tests" />
<!-- facebook test-->
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/app_id" />
<activity android:name=".AppActivity"
android:label="@string/app_name"
android:screenOrientation="landscape"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:configChanges="orientation">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.facebook.LoginActivity"
android:theme="@android:style/Theme.Translucent.NoTitleBar"
android:label="@string/app_name" />
<provider android:authorities="com.facebook.app.NativeAppCallContentProvider1426774790893461"
android:name="com.facebook.NativeAppCallContentProvider"
android:exported="true"/>
<meta-data android:value="50d2af93527015338b000052" android:name="UMENG_APPKEY"></meta-data>
</application>
<supports-screens android:anyDensity="true"
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_LOGS" />
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
</manifest>

View File

@ -0,0 +1 @@
aapt.ignore.assets="!*.pvr.gz:!*.gz:!.svn:!.git:.*:<dir>_*:!CVS:!thumbs.db:!picasa.ini:!*.scc:*~"

View File

@ -0,0 +1,65 @@
{
"copy_resources": [
{
"from": "../../src",
"to": "src"
},
{
"from": "../../res",
"to": "res"
},
{
"from": "../../../cpp-tests/Resources/",
"to": "res/"
},
{
"from": "../../main.js",
"to": ""
},
{
"from": "../../project.json",
"to": ""
},
{
"from": "../../../../cocos/scripting/js-bindings/script",
"to": "script"
},
{
"from": "../../../../plugin/jsbindings/script",
"to": ""
},
{
"from": "../../../../plugin/protocols/proj.android/src",
"to": "../src"
},
{
"from": "../../../../plugin/plugins/umeng/proj.android/src",
"to": "../src"
},
{
"from": "../../../../plugin/plugins/umeng/proj.android/sdk",
"to": "../libs"
},
{
"from": "../../../../plugin/plugins/flurry/proj.android/src",
"to": "../src"
},
{
"from": "../../../../plugin/plugins/flurry/proj.android/sdk",
"to": "../libs"
},
{
"from": "../../../../plugin/plugins/facebook/proj.android/src",
"to": "../src"
},
{
"from": "../../../../plugin/plugins/facebook/proj.android/sdk",
"to": "../libs"
}
],
"ndk_module_path": [
"../../../..",
"../../../../cocos",
"../../../../external"
]
}

View File

@ -0,0 +1,92 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="JSTests" default="help">
<!-- The local.properties file is created and updated by the 'android' tool.
It contains the path to the SDK. It should *NOT* be checked into
Version Control Systems. -->
<property file="local.properties" />
<!-- The ant.properties file can be created by you. It is only edited by the
'android' tool to add properties to it.
This is the place to change some Ant specific build properties.
Here are some properties you may want to change/update:
source.dir
The name of the source directory. Default is 'src'.
out.dir
The name of the output directory. Default is 'bin'.
For other overridable properties, look at the beginning of the rules
files in the SDK, at tools/ant/build.xml
Properties related to the SDK location or the project target should
be updated using the 'android' tool with the 'update' action.
This file is an integral part of the build system for your
application and should be checked into Version Control Systems.
-->
<property file="ant.properties" />
<!-- if sdk.dir was not set from one of the property file, then
get it from the ANDROID_HOME env var.
This must be done before we load project.properties since
the proguard config can use sdk.dir -->
<property environment="env" />
<condition property="sdk.dir" value="${env.ANDROID_HOME}">
<isset property="env.ANDROID_HOME" />
</condition>
<!-- The project.properties file is created and updated by the 'android'
tool, as well as ADT.
This contains project specific properties such as project target, and library
dependencies. Lower level build properties are stored in ant.properties
(or in .classpath for Eclipse projects).
This file is an integral part of the build system for your
application and should be checked into Version Control Systems. -->
<loadproperties srcFile="project.properties" />
<!-- quick check on sdk.dir -->
<fail
message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through the ANDROID_HOME environment variable."
unless="sdk.dir"
/>
<!--
Import per project custom build rules if present at the root of the project.
This is the place to put custom intermediary targets such as:
-pre-build
-pre-compile
-post-compile (This is typically used for code obfuscation.
Compiled code location: ${out.classes.absolute.dir}
If this is not done in place, override ${out.dex.input.absolute.dir})
-post-package
-post-build
-pre-clean
-->
<import file="custom_rules.xml" optional="true" />
<!-- Import the actual build file.
To customize existing targets, there are two options:
- Customize only one target:
- copy/paste the target into this file, *before* the
<import> task.
- customize it to your needs.
- Customize the whole content of build.xml
- copy/paste the content of the rules files (minus the top node)
into this file, replacing the <import> task.
- customize to your needs.
***********************
****** IMPORTANT ******
***********************
In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
in order to avoid having your file be overridden by tools such as "android update project"
-->
<!-- version-tag: 1 -->
<import file="${sdk.dir}/tools/ant/build.xml" />
</project>

View File

@ -0,0 +1,23 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := js_tests_shared
LOCAL_MODULE_FILENAME := libjs_tests
LOCAL_SRC_FILES := main.cpp \
../../Classes/AppDelegate.cpp \
../../Classes/js_DrawNode3D_bindings.cpp \
../../Classes/js_Effect3D_bindings.cpp
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes
LOCAL_STATIC_LIBRARIES := cocos2d_js_static
LOCAL_EXPORT_CFLAGS := -DCOCOS2D_DEBUG=1
include $(BUILD_SHARED_LIBRARY)
$(call import-module,scripting/js-bindings/proj.android)

View File

@ -0,0 +1,15 @@
APP_STL := gnustl_static
# Uncomment this line to compile to armeabi-v7a, your application will run faster but support less devices
#APP_ABI := armeabi-v7a
APP_CPPFLAGS := -frtti -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 -std=c++11 -fsigned-char
APP_LDFLAGS := -latomic
ifeq ($(NDK_DEBUG),1)
APP_CPPFLAGS += -DCOCOS2D_DEBUG=1
APP_OPTIM := debug
else
APP_CPPFLAGS += -DNDEBUG
APP_OPTIM := release
endif

View File

@ -0,0 +1,17 @@
#include "AppDelegate.h"
#include "cocos2d.h"
#include "platform/android/jni/JniHelper.h"
#include <jni.h>
#include <android/log.h>
#define LOG_TAG "main"
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__)
using namespace cocos2d;
void cocos_android_app_init (JNIEnv* env, jobject thiz) {
LOGD("cocos_android_app_init");
AppDelegate *pAppDelegate = new AppDelegate();
JavaVM* vm;
env->GetJavaVM(&vm);
}

View File

@ -0,0 +1,47 @@
APPNAME="JSTests"
APP_ANDROID_NAME="org.cocos2dx.js_tests"
if [ -z "${SDK_ROOT+aaa}" ]; then
# ... if SDK_ROOT is not set, use "$HOME/bin/android-sdk"
SDK_ROOT="$HOME/bin/android-sdk"
fi
if [ -z "${NDK_ROOT+aaa}" ]; then
# ... if NDK_ROOT is not set, use "$HOME/bin/android-ndk"
NDK_ROOT="$HOME/bin/android-ndk"
fi
if [ -z "${COCOS2DX_ROOT+aaa}" ]; then
# ... if COCOS2DX_ROOT is not set
# ... find current working directory
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# ... use paths relative to current directory
COCOS2DX_ROOT="$DIR/../../.."
APP_ROOT="$DIR/.."
APP_ANDROID_ROOT="$DIR"
else
APP_ROOT="$COCOS2DX_ROOT/samples/$APPNAME"
APP_ANDROID_ROOT="$COCOS2DX_ROOT/samples/$APPNAME/proj.android"
fi
echo "NDK_ROOT = $NDK_ROOT"
echo "SDK_ROOT = $SDK_ROOT"
echo "COCOS2DX_ROOT = $COCOS2DX_ROOT"
echo "APP_ROOT = $APP_ROOT"
echo "APP_ANDROID_ROOT = $APP_ANDROID_ROOT"
echo "APP_ANDROID_NAME = $APP_ANDROID_NAME"
echo
echo "Killing and restarting ${APP_ANDROID_NAME}"
echo
set -x
"${SDK_ROOT}"/platform-tools/adb shell am force-stop "${APP_ANDROID_NAME}"
NDK_MODULE_PATH="${COCOS2DX_ROOT}":"${COCOS2DX_ROOT}"/cocos2dx/platform/third_party/android/prebuilt \
"${NDK_ROOT}"/ndk-gdb \
--adb="${SDK_ROOT}"/platform-tools/adb \
--verbose \
--start \
--force

View File

@ -0,0 +1,20 @@
# To enable ProGuard in your project, edit project.properties
# to define the proguard.config property as described in that file.
#
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in ${sdk.dir}/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the ProGuard
# include property in project.properties.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

View File

@ -0,0 +1,14 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system use,
# "ant.properties", and override values to adapt the script to your
# project structure.
# Project target.
target=android-10
android.library.reference.1=../../../../cocos/platform/android/java
android.library.reference.2=../../../../plugin/plugins/facebook/proj.android/DependProject

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.4 KiB

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">JSTests</string>
<string name="app_id">1426774790893461</string>
</resources>

View File

@ -0,0 +1,97 @@
/****************************************************************************
Copyright (c) 2010-2012 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
package org.cocos2dx.js_tests;
import org.cocos2dx.js_tests.R;
import org.cocos2dx.lib.Cocos2dxActivity;
import org.cocos2dx.lib.Cocos2dxGLSurfaceView;
import org.cocos2dx.lib.Cocos2dxJavascriptJavaBridge;
import org.cocos2dx.plugin.PluginWrapper;
import org.cocos2dx.plugin.FacebookWrapper;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
public class AppActivity extends Cocos2dxActivity {
private static AppActivity app = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
app = this;
}
@Override
public Cocos2dxGLSurfaceView onCreateView() {
Cocos2dxGLSurfaceView glSurfaceView = new Cocos2dxGLSurfaceView(this);
// TestCpp should create stencil buffer
glSurfaceView.setEGLConfigChooser(5, 6, 5, 0, 16, 8);
PluginWrapper.init(this);
PluginWrapper.setGLSurfaceView(glSurfaceView);
FacebookWrapper.onCreate(this);
return glSurfaceView;
}
public static void showAlertDialog(final String title, final String message) {
app.runOnUiThread(new Runnable() {
@Override
public void run() {
AlertDialog alertDialog = new AlertDialog.Builder(app).create();
alertDialog.setTitle(title);
alertDialog.setMessage(message);
alertDialog.setCancelable(true);
alertDialog.setIcon(R.drawable.icon);
alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
app.runOnGLThread(new Runnable() {
@Override
public void run() {
Cocos2dxJavascriptJavaBridge.evalString("cc.log(\"Javascript Java bridge!\")");
}
});
}
});
alertDialog.show();
}
});
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
FacebookWrapper.onAcitivityResult(requestCode, resultCode, data);
}
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
FacebookWrapper.onSaveInstanceState(outState);
}
}

View File

@ -0,0 +1,35 @@
/****************************************************************************
Copyright (c) 2010-2013 cocos2d-x.org
Copyright (c) 2013-2014 Chukong Technologies Inc.
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
@class RootViewController;
@interface AppController : NSObject <UIAccelerometerDelegate, UIAlertViewDelegate, UITextFieldDelegate,UIApplicationDelegate>
{
UIWindow *window;
RootViewController *viewController;
}
@end

View File

@ -0,0 +1,144 @@
/****************************************************************************
Copyright (c) 2010-2013 cocos2d-x.org
Copyright (c) 2013-2014 Chukong Technologies Inc.
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#import <UIKit/UIKit.h>
#import "cocos2d.h"
#import "AppController.h"
#import "AppDelegate.h"
#import "RootViewController.h"
#import "platform/ios/CCEAGLView-ios.h"
//#import <FacebookSDK/FacebookSDK.h>
@implementation AppController
#pragma mark -
#pragma mark Application lifecycle
// cocos2d application instance
static AppDelegate s_sharedApplication;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
// Add the view controller's view to the window and display.
window = [[UIWindow alloc] initWithFrame: [[UIScreen mainScreen] bounds]];
CCEAGLView *eaglView = [CCEAGLView viewWithFrame: [window bounds]
pixelFormat: kEAGLColorFormatRGBA8
depthFormat: GL_DEPTH24_STENCIL8_OES
preserveBackbuffer: NO
sharegroup: nil
multiSampling: NO
numberOfSamples: 0 ];
[eaglView setMultipleTouchEnabled:YES];
// Use RootViewController manage CCEAGLView
viewController = [[RootViewController alloc] initWithNibName:nil bundle:nil];
viewController.wantsFullScreenLayout = YES;
viewController.view = eaglView;
// Set RootViewController to window
if ( [[UIDevice currentDevice].systemVersion floatValue] < 6.0)
{
// warning: addSubView doesn't work on iOS6
[window addSubview: viewController.view];
}
else
{
// use this method on ios6
[window setRootViewController:viewController];
}
[window makeKeyAndVisible];
[[UIApplication sharedApplication] setStatusBarHidden: YES];
// IMPORTANT: Setting the GLView should be done after creating the RootViewController
cocos2d::GLView *glview = cocos2d::GLViewImpl::createWithEAGLView(eaglView);
cocos2d::Director::getInstance()->setOpenGLView(glview);
cocos2d::Application::getInstance()->run();
return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application {
/*
Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
*/
cocos2d::Director::getInstance()->pause();
}
//- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
//{
// return [FBSession.activeSession handleOpenURL:url];
//}
//- (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.
// */
// [FBAppCall handleDidBecomeActive];
// cocos2d::Director::getInstance()->resume();
//}
- (void)applicationDidEnterBackground:(UIApplication *)application {
/*
Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
If your application supports background execution, called instead of applicationWillTerminate: when the user quits.
*/
cocos2d::Application::getInstance()->applicationDidEnterBackground();
}
- (void)applicationWillEnterForeground:(UIApplication *)application {
/*
Called as part of transition from the background to the inactive state: here you can undo many of the changes made on entering the background.
*/
cocos2d::Application::getInstance()->applicationWillEnterForeground();
}
- (void)applicationWillTerminate:(UIApplication *)application {
/*
Called when the application is about to terminate.
See also applicationDidEnterBackground:.
*/
}
#pragma mark -
#pragma mark Memory management
- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application {
/*
Free up as much memory as possible by purging cached data objects that can be recreated (or reloaded from disk) later.
*/
cocos2d::Director::getInstance()->purgeCachedData();
}
- (void)dealloc {
[super dealloc];
}
@end

Binary file not shown.

After

Width:  |  Height:  |  Size: 189 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 87 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 567 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

View File

@ -0,0 +1,96 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleDisplayName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIconFiles</key>
<array>
<string>Icon-72.png</string>
<string>Icon.png</string>
<string>Icon@2x.png</string>
<string>Icon-57.png</string>
<string>Icon-114.png</string>
<string>Icon-144.png</string>
</array>
<key>CFBundleIcons</key>
<dict>
<key>CFBundlePrimaryIcon</key>
<dict>
<key>CFBundleIconFiles</key>
<array>
<string>Icon-72.png</string>
<string>Icon.png</string>
<string>Icon@2x.png</string>
<string>Icon-57.png</string>
<string>Icon-114.png</string>
<string>Icon-144.png</string>
</array>
<key>UIPrerenderedIcon</key>
<true/>
</dict>
</dict>
<key>CFBundleIdentifier</key>
<string>org.cocos2d-x.${PRODUCT_NAME:rfc1034identifier}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIAppFonts</key>
<array>
<string>res/fonts/A Damn Mess.ttf</string>
<string>res/fonts/Abberancy.ttf</string>
<string>res/fonts/Abduction.ttf</string>
<string>res/fonts/American Typewriter.ttf</string>
<string>res/fonts/Courier New.ttf</string>
<string>res/fonts/Marker Felt.ttf</string>
<string>res/fonts/Paint Boy.ttf</string>
<string>res/fonts/Schwarzwald Regular.ttf</string>
<string>res/fonts/Scissor Cuts.ttf</string>
<string>res/fonts/tahoma.ttf</string>
<string>res/fonts/Thonburi.ttf</string>
<string>res/fonts/ThonburiBold.ttf</string>
</array>
<key>UIPrerenderedIcon</key>
<true/>
<key>UIRequiredDeviceCapabilities</key>
<dict>
<key>accelerometer</key>
<true/>
<key>opengles-1</key>
<true/>
</dict>
<key>UIStatusBarHidden</key>
<true/>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationLandscapeRight</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
</array>
<key>FacebookAppID</key>
<string>1426774790893461</string>
<key>FacebookDisplayName</key>
<string>myFc</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>fb1426774790893461</string>
</array>
</dict>
</array>
</dict>
</plist>

View File

@ -0,0 +1,33 @@
/*
* Copyright (c) 2013-2014 Chukong Technologies Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#import <Foundation/Foundation.h>
@interface NativeOcClass : NSObject
+(float) callNative:(NSNumber *)a andInt:(NSString *)str;
+(void) callNativeWithParam:(NSString *)str;
+(NSString *)callNativeWithReturnString;
+(BOOL)callNativeUIWithTitle:(NSString *) title andContent:(NSString *)content;
+(int)callNativeWithAdd:(NSNumber *)num1 and:(NSNumber *)num2;
@end

View File

@ -0,0 +1,67 @@
/*
* Copyright (c) 2013-2014 Chukong Technologies Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#import "NativeOcClass.h"
#if TARGET_OS_IPHONE
#import <UIKit/UIKit.h>
#elif TARGET_OS_MAC
#import <AppKit/AppKit.h>
#endif
@implementation NativeOcClass
+(float) callNative:(NSNumber *)a andInt:(NSString *)str{
float b = [a floatValue]+111.3333;
NSLog(@"callNative string is %@ and int value is %f",str,b);
return b;
}
+(void)callNativeWithParam:(NSString *)str{
NSLog(@"callNativeWithParam: str is %@ ",str);
}
+(NSString *)callNativeWithReturnString{
return @"yes is a return string form objective-c";
}
+(BOOL)callNativeWithReturnBool{
return true;
}
+(int)callNativeWithAdd:(NSNumber *)num1 and:(NSNumber *)num2{
return [num1 intValue]+[num2 intValue];
}
#if TARGET_OS_IPHONE
+(BOOL)callNativeUIWithTitle:(NSString *) title andContent:(NSString *)content{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:title message:content delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK", nil];
[alertView show];
return true;
}
#elif TARGET_OS_MAC
+(BOOL)callNativeUIWithTitle:(NSString *) title andContent:(NSString *)content{
NSAlert *alert = [[NSAlert alloc] init];
[alert addButtonWithTitle:@"OK"];
[alert addButtonWithTitle:@"Cancel"];
[alert setMessageText:title];
[alert setInformativeText:content];
[alert setAlertStyle:NSWarningAlertStyle];
[alert runModal];
return true;
}
#endif
@end

View File

@ -0,0 +1,8 @@
//
// Prefix header for all source files of the 'testjs' target in the 'testjs' project
//
#ifdef __OBJC__
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#endif

View File

@ -0,0 +1,33 @@
/****************************************************************************
Copyright (c) 2010-2011 cocos2d-x.org
Copyright (c) 2010 Ricardo Quesada
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#import <UIKit/UIKit.h>
@interface RootViewController : UIViewController {
}
- (BOOL)prefersStatusBarHidden;
@end

View File

@ -0,0 +1,79 @@
//
// testjsAppController.h
// testjs
//
// Created by Rolando Abarca on 3/19/12.
// Copyright __MyCompanyName__ 2012. All rights reserved.
//
#import "RootViewController.h"
@implementation RootViewController
/*
// The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
// Custom initialization
}
return self;
}
*/
/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
}
*/
/*
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
[super viewDidLoad];
}
*/
// Override to allow orientations other than the default portrait orientation.
// This method is deprecated on ios6
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return UIInterfaceOrientationIsLandscape( interfaceOrientation );
}
// For ios6, use supportedInterfaceOrientations & shouldAutorotate instead
- (NSUInteger) supportedInterfaceOrientations{
#ifdef __IPHONE_6_0
return UIInterfaceOrientationMaskAllButUpsideDown;
#endif
}
- (BOOL) shouldAutorotate {
return YES;
}
//fix not hide status on ios7
- (BOOL)prefersStatusBarHidden
{
return YES;
}
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
- (void)viewDidUnload {
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)dealloc {
[super dealloc];
}
@end

View File

@ -0,0 +1,17 @@
//
// main.m
// testjs
//
// Created by Rolando Abarca on 3/19/12.
// Copyright __MyCompanyName__ 2012. All rights reserved.
//
#import <UIKit/UIKit.h>
int main(int argc, char *argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, nil, @"AppController");
[pool release];
return retVal;
}

View File

@ -0,0 +1,10 @@
#include "../Classes/AppDelegate.h"
USING_NS_CC;
int main(int argc, char **argv)
{
// create the application instance
AppDelegate app;
return Application::getInstance()->run();
}

Binary file not shown.

View File

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIconFile</key>
<string>Icon</string>
<key>CFBundleIdentifier</key>
<string>org.cocos2d-x.$(PRODUCT_NAME:rfc1034identifier)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSMinimumSystemVersion</key>
<string>${MACOSX_DEPLOYMENT_TARGET}</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2012. All rights reserved.</string>
<key>NSMainNibFile</key>
<string>MainMenu</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
</dict>
</plist>

View File

@ -0,0 +1,7 @@
//
// Prefix header for all source files of the 'Paralaxer' target in the 'Paralaxer' project
//
#ifdef __OBJC__
#import <Cocoa/Cocoa.h>
#endif

View File

@ -0,0 +1,2 @@
/* Localized versions of Info.plist keys */

View File

@ -0,0 +1,812 @@
<?xml version="1.0" encoding="UTF-8"?>
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.10">
<data>
<int key="IBDocument.SystemTarget">1060</int>
<string key="IBDocument.SystemVersion">10K549</string>
<string key="IBDocument.InterfaceBuilderVersion">1938</string>
<string key="IBDocument.AppKitVersion">1038.36</string>
<string key="IBDocument.HIToolboxVersion">461.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="NS.object.0">1938</string>
</object>
<object class="NSArray" key="IBDocument.IntegratedClassDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>NSMenuItem</string>
<string>NSCustomObject</string>
<string>NSMenu</string>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
</object>
<object class="NSMutableDictionary" key="IBDocument.Metadata">
<string key="NS.key.0">PluginDependencyRecalculationVersion</string>
<integer value="1" key="NS.object.0"/>
</object>
<object class="NSMutableArray" key="IBDocument.RootObjects" id="1048">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSCustomObject" id="1021">
<string key="NSClassName">NSApplication</string>
</object>
<object class="NSCustomObject" id="1014">
<string key="NSClassName">FirstResponder</string>
</object>
<object class="NSCustomObject" id="1050">
<string key="NSClassName">NSApplication</string>
</object>
<object class="NSMenu" id="649796088">
<string key="NSTitle">AMainMenu</string>
<object class="NSMutableArray" key="NSMenuItems">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSMenuItem" id="694149608">
<reference key="NSMenu" ref="649796088"/>
<string key="NSTitle">TestCpp</string>
<string key="NSKeyEquiv"/>
<int key="NSKeyEquivModMask">1048576</int>
<int key="NSMnemonicLoc">2147483647</int>
<object class="NSCustomResource" key="NSOnImage" id="35465992">
<string key="NSClassName">NSImage</string>
<string key="NSResourceName">NSMenuCheckmark</string>
</object>
<object class="NSCustomResource" key="NSMixedImage" id="502551668">
<string key="NSClassName">NSImage</string>
<string key="NSResourceName">NSMenuMixedState</string>
</object>
<string key="NSAction">submenuAction:</string>
<object class="NSMenu" key="NSSubmenu" id="110575045">
<string key="NSTitle">TestCpp</string>
<object class="NSMutableArray" key="NSMenuItems">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSMenuItem" id="238522557">
<reference key="NSMenu" ref="110575045"/>
<string key="NSTitle">About TestCpp</string>
<string key="NSKeyEquiv"/>
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="35465992"/>
<reference key="NSMixedImage" ref="502551668"/>
</object>
<object class="NSMenuItem" id="304266470">
<reference key="NSMenu" ref="110575045"/>
<bool key="NSIsDisabled">YES</bool>
<bool key="NSIsSeparator">YES</bool>
<string key="NSTitle"/>
<string key="NSKeyEquiv"/>
<int key="NSKeyEquivModMask">1048576</int>
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="35465992"/>
<reference key="NSMixedImage" ref="502551668"/>
</object>
<object class="NSMenuItem" id="609285721">
<reference key="NSMenu" ref="110575045"/>
<string key="NSTitle">Preferences…</string>
<string key="NSKeyEquiv">,</string>
<int key="NSKeyEquivModMask">1048576</int>
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="35465992"/>
<reference key="NSMixedImage" ref="502551668"/>
</object>
<object class="NSMenuItem" id="481834944">
<reference key="NSMenu" ref="110575045"/>
<bool key="NSIsDisabled">YES</bool>
<bool key="NSIsSeparator">YES</bool>
<string key="NSTitle"/>
<string key="NSKeyEquiv"/>
<int key="NSKeyEquivModMask">1048576</int>
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="35465992"/>
<reference key="NSMixedImage" ref="502551668"/>
</object>
<object class="NSMenuItem" id="1046388886">
<reference key="NSMenu" ref="110575045"/>
<string key="NSTitle">Services</string>
<string key="NSKeyEquiv"/>
<int key="NSKeyEquivModMask">1048576</int>
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="35465992"/>
<reference key="NSMixedImage" ref="502551668"/>
<string key="NSAction">submenuAction:</string>
<object class="NSMenu" key="NSSubmenu" id="752062318">
<string key="NSTitle">Services</string>
<object class="NSMutableArray" key="NSMenuItems">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
<string key="NSName">_NSServicesMenu</string>
</object>
</object>
<object class="NSMenuItem" id="646227648">
<reference key="NSMenu" ref="110575045"/>
<bool key="NSIsDisabled">YES</bool>
<bool key="NSIsSeparator">YES</bool>
<string key="NSTitle"/>
<string key="NSKeyEquiv"/>
<int key="NSKeyEquivModMask">1048576</int>
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="35465992"/>
<reference key="NSMixedImage" ref="502551668"/>
</object>
<object class="NSMenuItem" id="755159360">
<reference key="NSMenu" ref="110575045"/>
<string key="NSTitle">Hide TestCpp</string>
<string key="NSKeyEquiv">h</string>
<int key="NSKeyEquivModMask">1048576</int>
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="35465992"/>
<reference key="NSMixedImage" ref="502551668"/>
</object>
<object class="NSMenuItem" id="342932134">
<reference key="NSMenu" ref="110575045"/>
<string key="NSTitle">Hide Others</string>
<string key="NSKeyEquiv">h</string>
<int key="NSKeyEquivModMask">1572864</int>
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="35465992"/>
<reference key="NSMixedImage" ref="502551668"/>
</object>
<object class="NSMenuItem" id="908899353">
<reference key="NSMenu" ref="110575045"/>
<string key="NSTitle">Show All</string>
<string key="NSKeyEquiv"/>
<int key="NSKeyEquivModMask">1048576</int>
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="35465992"/>
<reference key="NSMixedImage" ref="502551668"/>
</object>
<object class="NSMenuItem" id="1056857174">
<reference key="NSMenu" ref="110575045"/>
<bool key="NSIsDisabled">YES</bool>
<bool key="NSIsSeparator">YES</bool>
<string key="NSTitle"/>
<string key="NSKeyEquiv"/>
<int key="NSKeyEquivModMask">1048576</int>
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="35465992"/>
<reference key="NSMixedImage" ref="502551668"/>
</object>
<object class="NSMenuItem" id="632727374">
<reference key="NSMenu" ref="110575045"/>
<string key="NSTitle">Quit TestCpp</string>
<string key="NSKeyEquiv">q</string>
<int key="NSKeyEquivModMask">1048576</int>
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="35465992"/>
<reference key="NSMixedImage" ref="502551668"/>
</object>
</object>
<string key="NSName">_NSAppleMenu</string>
</object>
</object>
<object class="NSMenuItem" id="586577488">
<reference key="NSMenu" ref="649796088"/>
<string key="NSTitle">View</string>
<string key="NSKeyEquiv"/>
<int key="NSKeyEquivModMask">1048576</int>
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="35465992"/>
<reference key="NSMixedImage" ref="502551668"/>
<string key="NSAction">submenuAction:</string>
<object class="NSMenu" key="NSSubmenu" id="466310130">
<string key="NSTitle">View</string>
<object class="NSMutableArray" key="NSMenuItems">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSMenuItem" id="204933491">
<reference key="NSMenu" ref="466310130"/>
<string key="NSTitle">Toggle Fullscreen</string>
<string key="NSKeyEquiv">f</string>
<int key="NSKeyEquivModMask">1048576</int>
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="35465992"/>
<reference key="NSMixedImage" ref="502551668"/>
</object>
</object>
</object>
</object>
<object class="NSMenuItem" id="713487014">
<reference key="NSMenu" ref="649796088"/>
<string key="NSTitle">Window</string>
<string key="NSKeyEquiv"/>
<int key="NSKeyEquivModMask">1048576</int>
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="35465992"/>
<reference key="NSMixedImage" ref="502551668"/>
<string key="NSAction">submenuAction:</string>
<object class="NSMenu" key="NSSubmenu" id="835318025">
<string key="NSTitle">Window</string>
<object class="NSMutableArray" key="NSMenuItems">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSMenuItem" id="1011231497">
<reference key="NSMenu" ref="835318025"/>
<string key="NSTitle">Minimize</string>
<string key="NSKeyEquiv">m</string>
<int key="NSKeyEquivModMask">1048576</int>
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="35465992"/>
<reference key="NSMixedImage" ref="502551668"/>
</object>
<object class="NSMenuItem" id="575023229">
<reference key="NSMenu" ref="835318025"/>
<string key="NSTitle">Zoom</string>
<string key="NSKeyEquiv"/>
<int key="NSKeyEquivModMask">1048576</int>
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="35465992"/>
<reference key="NSMixedImage" ref="502551668"/>
</object>
<object class="NSMenuItem" id="299356726">
<reference key="NSMenu" ref="835318025"/>
<bool key="NSIsDisabled">YES</bool>
<bool key="NSIsSeparator">YES</bool>
<string key="NSTitle"/>
<string key="NSKeyEquiv"/>
<int key="NSKeyEquivModMask">1048576</int>
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="35465992"/>
<reference key="NSMixedImage" ref="502551668"/>
</object>
<object class="NSMenuItem" id="625202149">
<reference key="NSMenu" ref="835318025"/>
<string key="NSTitle">Bring All to Front</string>
<string key="NSKeyEquiv"/>
<int key="NSKeyEquivModMask">1048576</int>
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="35465992"/>
<reference key="NSMixedImage" ref="502551668"/>
</object>
</object>
<string key="NSName">_NSWindowsMenu</string>
</object>
</object>
<object class="NSMenuItem" id="448692316">
<reference key="NSMenu" ref="649796088"/>
<string key="NSTitle">Help</string>
<string key="NSKeyEquiv"/>
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="35465992"/>
<reference key="NSMixedImage" ref="502551668"/>
<string key="NSAction">submenuAction:</string>
<object class="NSMenu" key="NSSubmenu" id="992780483">
<string key="NSTitle">Help</string>
<object class="NSMutableArray" key="NSMenuItems">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSMenuItem" id="105068016">
<reference key="NSMenu" ref="992780483"/>
<string key="NSTitle">TestCpp Help</string>
<string key="NSKeyEquiv">?</string>
<int key="NSKeyEquivModMask">1048576</int>
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="35465992"/>
<reference key="NSMixedImage" ref="502551668"/>
</object>
</object>
<string key="NSName">_NSHelpMenu</string>
</object>
</object>
</object>
<string key="NSName">_NSMainMenu</string>
</object>
<object class="NSCustomObject" id="976324537">
<string key="NSClassName">AppController</string>
</object>
<object class="NSCustomObject" id="755631768">
<string key="NSClassName">NSFontManager</string>
</object>
</object>
<object class="IBObjectContainer" key="IBDocument.Objects">
<object class="NSMutableArray" key="connectionRecords">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">terminate:</string>
<reference key="source" ref="1050"/>
<reference key="destination" ref="632727374"/>
</object>
<int key="connectionID">449</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">orderFrontStandardAboutPanel:</string>
<reference key="source" ref="1021"/>
<reference key="destination" ref="238522557"/>
</object>
<int key="connectionID">142</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">delegate</string>
<reference key="source" ref="1021"/>
<reference key="destination" ref="976324537"/>
</object>
<int key="connectionID">495</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">performMiniaturize:</string>
<reference key="source" ref="1014"/>
<reference key="destination" ref="1011231497"/>
</object>
<int key="connectionID">37</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">arrangeInFront:</string>
<reference key="source" ref="1014"/>
<reference key="destination" ref="625202149"/>
</object>
<int key="connectionID">39</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">performZoom:</string>
<reference key="source" ref="1014"/>
<reference key="destination" ref="575023229"/>
</object>
<int key="connectionID">240</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">hide:</string>
<reference key="source" ref="1014"/>
<reference key="destination" ref="755159360"/>
</object>
<int key="connectionID">367</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">hideOtherApplications:</string>
<reference key="source" ref="1014"/>
<reference key="destination" ref="342932134"/>
</object>
<int key="connectionID">368</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">unhideAllApplications:</string>
<reference key="source" ref="1014"/>
<reference key="destination" ref="908899353"/>
</object>
<int key="connectionID">370</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">showHelp:</string>
<reference key="source" ref="1014"/>
<reference key="destination" ref="105068016"/>
</object>
<int key="connectionID">493</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">toggleFullScreen:</string>
<reference key="source" ref="976324537"/>
<reference key="destination" ref="204933491"/>
</object>
<int key="connectionID">537</int>
</object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBObjectRecord">
<int key="objectID">0</int>
<object class="NSArray" key="object" id="0">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
<reference key="children" ref="1048"/>
<nil key="parent"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">-2</int>
<reference key="object" ref="1021"/>
<reference key="parent" ref="0"/>
<string key="objectName">File's Owner</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">-1</int>
<reference key="object" ref="1014"/>
<reference key="parent" ref="0"/>
<string key="objectName">First Responder</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">-3</int>
<reference key="object" ref="1050"/>
<reference key="parent" ref="0"/>
<string key="objectName">Application</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">29</int>
<reference key="object" ref="649796088"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="713487014"/>
<reference ref="694149608"/>
<reference ref="586577488"/>
<reference ref="448692316"/>
</object>
<reference key="parent" ref="0"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">19</int>
<reference key="object" ref="713487014"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="835318025"/>
</object>
<reference key="parent" ref="649796088"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">56</int>
<reference key="object" ref="694149608"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="110575045"/>
</object>
<reference key="parent" ref="649796088"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">57</int>
<reference key="object" ref="110575045"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="238522557"/>
<reference ref="755159360"/>
<reference ref="908899353"/>
<reference ref="632727374"/>
<reference ref="646227648"/>
<reference ref="609285721"/>
<reference ref="481834944"/>
<reference ref="304266470"/>
<reference ref="1046388886"/>
<reference ref="1056857174"/>
<reference ref="342932134"/>
</object>
<reference key="parent" ref="694149608"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">58</int>
<reference key="object" ref="238522557"/>
<reference key="parent" ref="110575045"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">134</int>
<reference key="object" ref="755159360"/>
<reference key="parent" ref="110575045"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">150</int>
<reference key="object" ref="908899353"/>
<reference key="parent" ref="110575045"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">136</int>
<reference key="object" ref="632727374"/>
<reference key="parent" ref="110575045"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">144</int>
<reference key="object" ref="646227648"/>
<reference key="parent" ref="110575045"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">129</int>
<reference key="object" ref="609285721"/>
<reference key="parent" ref="110575045"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">143</int>
<reference key="object" ref="481834944"/>
<reference key="parent" ref="110575045"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">236</int>
<reference key="object" ref="304266470"/>
<reference key="parent" ref="110575045"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">131</int>
<reference key="object" ref="1046388886"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="752062318"/>
</object>
<reference key="parent" ref="110575045"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">149</int>
<reference key="object" ref="1056857174"/>
<reference key="parent" ref="110575045"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">145</int>
<reference key="object" ref="342932134"/>
<reference key="parent" ref="110575045"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">130</int>
<reference key="object" ref="752062318"/>
<reference key="parent" ref="1046388886"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">24</int>
<reference key="object" ref="835318025"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="299356726"/>
<reference ref="625202149"/>
<reference ref="575023229"/>
<reference ref="1011231497"/>
</object>
<reference key="parent" ref="713487014"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">92</int>
<reference key="object" ref="299356726"/>
<reference key="parent" ref="835318025"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">5</int>
<reference key="object" ref="625202149"/>
<reference key="parent" ref="835318025"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">239</int>
<reference key="object" ref="575023229"/>
<reference key="parent" ref="835318025"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">23</int>
<reference key="object" ref="1011231497"/>
<reference key="parent" ref="835318025"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">295</int>
<reference key="object" ref="586577488"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="466310130"/>
</object>
<reference key="parent" ref="649796088"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">296</int>
<reference key="object" ref="466310130"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="204933491"/>
</object>
<reference key="parent" ref="586577488"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">420</int>
<reference key="object" ref="755631768"/>
<reference key="parent" ref="0"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">490</int>
<reference key="object" ref="448692316"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="992780483"/>
</object>
<reference key="parent" ref="649796088"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">491</int>
<reference key="object" ref="992780483"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="105068016"/>
</object>
<reference key="parent" ref="448692316"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">492</int>
<reference key="object" ref="105068016"/>
<reference key="parent" ref="992780483"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">494</int>
<reference key="object" ref="976324537"/>
<reference key="parent" ref="0"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">536</int>
<reference key="object" ref="204933491"/>
<reference key="parent" ref="466310130"/>
</object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>-1.IBPluginDependency</string>
<string>-2.IBPluginDependency</string>
<string>-3.IBPluginDependency</string>
<string>129.IBPluginDependency</string>
<string>130.IBPluginDependency</string>
<string>131.IBPluginDependency</string>
<string>134.IBPluginDependency</string>
<string>136.IBPluginDependency</string>
<string>143.IBPluginDependency</string>
<string>144.IBPluginDependency</string>
<string>145.IBPluginDependency</string>
<string>149.IBPluginDependency</string>
<string>150.IBPluginDependency</string>
<string>19.IBPluginDependency</string>
<string>23.IBPluginDependency</string>
<string>236.IBPluginDependency</string>
<string>239.IBPluginDependency</string>
<string>24.IBPluginDependency</string>
<string>29.IBPluginDependency</string>
<string>295.IBPluginDependency</string>
<string>296.IBPluginDependency</string>
<string>420.IBPluginDependency</string>
<string>490.IBPluginDependency</string>
<string>491.IBPluginDependency</string>
<string>492.IBPluginDependency</string>
<string>494.IBPluginDependency</string>
<string>5.IBPluginDependency</string>
<string>536.IBPluginDependency</string>
<string>56.IBPluginDependency</string>
<string>57.IBPluginDependency</string>
<string>58.IBPluginDependency</string>
<string>92.IBPluginDependency</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
</object>
</object>
<object class="NSMutableDictionary" key="unlocalizedProperties">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference key="dict.sortedKeys" ref="0"/>
<reference key="dict.values" ref="0"/>
</object>
<nil key="activeLocalization"/>
<object class="NSMutableDictionary" key="localizations">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference key="dict.sortedKeys" ref="0"/>
<reference key="dict.values" ref="0"/>
</object>
<nil key="sourceID"/>
<int key="maxID">541</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBPartialClassDescription">
<string key="className">AppController</string>
<string key="superclassName">NSObject</string>
<object class="NSMutableDictionary" key="actions">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>exitFullScreen:</string>
<string>toggleFullScreen:</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>id</string>
<string>id</string>
</object>
</object>
<object class="NSMutableDictionary" key="actionInfosByName">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>exitFullScreen:</string>
<string>toggleFullScreen:</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBActionInfo">
<string key="name">exitFullScreen:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo">
<string key="name">toggleFullScreen:</string>
<string key="candidateClassName">id</string>
</object>
</object>
</object>
<object class="NSMutableDictionary" key="outlets">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>glView</string>
<string>window</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>EAGLView</string>
<string>NSWindow</string>
</object>
</object>
<object class="NSMutableDictionary" key="toOneOutletInfosByName">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>glView</string>
<string>window</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBToOneOutletInfo">
<string key="name">glView</string>
<string key="candidateClassName">EAGLView</string>
</object>
<object class="IBToOneOutletInfo">
<string key="name">window</string>
<string key="candidateClassName">NSWindow</string>
</object>
</object>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/AppController.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">EAGLView</string>
<string key="superclassName">NSOpenGLView</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/EAGLView.h</string>
</object>
</object>
</object>
</object>
<int key="IBDocument.localizationMode">0</int>
<string key="IBDocument.TargetRuntimeIdentifier">IBCocoaFramework</string>
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDevelopmentDependencies">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3</string>
<integer value="3000" key="NS.object.0"/>
</object>
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
<int key="IBDocument.defaultPropertyAccessControl">3</int>
<object class="NSMutableDictionary" key="IBDocument.LastKnownImageSizes">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>NSMenuCheckmark</string>
<string>NSMenuMixedState</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>{9, 8}</string>
<string>{7, 2}</string>
</object>
</object>
</data>
</archive>

View File

@ -0,0 +1,35 @@
/****************************************************************************
Copyright (c) 2010 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "AppDelegate.h"
#include "cocos2d.h"
USING_NS_CC;
int main(int argc, char *argv[])
{
AppDelegate app;
return Application::getInstance()->run();
}

View File

@ -0,0 +1,24 @@
{
"copy_resources": [
{
"from": "../../src",
"to": "src"
},
{
"from": "../../res",
"to": "res"
},
{
"from": "../../main.js",
"to": ""
},
{
"from": "../../project.json",
"to": ""
},
{
"from": "../../../../frameworks/js-bindings/bindings/script",
"to": "script"
}
]
}

View File

@ -0,0 +1,86 @@
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#define APSTUDIO_HIDDEN_SYMBOLS
#include "windows.h"
#undef APSTUDIO_HIDDEN_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDR_MAINFRAME ICON "res\\js-tests.ico"
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,1
PRODUCTVERSION 1,0,0,1
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904B0"
BEGIN
VALUE "CompanyName", "\0"
VALUE "FileDescription", "js-tests Module\0"
VALUE "FileVersion", "1, 0, 0, 1\0"
VALUE "InternalName", "js-tests\0"
VALUE "LegalCopyright", "Copyright \0"
VALUE "OriginalFilename", "js-tests.exe\0"
VALUE "ProductName", "js-tests Module\0"
VALUE "ProductVersion", "1, 0, 0, 1\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x0409, 0x04B0
END
END
/////////////////////////////////////////////////////////////////////////////
#endif // !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)

View File

@ -0,0 +1,218 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{D0F06A44-A245-4D13-A498-0120C203B539}</ProjectGuid>
<RootNamespace>js-tests</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '10.0'">v100</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '11.0'">v110</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '11.0' and exists('$(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A')">v110_xp</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '12.0'">v120</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '12.0' and exists('$(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A')">v120_xp</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '10.0'">v100</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '11.0'">v110</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '11.0' and exists('$(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A')">v110_xp</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '12.0'">v120</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '12.0' and exists('$(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A')">v120_xp</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\..\..\cocos\2d\cocos2dx.props" />
<Import Project="..\..\..\..\cocos\2d\cocos2d_headers.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\..\..\cocos\2d\cocos2dx.props" />
<Import Project="..\..\..\..\cocos\2d\cocos2d_headers.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.40219.1</_ProjectFileVersion>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration).win32\js-tests\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration).win32\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration).win32\js-tests\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration).win32\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LibraryPath>$(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\lib;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LibraryPath>$(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\lib;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Midl>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MkTypLibCompatible>false</MkTypLibCompatible>
<TargetEnvironment>Win32</TargetEnvironment>
<GenerateStublessProxies>true</GenerateStublessProxies>
<TypeLibraryName>$(IntDir)js-tests.tlb</TypeLibraryName>
<HeaderFileName>js-tests.h</HeaderFileName>
<DllDataFileName>
</DllDataFileName>
<InterfaceIdentifierFileName>js-tests_i.c</InterfaceIdentifierFileName>
<ProxyFileName>js-tests_p.c</ProxyFileName>
</Midl>
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\base;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\editor-support;$(EngineRoot)cocos\audio\include;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)extensions;$(ProjectDir)..\Classes;$(EngineRoot)external\spidermonkey\include\win32;$(EngineRoot)cocos\scripting\js-bindings\auto;$(EngineRoot)cocos\scripting\js-bindings\manual;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_WINDOWS;STRICT;_DEBUG;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_DEBUG=1;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>false</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<DisableSpecificWarnings>4267;4251;4244;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Culture>0x0409</Culture>
<AdditionalIncludeDirectories>$(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\include;$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile>
<PreLinkEvent>
<Command>if not exist "$(OutDir)" mkdir "$(OutDir)"
xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\spidermonkey\prebuilt\win32\debug-build\*.*" "$(OutDir)"
xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\websockets\prebuilt\win32\*.*" "$(OutDir)"</Command>
</PreLinkEvent>
<Link>
<AdditionalDependencies>libcurl_imp.lib;mozjs-33.lib;ws2_32.lib;sqlite3.lib;websockets.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(OutDir);$(SolutionDir)$(Configuration).win32;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<TargetMachine>MachineX86</TargetMachine>
</Link>
<PreBuildEvent>
<Command>if not exist "$(OutDir)" mkdir "$(OutDir)"
mkdir "$(OutDir)\script"
mkdir "$(OutDir)\src"
mkdir "$(OutDir)\res"
xcopy "$(OutDir)..\*.dll" "$(OutDir)" /D /Y
xcopy "$(ProjectDir)..\..\..\..\cocos\scripting\js-bindings\script\*" "$(OutDir)\script" /e /Y
xcopy "$(ProjectDir)..\..\src" "$(OutDir)\src\" /e /Y
xcopy "$(ProjectDir)..\..\res" "$(OutDir)\res\" /e /Y
copy "$(ProjectDir)..\..\main.js" "$(OutDir)"
copy "$(ProjectDir)..\..\project.json" "$(OutDir)"</Command>
</PreBuildEvent>
<PreBuildEvent>
<Message>Copy js and resource files.</Message>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Midl>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MkTypLibCompatible>false</MkTypLibCompatible>
<TargetEnvironment>Win32</TargetEnvironment>
<GenerateStublessProxies>true</GenerateStublessProxies>
<TypeLibraryName>$(IntDir)js-tests.tlb</TypeLibraryName>
<HeaderFileName>js-tests.h</HeaderFileName>
<DllDataFileName>
</DllDataFileName>
<InterfaceIdentifierFileName>js-tests_i.c</InterfaceIdentifierFileName>
<ProxyFileName>js-tests_p.c</ProxyFileName>
</Midl>
<ClCompile>
<AdditionalIncludeDirectories>$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\base;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\editor-support;$(EngineRoot)cocos\audio\include;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)extensions;$(ProjectDir)..\Classes;$(EngineRoot)external\spidermonkey\include\win32;$(EngineRoot)cocos\scripting\js-bindings\auto;$(EngineRoot)cocos\scripting\js-bindings\manual;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_WINDOWS;STRICT;NDEBUG;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ExceptionHandling>
</ExceptionHandling>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>
</DebugInformationFormat>
<DisableSpecificWarnings>4267;4251;4244;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Culture>0x0409</Culture>
<AdditionalIncludeDirectories>$(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\include;$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile>
<PreLinkEvent>
<Command>if not exist "$(OutDir)" mkdir "$(OutDir)"
xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\spidermonkey\prebuilt\win32\release-build\*.*" "$(OutDir)"
xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\websockets\prebuilt\win32\*.*" "$(OutDir)"</Command>
</PreLinkEvent>
<Link>
<AdditionalDependencies>libcurl_imp.lib;mozjs-33.lib;ws2_32.lib;sqlite3.lib;websockets.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(OutDir);$(SolutionDir)$(Configuration).win32;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<SubSystem>Windows</SubSystem>
<TargetMachine>MachineX86</TargetMachine>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
<PreBuildEvent>
<Command>if not exist "$(OutDir)" mkdir "$(OutDir)"
mkdir "$(OutDir)\script"
mkdir "$(OutDir)\src"
mkdir "$(OutDir)\res"
xcopy "$(OutDir)..\*.dll" "$(OutDir)" /D /Y
xcopy "$(ProjectDir)..\..\..\..\cocos\scripting\js-bindings\script\*" "$(OutDir)\script" /e /Y
xcopy "$(ProjectDir)..\..\src" "$(OutDir)\src\" /e /Y
xcopy "$(ProjectDir)..\..\..\cpp-tests\Resources" "$(OutDir)\res\" /e /Y
copy "$(ProjectDir)..\..\main.js" "$(OutDir)"
copy "$(ProjectDir)..\..\project.json" "$(OutDir)"</Command>
<Message>Copy js and resource files.</Message>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\Classes\js_DrawNode3D_bindings.cpp" />
<ClCompile Include="..\Classes\js_Effect3D_bindings.cpp" />
<ClCompile Include="main.cpp" />
<ClCompile Include="..\Classes\AppDelegate.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\Classes\js_DrawNode3D_bindings.h" />
<ClInclude Include="..\Classes\js_Effect3D_bindings.h" />
<ClInclude Include="main.h" />
<ClInclude Include="resource.h" />
<ClInclude Include="..\Classes\AppDelegate.h" />
</ItemGroup>
<ItemGroup>
<None Include="res\js-tests.ico" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="js-tests.rc" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\cocos\scripting\js-bindings\proj.win32\libjscocos2d.vcxproj">
<Project>{39379840-825a-45a0-b363-c09ffef864bd}</Project>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,55 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ClCompile Include="..\Classes\AppDelegate.cpp">
<Filter>Classes</Filter>
</ClCompile>
<ClCompile Include="main.cpp">
<Filter>win32</Filter>
</ClCompile>
<ClCompile Include="..\Classes\js_DrawNode3D_bindings.cpp">
<Filter>Classes</Filter>
</ClCompile>
<ClCompile Include="..\Classes\js_Effect3D_bindings.cpp">
<Filter>Classes</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\Classes\AppDelegate.h">
<Filter>Classes</Filter>
</ClInclude>
<ClInclude Include="main.h">
<Filter>win32</Filter>
</ClInclude>
<ClInclude Include="resource.h">
<Filter>win32</Filter>
</ClInclude>
<ClInclude Include="..\Classes\js_DrawNode3D_bindings.h">
<Filter>Classes</Filter>
</ClInclude>
<ClInclude Include="..\Classes\js_Effect3D_bindings.h">
<Filter>Classes</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Filter Include="Classes">
<UniqueIdentifier>{73cd069e-e032-4051-8d30-65b08ab4f954}</UniqueIdentifier>
</Filter>
<Filter Include="resource">
<UniqueIdentifier>{abaf0468-14d3-43ce-8d1a-8a4a34dba59b}</UniqueIdentifier>
</Filter>
<Filter Include="win32">
<UniqueIdentifier>{bbe7342c-1f30-4512-b00a-841aa2d4ca9f}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<None Include="res\js-tests.ico">
<Filter>resource</Filter>
</None>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="js-tests.rc">
<Filter>resource</Filter>
</ResourceCompile>
</ItemGroup>
</Project>

View File

@ -0,0 +1,34 @@
#include "main.h"
#include "AppDelegate.h"
USING_NS_CC;
// uncomment below line, open debug console
// #define USE_WIN32_CONSOLE
int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);
#ifdef USE_WIN32_CONSOLE
AllocConsole();
freopen("CONIN$", "r", stdin);
freopen("CONOUT$", "w", stdout);
freopen("CONOUT$", "w", stderr);
#endif
// create the application instance
AppDelegate app;
int ret = Application::getInstance()->run();
#ifdef USE_WIN32_CONSOLE
FreeConsole();
#endif
return ret;
}

View File

@ -0,0 +1,12 @@
#ifndef __MAIN_H__
#define __MAIN_H__
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
// Windows Header Files:
#include <tchar.h>
// C RunTime Header Files
#include "CCStdC.h"
#endif // __WINMAIN_H__

View File

@ -0,0 +1,20 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by js-tests.RC
//
#define IDS_PROJNAME 100
#define IDR_TESTJS 100
#define ID_FILE_NEW_WINDOW 32771
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 201
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 101
#define _APS_NEXT_COMMAND_VALUE 32775
#endif
#endif

View File

@ -0,0 +1,13 @@
<Application
x:Class="cocos2d.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:cocos2d"
xmlns:localData="using:Shared">
<Application.Resources>
<x:String x:Key="AppName">cpp_tests</x:String>
</Application.Resources>
</Application>

View File

@ -0,0 +1,21 @@
#include "App.xaml.h"
#include "OpenGLESPage.xaml.h"
using namespace cocos2d;
App::App()
{
InitializeComponent();
}
void App::OnLaunched(Windows::ApplicationModel::Activation::LaunchActivatedEventArgs^ e)
{
if (mPage == nullptr)
{
mPage = ref new OpenGLESPage(&mOpenGLES);
}
// Place the page in the current window and ensure that it is active.
Windows::UI::Xaml::Window::Current->Content = mPage;
Windows::UI::Xaml::Window::Current->Activate();
}

View File

@ -0,0 +1,19 @@
#pragma once
#include "app.g.h"
#include "OpenGLES.h"
#include "openglespage.xaml.h"
namespace cocos2d
{
ref class App sealed
{
public:
App();
virtual void OnLaunched(Windows::ApplicationModel::Activation::LaunchActivatedEventArgs^ e) override;
private:
OpenGLESPage^ mPage;
OpenGLES mOpenGLES;
};
}

View File

@ -0,0 +1,64 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="Globals">
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
<HasSharedItems>true</HasSharedItems>
<SharedGUID>e956c24b-f04e-47bf-bf00-746681ae1301</SharedGUID>
<ItemsProjectGuid>{AE6763F6-1549-441E-AFB5-377BE1C776DC}</ItemsProjectGuid>
<ItemsRootNamespace>js-tests</ItemsRootNamespace>
</PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(MSBuildThisFileDirectory)</AdditionalIncludeDirectories>
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup>
<ApplicationDefinition Include="$(MSBuildThisFileDirectory)App.xaml">
<SubType>Designer</SubType>
</ApplicationDefinition>
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\..\cocos\platform\win8.1-universal\Cocos2dRenderer.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\..\cocos\platform\win8.1-universal\OpenGLES.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\..\cocos\platform\win8.1-universal\OpenGLESPage.xaml.cpp">
<DependentUpon>$(MSBuildThisFileDirectory)..\..\..\..\..\cocos\platform\win8.1-universal\OpenGLESPage.xaml</DependentUpon>
</ClCompile>
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\Classes\AppDelegate.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\Classes\js_DrawNode3D_bindings.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\Classes\js_Effect3D_bindings.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)App.xaml.cpp">
<DependentUpon>$(MSBuildThisFileDirectory)App.xaml</DependentUpon>
</ClCompile>
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\..\cocos\platform\win8.1-universal\Cocos2dRenderer.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\..\cocos\platform\win8.1-universal\OpenGLES.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\..\cocos\platform\win8.1-universal\OpenGLESPage.xaml.h">
<DependentUpon>$(MSBuildThisFileDirectory)..\..\..\..\..\cocos\platform\win8.1-universal\OpenGLESPage.xaml</DependentUpon>
</ClInclude>
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\Classes\AppDelegate.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\Classes\js_DrawNode3D_bindings.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\Classes\js_Effect3D_bindings.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)App.xaml.h">
<DependentUpon>$(MSBuildThisFileDirectory)App.xaml</DependentUpon>
</ClInclude>
<ClCompile Include="$(MSBuildThisFileDirectory)pch.cpp">
<PrecompiledHeader>Create</PrecompiledHeader>
</ClCompile>
<ClInclude Include="$(MSBuildThisFileDirectory)pch.h" />
</ItemGroup>
<ItemGroup>
<ProjectCapability Include="SourceItemsFromImports" />
</ItemGroup>
<ItemGroup>
<_CustomResource Include="$(MSBuildThisFileDirectory)..\..\Resources\**\*">
<Link>Assets\Resources\%(RecursiveDir)%(FileName)%(Extension)</Link>
<DeploymentContent>true</DeploymentContent>
</_CustomResource>
</ItemGroup>
<ItemGroup>
<Page Include="$(MSBuildThisFileDirectory)..\..\..\..\..\cocos\platform\win8.1-universal\OpenGLESPage.xaml" />
</ItemGroup>
<Target Name="_CollectCustomResources" BeforeTargets="AssignTargetPaths">
<Message Text="Adding resource: %(_CustomResource.Identity) -&gt; %(_CustomResource.Link)" />
<ItemGroup>
<None Include="@(_CustomResource)" />
</ItemGroup>
</Target>
</Project>

View File

@ -0,0 +1,46 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<CLCompile Include="$(MSBuildThisFileDirectory)App.xaml.cpp" />
<ClInclude Include="$(MSBuildThisFileDirectory)App.xaml.h" />
<CLCompile Include="$(MSBuildThisFileDirectory)pch.cpp" />
<ClInclude Include="$(MSBuildThisFileDirectory)pch.h" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\Classes\AppDelegate.cpp">
<Filter>Classes</Filter>
</ClCompile>
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\Classes\js_DrawNode3D_bindings.cpp">
<Filter>Classes</Filter>
</ClCompile>
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\Classes\js_Effect3D_bindings.cpp">
<Filter>Classes</Filter>
</ClCompile>
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\..\cocos\platform\win8.1-universal\Cocos2dRenderer.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\..\cocos\platform\win8.1-universal\OpenGLES.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\..\cocos\platform\win8.1-universal\OpenGLESPage.xaml.cpp" />
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="$(MSBuildThisFileDirectory)App.xaml" />
</ItemGroup>
<ItemGroup>
<Filter Include="Classes">
<UniqueIdentifier>{38ad799c-8c3c-44a2-8e41-516c8f62f556}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\Classes\AppDelegate.h">
<Filter>Classes</Filter>
</ClInclude>
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\Classes\js_DrawNode3D_bindings.h">
<Filter>Classes</Filter>
</ClInclude>
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\Classes\js_Effect3D_bindings.h">
<Filter>Classes</Filter>
</ClInclude>
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\..\cocos\platform\win8.1-universal\Cocos2dRenderer.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\..\cocos\platform\win8.1-universal\OpenGLES.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\..\cocos\platform\win8.1-universal\OpenGLESPage.xaml.h" />
</ItemGroup>
<ItemGroup>
<Page Include="$(MSBuildThisFileDirectory)..\..\..\..\..\cocos\platform\win8.1-universal\OpenGLESPage.xaml" />
</ItemGroup>
</Project>

View File

@ -0,0 +1 @@
#include "pch.h"

View File

@ -0,0 +1,12 @@
//
// pch.h
// Header for standard system include files.
//
#pragma once
#include "mozilla\Char16.h"
#include "cocos2d.h"
#include "cocos-ext.h"

Binary file not shown.

After

Width:  |  Height:  |  Size: 801 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 329 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 103 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 429 B

View File

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/2010/manifest" xmlns:m2="http://schemas.microsoft.com/appx/2013/manifest">
<Identity Name="a39cf818-af13-4d5f-9d18-3dbac1159b33" Publisher="CN=msopentech" Version="1.0.0.6" />
<Properties>
<DisplayName>js-tests.Windows</DisplayName>
<PublisherDisplayName>msopentech</PublisherDisplayName>
<Logo>Assets\StoreLogo.png</Logo>
</Properties>
<Prerequisites>
<OSMinVersion>6.3.0</OSMinVersion>
<OSMaxVersionTested>6.3.0</OSMaxVersionTested>
</Prerequisites>
<Resources>
<Resource Language="x-generate" />
</Resources>
<Applications>
<Application Id="App" Executable="$targetnametoken$.exe" EntryPoint="cocos2d_Windows.App">
<m2:VisualElements DisplayName="js-tests.Windows" Square150x150Logo="Assets\Logo.png" Square30x30Logo="Assets\SmallLogo.png" Description="js-tests.Windows" ForegroundText="light" BackgroundColor="#464646">
<m2:SplashScreen Image="Assets\SplashScreen.png" />
<m2:InitialRotationPreference>
<m2:Rotation Preference="landscape" />
<m2:Rotation Preference="landscapeFlipped" />
</m2:InitialRotationPreference>
</m2:VisualElements>
</Application>
</Applications>
<Capabilities>
<Capability Name="internetClient" />
</Capabilities>
</Package>

View File

@ -0,0 +1,227 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|ARM">
<Configuration>Debug</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|ARM">
<Configuration>Release</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{70914FC8-7709-4CD6-B86B-C63FDE5478DB}</ProjectGuid>
<RootNamespace>cocos2d</RootNamespace>
<DefaultLanguage>en-US</DefaultLanguage>
<MinimumVisualStudioVersion>12.0</MinimumVisualStudioVersion>
<AppContainerApplication>true</AppContainerApplication>
<ApplicationType>Windows Store</ApplicationType>
<ApplicationTypeRevision>8.1</ApplicationTypeRevision>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>false</WholeProgramOptimization>
<PlatformToolset>v120</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>false</WholeProgramOptimization>
<PlatformToolset>v120</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>false</WholeProgramOptimization>
<PlatformToolset>v120</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<Import Project="..\App.Shared\js-tests.Shared.vcxitems" Label="Shared" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="..\..\..\..\..\cocos\2d\winrt_8.1_props\cocos2d_winrt_8.1_platform.props" />
<Import Project="..\..\..\..\..\cocos\2d\winrt_8.1_props\cocos2d_winrt_8.1.props" />
<Import Project="..\..\..\..\..\cocos\2d\winrt_8.1_props\cocos2d_winrt_8.1_app.props" />
<Import Project="..\resources.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
<Import Project="..\..\..\..\..\cocos\2d\winrt_8.1_props\cocos2d_winrt_8.1_platform.props" />
<Import Project="..\..\..\..\..\cocos\2d\winrt_8.1_props\cocos2d_winrt_8.1.props" />
<Import Project="..\..\..\..\..\cocos\2d\winrt_8.1_props\cocos2d_winrt_8.1_app.props" />
<Import Project="..\resources.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="..\..\..\..\..\cocos\2d\winrt_8.1_props\cocos2d_winrt_8.1_platform.props" />
<Import Project="..\..\..\..\..\cocos\2d\winrt_8.1_props\cocos2d_winrt_8.1.props" />
<Import Project="..\..\..\..\..\cocos\2d\winrt_8.1_props\cocos2d_winrt_8.1_app.props" />
<Import Project="..\resources.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="..\..\..\..\..\cocos\2d\winrt_8.1_props\cocos2d_winrt_8.1_platform.props" />
<Import Project="..\..\..\..\..\cocos\2d\winrt_8.1_props\cocos2d_winrt_8.1.props" />
<Import Project="..\..\..\..\..\cocos\2d\winrt_8.1_props\cocos2d_winrt_8.1_app.props" />
<Import Project="..\resources.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
<Import Project="..\..\..\..\..\cocos\2d\winrt_8.1_props\cocos2d_winrt_8.1_platform.props" />
<Import Project="..\..\..\..\..\cocos\2d\winrt_8.1_props\cocos2d_winrt_8.1.props" />
<Import Project="..\..\..\..\..\cocos\2d\winrt_8.1_props\cocos2d_winrt_8.1_app.props" />
<Import Project="..\resources.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="..\..\..\..\..\cocos\2d\winrt_8.1_props\cocos2d_winrt_8.1_platform.props" />
<Import Project="..\..\..\..\..\cocos\2d\winrt_8.1_props\cocos2d_winrt_8.1.props" />
<Import Project="..\..\..\..\..\cocos\2d\winrt_8.1_props\cocos2d_winrt_8.1_app.props" />
<Import Project="..\resources.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<PackageCertificateKeyFile>js-tests.Windows_TemporaryKey.pfx</PackageCertificateKeyFile>
<AppxAutoIncrementPackageRevision>True</AppxAutoIncrementPackageRevision>
<AppxBundlePlatforms>x86</AppxBundlePlatforms>
<PackageCertificateThumbprint>FB58178D2A50D64A72EC25130D072580B999A12E</PackageCertificateThumbprint>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
<ClCompile>
<AdditionalOptions>/bigobj /Zm200 %(AdditionalOptions)</AdditionalOptions>
<DisableSpecificWarnings>4800;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<ForcedIncludeFiles>pch.h</ForcedIncludeFiles>
<AdditionalIncludeDirectories>$(ProjectDir)..\..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<SDLCheck>false</SDLCheck>
</ClCompile>
<PreBuildEvent>
<Command>
</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
<ClCompile>
<AdditionalOptions>/bigobj /Zm200 %(AdditionalOptions)</AdditionalOptions>
<DisableSpecificWarnings>4800;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<ForcedIncludeFiles>pch.h</ForcedIncludeFiles>
<AdditionalIncludeDirectories>$(ProjectDir)..\..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<SDLCheck>false</SDLCheck>
</ClCompile>
<PreBuildEvent>
<Command>
</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<AdditionalOptions>/bigobj /Zm200 %(AdditionalOptions)</AdditionalOptions>
<DisableSpecificWarnings>4800;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<ForcedIncludeFiles>pch.h</ForcedIncludeFiles>
<AdditionalIncludeDirectories>$(ProjectDir)..\..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<SDLCheck>false</SDLCheck>
</ClCompile>
<PreBuildEvent>
<Command>
</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<AdditionalOptions>/bigobj /Zm200 %(AdditionalOptions)</AdditionalOptions>
<DisableSpecificWarnings>4800;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<ForcedIncludeFiles>pch.h</ForcedIncludeFiles>
<AdditionalIncludeDirectories>$(ProjectDir)..\..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<SDLCheck>false</SDLCheck>
</ClCompile>
<PreBuildEvent>
<Command>
</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<AdditionalOptions>/bigobj /Zm200 %(AdditionalOptions)</AdditionalOptions>
<DisableSpecificWarnings>4800;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<ForcedIncludeFiles>pch.h</ForcedIncludeFiles>
<AdditionalIncludeDirectories>$(ProjectDir)..\..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<SDLCheck>false</SDLCheck>
</ClCompile>
<PreBuildEvent>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<AdditionalOptions>/bigobj /Zm200 %(AdditionalOptions)</AdditionalOptions>
<DisableSpecificWarnings>4800;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<ForcedIncludeFiles>pch.h</ForcedIncludeFiles>
<AdditionalIncludeDirectories>$(ProjectDir)..\..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<SDLCheck>false</SDLCheck>
</ClCompile>
<PreBuildEvent>
<Command>echo "Copying Windows 8.1 Universal App CPP template files"
xcopy "$(EngineRoot)external\win8.1-universal\OpenGLESPage.xaml" "$(EngineRoot)templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /eiycq
xcopy "$(EngineRoot)external\win8.1-universal\OpenGLESPage.xaml.cpp" "$(EngineRoot)templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /eiycq
xcopy "$(EngineRoot)external\win8.1-universal\OpenGLESPage.xaml.h" "$(EngineRoot)templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /eiycq
</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<AppxManifest Include="Package.appxmanifest">
<SubType>Designer</SubType>
</AppxManifest>
<None Include="js-tests.Windows_TemporaryKey.pfx" />
</ItemGroup>
<ItemGroup>
<Image Include="Assets\Logo.scale-100.png" />
<Image Include="Assets\SmallLogo.scale-100.png" />
<Image Include="Assets\StoreLogo.scale-100.png" />
<Image Include="Assets\SplashScreen.scale-100.png" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\..\cocos\scripting\js-bindings\proj.win8.1-universal\libjscocos2d\libjscocos2d.Windows\libjscocos2d.Windows.vcxproj">
<Project>{bcf5546d-66a0-4998-afd6-c5514f618930}</Project>
</ProjectReference>
<ProjectReference Include="..\..\..\..\..\cocos\2d\libcocos2d_8_1\libcocos2d_8_1\libcocos2d_8_1.Windows\libcocos2d_8_1.Windows.vcxproj">
<Project>{9335005f-678e-4e8e-9b84-50037216aec8}</Project>
</ProjectReference>
<ProjectReference Include="..\..\..\..\..\cocos\editor-support\spine\proj.win8.1-universal\libSpine.Windows\libSpine.Windows.vcxproj">
<Project>{f3550fe0-c795-44f6-8feb-093eb68143ae}</Project>
</ProjectReference>
<ProjectReference Include="..\..\..\..\..\external\Box2D\proj.win8.1-universal\libbox2d.Windows\libbox2d.Windows.vcxproj">
<Project>{3b26a12d-3a44-47ea-82d2-282660fc844d}</Project>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Assets">
<UniqueIdentifier>{1a9fa652-867e-41d2-8588-962f108d2d8f}</UniqueIdentifier>
<Extensions>bmp;fbx;gif;jpg;jpeg;tga;tiff;tif;png</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<AppxManifest Include="Package.appxmanifest" />
</ItemGroup>
<ItemGroup>
<None Include="js-tests.Windows_TemporaryKey.pfx" />
</ItemGroup>
<ItemGroup>
<Image Include="Assets\Logo.scale-100.png">
<Filter>Assets</Filter>
</Image>
<Image Include="Assets\SmallLogo.scale-100.png">
<Filter>Assets</Filter>
</Image>
<Image Include="Assets\StoreLogo.scale-100.png">
<Filter>Assets</Filter>
</Image>
<Image Include="Assets\SplashScreen.scale-100.png">
<Filter>Assets</Filter>
</Image>
</ItemGroup>
</Project>

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 753 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 671 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

View File

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/2010/manifest" xmlns:m2="http://schemas.microsoft.com/appx/2013/manifest" xmlns:m3="http://schemas.microsoft.com/appx/2014/manifest" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest">
<Identity Name="839e6be3-2571-47d8-910b-1d7386788d3b" Publisher="CN=dalestam" Version="1.0.0.5" />
<mp:PhoneIdentity PhoneProductId="839e6be3-2571-47d8-910b-1d7386788d3b" PhonePublisherId="00000000-0000-0000-0000-000000000000" />
<Properties>
<DisplayName>js-tests.WindowsPhone</DisplayName>
<PublisherDisplayName>dalestam</PublisherDisplayName>
<Logo>Assets\StoreLogo.png</Logo>
</Properties>
<Prerequisites>
<OSMinVersion>6.3.1</OSMinVersion>
<OSMaxVersionTested>6.3.1</OSMaxVersionTested>
</Prerequisites>
<Resources>
<Resource Language="x-generate" />
</Resources>
<Applications>
<Application Id="App" Executable="$targetnametoken$.exe" EntryPoint="cocos2d_WindowsPhone.App">
<m3:VisualElements DisplayName="js-tests.WindowsPhone" Square150x150Logo="Assets\Logo.png" Square44x44Logo="Assets\SmallLogo.png" Description="js-tests.WindowsPhone" ForegroundText="light" BackgroundColor="transparent">
<m3:DefaultTile Wide310x150Logo="Assets\WideLogo.png" Square71x71Logo="Assets\Square71x71Logo.png">
</m3:DefaultTile>
<m3:SplashScreen Image="Assets\SplashScreen.png" />
<m3:InitialRotationPreference>
<m3:Rotation Preference="landscape" />
<m3:Rotation Preference="landscapeFlipped" />
</m3:InitialRotationPreference>
</m3:VisualElements>
</Application>
</Applications>
<Capabilities>
<Capability Name="internetClientServer" />
</Capabilities>
</Package>

View File

@ -0,0 +1,151 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|ARM">
<Configuration>Debug</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|ARM">
<Configuration>Release</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{94874B5B-398F-448A-A366-35A35DC1DB9C}</ProjectGuid>
<RootNamespace>cocos2d</RootNamespace>
<DefaultLanguage>en-US</DefaultLanguage>
<MinimumVisualStudioVersion>12.0</MinimumVisualStudioVersion>
<AppContainerApplication>true</AppContainerApplication>
<ApplicationType>Windows Phone</ApplicationType>
<ApplicationTypeRevision>8.1</ApplicationTypeRevision>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120_wp81</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120_wp81</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>false</WholeProgramOptimization>
<PlatformToolset>v120_wp81</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>false</WholeProgramOptimization>
<PlatformToolset>v120_wp81</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<Import Project="..\App.Shared\js-tests.Shared.vcxitems" Label="Shared" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="..\..\..\..\..\cocos\2d\wp_8.1_props\cocos2d_wp_8.1_platform.props" />
<Import Project="..\..\..\..\..\cocos\2d\winrt_8.1_props\cocos2d_winrt_8.1.props" />
<Import Project="..\..\..\..\..\cocos\2d\winrt_8.1_props\cocos2d_winrt_8.1_app.props" />
<Import Project="..\resources.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
<Import Project="..\..\..\..\..\cocos\2d\wp_8.1_props\cocos2d_wp_8.1_platform.props" />
<Import Project="..\..\..\..\..\cocos\2d\winrt_8.1_props\cocos2d_winrt_8.1.props" />
<Import Project="..\..\..\..\..\cocos\2d\winrt_8.1_props\cocos2d_winrt_8.1_app.props" />
<Import Project="..\resources.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="..\..\..\..\..\cocos\2d\wp_8.1_props\cocos2d_wp_8.1_platform.props" />
<Import Project="..\..\..\..\..\cocos\2d\winrt_8.1_props\cocos2d_winrt_8.1.props" />
<Import Project="..\..\..\..\..\cocos\2d\winrt_8.1_props\cocos2d_winrt_8.1_app.props" />
<Import Project="..\resources.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
<Import Project="..\..\..\..\..\cocos\2d\wp_8.1_props\cocos2d_wp_8.1_platform.props" />
<Import Project="..\..\..\..\..\cocos\2d\winrt_8.1_props\cocos2d_winrt_8.1.props" />
<Import Project="..\..\..\..\..\cocos\2d\winrt_8.1_props\cocos2d_winrt_8.1_app.props" />
<Import Project="..\resources.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros">
<AppxAutoIncrementPackageRevision>True</AppxAutoIncrementPackageRevision>
<AppxBundlePlatforms>arm</AppxBundlePlatforms>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
<ClCompile>
<AdditionalOptions>/bigobj /Zm200 %(AdditionalOptions)</AdditionalOptions>
<DisableSpecificWarnings>4800;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<ForcedIncludeFiles>pch.h</ForcedIncludeFiles>
<AdditionalIncludeDirectories>$(ProjectDir)..\..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<SDLCheck>false</SDLCheck>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
<ClCompile>
<AdditionalOptions>/bigobj /Zm200 %(AdditionalOptions)</AdditionalOptions>
<DisableSpecificWarnings>4800;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<ForcedIncludeFiles>pch.h</ForcedIncludeFiles>
<AdditionalIncludeDirectories>$(ProjectDir)..\..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<SDLCheck>false</SDLCheck>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<AdditionalOptions>/bigobj /Zm200 %(AdditionalOptions)</AdditionalOptions>
<DisableSpecificWarnings>4800;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<ForcedIncludeFiles>pch.h</ForcedIncludeFiles>
<AdditionalIncludeDirectories>$(ProjectDir)..\..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<SDLCheck>false</SDLCheck>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<AdditionalOptions>/bigobj /Zm200 %(AdditionalOptions)</AdditionalOptions>
<DisableSpecificWarnings>4800;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<ForcedIncludeFiles>pch.h</ForcedIncludeFiles>
<AdditionalIncludeDirectories>$(ProjectDir)..\..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<SDLCheck>false</SDLCheck>
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup>
<AppxManifest Include="Package.appxmanifest">
<SubType>Designer</SubType>
</AppxManifest>
</ItemGroup>
<ItemGroup>
<Image Include="Assets\Logo.scale-240.png" />
<Image Include="Assets\SmallLogo.scale-240.png" />
<Image Include="Assets\Square71x71Logo.scale-240.png" />
<Image Include="Assets\StoreLogo.scale-240.png" />
<Image Include="Assets\SplashScreen.scale-240.png" />
<Image Include="Assets\WideLogo.scale-240.png" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\..\cocos\scripting\js-bindings\proj.win8.1-universal\libjscocos2d\libjscocos2d.WindowsPhone\libjscocos2d.WindowsPhone.vcxproj">
<Project>{ca082ec4-17ce-430b-8207-d1e947a5d1e9}</Project>
</ProjectReference>
<ProjectReference Include="..\..\..\..\..\cocos\2d\libcocos2d_8_1\libcocos2d_8_1\libcocos2d_8_1.WindowsPhone\libcocos2d_8_1.WindowsPhone.vcxproj">
<Project>{22f3b9df-1209-4574-8331-003966f562bf}</Project>
</ProjectReference>
<ProjectReference Include="..\..\..\..\..\cocos\editor-support\spine\proj.win8.1-universal\libSpine.WindowsPhone\libSpine.WindowsPhone.vcxproj">
<Project>{cc1da216-a80d-4be4-b309-acb6af313aff}</Project>
</ProjectReference>
<ProjectReference Include="..\..\..\..\..\external\Box2D\proj.win8.1-universal\libbox2d.WindowsPhone\libbox2d.WindowsPhone.vcxproj">
<Project>{22f798d8-bfff-4754-996f-a5395343d5ec}</Project>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Assets">
<UniqueIdentifier>{c8beb60d-689b-4aaa-9749-99bd3e2dcf75}</UniqueIdentifier>
<Extensions>bmp;fbx;gif;jpg;jpeg;tga;tiff;tif;png</Extensions>
</Filter>
<Image Include="Assets\Logo.scale-240.png">
<Filter>Assets</Filter>
</Image>
<Image Include="Assets\SmallLogo.scale-240.png">
<Filter>Assets</Filter>
</Image>
<Image Include="Assets\Square71x71Logo.scale-240.png">
<Filter>Assets</Filter>
</Image>
<Image Include="Assets\StoreLogo.scale-240.png">
<Filter>Assets</Filter>
</Image>
<Image Include="Assets\SplashScreen.scale-240.png">
<Filter>Assets</Filter>
</Image>
<Image Include="Assets\WideLogo.scale-240.png">
<Filter>Assets</Filter>
</Image>
</ItemGroup>
<ItemGroup>
<AppxManifest Include="Package.appxmanifest" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,63 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ImportGroup Label="PropertySheets" />
<ItemDefinitionGroup>
<ClCompile>
<AdditionalIncludeDirectories>$(EngineRoot)cocos\scripting\js-bindings\manual;$(EngineRoot)cocos\scripting\js-bindings\auto;$(EngineRoot)external\spidermonkey\include\$(COCOS2D_PLATFORM);$(EngineRoot)cocos\base;%(AdditionalIncludeDirectories);</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<AdditionalDependencies>mozjs-33.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(EngineRoot)external\spidermonkey\prebuilt\$(COCOS2D_PLATFORM)\$(Platform);%(AdditionalLibraryDirectories);</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<PropertyGroup Label="APP_DLLS">
<SpiderMonkeyBinPath Condition=" '$(SpiderMonkeyBinPath)' == '' ">$(EngineRoot)external\spidermonkey\prebuilt\$(COCOS2D_PLATFORM)\$(Platform)\</SpiderMonkeyBinPath>
</PropertyGroup>
<ItemGroup Label="APP_DLLs">
<None Include="$(SpiderMonkeyBinPath)mozjs-33.dll">
<DeploymentContent>true</DeploymentContent>
</None>
</ItemGroup>
<ItemGroup>
<_CustomResource Include="..\..\..\res\**\*">
<Link>Assets\Resources\res\%(RecursiveDir)%(FileName)%(Extension)</Link>
<DeploymentContent>true</DeploymentContent>
</_CustomResource>
</ItemGroup>
<ItemGroup>
<_CustomResource Include="..\..\..\src\**\*">
<Link>Assets\Resources\src\%(RecursiveDir)%(FileName)%(Extension)</Link>
<DeploymentContent>true</DeploymentContent>
</_CustomResource>
</ItemGroup>
<ItemGroup>
<_CustomResource Include="..\..\..\..\..\cocos\scripting\js-bindings\script\**\*">
<Link>Assets\Resources\script\%(RecursiveDir)%(FileName)%(Extension)</Link>
<DeploymentContent>true</DeploymentContent>
</_CustomResource>
</ItemGroup>
<ItemGroup>
<_CustomResource Include="..\..\..\main.js">
<Link>Assets\Resources\%(RecursiveDir)%(FileName)%(Extension)</Link>
<DeploymentContent>true</DeploymentContent>
</_CustomResource>
</ItemGroup>
<ItemGroup>
<_CustomResource Include="..\..\..\project.json">
<Link>Assets\Resources\%(RecursiveDir)%(FileName)%(Extension)</Link>
<DeploymentContent>true</DeploymentContent>
</_CustomResource>
</ItemGroup>
<Target Name="_CollectCustomResources" BeforeTargets="AssignTargetPaths">
<Message Text="Adding resource: %(_CustomResource.Identity) -&gt; %(_CustomResource.Link)" />
<ItemGroup>
<None Include="@(_CustomResource)" />
</ItemGroup>
</Target>
</Project>

View File

@ -0,0 +1,428 @@
/****************************************************************************
Copyright (c) 2008-2010 Ricardo Quesada
Copyright (c) 2011-2012 cocos2d-x.org
Copyright (c) 2013-2014 Chukong Technologies Inc.
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
var TAG_NODE = 5560;
var TAG_GROSSINI = 5561;
var TAG_SEQUENCE = 5562;
var ActionMgrTestIdx = -1;
var NOT_CRASHED_CONST = "NOT_CRASHED";
//------------------------------------------------------------------
//
// ActionManagerTest
//
//------------------------------------------------------------------
var ActionManagerTest = BaseTestLayer.extend({
_atlas:null,
_title:"",
title:function () {
return "No title";
},
subtitle:function () {
return "";
},
onBackCallback:function (sender) {
var s = new ActionManagerTestScene();
s.addChild(previousActionMgrTest());
director.runScene(s);
},
onRestartCallback:function (sender) {
var s = new ActionManagerTestScene();
s.addChild(restartActionMgrTest());
director.runScene(s);
},
onNextCallback:function (sender) {
var s = new ActionManagerTestScene();
s.addChild(nextActionMgrTest());
director.runScene(s);
},
// automation
numberOfPendingTests:function() {
return ( (arrayOfActionMgrTest.length-1) - ActionMgrTestIdx );
},
getTestNumber:function() {
return ActionMgrTestIdx;
}
});
//------------------------------------------------------------------
//
// Test1
//
//------------------------------------------------------------------
var CrashTest = ActionManagerTest.extend({
title:function () {
return "Test 1. Should not crash";
},
onEnter:function () {
//----start0----onEnter
this._super();
var child = new cc.Sprite(s_pathGrossini);
child.x = 200;
child.y = 200;
this.addChild(child, 1);
//Sum of all action's duration is 1.5 second.
child.runAction(cc.rotateBy(1.5, 90));
child.runAction(cc.sequence(
cc.delayTime(1.4),
cc.fadeOut(1.1))
);
//After 1.5 second, self will be removed.
//this.runAction(cc.sequence(
// cc.delayTime(1.4),
// cc.callFunc(this.onRemoveThis, this))
//);
//----end0----
},
onRemoveThis:function () {
//----start0----onRemoveThis
this.parent.removeChild(this);
this.onNextCallback(this);
//----end0----
},
//
// Automation
//
getExpectedResult:function() {
return NOT_CRASHED_CONST;
},
getCurrentResult:function() {
return NOT_CRASHED_CONST;
}
});
//------------------------------------------------------------------
//
// Test2
//
//------------------------------------------------------------------
var LogicTest = ActionManagerTest.extend({
title:function () {
return "Logic test";
},
onEnter:function () {
//----start1----onEnter
this._super();
var grossini = new cc.Sprite(s_pathGrossini);
this.addChild(grossini, 0, 2);
grossini.x = 200;
grossini.y = 200;
grossini.runAction(cc.sequence(
cc.moveBy(1, cc.p(150, 0)),
cc.callFunc(this.onBugMe, this))
);
//
// only for automation
//
if ( autoTestEnabled ) {
this._grossini = grossini;
}
//----end1----
},
onBugMe:function (node) {
//----start1----onBugMe
node.stopAllActions(); //After this stop next action not working, if remove this stop everything is working
node.runAction(cc.scaleTo(2, 2));
//----end1----
},
//
// Automation
//
testDuration: 4.0,
getExpectedResult:function() {
var ret = [ {"scaleX":2, "scaleY":2} ];
return JSON.stringify(ret);
},
getCurrentResult:function() {
var ret = [ {"scaleX":this._grossini.scaleX, "scaleY":this._grossini.scaleY} ];
return JSON.stringify(ret);
}
});
//------------------------------------------------------------------
//
// PauseTest
//
//------------------------------------------------------------------
var PauseTest = ActionManagerTest.extend({
title:function () {
return "Pause Test";
},
onEnter:function () {
//----start2----onEnter
//
// This test MUST be done in 'onEnter' and not on 'init'
// otherwise the paused action will be resumed at 'onEnter' time
//
this._super();
var s = director.getWinSize();
var l = new cc.LabelTTF("After 3 seconds grossini should move", "Thonburi", 16);
this.addChild(l);
l.x = s.width / 2;
l.y = 245;
//
// Also, this test MUST be done, after [super onEnter]
//
var grossini = new cc.Sprite(s_pathGrossini);
this.addChild(grossini, 0, TAG_GROSSINI);
grossini.x = 200;
grossini.y = 200;
var action = cc.moveBy(1, cc.p(150, 0));
director.getActionManager().addAction(action, grossini, true);
this.schedule(this.onUnpause, 3);
//
// only for automation
//
if ( autoTestEnabled ) {
this.scheduleOnce(this.checkControl1, 2.0);
this.scheduleOnce(this.checkControl2, 4.5);
this._grossini = grossini;
}
//----end2----
},
onUnpause:function (dt) {
//----start2----onUnpause
this.unschedule(this.onUnpause);
var node = this.getChildByTag(TAG_GROSSINI);
director.getActionManager().resumeTarget(node);
//----end2----
},
//
// Automation
//
testDuration:5.5,
checkControl1:function(dt) {
this.control1 = cc.p(this._grossini.x, this._grossini.y);
},
checkControl2:function(dt) {
this.control2 = cc.p(this._grossini.x, this._grossini.y);
},
getExpectedResult:function() {
var ret = [ {"x":200, "y":200}, {"x":350, "y":200} ];
return JSON.stringify(ret);
},
getCurrentResult:function() {
var ret = [ {"x":this.control1.x, "y":this.control1.y}, {"x":this.control2.x, "y":this.control2.y} ];
return JSON.stringify(ret);
}
});
//------------------------------------------------------------------
//
// RemoveTest
//
//------------------------------------------------------------------
var RemoveTest = ActionManagerTest.extend({
title:function () {
return "Remove Test";
},
onEnter:function () {
//----start3----onEnter
this._super();
var s = director.getWinSize();
var l = new cc.LabelTTF("Should not crash", "Thonburi", 16);
this.addChild(l);
l.x = s.width / 2;
l.y = 245;
var move = cc.moveBy(2, cc.p(200, 0));
var callback = cc.callFunc(this.stopAction, this);
var sequence = cc.sequence(move, callback);
sequence.tag = TAG_SEQUENCE;
var child = new cc.Sprite(s_pathGrossini);
child.x = 200;
child.y = 200;
this.addChild(child, 1, TAG_GROSSINI);
child.runAction(sequence);
//----end3----
},
stopAction:function () {
//----start3----onEnter
var sprite = this.getChildByTag(TAG_GROSSINI);
sprite.stopActionByTag(TAG_SEQUENCE);
//----end3----
},
//
// Automation
//
testDuration:3.5,
getExpectedResult:function() {
return NOT_CRASHED_CONST;
},
getCurrentResult:function() {
return NOT_CRASHED_CONST;
}
});
//------------------------------------------------------------------
//
// ResumeTest
//
//------------------------------------------------------------------
var ResumeTest = ActionManagerTest.extend({
title:function () {
return "Resume Test";
},
onEnter:function () {
//----start4----onEnter
this._super();
var s = director.getWinSize();
var l = new cc.LabelTTF("Grossini only rotate/scale in 3 seconds", "Thonburi", 16);
this.addChild(l);
l.x = s.width / 2;
l.y = 245;
var grossini = new cc.Sprite(s_pathGrossini);
this._grossini = grossini;
this.addChild(grossini, 0, TAG_GROSSINI);
grossini.x = s.width / 2;
grossini.y = s.height / 2;
grossini.runAction(cc.scaleBy(2, 2));
director.getActionManager().pauseTarget(grossini);
grossini.runAction(cc.rotateBy(2, 360));
this.schedule(this.resumeGrossini, 3.0);
//----end4----
},
resumeGrossini:function (time) {
//----start4----resumeGrossini
this.unschedule(this.resumeGrossini);
var grossini = this.getChildByTag(TAG_GROSSINI);
director.getActionManager().resumeTarget(grossini);
//----end4----
},
//
// Automation
//
testDuration:6.0,
setupAutomation:function() {
this.scheduleOnce(this.checkControl1, 1.0);
this.scheduleOnce(this.checkControl2, 5.5);
},
checkControl1:function(dt) {
this.control1ScaleX = this._grossini.scaleX;
this.control1ScaleY = this._grossini.scaleY;
this.control1Rotation = this._grossini.rotation;
},
checkControl2:function(dt) {
this.control2ScaleX = this._grossini.scaleX;
this.control2ScaleY = this._grossini.scaleY;
this.control2Rotation = this._grossini.rotation;
},
getExpectedResult:function() {
var ret = [ {"Rot":0 }, {"sX":1, "sY":1}, {"Rot":360 }, {"sX":2, "sY":2} ];
return JSON.stringify(ret);
},
getCurrentResult:function() {
var ret = [ {"Rot": this.control1Rotation }, {"sX": this.control1ScaleX, "sY": this.control1ScaleY}, {"Rot": this.control2Rotation }, {"sX": this.control2ScaleX, "sY": this.control2ScaleY} ];
return JSON.stringify(ret);
}
});
var ActionManagerTestScene = TestScene.extend({
runThisTest:function (num) {
ActionMgrTestIdx = (num || 0) - 1;
this.addChild(nextActionMgrTest());
director.runScene(this);
}
});
//-
//
// Flow control
//
var arrayOfActionMgrTest = [
CrashTest,
LogicTest,
PauseTest,
RemoveTest,
ResumeTest
];
var nextActionMgrTest = function (num) {
ActionMgrTestIdx = num ? num - 1 : ActionMgrTestIdx;
ActionMgrTestIdx++;
ActionMgrTestIdx = ActionMgrTestIdx % arrayOfActionMgrTest.length;
if(window.sideIndexBar){
ActionMgrTestIdx = window.sideIndexBar.changeTest(ActionMgrTestIdx, 0);
}
return new arrayOfActionMgrTest[ActionMgrTestIdx]();
};
var previousActionMgrTest = function () {
ActionMgrTestIdx--;
if (ActionMgrTestIdx < 0)
ActionMgrTestIdx += arrayOfActionMgrTest.length;
if(window.sideIndexBar){
ActionMgrTestIdx = window.sideIndexBar.changeTest(ActionMgrTestIdx, 0);
}
return new arrayOfActionMgrTest[ActionMgrTestIdx]();
};
var restartActionMgrTest = function () {
return new arrayOfActionMgrTest[ActionMgrTestIdx]();
};

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,239 @@
/****************************************************************************
Copyright (c) 2008-2010 Ricardo Quesada
Copyright (c) 2011-2012 cocos2d-x.org
Copyright (c) 2013-2014 Chukong Technologies Inc.
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
var _bakeLayerTestIdx = -1;
//------------------------------------------------------------------
//
// ActionManagerTest
//
//------------------------------------------------------------------
var BakeLayerBaseTest = BaseTestLayer.extend({
_atlas:null,
_title:"",
title:function () {
return "No title";
},
subtitle:function () {
return "";
},
onBackCallback:function (sender) {
var s = new BakeLayerTestScene();
s.addChild(previousBakeLayerTest());
director.runScene(s);
},
onRestartCallback:function (sender) {
var s = new BakeLayerTestScene();
s.addChild(restartBakeLayerTest());
director.runScene(s);
},
onNextCallback:function (sender) {
var s = new BakeLayerTestScene();
s.addChild(nextBakeLayerTest());
director.runScene(s);
},
// automation
numberOfPendingTests:function() {
return ( (arrayOfBakeLayerTest.length-1) - _bakeLayerTestIdx );
},
getTestNumber:function() {
return _bakeLayerTestIdx;
}
});
var BakeLayerTest1 = BakeLayerBaseTest.extend({
_bakeLayer: null,
title:function () {
return "Test 1. Bake Layer (Canvas only)";
},
ctor: function(){
this._super();
var winSize = cc.winSize;
var bakeItem = new cc.MenuItemFont("bake", this.onBake, this);
var unbakeItem = new cc.MenuItemFont("unbake", this.onUnbake, this);
var runActionItem = new cc.MenuItemFont("run action", this.onRunAction, this);
var menu = new cc.Menu(bakeItem, unbakeItem, runActionItem);
menu.alignItemsVertically();
menu.x = winSize.width - 70;
menu.y = winSize.height - 120;
this.addChild(menu, 10);
var rootLayer = new cc.Layer();
rootLayer.setPosition(20,20);
this.addChild(rootLayer);
var bakeLayer = new cc.Layer();
bakeLayer.bake();
bakeLayer.setRotation(30);
rootLayer.addChild(bakeLayer);
for(var i = 0; i < 9; i++){
var sprite1 = new cc.Sprite(s_pathGrossini);
if (i % 2 === 0) {
sprite1.setPosition(90 + i * 80, winSize.height / 2 - 50);
} else {
sprite1.setPosition(90 + i * 80, winSize.height / 2 + 50);
}
if(i === 4)
this._actionSprite = sprite1;
sprite1.rotation = 360 * Math.random();
bakeLayer.addChild(sprite1);
}
this._bakeLayer = bakeLayer;
bakeLayer.runAction(cc.sequence(cc.moveBy(2, cc.p(100,100)), cc.moveBy(2, cc.p(-100,-100))));
},
onBake: function(){
this._bakeLayer.bake();
},
onUnbake: function(){
this._bakeLayer.unbake();
},
onRunAction: function(){
this._actionSprite.runAction(cc.rotateBy(1, 180));
}
});
var BakeLayerColorTest = BakeLayerBaseTest.extend({
_bakeLayer: null,
_actionSprite: null,
title:function () {
return "Test 2. Bake Layer Gradient (Canvas only)";
},
ctor: function(){
this._super();
var winSize = cc.winSize;
var bakeItem = new cc.MenuItemFont("bake", this.onBake, this);
var unbakeItem = new cc.MenuItemFont("unbake", this.onUnbake, this);
var runActionItem = new cc.MenuItemFont("run action", this.onRunAction, this);
var menu = new cc.Menu(bakeItem, unbakeItem, runActionItem);
menu.alignItemsVertically();
menu.x = winSize.width - 70;
menu.y = winSize.height - 120;
this.addChild(menu, 10);
var rootLayer = new cc.Layer();
rootLayer.setPosition(20,20);
this.addChild(rootLayer);
//var bakeLayer = cc.LayerColor.create(cc.color(128,0, 128, 128), 700, 300); //test for LayerColor
//bakeLayer.setPosition(60, 80);
var bakeLayer = new cc.LayerGradient(cc.color(128,0, 128, 255), cc.color(0, 0, 128, 255));
bakeLayer.setPosition(60, 80);
bakeLayer.setContentSize(700, 300);
bakeLayer.setRotation(30);
//bakeLayer.setPosition(winSize.width /2, winSize.height /2); //test for ignoreAnchorPointForPosition
//bakeLayer.ignoreAnchorPointForPosition(false);
rootLayer.addChild(bakeLayer);
for(var i = 0; i < 9; i++){
var sprite1 = new cc.Sprite(s_pathGrossini);
if (i % 2 === 0) {
sprite1.setPosition(20 + i * 80, 100);
} else {
sprite1.setPosition(20 + i * 80, 200);
}
if(i === 4)
this._actionSprite = sprite1;
sprite1.rotation = 180 * Math.random();
bakeLayer.addChild(sprite1);
}
this._bakeLayer = bakeLayer;
bakeLayer.bake();
bakeLayer.runAction(cc.sequence(cc.moveBy(2, cc.p(100,100)), cc.moveBy(2, cc.p(-100,-100))));
},
onBake: function(){
this._bakeLayer.bake();
},
onUnbake: function(){
this._bakeLayer.unbake();
},
onRunAction: function(){
this._actionSprite.runAction(cc.rotateBy(2, 180));
}
});
var BakeLayerTestScene = TestScene.extend({
runThisTest:function (num) {
_bakeLayerTestIdx = (num || 0) - 1;
this.addChild(nextBakeLayerTest());
director.runScene(this);
}
});
//-
//
// Flow control
//
var arrayOfBakeLayerTest = [
BakeLayerTest1,
BakeLayerColorTest
];
var nextBakeLayerTest = function (num) {
_bakeLayerTestIdx = num ? num - 1 : _bakeLayerTestIdx;
_bakeLayerTestIdx++;
_bakeLayerTestIdx = _bakeLayerTestIdx % arrayOfBakeLayerTest.length;
if(window.sideIndexBar){
_bakeLayerTestIdx = window.sideIndexBar.changeTest(_bakeLayerTestIdx, 0);
}
return new arrayOfBakeLayerTest[_bakeLayerTestIdx]();
};
var previousBakeLayerTest = function () {
_bakeLayerTestIdx--;
if (_bakeLayerTestIdx < 0)
_bakeLayerTestIdx += arrayOfBakeLayerTest.length;
if(window.sideIndexBar){
_bakeLayerTestIdx = window.sideIndexBar.changeTest(_bakeLayerTestIdx, 0);
}
return new arrayOfBakeLayerTest[_bakeLayerTestIdx]();
};
var restartBakeLayerTest = function () {
return new arrayOfBakeLayerTest[_bakeLayerTestIdx]();
};

View File

@ -0,0 +1,294 @@
/****************************************************************************
Copyright (c) 2008-2010 Ricardo Quesada
Copyright (c) 2011-2012 cocos2d-x.org
Copyright (c) 2013-2014 Chukong Technologies Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
var BASE_TEST_MENUITEM_PREV_TAG = 1;
var BASE_TEST_MENUITEM_RESET_TAG = 2;
var BASE_TEST_MENUITEM_NEXT_TAG = 3;
var BASE_TEST_MENU_TAG = 10;
var BASE_TEST_TITLE_TAG = 11;
var BASE_TEST_SUBTITLE_TAG = 12;
var autoTestEnabled = autoTestEnabled || false;
var autoTestCurrentTestName = autoTestCurrentTestName || "N/A";
var BaseTestLayerProps = {
ctor:function(colorA, colorB ) {
cc.sys.garbageCollect();
// default gradient colors
var a = cc.color(98,99,117,255);
var b = cc.color(0,0,0,255);
if( arguments.length >= 1 )
a = colorA;
if( arguments.length == 2 )
b = colorB;
// for automation, no gradient. helps for grabbing the screen if needed
if( autoTestEnabled ) {
a = cc.color(0,0,0,255);
b = cc.color(0,0,0,255);
}
this._super( a, b );
// Update winsize in case it was resized
winSize = director.getWinSize();
if( autoTestEnabled ) {
this.totalNumberOfTests = this.numberOfPendingTests();
this.scheduleOnce( this.endTest, this.testDuration );
this.setupAutomation();
}
},
setupAutomation:function() {
// override me
// Will be called only if automation is activated
},
getTitle:function() {
var t = "";
// some tests use "this.title()" and others use "this._title";
if( 'title' in this )
t = this.title();
else if('_title' in this || this._title)
t = this._title;
return t;
},
getSubtitle:function() {
var st = "";
// some tests use "this.subtitle()" and others use "this._subtitle";
if(this.subtitle)
st = this.subtitle();
else if(this._subtitle)
st = this._subtitle;
return st;
},
log:function(str) {
if( !autoTestEnabled )
cc.log(str);
},
//
// Menu
//
onEnter:function () {
this._super();
var t = this.getTitle();
var label = new cc.LabelTTF(t, "Arial", 28);
this.addChild(label, 100, BASE_TEST_TITLE_TAG);
label.x = winSize.width / 2;
label.y = winSize.height - 50;
var st = this.getSubtitle();
if (st) {
var l = new cc.LabelTTF(st.toString(), "Thonburi", 16);
this.addChild(l, 101, BASE_TEST_SUBTITLE_TAG);
l.x = winSize.width / 2;
l.y = winSize.height - 80;
}
var item1 = new cc.MenuItemImage(s_pathB1, s_pathB2, this.onBackCallback, this);
var item2 = new cc.MenuItemImage(s_pathR1, s_pathR2, this.onRestartCallback, this);
var item3 = new cc.MenuItemImage(s_pathF1, s_pathF2, this.onNextCallback, this);
item1.tag = BASE_TEST_MENUITEM_PREV_TAG;
item2.tag = BASE_TEST_MENUITEM_RESET_TAG;
item3.tag = BASE_TEST_MENUITEM_NEXT_TAG;
var menu = new cc.Menu(item1, item2, item3);
menu.x = 0;
menu.y = 0;
var width = item2.width, height = item2.height;
item1.x = winSize.width/2 - width*2;
item1.y = height/2 ;
item2.x = winSize.width/2;
item2.y = height/2 ;
item3.x = winSize.width/2 + width*2;
item3.y = height/2 ;
this.addChild(menu, 102, BASE_TEST_MENU_TAG);
},
onRestartCallback:function (sender) {
// override me
},
onNextCallback:function (sender) {
// override me
},
onBackCallback:function (sender) {
// override me
},
//------------------------------------------
//
// Automation Test code
//
//------------------------------------------
// How many seconds should this test run
testDuration:0.25,
// Automated test
getExpectedResult:function() {
// Override me
throw "Not Implemented";
},
// Automated test
getCurrentResult:function() {
// Override me
throw "Not Implemented";
},
compareResults:function(current, expected) {
return (current == expected);
},
tearDown:function(dt) {
// Override to have a different behavior
var current = this.getCurrentResult();
var expected = this.getExpectedResult();
var ret = this.compareResults(current, expected);
if( ! ret )
this.errorDescription = "Expected value: '" + expected + "'. Current value'" + current + "'.";
return ret;
},
endTest:function(dt) {
this.errorDescription = "";
var title = this.getTitle();
try {
if( this.tearDown(dt) ) {
// Test OK
cc.log( autoTestCurrentTestName + " - " + this.getTestNumber() + ": Test '" + title + "':' OK");
} else {
// Test failed
cc.log( autoTestCurrentTestName + " - " +this.getTestNumber() + ": Test '" + title + "': Error: " + this.errorDescription );
}
} catch(err) {
cc.log( autoTestCurrentTestName + " - " +this.getTestNumber() + ": Test '" + title + "':'" + err);
}
this.runNextTest();
},
numberOfPendingTests:function() {
// override me. Should return true if the last test was executed
throw "Override me: numberOfPendingTests";
},
getTestNumber:function() {
throw "Override me: getTestNumber";
},
runNextTest:function() {
if( this.numberOfPendingTests() <= 0 ) {
var scene = new cc.Scene();
var layer = new TestController();
scene.addChild(layer);
director.runScene(scene);
} else
try {
this.onNextCallback(this);
} catch (err) {
cc.log( autoTestCurrentTestName + " - " +this.getTestNumber() + ": Test '" + this.getTitle() + "':'" + err);
this.runNextTest();
}
},
containsPixel: function(arr, pix, approx, range) {
range = range || 50.0;
approx = approx || false;
var abs = function(a,b) {
return ((a-b) > 0) ? (a-b) : (b-a);
};
var pixelEqual = function(pix1, pix2) {
if(approx && abs(pix1, pix2) < range) return true;
else if(!approx && pix1 == pix2) return true;
return false;
};
for(var i=0; i < arr.length; i += 4) {
if(pixelEqual(arr[i], pix[0]) && pixelEqual(arr[i + 1], pix[1]) &&
pixelEqual(arr[i + 2], pix[2]) && pixelEqual(arr[i + 3], pix[3])) {
return true;
}
}
return false;
},
readPixels:function(x,y,w,h) {
if( 'opengl' in cc.sys.capabilities) {
var size = 4 * w * h;
var array = new Uint8Array(size);
gl.readPixels(x, y, w, h, gl.RGBA, gl.UNSIGNED_BYTE, array);
return array;
} else {
// implement a canvas-html5 readpixels
return cc._renderContext.getImageData(x, winSize.height-y-h, w, h).data;
}
},
//
// Useful for comparing results
// From: http://stackoverflow.com/a/1359808
//
sortObject:function(o) {
var sorted = {},
key, a = [];
for (key in o) {
if (o.hasOwnProperty(key)) {
a.push(key);
}
}
a.sort();
for (key = 0; key < a.length; key++) {
sorted[a[key]] = o[a[key]];
}
return sorted;
}
};
var BaseTestLayer = cc.LayerGradient.extend(BaseTestLayerProps);

View File

@ -0,0 +1,359 @@
/****************************************************************************
Copyright (c) 2008-2010 Ricardo Quesada
Copyright (c) 2011-2012 cocos2d-x.org
Copyright (c) 2013-2014 Chukong Technologies Inc.
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
var BillBoardTestIdx = -1;
var BillBoardTestDemo = cc.Layer.extend({
_title:"",
_subtitle:"",
ctor:function () {
this._super();
},
//
// Menu
//
onEnter:function () {
this._super();
var label = new cc.LabelTTF(this._title, "Arial", 28);
this.addChild(label, 100, BASE_TEST_TITLE_TAG);
label.x = winSize.width / 2;
label.y = winSize.height - 50;
var label2 = new cc.LabelTTF(this._subtitle, "Thonburi", 16);
this.addChild(label2, 101, BASE_TEST_SUBTITLE_TAG);
label2.x = winSize.width / 2;
label2.y = winSize.height - 80;
var item1 = new cc.MenuItemImage(s_pathB1, s_pathB2, this.onBackCallback, this);
var item2 = new cc.MenuItemImage(s_pathR1, s_pathR2, this.onRestartCallback, this);
var item3 = new cc.MenuItemImage(s_pathF1, s_pathF2, this.onNextCallback, this);
item1.tag = BASE_TEST_MENUITEM_PREV_TAG;
item2.tag = BASE_TEST_MENUITEM_RESET_TAG;
item3.tag = BASE_TEST_MENUITEM_NEXT_TAG;
var menu = new cc.Menu(item1, item2, item3);
menu.x = 0;
menu.y = 0;
var width = item2.width, height = item2.height;
item1.x = winSize.width/2 - width*2;
item1.y = height/2 ;
item2.x = winSize.width/2;
item2.y = height/2 ;
item3.x = winSize.width/2 + width*2;
item3.y = height/2 ;
this.addChild(menu, 102, BASE_TEST_MENU_TAG);
},
onRestartCallback:function (sender) {
var s = new BillBoardTestScene();
s.addChild(restartBillBoardTest());
director.runScene(s);
},
onNextCallback:function (sender) {
var s = new BillBoardTestScene();
s.addChild(nextBillBoardTest());
director.runScene(s);
},
onBackCallback:function (sender) {
var s = new BillBoardTestScene();
s.addChild(previousBillBoardTest());
director.runScene(s);
},
});
var BillBoardTestScene = cc.Scene.extend({
ctor:function () {
this._super();
var label = new cc.LabelTTF("Main Menu", "Arial", 20);
var menuItem = new cc.MenuItemLabel(label, this.onMainMenuCallback, this);
var menu = new cc.Menu(menuItem);
menu.x = 0;
menu.y = 0;
menuItem.x = winSize.width - 50;
menuItem.y = 25;
this.addChild(menu);
},
onMainMenuCallback:function () {
var scene = new cc.Scene();
var layer = new TestController();
scene.addChild(layer);
director.runScene(scene);
},
runThisTest:function (num) {
BillBoardTestIdx = (num || num == 0) ? (num - 1) : -1;
var layer = nextBillBoardTest();
this.addChild(layer);
director.runScene(this);
}
});
var BillBoardRotationTest = BillBoardTestDemo.extend({
_title:"Rotation Test",
_subtitle:"All the sprites should still facing camera",
ctor:function(){
this._super();
var root = new jsb.Sprite3D();
root.setNormalizedPosition(cc.p(0.5, 0.25));
this.addChild(root);
var model = new jsb.Sprite3D("Sprite3DTest/orc.c3b");
model.setScale(5);
model.setRotation3D(cc.math.vec3(0, 180, 0));
root.addChild(model);
var bill = new jsb.BillBoard();
bill.setPosition(0, 120);
root.addChild(bill);
var sp = new cc.Sprite("Images/SpookyPeas.png");
bill.addChild(sp);
var label = new cc.LabelTTF("+100");
label.setPosition(0, 30);
bill.addChild(label);
root.runAction(cc.rotateBy(10, cc.math.vec3(0, 360, 0)).repeatForever());
var jump = cc.jumpBy(1, cc.p(0, 0), 30, 1);
var scale = cc.scaleBy(2, 2, 2, 0.1);
var rot = cc.rotateBy(2, cc.math.vec3(-90, 0, 0));
model.runAction(cc.sequence(cc.spawn(cc.sequence(jump, scale), rot), cc.spawn(scale.reverse(), rot.reverse())).repeatForever());
}
});
var BillBoardTest = BillBoardTestDemo.extend({
_title:"BillBoard Test",
_subtitle:"",
_camera:null,
_layerBillBorad:null,
_billboards:[],
ctor:function(){
this._super();
//Create touch listener
cc.eventManager.addListener({
event:cc.EventListener.TOUCH_ALL_AT_ONCE,
onTouchesMoved:this.onTouchesMoved.bind(this)
}, this);
var layer3D = new cc.Layer();
this.addChild(layer3D, 0);
this._layerBillBorad = layer3D;
var s = cc.winSize;
if(!this._camera){
this._camera = cc.Camera.createPerspective(60, s.width/s.height, 1, 500);
this._camera.setCameraFlag(cc.CameraFlag.USER1);
this._layerBillBorad.addChild(this._camera);
}
//Create rotating billboards
var imgs = ["Images/Icon.png", "Images/r2.png"];
for(var i = 0; i < 4; ++i){
var layer = new cc.Layer();
var billboard = new jsb.BillBoard(imgs[Math.floor(Math.random() + 0.5)]);
billboard.setScale(0.5);
billboard.setPosition3D(cc.math.vec3(0, 0, (Math.random() * 2 - 1) * 150));
billboard.setOpacity(Math.random() * 128 + 128);
this._billboards.push(billboard);
layer.addChild(billboard);
this._layerBillBorad.addChild(layer);
layer.runAction(cc.rotateBy(Math.random() * 10, cc.math.vec3(0, 45, 0)).repeatForever());
}
{
var billboard1 = new jsb.BillBoard("Images/Icon.png");
billboard1.setScale(0.2);
billboard1.setPosition3D(cc.math.vec3(0, 30, 0));
var billboard2 = new jsb.BillBoard("Images/r2.png");
billboard2.setPosition3D(cc.math.vec3(0, 0, 100));
billboard1.addChild(billboard2);
this._billboards.push(billboard1);
this._billboards.push(billboard2);
var sprite3d = new jsb.Sprite3D("Sprite3DTest/orc.c3b");
sprite3d.setScale(2);
sprite3d.addChild(billboard1);
sprite3d.runAction(cc.rotateBy(10, cc.math.vec3(0, 360, 0)).repeatForever());
this._layerBillBorad.addChild(sprite3d);
}
this.addNewBillBoradWithCoords(cc.math.vec3(20, 5, 0));
this.addNewBillBoradWithCoords(cc.math.vec3(60, 5, 0));
this.addNewBillBoradWithCoords(cc.math.vec3(100, 5, 0));
this.addNewBillBoradWithCoords(cc.math.vec3(140, 5, 0));
this.addNewBillBoradWithCoords(cc.math.vec3(180, 5, 0));
this.addNewAniBillBoradWithCoords(cc.math.vec3(-20, 0, 0));
this.addNewAniBillBoradWithCoords(cc.math.vec3(-60, 0, 0));
this.addNewAniBillBoradWithCoords(cc.math.vec3(-100, 0, 0));
this.addNewAniBillBoradWithCoords(cc.math.vec3(-140, 0, 0));
this.addNewAniBillBoradWithCoords(cc.math.vec3(-180, 0, 0));
this._camera.setPosition3D(cc.math.vec3(0, 100, 230));
this._camera.lookAt(cc.math.vec3(0, 0, 0), cc.math.vec3(0, 1, 0));
this._layerBillBorad.setCameraMask(2);
var label1 = new cc.LabelTTF("rotate+", "Arial", 16);
var item1 = new cc.MenuItemLabel(label1, function(){
var rotation3D = this._camera.getRotation3D();
rotation3D.y += 10;
this._camera.setRotation3D(rotation3D);
}, this);
var label2 = new cc.LabelTTF("rotate-", "Arial", 16);
var item2 = new cc.MenuItemLabel(label2, function(){
var rotation3D = this._camera.getRotation3D();
rotation3D.y -= 10;
this._camera.setRotation3D(rotation3D);
}, this);
var label3 = new cc.LabelTTF("Point Oriented", "Arial", 16);
var item3 = new cc.MenuItemLabel(label3, this.menuCallback_orientedPoint, this);
var label4 = new cc.LabelTTF("Plane Oriented", "Arial", 16);
var item4 = new cc.MenuItemLabel(label4, this.menuCallback_orientedPlane, this);
item1.setPosition(cc.p(s.width-80, s.height-160));
item2.setPosition(cc.p(s.width-80, s.height-190));
item3.setPosition(cc.p(s.width-80, s.height-100));
item4.setPosition(cc.p(s.width-80, s.height-130));
var menu = new cc.Menu(item1, item2, item3, item4);
this.addChild(menu);
menu.setPosition(0, 0);
},
addNewBillBoradWithCoords:function(position){
var imgs = ["Images/Icon.png", "Images/r2.png"];
for(var i = 0; i < 10; ++i){
var billboard = new jsb.BillBoard(imgs[Math.floor(Math.random() + 0.5)]);
billboard.setScale(0.5);
billboard.setPosition3D(cc.math.vec3(position.x, position.y, -150+30*i));
billboard.setOpacity(Math.random() * 128 + 128);
this._layerBillBorad.addChild(billboard);
this._billboards.push(billboard);
}
},
addNewAniBillBoradWithCoords:function(position){
for(var i = 0; i < 10; ++i){
var billboardAni = new jsb.BillBoard("Images/grossini.png");
billboardAni.setScale(0.5);
billboardAni.setPosition3D(cc.math.vec3(position.x, position.y, -150+30*i));
this._layerBillBorad.addChild(billboardAni);
var animation = new cc.Animation();
for(var j = 1; j < 15; ++j){
if(j < 10)
animation.addSpriteFrameWithFile("Images/grossini_dance_0"+j+".png");
else
animation.addSpriteFrameWithFile("Images/grossini_dance_"+j+".png");
}
// should last 2.8 seconds. And there are 14 frames.
animation.setDelayPerUnit(2.8/14.0);
animation.setRestoreOriginalFrame(true);
var action = new cc.Animate(animation);
billboardAni.runAction(action.repeatForever());
billboardAni.setOpacity(Math.random() * 128 + 128);
this._billboards.push(billboardAni);
}
},
menuCallback_orientedPoint:function(sender){
for(var i = 0; i < this._billboards.length; ++i){
this._billboards[i].setMode(jsb.BillBoard.Mode.VIEW_POINT_ORIENTED);
}
},
menuCallback_orientedPlane:function(sender){
for(var i = 0; i < this._billboards.length; ++i){
this._billboards[i].setMode(jsb.BillBoard.Mode.VIEW_PLANE_ORIENTED);
}
},
onTouchesMoved:function(touches, event){
if(touches.length == 1){
var touch = touches[0];
var location = touch.getLocation();
var previousLocation = touch.getPreviousLocation();
var newPos = cc.p(previousLocation.x - location.x, previousLocation.y - location.y);
var m = this._camera.getNodeToWorldTransform3D();
var cameraDir = cc.math.vec3(-m[8], -m[9], -m[10]);
cameraDir.normalize();
cameraDir.y = 0;
var cameraRightDir = cc.math.vec3(m[0], m[1], m[2]);
cameraRightDir.normalize();
cameraRightDir.y = 0;
var cameraPos = this._camera.getPosition3D();
cameraPos.x += cameraDir.x * newPos.y * 0.5 + cameraRightDir.x * newPos.x * 0.5;
cameraPos.y += cameraDir.y * newPos.y * 0.5 + cameraRightDir.y * newPos.x * 0.5;
cameraPos.z += cameraDir.z * newPos.y * 0.5 + cameraRightDir.z * newPos.x * 0.5;
this._camera.setPosition3D(cameraPos);
}
}
});
//
// Flow control
//
var arrayOfBillBoardTest = [
BillBoardRotationTest,
BillBoardTest
];
var nextBillBoardTest = function () {
BillBoardTestIdx++;
BillBoardTestIdx = BillBoardTestIdx % arrayOfBillBoardTest.length;
return new arrayOfBillBoardTest[BillBoardTestIdx ]();
};
var previousBillBoardTest = function () {
BillBoardTestIdx--;
if (BillBoardTestIdx < 0)
BillBoardTestIdx += arrayOfBillBoardTest.length;
return new arrayOfBillBoardTest[BillBoardTestIdx ]();
};
var restartBillBoardTest = function () {
return new arrayOfBillBoardTest[BillBoardTestIdx ]();
};

View File

@ -0,0 +1,197 @@
/****************************************************************************
Copyright (c) 2008-2010 Ricardo Quesada
Copyright (c) 2011-2012 cocos2d-x.org
Copyright (c) 2013-2014 Chukong Technologies Inc.
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
var TAG_SPRITE_MANAGER = 1;
var PTM_RATIO = 32;
var Box2DTestLayer = cc.Layer.extend({
world:null,
//GLESDebugDraw *m_debugDraw;
ctor:function () {
if(window.sideIndexBar){
window.sideIndexBar.changeTest(0, 2);
}
//----start0----ctor
this._super();
cc.eventManager.addListener(cc.EventListener.create({
event: cc.EventListener.TOUCH_ALL_AT_ONCE,
onTouchesEnded: function(touches, event){
//Add a new body/atlas sprite at the touched location
var touch = touches[0];
var location = touch.getLocation();
event.getCurrentTarget().addNewSpriteWithCoords(location);
}
}), this);
var b2Vec2 = Box2D.Common.Math.b2Vec2
, b2BodyDef = Box2D.Dynamics.b2BodyDef
, b2Body = Box2D.Dynamics.b2Body
, b2FixtureDef = Box2D.Dynamics.b2FixtureDef
, b2World = Box2D.Dynamics.b2World
, b2PolygonShape = Box2D.Collision.Shapes.b2PolygonShape;
var screenSize = cc.director.getWinSize();
//UXLog(L"Screen width %0.2f screen height %0.2f",screenSize.width,screenSize.height);
// Construct a world object, which will hold and simulate the rigid bodies.
this.world = new b2World(new b2Vec2(0, -10), true);
this.world.SetContinuousPhysics(true);
// Define the ground body.
//var groundBodyDef = new b2BodyDef(); // TODO
//groundBodyDef.position.Set(screenSize.width / 2 / PTM_RATIO, screenSize.height / 2 / PTM_RATIO); // bottom-left corner
// Call the body factory which allocates memory for the ground body
// from a pool and creates the ground box shape (also from a pool).
// The body is also added to the world.
//var groundBody = this.world.CreateBody(groundBodyDef);
var fixDef = new b2FixtureDef;
fixDef.density = 1.0;
fixDef.friction = 0.5;
fixDef.restitution = 0.2;
var bodyDef = new b2BodyDef;
//create ground
bodyDef.type = b2Body.b2_staticBody;
fixDef.shape = new b2PolygonShape;
fixDef.shape.SetAsBox(20, 2);
// upper
bodyDef.position.Set(10, screenSize.height / PTM_RATIO + 1.8);
this.world.CreateBody(bodyDef).CreateFixture(fixDef);
// bottom
bodyDef.position.Set(10, -1.8);
this.world.CreateBody(bodyDef).CreateFixture(fixDef);
fixDef.shape.SetAsBox(2, 14);
// left
bodyDef.position.Set(-1.8, 13);
this.world.CreateBody(bodyDef).CreateFixture(fixDef);
// right
bodyDef.position.Set(26.8, 13);
this.world.CreateBody(bodyDef).CreateFixture(fixDef);
//Set up sprite
var mgr = new cc.SpriteBatchNode(s_pathBlock, 150);
this.addChild(mgr, 0, TAG_SPRITE_MANAGER);
this.addNewSpriteWithCoords(cc.p(screenSize.width / 2, screenSize.height / 2));
var label = new cc.LabelTTF("Tap screen", "Marker Felt", 32);
this.addChild(label, 0);
label.color = cc.color(0, 0, 255);
label.x = screenSize.width / 2;
label.y = screenSize.height - 50;
this.scheduleUpdate();
//----end0----
},
addNewSpriteWithCoords:function (p) {
//----start0----addNewSpriteWithCoords
//UXLog(L"Add sprite %0.2f x %02.f",p.x,p.y);
var batch = this.getChildByTag(TAG_SPRITE_MANAGER);
//We have a 64x64 sprite sheet with 4 different 32x32 images. The following code is
//just randomly picking one of the images
var idx = (Math.random() > .5 ? 0 : 1);
var idy = (Math.random() > .5 ? 0 : 1);
var sprite = new cc.Sprite(batch.texture, cc.rect(32 * idx, 32 * idy, 32, 32));
batch.addChild(sprite);
sprite.x = p.x;
sprite.y = p.y;
// Define the dynamic body.
//Set up a 1m squared box in the physics world
var b2BodyDef = Box2D.Dynamics.b2BodyDef
, b2Body = Box2D.Dynamics.b2Body
, b2FixtureDef = Box2D.Dynamics.b2FixtureDef
, b2PolygonShape = Box2D.Collision.Shapes.b2PolygonShape;
var bodyDef = new b2BodyDef();
bodyDef.type = b2Body.b2_dynamicBody;
bodyDef.position.Set(p.x / PTM_RATIO, p.y / PTM_RATIO);
bodyDef.userData = sprite;
var body = this.world.CreateBody(bodyDef);
// Define another box shape for our dynamic body.
var dynamicBox = new b2PolygonShape();
dynamicBox.SetAsBox(0.5, 0.5);//These are mid points for our 1m box
// Define the dynamic body fixture.
var fixtureDef = new b2FixtureDef();
fixtureDef.shape = dynamicBox;
fixtureDef.density = 1.0;
fixtureDef.friction = 0.3;
body.CreateFixture(fixtureDef);
//----end0----
},
update:function (dt) {
//----start0----update
//It is recommended that a fixed time step is used with Box2D for stability
//of the simulation, however, we are using a variable time step here.
//You need to make an informed choice, the following URL is useful
//http://gafferongames.com/game-physics/fix-your-timestep/
var velocityIterations = 8;
var positionIterations = 1;
// Instruct the world to perform a single step of simulation. It is
// generally best to keep the time step and iterations fixed.
this.world.Step(dt, velocityIterations, positionIterations);
//Iterate over the bodies in the physics world
for (var b = this.world.GetBodyList(); b; b = b.GetNext()) {
if (b.GetUserData() != null) {
//Synchronize the AtlasSprites position and rotation with the corresponding body
var myActor = b.GetUserData();
myActor.x = b.GetPosition().x * PTM_RATIO;
myActor.y = b.GetPosition().y * PTM_RATIO;
myActor.rotation = -1 * cc.radiansToDegrees(b.GetAngle());
}
}
//----end0----
}
//CREATE_NODE(Box2DTestLayer);
});
var Box2DTestScene = TestScene.extend({
runThisTest:function () {
var layer = new Box2DTestLayer();
this.addChild(layer);
cc.director.runScene(this);
}
});
var arrayOfBox2DTest = [
Box2DTestLayer
];

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,101 @@
/****************************************************************************
Copyright (c) 2008-2010 Ricardo Quesada
Copyright (c) 2011-2012 cocos2d-x.org
Copyright (c) 2013-2014 Chukong Technologies Inc.
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
var TAG_SPRITE = 1;
var ClickAndMoveTestScene = TestScene.extend({
runThisTest:function () {
var layer = new ClickAndMoveTestLayer();
this.addChild(layer);
director.runScene(this);
}
});
var ClickAndMoveTestLayer = cc.Layer.extend({
ctor:function () {
if(window.sideIndexBar){
window.sideIndexBar.changeTest(0, 4);
}
this._super();
this.init();
if( 'touches' in cc.sys.capabilities )
cc.eventManager.addListener(cc.EventListener.create({
event: cc.EventListener.TOUCH_ALL_AT_ONCE,
onTouchesEnded:function (touches, event) {
if (touches.length <= 0)
return;
event.getCurrentTarget().moveSprite(touches[0].getLocation());
}
}), this);
else if ('mouse' in cc.sys.capabilities )
cc.eventManager.addListener({
event: cc.EventListener.MOUSE,
onMouseUp: function (event) {
event.getCurrentTarget().moveSprite(event.getLocation());
}
}, this);
var sprite = new cc.Sprite(s_pathGrossini);
var layer = new cc.LayerColor(cc.color(255, 255, 0, 100));
this.addChild(layer, -1);
this.addChild(sprite, 0, TAG_SPRITE);
sprite.x = 20;
sprite.y = 150;
sprite.runAction(cc.jumpTo(4, cc.p(300, 48), 100, 4));
var fadeIn = cc.fadeIn(1);
var fadeOut = cc.fadeOut(1);
var forever = cc.sequence(fadeIn, fadeOut).repeatForever();
layer.runAction(forever);
},
moveSprite:function(position) {
var sprite = this.getChildByTag(TAG_SPRITE);
sprite.stopAllActions();
sprite.runAction(cc.moveTo(1, position));
var o = position.x - sprite.x;
var a = position.y - sprite.y;
var at = Math.atan(o / a) * 57.29577951; // radians to degrees
if (a < 0) {
if (o < 0)
at = 180 + Math.abs(at);
else
at = 180 - Math.abs(at);
}
sprite.runAction(cc.rotateTo(1, at));
}
});
var arrayOfClickMoveTest = [ClickAndMoveTestLayer];

View File

@ -0,0 +1,768 @@
/****************************************************************************
Copyright (c) 2010-2013 cocos2d-x.org
Copyright (c) 2008-2010 Ricardo Quesada
Copyright (c) 2012 Pierre-David Bélanger
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
var TAG_TITLELABEL = 1;
var TAG_SUBTITLELABEL = 2;
var TAG_STENCILNODE = 100;
var TAG_CLIPPERNODE = 101;
var TAG_CONTENTNODE = 102;
var clippingNodeTestSceneIdx = -1;
var BaseClippingNodeTest = BaseTestLayer.extend({
_title:"",
_subtitle:"",
ctor:function() {
this._super(cc.color(0,0,0,255), cc.color(98,99,117,255));
this.setup();
},
onRestartCallback:function (sender) {
var s = new ClippingNodeTestScene();
s.addChild(restartClippingNodeTest());
director.runScene(s);
},
onNextCallback:function (sender) {
var s = new ClippingNodeTestScene();
s.addChild(nextClippingNodeTest());
director.runScene(s);
},
onBackCallback:function (sender) {
var s = new ClippingNodeTestScene();
s.addChild(previousClippingNodeTest());
director.runScene(s);
},
// automation
numberOfPendingTests:function() {
return ( (arrayOfClippingNodeTest.length-1) - clippingNodeTestSceneIdx );
},
getTestNumber:function() {
return clippingNodeTestSceneIdx;
}
});
var BasicTest = BaseClippingNodeTest.extend({
title:function () {
return "Basic Test";
},
subtitle:function () {
return "";
},
setup:function () {
var winSize = cc.director.getWinSize();
var stencil = this.stencil();
stencil.tag = TAG_STENCILNODE;
stencil.x = 50;
stencil.y = 50;
var clipper = this.clipper();
clipper.tag = TAG_CLIPPERNODE;
clipper.anchorX = 0.5;
clipper.anchorY = 0.5;
clipper.x = winSize.width / 2 - 50;
clipper.y = winSize.height / 2 - 50;
clipper.stencil = stencil;
this.addChild(clipper);
var content = this.content();
content.x = 50;
content.y = 50;
clipper.addChild(content);
//content.x = 400;
//content.y = 225;
//this.addChild(content);
},
actionRotate:function () {
return cc.rotateBy(1.0, 90.0).repeatForever();
},
actionScale:function () {
var scale = cc.scaleBy(1.33, 1.5);
return cc.sequence(scale, scale.reverse()).repeatForever();
},
shape:function () {
var shape = new cc.DrawNode();
var triangle = [cc.p(-100, -100),cc.p(100, -100), cc.p(0, 100)];
var green = cc.color(0, 255, 0, 255);
shape.drawPoly(triangle, green, 3, green);
return shape;
},
grossini:function () {
var grossini = new cc.Sprite(s_pathGrossini);
grossini.scale = 1.5;
return grossini;
},
stencil:function () {
return null;
},
clipper:function () {
return new cc.ClippingNode();
},
content:function () {
return null;
}
});
var ShapeTest = BasicTest.extend({
title:function () {
return "Shape Basic Test";
},
subtitle:function () {
return "A DrawNode as stencil and Sprite as content";
},
stencil:function () {
var node = this.shape();
node.runAction(this.actionRotate());
return node;
},
content:function () {
var node = this.grossini();
node.runAction(this.actionScale());
return node;
}
});
var ShapeInvertedTest = ShapeTest.extend({
title:function () {
return "Shape Inverted Basic Test";
},
subtitle:function () {
return "A DrawNode as stencil and Sprite as content, inverted";
},
clipper:function () {
var clipper = this._super();
clipper.setInverted(true);
return clipper;
}
});
var SpriteTest = BasicTest.extend({
title:function () {
return "Sprite Basic Test";
},
subtitle:function () {
return "A Sprite as stencil and DrawNode as content";
},
stencil:function () {
var node = this.grossini();
node.runAction(this.actionRotate());
return node;
},
clipper:function () {
var clipper = this._super();
clipper.alphaThreshold = 0.05;
return clipper;
},
content:function () {
var node = this.shape();
node.runAction(this.actionScale());
return node;
}
});
var SpriteNoAlphaTest = SpriteTest.extend({
title:function () {
return "Sprite No Alpha Basic Test";
},
subtitle:function () {
return "A Sprite as stencil and DrawNode as content, no alpha";
},
clipper:function () {
var clipper = this._super();
clipper.alphaThreshold = 1;
return clipper;
}
});
var SpriteInvertedTest = SpriteTest.extend({
title:function () {
return "Sprite Inverted Basic Test";
},
subtitle:function () {
return "A Sprite as stencil and DrawNode as content, inverted";
},
clipper:function () {
var clipper = this._super();
clipper.alphaThreshold = 0.05;
clipper.inverted = true;
return clipper;
}
});
var NestedTest = BaseClippingNodeTest.extend({
title:function () {
return "Nested Test";
},
subtitle:function () {
return "Nest 9 Clipping Nodes, max is usually 8";
},
setup:function () {
var depth = 9;
var parent = this;
for (var i = 0; i < depth; i++ ) {
var size = 225 - i * (225 / (depth * 2));
var clipper = new cc.ClippingNode();
clipper.attr({
width: size,
height: size,
anchorX: 0.5,
anchorY: 0.5,
x: parent.width / 2,
y: parent.height / 2
});
clipper.alphaThreshold = 0.05;
clipper.runAction(cc.rotateBy((i % 3) ? 1.33 : 1.66, (i % 2) ? 90 : -90).repeatForever());
parent.addChild(clipper);
var stencil = new cc.Sprite(s_pathGrossini);
stencil.attr({
scale: 2.5 - (i * (2.5 / depth)),
anchorX: 0.5,
anchorY: 0.5,
x: clipper.width / 2,
y: clipper.height / 2,
visible: false
});
stencil.runAction(cc.sequence(cc.delayTime(i), cc.show()));
clipper.stencil = stencil;
clipper.addChild(stencil);
parent = clipper;
}
}
});
var HoleDemo = BaseClippingNodeTest.extend({
_outerClipper:null,
_holes:null,
_holesStencil:null,
setup:function () {
var target = new cc.Sprite(s_pathBlock);
target.anchorX = 0;
target.anchorY = 0;
target.scale = 3;
var scale = target.scale;
var stencil = new cc.DrawNode();
var rectangle = [cc.p(0, 0),cc.p(target.width*scale, 0),
cc.p(target.width*scale, target.height*scale),
cc.p(0, target.height*scale)];
stencil.drawPoly(rectangle, cc.color(255, 0, 0, 255), 0, cc.color(255, 255, 255, 0));
this._outerClipper = new cc.ClippingNode();
this._outerClipper.retain();
var transform = cc.affineTransformMakeIdentity();
transform = cc.affineTransformScale(transform, target.scale, target.scale);
var ocsize = cc.sizeApplyAffineTransform(cc.size(target.width, target.height), transform);
this._outerClipper.width = ocsize.width;
this._outerClipper.height = ocsize.height;
this._outerClipper.anchorX = 0.5;
this._outerClipper.anchorY = 0.5;
this._outerClipper.x = this.width * 0.5;
this._outerClipper.y = this.height * 0.5;
this._outerClipper.runAction(cc.rotateBy(1, 45).repeatForever());
this._outerClipper.stencil = stencil;
var holesClipper = new cc.ClippingNode();
holesClipper.inverted = true;
holesClipper.alphaThreshold = 0.05;
holesClipper.addChild(target);
this._holes = new cc.Node();
this._holes.retain();
holesClipper.addChild(this._holes);
this._holesStencil = new cc.Node();
this._holesStencil.retain();
holesClipper.stencil = this._holesStencil;
this._outerClipper.addChild(holesClipper);
this.addChild(this._outerClipper);
cc.eventManager.addListener(cc.EventListener.create({
event: cc.EventListener.TOUCH_ALL_AT_ONCE,
onTouchesBegan:function (touches, event) {
var target = event.getCurrentTarget();
var touch = touches[0];
var point = target._outerClipper.convertToNodeSpace(touch.getLocation());
var rect = cc.rect(0, 0, target._outerClipper.width, target._outerClipper.height);
if (!cc.rectContainsPoint(rect,point))
return;
target.pokeHoleAtPoint(point);
}
}), this);
},
title:function () {
return "Hole Demo";
},
subtitle:function () {
return "Touch/click to poke holes";
},
pokeHoleAtPoint:function (point) {
var scale = Math.random() * 0.2 + 0.9;
var rotation = Math.random() * 360;
var hole = new cc.Sprite(s_hole_effect_png);
hole.attr({
x: point.x,
y: point.y,
rotation: rotation,
scale: scale
});
this._holes.addChild(hole);
var holeStencil = new cc.Sprite(s_hole_stencil_png);
holeStencil.attr({
x: point.x,
y: point.y,
rotation: rotation,
scale: scale
});
this._holesStencil.addChild(holeStencil);
this._outerClipper.runAction(cc.sequence(cc.scaleBy(0.05, 0.95), cc.scaleTo(0.125, 1)));
}
});
var ScrollViewDemo = BaseClippingNodeTest.extend({
_scrolling:false,
_lastPoint:null,
title:function () {
return "Scroll View Demo";
},
subtitle:function () {
return "Move/drag to scroll the content";
},
setup:function () {
var clipper = new cc.ClippingNode();
clipper.tag = TAG_CLIPPERNODE;
clipper.width = 200;
clipper.height = 200;
clipper.anchorX = 0.5;
clipper.anchorY = 0.5;
clipper.x = this.width / 2;
clipper.y = this.height / 2;
clipper.runAction(cc.rotateBy(1, 45).repeatForever());
this.addChild(clipper);
var stencil = new cc.DrawNode();
var rectangle = [cc.p(0, 0),cc.p(clipper.width, 0),
cc.p(clipper.width, clipper.height),
cc.p(0, clipper.height)];
var white = cc.color(255, 255, 255, 255);
stencil.drawPoly(rectangle, white, 1, white);
clipper.stencil = stencil;
var content = new cc.Sprite(s_back2);
content.tag = TAG_CONTENTNODE;
content.anchorX = 0.5;
content.anchorY = 0.5;
content.x = clipper.width / 2;
content.y = clipper.height / 2;
clipper.addChild(content);
this._scrolling = false;
cc.eventManager.addListener(cc.EventListener.create({
event: cc.EventListener.TOUCH_ALL_AT_ONCE,
onTouchesBegan: function (touches, event) {
if (!touches || touches.length == 0)
return;
var target = event.getCurrentTarget();
var touch = touches[0];
var clipper = target.getChildByTag(TAG_CLIPPERNODE);
var point = clipper.convertToNodeSpace(touch.getLocation());
var rect = cc.rect(0, 0, clipper.width, clipper.height);
target._scrolling = cc.rectContainsPoint(rect, point);
target._lastPoint = point;
},
onTouchesMoved: function (touches, event) {
var target = event.getCurrentTarget();
if (!target._scrolling)
return;
if (!touches || touches.length == 0)
return;
var touch = touches[0];
var clipper = target.getChildByTag(TAG_CLIPPERNODE);
var point = clipper.convertToNodeSpace(touch.getLocation());
var diff = cc.pSub(point, target._lastPoint);
var content = clipper.getChildByTag(TAG_CONTENTNODE);
content.setPosition(cc.pAdd(content.getPosition(), diff));
target._lastPoint = point;
},
onTouchesEnded: function (touches, event) {
var target = event.getCurrentTarget();
if (!target._scrolling) return;
target._scrolling = false;
}
}), this);
}
});
var _stencilBits = -1;
var _alphaThreshold = 0.05;
var _PLANE_COUNT = 8;
var _planeColor = [
cc.color(0, 0, 0, 166),
cc.color(179, 0, 0, 153),
cc.color(0, 179, 0, 140),
cc.color(0, 0, 179, 128),
cc.color(179, 179, 0, 115),
cc.color(0, 179, 179, 102),
cc.color(179, 0, 179, 89),
cc.color(179, 179, 179, 77)
];
var RawStencilBufferTest = BaseClippingNodeTest.extend({
_sprite:null,
_initRendererCmd: function(){
this._rendererCmd = new cc.CustomRenderCmdWebGL(this, this.draw);
},
title:function () {
return "Raw Stencil Tests";
},
subtitle:function () {
return "1:Default";
},
setup:function () {
_stencilBits = cc._renderContext.getParameter(cc._renderContext.STENCIL_BITS);
if (_stencilBits < 3)
cc.log("Stencil must be enabled for the current CCGLView.");
this._sprite = new cc.Sprite(s_pathGrossini);
this._sprite.anchorX = 0.5;
this._sprite.anchorY = 0;
this._sprite.scale = 2.5;
cc.director.setAlphaBlending(true);
},
draw:function (ctx) {
var gl = ctx || cc._renderContext;
var winPoint = cc.pFromSize(cc.director.getWinSize());
var planeSize = cc.pMult(winPoint, 1.0 / _PLANE_COUNT);
gl.enable(gl.STENCIL_TEST);
//cc.checkGLErrorDebug();
for (var i = 0; i < _PLANE_COUNT; i++) {
var stencilPoint = cc.pMult(planeSize, _PLANE_COUNT - i);
stencilPoint.x = winPoint.x;
var x = planeSize.x / 2 + planeSize.x * i, y = 0;
this._sprite.x = x;
this._sprite.y = y;
this.setupStencilForClippingOnPlane(i);
//cc.checkGLErrorDebug();
cc._drawingUtil.drawSolidRect(cc.p(0, 0), stencilPoint, cc.color(255, 255, 255, 255));
cc.kmGLPushMatrix();
this.transform();
this._sprite.visit();
cc.kmGLPopMatrix();
this.setupStencilForDrawingOnPlane(i);
//cc.checkGLErrorDebug();
cc._drawingUtil.drawSolidRect(cc.p(0, 0), winPoint, _planeColor[i]);
cc.kmGLPushMatrix();
this.transform();
this._sprite.visit();
cc.kmGLPopMatrix();
}
gl.disable(gl.STENCIL_TEST);
//cc.checkGLErrorDebug();
},
setupStencilForClippingOnPlane:function (plane) {
var gl = cc._renderContext;
var planeMask = 0x1 << plane;
gl.stencilMask(planeMask);
gl.clearStencil(0x0);
gl.clear(gl.STENCIL_BUFFER_BIT);
gl.flush();
gl.stencilFunc(gl.NEVER, planeMask, planeMask);
gl.stencilOp(gl.REPLACE, gl.KEEP, gl.KEEP);
},
setupStencilForDrawingOnPlane:function (plane) {
var gl = cc._renderContext;
var planeMask = 0x1 << plane;
var equalOrLessPlanesMask = planeMask | (planeMask - 1);
gl.stencilFunc(gl.EQUAL, equalOrLessPlanesMask, equalOrLessPlanesMask);
gl.stencilOp(gl.KEEP, gl.KEEP, gl.KEEP);
}
});
var RawStencilBufferTest2 = RawStencilBufferTest.extend({
subtitle:function () {
return "2:DepthMask:FALSE";
},
setupStencilForClippingOnPlane:function (plane) {
this._super(plane);
cc._renderContext.depthMask(false);
},
setupStencilForDrawingOnPlane:function (plane) {
cc._renderContext.depthMask(true);
this._super(plane);
}
});
var RawStencilBufferTest3 = RawStencilBufferTest.extend({
subtitle:function () {
return "3:DepthTest:DISABLE,DepthMask:FALSE";
},
setupStencilForClippingOnPlane:function (plane) {
var gl = cc._renderContext;
this._super(plane);
gl.disable(gl.DEPTH_TEST);
gl.depthMask(false);
},
setupStencilForDrawingOnPlane:function (plane) {
var gl = cc._renderContext;
gl.depthMask(true);
//gl.enable(gl.DEPTH_TEST);
this._super(plane);
}
});
var RawStencilBufferTest4 = RawStencilBufferTest.extend({
subtitle:function () {
return "4:DepthMask:FALSE,AlphaTest:ENABLE";
},
setupStencilForClippingOnPlane:function (plane) {
var gl = cc._renderContext;
this._super(plane);
gl.depthMask(false);
var program = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLORALPHATEST);
var alphaValueLocation = gl.getUniformLocation(program.getProgram(),cc.UNIFORM_ALPHA_TEST_VALUE_S);
cc.glUseProgram(program.getProgram());
program.setUniformLocationWith1f(alphaValueLocation, _alphaThreshold);
this._sprite.shaderProgram = program;
},
setupStencilForDrawingOnPlane:function (plane) {
cc._renderContext.depthMask(true);
this._super(plane);
}
});
var RawStencilBufferTest5 = RawStencilBufferTest.extend({
subtitle:function () {
return "5:DepthTest:DISABLE,DepthMask:FALSE,AlphaTest:ENABLE";
},
setupStencilForClippingOnPlane:function (plane) {
var gl = cc._renderContext;
this._super(plane);
gl.disable(gl.DEPTH_TEST);
gl.depthMask(false);
var program = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLORALPHATEST);
var alphaValueLocation = gl.getUniformLocation(program.getProgram(), cc.UNIFORM_ALPHA_TEST_VALUE_S);
cc.glUseProgram(program.getProgram());
program.setUniformLocationWith1f(alphaValueLocation, _alphaThreshold);
this._sprite.shaderProgram = program;
},
setupStencilForDrawingOnPlane:function (plane) {
cc._renderContext.depthMask(true);
//cc._renderContext.enable(cc._renderContext.DEPTH_TEST);
this._super(plane);
}
});
var RawStencilBufferTest6 = RawStencilBufferTest.extend({
subtitle:function () {
return "6:ManualClear,AlphaTest:ENABLE";
},
setup:function () {
cc._renderContext.stencilMask(~0);
this._super();
},
setupStencilForClippingOnPlane:function (plane) {
var gl = cc._renderContext;
var planeMask = 0x1 << plane;
gl.stencilMask(planeMask);
gl.stencilFunc(gl.NEVER, 0, planeMask);
gl.stencilOp(gl.REPLACE, gl.KEEP, gl.KEEP);
cc._drawingUtil.drawSolidRect(cc.p(0, 0), cc.pFromSize(cc.director.getWinSize()), cc.color(255, 255, 255, 255));
gl.stencilFunc(gl.NEVER, planeMask, planeMask);
gl.stencilOp(gl.REPLACE, gl.KEEP, gl.KEEP);
gl.disable(gl.DEPTH_TEST);
gl.depthMask(false);
var program = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLORALPHATEST);
var alphaValueLocation = gl.getUniformLocation(program.getProgram(), cc.UNIFORM_ALPHA_TEST_VALUE_S);
cc.glUseProgram(program.getProgram());
program.setUniformLocationWith1f(alphaValueLocation, _alphaThreshold);
this._sprite.shaderProgram = program;
gl.flush();
},
setupStencilForDrawingOnPlane:function (plane) {
var gl = cc._renderContext;
gl.depthMask(true);
//gl.enable(gl.DEPTH_TEST);
this._super(plane);
gl.flush();
}
});
var arrayOfClippingNodeTest = [
ScrollViewDemo,
ShapeTest,
SpriteTest
];
if (!cc.sys.isNative && ("opengl" in cc.sys.capabilities)) {
arrayOfClippingNodeTest.push(
ShapeInvertedTest,
SpriteNoAlphaTest,
SpriteInvertedTest
//TODO re-open them later.
/* RawStencilBufferTest,
RawStencilBufferTest2,
RawStencilBufferTest3,
RawStencilBufferTest4,
RawStencilBufferTest5,
RawStencilBufferTest6*/
);
}
if ( cc.sys.isNative){
arrayOfClippingNodeTest.push(
ShapeInvertedTest,
SpriteNoAlphaTest,
SpriteInvertedTest,
NestedTest);
} else {
arrayOfClippingNodeTest.push(HoleDemo
);
}
var nextClippingNodeTest = function () {
clippingNodeTestSceneIdx++;
clippingNodeTestSceneIdx = clippingNodeTestSceneIdx % arrayOfClippingNodeTest.length;
if(window.sideIndexBar){
clippingNodeTestSceneIdx = window.sideIndexBar.changeTest(clippingNodeTestSceneIdx, 5);
}
return new arrayOfClippingNodeTest[clippingNodeTestSceneIdx]();
};
var previousClippingNodeTest = function () {
clippingNodeTestSceneIdx--;
if (clippingNodeTestSceneIdx < 0)
clippingNodeTestSceneIdx += arrayOfClippingNodeTest.length;
if(window.sideIndexBar){
clippingNodeTestSceneIdx = window.sideIndexBar.changeTest(clippingNodeTestSceneIdx, 5);
}
return new arrayOfClippingNodeTest[clippingNodeTestSceneIdx]();
};
var restartClippingNodeTest = function () {
return new arrayOfClippingNodeTest[clippingNodeTestSceneIdx]();
};
var ClippingNodeTestScene = TestScene.extend({
runThisTest:function (num) {
clippingNodeTestSceneIdx = (num || num == 0) ? (num - 1) : -1;
cc.director.runScene(this);
var layer = nextClippingNodeTest();
this.addChild(layer);
}
});

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,139 @@
/****************************************************************************
Copyright (c) 2008-2010 Ricardo Quesada
Copyright (c) 2011-2012 cocos2d-x.org
Copyright (c) 2013-2014 Chukong Technologies Inc.
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
var LINE_SPACE = 40;
var ITEM_TAG_BASIC = 1000;
var cocoStudioTestItemNames = [
{
itemTitle:"CocoStudioArmatureTest",
testScene:function () {
runArmatureTestScene();
}
},
{
itemTitle:"CocoStudioGUITest",
testScene:function () {
runGuiTestMain();
}
},
{
itemTitle:"CocoStudioSceneTest",
testScene:function () {
runSceneEditorTest();
}
},
{
itemTitle:"ParserTest",
testScene:function(){
runParserTest();
}
}
];
if(!cc.sys.isNative){
cocoStudioTestItemNames.push({
itemTitle: "CocoStudioComponentsTest",
testScene: function () {
runComponentsTestLayer();
}
});
cocoStudioTestItemNames.push({
itemTitle:"CustomWidget",
testScene:function(){
runCustomGUITest();
}
});
}
var CocoStudioMainLayer = cc.Layer.extend({
onEnter:function () {
this._super();
var winSize = cc.director.getWinSize();
var pMenu = new cc.Menu();
pMenu.x = 0;
pMenu.y = 0;
cc.MenuItemFont.setFontName("Arial");
cc.MenuItemFont.setFontSize(24);
for (var i = 0; i < cocoStudioTestItemNames.length; ++i) {
var selItem = cocoStudioTestItemNames[i];
var pItem = new cc.MenuItemFont(selItem.itemTitle,
this.menuCallback, this);
pItem.x = winSize.width / 2;
pItem.y = winSize.height - (i + 1) * LINE_SPACE;
pMenu.addChild(pItem, ITEM_TAG_BASIC + i);
}
this.addChild(pMenu);
},
menuCallback:function (sender) {
var nIndex = sender.zIndex - ITEM_TAG_BASIC;
cocoStudioTestItemNames[nIndex].testScene();
}
});
var cocoStudioOldApiFlag = 0;
var CocoStudioTestScene = TestScene.extend({
onEnter: function(){
TestScene.prototype.onEnter.call(this);
var winSize = cc.director.getWinSize();
var pMenu = new cc.Menu();
pMenu.x = 0;
pMenu.y = 0;
cc.MenuItemFont.setFontName("Arial");
cc.MenuItemFont.setFontSize(24);
var str = "new api";
if(cocoStudioOldApiFlag){
str = "old api";
}
var pItem = new cc.MenuItemFont(str,
function(){
if(cocoStudioOldApiFlag){
cocoStudioOldApiFlag = 0;
pItem.setString("new api");
}else{
cocoStudioOldApiFlag = 1;
pItem.setString("old api");
}
}, this);
pItem.x = 50;
pItem.y = winSize.height - 20;
pMenu.addChild(pItem);
this.addChild(pMenu);
},
runThisTest:function () {
var pLayer = new CocoStudioMainLayer();
this.addChild(pLayer);
cc.director.runScene(this);
}
});

View File

@ -0,0 +1,77 @@
/****************************************************************************
Copyright (c) 2008-2010 Ricardo Quesada
Copyright (c) 2011-2012 cocos2d-x.org
Copyright (c) 2013-2014 Chukong Technologies Inc.
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
var ComponentsTestLayer = cc.LayerColor.extend({
init: function () {
if (cc.LayerColor.prototype.init.call(this, cc.color(255, 255, 255, 255))) {
var root = this.createGameScene();
this.addChild(root, 0, 1);
root.getChildByTag(1).addComponent(new ccs.ComAudio());
root.getChildByTag(1).addComponent(PlayerController.create());
root.addComponent(new ccs.ComAudio());
root.addComponent(new ccs.ComAttribute());
root.addComponent(SceneController.create());
return true;
}
return false;
},
createGameScene: function () {
var root = new cc.Node();
var winSize = cc.director.getWinSize();
var player = new cc.Sprite("res/components/Player.png", cc.rect(0, 0, 27, 40));
player.x = 30;
player.y = winSize.height / 2;
root.addChild(player, 1, 1);
var itemBack = new cc.MenuItemFont("Back", this.toExtensionsMainLayer, this);
itemBack.color = cc.color(0, 0, 0);
itemBack.x = cc.visibleRect.bottomRight.x - 50;
itemBack.y = cc.visibleRect.bottomRight.y + 25;
var menuBack = new cc.Menu(itemBack);
menuBack.x = 0;
menuBack.y = 0;
this.addChild(menuBack);
return root;
},
toExtensionsMainLayer: function (sender) {
cc.audioEngine.stopMusic("res/Sound/background-music-aac.wav");
var scene = new CocoStudioTestScene();
scene.runThisTest();
}
});
ComponentsTestLayer.scene = function(){
var scene = new cc.Scene();
var layer = new ComponentsTestLayer();
layer.init();
scene.addChild(layer);
return scene;
};
var runComponentsTestLayer = function () {
var scene = ComponentsTestLayer.scene();
cc.director.runScene(scene);
};

View File

@ -0,0 +1,83 @@
/****************************************************************************
Copyright (c) 2008-2010 Ricardo Quesada
Copyright (c) 2011-2012 cocos2d-x.org
Copyright (c) 2013-2014 Chukong Technologies Inc.
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
var EnemyController = ccs.ComController.extend({
ctor: function () {
this._super();
this._name = "EnemyController";
},
init: function () {
return true;
},
onEnter: function () {
// Determine where to spawn the target along the Y axis
var winSize = cc.director.getWinSize();
var minY = this.getOwner().height / 2;
var rangeY = winSize.height - this.getOwner().height;
var actualY = (Math.random() * rangeY ) + minY;
// Create the target slightly off-screen along the right edge,
// and along a random position along the Y axis as calculated
this.getOwner().x = winSize.width + (this.getOwner().width / 2);
this.getOwner().y = actualY;
// Determine speed of the target
var minDuration = 2.0;
var maxDuration = 4.0;
var rangeDuration = maxDuration - minDuration;
var actualDuration = ( Math.random() % rangeDuration ) + minDuration;
// Create the actions
var actionMove = cc.moveTo(actualDuration, cc.p(0 - this.getOwner().width / 2, actualY));
var actionMoveDone = cc.callFunc(function () {
var comController = this.getOwner().parent.getComponent("SceneController");
comController.spriteMoveFinished(this.getOwner());
}, this);
this.getOwner().runAction(cc.sequence(actionMove, actionMoveDone));
},
onExit: function () {
},
update: function (dt) {
},
die: function () {
var com = this.getOwner().parent.getComponent("SceneController");
var targets = com.getTargets();
cc.arrayRemoveObject(targets, this.getOwner());
this.getOwner().removeFromParent(true);
com.increaseKillCount();
}
});
EnemyController.create = function () {
var controller = new EnemyController();
controller.init();
return controller;
};

Some files were not shown because too many files have changed in this diff Show More