From 2cf579de6bd068ebc67b2e2e1b9b468f56fd226e Mon Sep 17 00:00:00 2001 From: folecr Date: Thu, 11 Oct 2012 14:25:19 -0700 Subject: [PATCH 01/16] NDK debugger script --- samples/TestJavascript/proj.android/ndkgdb.sh | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100755 samples/TestJavascript/proj.android/ndkgdb.sh diff --git a/samples/TestJavascript/proj.android/ndkgdb.sh b/samples/TestJavascript/proj.android/ndkgdb.sh new file mode 100755 index 0000000000..5df7332ceb --- /dev/null +++ b/samples/TestJavascript/proj.android/ndkgdb.sh @@ -0,0 +1,47 @@ +APPNAME="TestJavascript" +APP_ANDROID_NAME="org.cocos2dx.testjavascript" + +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 From a763e4242fc72fec5a9007877ed9fdbaeaf3bb15 Mon Sep 17 00:00:00 2001 From: folecr Date: Thu, 11 Oct 2012 11:45:20 -0700 Subject: [PATCH 02/16] Remove samples/TestJavascript/Resources --- .../Cyber Advance!.mp3.REMOVED.git-id | 1 - .../Fonts/arial-unicode-26.GlyphProject | Bin 3462 -> 0 bytes .../Fonts/arial-unicode-26.png.REMOVED.git-id | 1 - .../Fonts/bitmapFontTest.png.REMOVED.git-id | 1 - .../Fonts/bitmapFontTest2.bmp.REMOVED.git-id | 1 - .../font-issue1343-hd.png.REMOVED.git-id | 1 - .../Resources/Fonts/fps_images.GlyphProject | Bin 2908 -> 0 bytes .../Resources/Fonts/futura-48.GlyphProject | Bin 3091 -> 0 bytes .../Fonts/futura-48.png.REMOVED.git-id | 1 - .../helvetica-geneva-32.png.REMOVED.git-id | 1 - .../Fonts/markerFelt-hd.fnt.REMOVED.git-id | 1 - .../Fonts/markerFelt-hd.png.REMOVED.git-id | 1 - .../Fonts/markerFelt.fnt.REMOVED.git-id | 1 - ..._bold_italic-charmap-hd.png.REMOVED.git-id | 1 - ...Cute-1024x1024-rgba4444.pvr.REMOVED.git-id | 1 - ...-1024x1024-rgba4444.pvr.ccz.REMOVED.git-id | 1 - ...e-1024x1024-rgba4444.pvr.gz.REMOVED.git-id | 1 - .../PlanetCute-1024x1024.png.REMOVED.git-id | 1 - .../Images/atlastest.png.REMOVED.git-id | 1 - .../Images/background2-hd.jpg.REMOVED.git-id | 1 - .../Images/background2.jpg.REMOVED.git-id | 1 - .../Default-Landscape~ipad.png.REMOVED.git-id | 1 - .../Images/bugs/bug886.png.REMOVED.git-id | 1 - .../Images/clouds.pvrtc.REMOVED.git-id | 1 - ...ossini_dance_atlas-mono.png.REMOVED.git-id | 1 - .../grossini_dance_atlas.pvr.REMOVED.git-id | 1 - ...cape-1024x1024-rgba8888.pvr.REMOVED.git-id | 1 - ...-1024x1024-rgba8888.pvr.ccz.REMOVED.git-id | 1 - ...e-1024x1024-rgba8888.pvr.gz.REMOVED.git-id | 1 - .../landscape-1024x1024.png.REMOVED.git-id | 1 - .../Images/spritesheet1.png.REMOVED.git-id | 1 - .../Images/test_1021x1024.png.REMOVED.git-id | 1 - ...est_1021x1024_rgb888.pvr.gz.REMOVED.git-id | 1 - ...t_1021x1024_rgba4444.pvr.gz.REMOVED.git-id | 1 - ...t_1021x1024_rgba8888.pvr.gz.REMOVED.git-id | 1 - .../Resources/Images/test_image.gif | Bin 11529 -> 0 bytes ...xture1024x1024_rgba4444.pvr.REMOVED.git-id | 1 - ...xture2048x2048_rgba4444.pvr.REMOVED.git-id | 1 - .../texture4096x4096.png.REMOVED.git-id | 1 - ...texture512x512_rgba4444.pvr.REMOVED.git-id | 1 - .../Silly Fun Theme A.mp3.REMOVED.git-id | 1 - .../TileMaps/hexa-tiles.png.REMOVED.git-id | 1 - .../TileMaps/ortho-test1.png.REMOVED.git-id | 1 - .../ortho-test1_bw.png.REMOVED.git-id | 1 - .../animations/grossini.pvr.REMOVED.git-id | 1 - .../PerformanceNodeChildrenTest.js | 517 ------ .../PerformanceParticleTest.js | 515 ------ .../PerformanceTest/PerformanceSpriteTest.js | 576 ------- .../js/PerformanceTest/PerformanceTest.js | 188 -- .../PerformanceTest/PerformanceTextureTest.js | 171 -- .../PerformanceTest/PerformanceTouchesTest.js | 162 -- .../js/PerformanceTest/testResource.js | 322 ---- .../Resources/js/PerformanceTest/testbasic.js | 330 ---- .../TestJavascript/Resources/js/game-main.js | 1100 ------------ samples/TestJavascript/Resources/js/helper.js | 437 ----- .../TestJavascript/Resources/js/helper.old.js | 361 ---- samples/TestJavascript/Resources/js/main.js | 219 --- .../TestJavascript/Resources/js/old/main.js | 47 - .../TestJavascript/Resources/js/old/main2.js | 227 --- .../Resources/js/old/simpletest.js | 2 - .../Resources/js/old/test-sprite.js | 784 --------- .../TestJavascript/Resources/js/old/test1.js | 313 ---- .../TestJavascript/Resources/js/playground.js | 232 --- .../Resources/js/playground_gc.js | 25 - .../Resources/js/test-actions.js | 1514 ----------------- .../Resources/js/test-actionsprogress.js | 461 ----- .../Resources/js/test-chipmunk.js | 455 ----- .../Resources/js/test-cocos2djs.js | 749 -------- .../Resources/js/test-cocosdenshion.js | 306 ---- .../Resources/js/test-easeactions.js | 656 ------- .../Resources/js/test-effects.js | 266 --- .../TestJavascript/Resources/js/test-label.js | 245 --- .../TestJavascript/Resources/js/test-menu.js | 510 ------ .../Resources/js/test-parallax.js | 322 ---- .../Resources/js/test-particles.js | 1155 ------------- .../Resources/js/test-performance.js | 122 -- .../Resources/js/test-rendertexture.js | 283 --- .../Resources/js/test-sprite.js | 781 --------- .../Resources/js/test-tilemap.js | 1210 ------------- .../Resources/oldjs/1to1/menu.js | 35 - .../Resources/oldjs/1to1/test_actions.js | 305 ---- .../Resources/oldjs/1to1/test_bindings.js | 42 - .../Resources/oldjs/1to1/test_ease_actions.js | 572 ------- .../Resources/oldjs/1to1/test_layer.js | 206 --- .../Resources/oldjs/1to1/test_particles.js | 484 ------ .../Resources/oldjs/1to1/test_require.js | 3 - .../oldjs/1to1/test_require_second.js | 1 - .../Resources/oldjs/1to1/test_sound.js | 166 -- .../Resources/oldjs/1to1/test_transitions.js | 171 -- .../TestJavascript/Resources/oldjs/jorendb.js | 517 ------ .../TestJavascript/Resources/oldjs/main.js | 125 -- .../Resources/oldjs/oa-benchmark.js | 121 -- .../Resources/oldjs/test-nodes.js | 55 - 93 files changed, 18407 deletions(-) delete mode 100644 samples/TestJavascript/Resources/Cyber Advance!.mp3.REMOVED.git-id delete mode 100644 samples/TestJavascript/Resources/Fonts/arial-unicode-26.GlyphProject delete mode 100644 samples/TestJavascript/Resources/Fonts/arial-unicode-26.png.REMOVED.git-id delete mode 100644 samples/TestJavascript/Resources/Fonts/bitmapFontTest.png.REMOVED.git-id delete mode 100644 samples/TestJavascript/Resources/Fonts/bitmapFontTest2.bmp.REMOVED.git-id delete mode 100644 samples/TestJavascript/Resources/Fonts/font-issue1343-hd.png.REMOVED.git-id delete mode 100644 samples/TestJavascript/Resources/Fonts/fps_images.GlyphProject delete mode 100644 samples/TestJavascript/Resources/Fonts/futura-48.GlyphProject delete mode 100644 samples/TestJavascript/Resources/Fonts/futura-48.png.REMOVED.git-id delete mode 100644 samples/TestJavascript/Resources/Fonts/helvetica-geneva-32.png.REMOVED.git-id delete mode 100644 samples/TestJavascript/Resources/Fonts/markerFelt-hd.fnt.REMOVED.git-id delete mode 100644 samples/TestJavascript/Resources/Fonts/markerFelt-hd.png.REMOVED.git-id delete mode 100644 samples/TestJavascript/Resources/Fonts/markerFelt.fnt.REMOVED.git-id delete mode 100644 samples/TestJavascript/Resources/Fonts/tuffy_bold_italic-charmap-hd.png.REMOVED.git-id delete mode 100644 samples/TestJavascript/Resources/Images/PlanetCute-1024x1024-rgba4444.pvr.REMOVED.git-id delete mode 100644 samples/TestJavascript/Resources/Images/PlanetCute-1024x1024-rgba4444.pvr.ccz.REMOVED.git-id delete mode 100644 samples/TestJavascript/Resources/Images/PlanetCute-1024x1024-rgba4444.pvr.gz.REMOVED.git-id delete mode 100644 samples/TestJavascript/Resources/Images/PlanetCute-1024x1024.png.REMOVED.git-id delete mode 100644 samples/TestJavascript/Resources/Images/atlastest.png.REMOVED.git-id delete mode 100644 samples/TestJavascript/Resources/Images/background2-hd.jpg.REMOVED.git-id delete mode 100644 samples/TestJavascript/Resources/Images/background2.jpg.REMOVED.git-id delete mode 100644 samples/TestJavascript/Resources/Images/bugs/Default-Landscape~ipad.png.REMOVED.git-id delete mode 100644 samples/TestJavascript/Resources/Images/bugs/bug886.png.REMOVED.git-id delete mode 100644 samples/TestJavascript/Resources/Images/clouds.pvrtc.REMOVED.git-id delete mode 100644 samples/TestJavascript/Resources/Images/grossini_dance_atlas-mono.png.REMOVED.git-id delete mode 100644 samples/TestJavascript/Resources/Images/grossini_dance_atlas.pvr.REMOVED.git-id delete mode 100644 samples/TestJavascript/Resources/Images/landscape-1024x1024-rgba8888.pvr.REMOVED.git-id delete mode 100644 samples/TestJavascript/Resources/Images/landscape-1024x1024-rgba8888.pvr.ccz.REMOVED.git-id delete mode 100644 samples/TestJavascript/Resources/Images/landscape-1024x1024-rgba8888.pvr.gz.REMOVED.git-id delete mode 100644 samples/TestJavascript/Resources/Images/landscape-1024x1024.png.REMOVED.git-id delete mode 100644 samples/TestJavascript/Resources/Images/spritesheet1.png.REMOVED.git-id delete mode 100644 samples/TestJavascript/Resources/Images/test_1021x1024.png.REMOVED.git-id delete mode 100644 samples/TestJavascript/Resources/Images/test_1021x1024_rgb888.pvr.gz.REMOVED.git-id delete mode 100644 samples/TestJavascript/Resources/Images/test_1021x1024_rgba4444.pvr.gz.REMOVED.git-id delete mode 100644 samples/TestJavascript/Resources/Images/test_1021x1024_rgba8888.pvr.gz.REMOVED.git-id delete mode 100644 samples/TestJavascript/Resources/Images/test_image.gif delete mode 100644 samples/TestJavascript/Resources/Images/texture1024x1024_rgba4444.pvr.REMOVED.git-id delete mode 100644 samples/TestJavascript/Resources/Images/texture2048x2048_rgba4444.pvr.REMOVED.git-id delete mode 100644 samples/TestJavascript/Resources/Images/texture4096x4096.png.REMOVED.git-id delete mode 100644 samples/TestJavascript/Resources/Images/texture512x512_rgba4444.pvr.REMOVED.git-id delete mode 100644 samples/TestJavascript/Resources/Silly Fun Theme A.mp3.REMOVED.git-id delete mode 100644 samples/TestJavascript/Resources/TileMaps/hexa-tiles.png.REMOVED.git-id delete mode 100644 samples/TestJavascript/Resources/TileMaps/ortho-test1.png.REMOVED.git-id delete mode 100644 samples/TestJavascript/Resources/TileMaps/ortho-test1_bw.png.REMOVED.git-id delete mode 100644 samples/TestJavascript/Resources/animations/grossini.pvr.REMOVED.git-id delete mode 100644 samples/TestJavascript/Resources/js/PerformanceTest/PerformanceNodeChildrenTest.js delete mode 100644 samples/TestJavascript/Resources/js/PerformanceTest/PerformanceParticleTest.js delete mode 100644 samples/TestJavascript/Resources/js/PerformanceTest/PerformanceSpriteTest.js delete mode 100644 samples/TestJavascript/Resources/js/PerformanceTest/PerformanceTest.js delete mode 100644 samples/TestJavascript/Resources/js/PerformanceTest/PerformanceTextureTest.js delete mode 100644 samples/TestJavascript/Resources/js/PerformanceTest/PerformanceTouchesTest.js delete mode 100644 samples/TestJavascript/Resources/js/PerformanceTest/testResource.js delete mode 100644 samples/TestJavascript/Resources/js/PerformanceTest/testbasic.js delete mode 100644 samples/TestJavascript/Resources/js/game-main.js delete mode 100644 samples/TestJavascript/Resources/js/helper.js delete mode 100644 samples/TestJavascript/Resources/js/helper.old.js delete mode 100644 samples/TestJavascript/Resources/js/main.js delete mode 100644 samples/TestJavascript/Resources/js/old/main.js delete mode 100644 samples/TestJavascript/Resources/js/old/main2.js delete mode 100644 samples/TestJavascript/Resources/js/old/simpletest.js delete mode 100644 samples/TestJavascript/Resources/js/old/test-sprite.js delete mode 100644 samples/TestJavascript/Resources/js/old/test1.js delete mode 100644 samples/TestJavascript/Resources/js/playground.js delete mode 100644 samples/TestJavascript/Resources/js/playground_gc.js delete mode 100644 samples/TestJavascript/Resources/js/test-actions.js delete mode 100644 samples/TestJavascript/Resources/js/test-actionsprogress.js delete mode 100644 samples/TestJavascript/Resources/js/test-chipmunk.js delete mode 100644 samples/TestJavascript/Resources/js/test-cocos2djs.js delete mode 100644 samples/TestJavascript/Resources/js/test-cocosdenshion.js delete mode 100644 samples/TestJavascript/Resources/js/test-easeactions.js delete mode 100644 samples/TestJavascript/Resources/js/test-effects.js delete mode 100644 samples/TestJavascript/Resources/js/test-label.js delete mode 100644 samples/TestJavascript/Resources/js/test-menu.js delete mode 100644 samples/TestJavascript/Resources/js/test-parallax.js delete mode 100644 samples/TestJavascript/Resources/js/test-particles.js delete mode 100644 samples/TestJavascript/Resources/js/test-performance.js delete mode 100644 samples/TestJavascript/Resources/js/test-rendertexture.js delete mode 100644 samples/TestJavascript/Resources/js/test-sprite.js delete mode 100644 samples/TestJavascript/Resources/js/test-tilemap.js delete mode 100644 samples/TestJavascript/Resources/oldjs/1to1/menu.js delete mode 100644 samples/TestJavascript/Resources/oldjs/1to1/test_actions.js delete mode 100644 samples/TestJavascript/Resources/oldjs/1to1/test_bindings.js delete mode 100644 samples/TestJavascript/Resources/oldjs/1to1/test_ease_actions.js delete mode 100644 samples/TestJavascript/Resources/oldjs/1to1/test_layer.js delete mode 100644 samples/TestJavascript/Resources/oldjs/1to1/test_particles.js delete mode 100644 samples/TestJavascript/Resources/oldjs/1to1/test_require.js delete mode 100644 samples/TestJavascript/Resources/oldjs/1to1/test_require_second.js delete mode 100644 samples/TestJavascript/Resources/oldjs/1to1/test_sound.js delete mode 100644 samples/TestJavascript/Resources/oldjs/1to1/test_transitions.js delete mode 100644 samples/TestJavascript/Resources/oldjs/jorendb.js delete mode 100644 samples/TestJavascript/Resources/oldjs/main.js delete mode 100644 samples/TestJavascript/Resources/oldjs/oa-benchmark.js delete mode 100644 samples/TestJavascript/Resources/oldjs/test-nodes.js diff --git a/samples/TestJavascript/Resources/Cyber Advance!.mp3.REMOVED.git-id b/samples/TestJavascript/Resources/Cyber Advance!.mp3.REMOVED.git-id deleted file mode 100644 index d875a8fb67..0000000000 --- a/samples/TestJavascript/Resources/Cyber Advance!.mp3.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -1dcdf55f77f03e091227a0e3ecb4e22370811560 \ No newline at end of file diff --git a/samples/TestJavascript/Resources/Fonts/arial-unicode-26.GlyphProject b/samples/TestJavascript/Resources/Fonts/arial-unicode-26.GlyphProject deleted file mode 100644 index 87994d2173f223f0edf3fc271e44bd9a5bfc8715..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3462 zcmb7G349dQ9sb_i9WyfvvH?+vh#>@#BV@D5<^UlOAmPde*xZ4n%kCr@S$4wCED(|M zyl)gd5EM!yrKuOzT1%}J6|Y)qRZ_~KRuQ#Us`a+iqyO36KtO-L+MVC-?7P4B{r~U# z-r|mkZdx8s4;VNca6-aqOl7Y6?B!a_)QxC;wz2pkEo7Mu*}+(-U8m~mY|H2v2zJ%h z9qtySL57Ztumlk-MHB`)unaMnun@;`tiVci;$p1AC0LCgV+{l@#bvl0SKvxqg{yH5 zuElk@9yj1dti?^Z8SAhfx8PRXhTE|LcVHtn;ZEFz&A1!Cz&-dW?!|q$9}nOW{05KW zDeT76cmaRHUi=jY@jCv7!+0C-;9dL!ALA2ziZAgWe9JgYUPP38TDF(!>9qt^Qjsb8Z9Ro24XJ9bS#925SLy&=U zFcjxv7|uf`h9e6jkd2WzAER&qMq>=dVjOZX9=Y%!4_@S>06r9=2*oJD1i^(vIE5rm z6KO&gicp11^b`HX>0*Fzi*zwi3=(IE!QxDDmN;7s5gFnfF;tu@hKch;rWh`=#0Zfs zMvC*rC~<)pEyjqkVw}hk<89a%ViG2!6jLx2Wtc{#8T6fmnN(AXIhae2A5~N{9}5sb zHEK|cI%;d6x~4>XGg|N?DwQIHFf_EH4W%MictoD?ihNNZe4>y_#q{-v5~}fv31T8W z7m7(#Gg(X(v&9@SS5yi=wN+8wyhMAQs22@X@`^^$Bo>NAqFH!b+yg@KSWJsr<$6T( z2bXG8(-!IMXfM}SYT-IPY_%^m;#NeDYEz?a5o#V}X)CRGjEa^%HKGSiJ=(TNTiId6 ztT|dNN~IQeMsFXB;#{k1D+2n(TFVN1w&qqn5(z9d468k=nP!7soMuFf*uuoJ^Mc`U zVv6IqjHqRg?nM!>I&BmKQlJQSq`I?1TV%Ee!^VoL)>c!q8d}`$*5mjq?CqGf$qs$+ z+t>mf!4NH1Z=Yaiyn_3gd zntJIZ*e&jX_PiCbU|1)H6T39~Fiu@;#+#DJ63s2{bNW(O77Q(Eiy84~I7yM+w!pB0 z7O4g;o*Y;fiN_Yu5^6{QH(C;w`;VkL%lQHSn&f1oO%+wP34T>@~k##P<| z&$!IILeFZ${ZUEdm7G@_@pfaHX^G;ELdQyQ#1hKf!$#4Hbvj1J7^U$`3 zla7>~A z;}2v#f5aZLpBM3Gyo8r2PH{>oa_gFUYw5jbmh9U*T(fgKyWYZCJhh3O^b~UuJlw`=PzZHxo`UCcfrk5>Qlpw9;kzkuCrijuJQzqCsNonG4o*L7Gk(#I; zGQwJAAenJQ0SzlBP3Xc-bf56c$FNJx>avLuWnx;F&5f8YDr!TvXnK;byuEmau%xJ} zNi@|*j8H--#0*iMI1hbK!5&dm@aNc?1k4uk=!R{5}r~4ir7>sq^P2qnH-E_E5)R9Cc zsLo7romm;^yXKoI4hnppl44JOiO*g>-{UJL2!#bcDtJl?^74ub3yMqnfV~$-L=mY4 zJ;*A17|5DJVeLEdd(=)^LTX~yCa*n5@u3|?%0Dq*Ea5z?^ngYS49T6?lmiI&+BuOL=K`!GD z%+Wfv@YK{r_+{3Q^{@K#2ZDn0-8{5vh**)w&_5gd3J;WYnkFcHWQT7;noISywVo$SY+4JlLwuimQ zUShAX9=4C|X9wA<>~;1AJIs!-clb0ugIDlbd=9VVReU}V@ETsn8+a36#9Mffhq%Vu zxXzdGrQG1lxXI&u1@Gjm_-ej}U&=4%SMsa*wfuU1Bfp8S9BM}dQW;^`aJDW+R?O6(vHavS(4Law>(fDE{~D( z&z1dhK(3MNca=|-&y}xLRqdyytAo_RYKA&g9j1;{$EhXi zM0Ju{rdFx*)m7>>>UHW3>N<6cx>en!KIu|i{aop;b6r`kQLb^W$*yUxnRfO7oG0Jx L^yItu*ERdUIQ|Gx diff --git a/samples/TestJavascript/Resources/Fonts/arial-unicode-26.png.REMOVED.git-id b/samples/TestJavascript/Resources/Fonts/arial-unicode-26.png.REMOVED.git-id deleted file mode 100644 index f731cbb795..0000000000 --- a/samples/TestJavascript/Resources/Fonts/arial-unicode-26.png.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -c2eabd7cd8b62d39967387739fe05799de4ca764 \ No newline at end of file diff --git a/samples/TestJavascript/Resources/Fonts/bitmapFontTest.png.REMOVED.git-id b/samples/TestJavascript/Resources/Fonts/bitmapFontTest.png.REMOVED.git-id deleted file mode 100644 index c32358b304..0000000000 --- a/samples/TestJavascript/Resources/Fonts/bitmapFontTest.png.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -4da0aa09555ebddf2caf1c9ece272f2fe38d2a4b \ No newline at end of file diff --git a/samples/TestJavascript/Resources/Fonts/bitmapFontTest2.bmp.REMOVED.git-id b/samples/TestJavascript/Resources/Fonts/bitmapFontTest2.bmp.REMOVED.git-id deleted file mode 100644 index b934758bd2..0000000000 --- a/samples/TestJavascript/Resources/Fonts/bitmapFontTest2.bmp.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -263832e2766c734b77335f353e3066033c158c90 \ No newline at end of file diff --git a/samples/TestJavascript/Resources/Fonts/font-issue1343-hd.png.REMOVED.git-id b/samples/TestJavascript/Resources/Fonts/font-issue1343-hd.png.REMOVED.git-id deleted file mode 100644 index 4d9f7c904d..0000000000 --- a/samples/TestJavascript/Resources/Fonts/font-issue1343-hd.png.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -a6ca8414e453957fa2fbc456b47160ac402ea35e \ No newline at end of file diff --git a/samples/TestJavascript/Resources/Fonts/fps_images.GlyphProject b/samples/TestJavascript/Resources/Fonts/fps_images.GlyphProject deleted file mode 100644 index dba3cce4773ea319379549988b8b33bad3f0d6ef..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2908 zcmZuz33yc175?v?c}rL)1Y{M45I_h?X35H8Hb_{^LMD3%=`iz>JebTI=DmR=h+eg5 zQ4m)Ip+Y0l6cEs&Roa5Jlv2t^QP3*2e3VkRYNZuhx@qs5nLyCa`@XsNo_o(Z|M}0k z=e=d2fT|k~$2kyCSYU+!kqjUM>r+-KVO`aN^(or2<%-YH8&bSsU%Sf1)hUJ+8U}Lz z&I7ikkRU_Fa;!iA9SA~02rChW4g(Ra!fJG)3*A_QJFymb;chV8gL`owzKwOb9}nO= zSdRzs5H?^V9>yj-f=BTf9>)`S5}WZ9wqPrs#x`unckwKKfIZlYeRv-GaR5KUEBG;f zj$`-*evRMYExe20;{yJG%lH%C$H({^KF3vD!@uzrp~OP0L?9xOh)fb{Qi72{;4Bg_ z00S`ygE6Z%#TW4EdR@6EeTCAcH}WwaKbwERmWCl13L6qJ3`rP{5x4~-F$$wG24gV} zw_-ddz>bMX#w4U*GNxcEZo@Q8M=E9@4e7{$15UW$Mkcb5jU4164>K8M7G`Av6Pd(h zmcRzEfou>P%!aU`%*GPgFqXuIvk~kTHj<5EquCfXmW^Y#vhi#Jv$KgTnN4CTY%-g| zrn1}EG&Y^3vKcImrJJy4V-9XdJ_=BXA{1jT=5fg!%;&QF=&TIosNl23sDcO8s6j32 z`1uAdYeE@+mZAmU;;Vf4;D>@%v>~5mFb8uo7jv^rmc_DJF3aN*2b;-duIOwQo6Y9% z+3l>5Eno}TB6bHWcj zC|uGO=nA!$sGW+xPW2n@OSFg)P=iWgur0v1lMJQPh=lplPzwX9S672=%}QrT3mc1+ zaFDNBY-9S)7(CCls0YA)j+`0p=m~YP|@`Ub6KnfwD6Ls+e)wBA2o3u zmliZk?LHJ9qsv4wG!BZx4peuAlxDr%>(^FSw6^Ms(a>VEwO+?xYKEiN#t!tuZ({R= zygu%(-b7)V;fkTKvMP>vLC~*sHgR_RO1M%}gT_)d=nF*ria%zPpN_*=$aka2n)>ME zuv=`yOuMCFuV3X1N2ApHG0u;ej5o!QMYmgQWBXHA}KSq(cSEU(VgZB*X zJf>I_h=i-SiwL(p+#4}8ozqnvPm&pAA9Yb1jWMNIup{E|zYa0+rhG04wrU)9L|5Vo z_HYE8s>HZSI&I>{n669)6&=zT8t0?b$Y~%^r1UBaLfZnT{EDXSQQ) zb9#ou>2hagW#{DP+0SwR2k`=4#1C-@FX83da*vsMKA5%5ZMBvJylpxwVEK~@3QX{T z&9-#D5?G}es?VENqy_vjaIfMpS1aMg(}P#hd!w=b6tA)QJvf4+tcVr&;AeQ9&1I#v zKJ#`tVuSN6j&m%(#0mTgCu^cx^#RQnttd8+l|&N4#H1n?Yfh^`A-{I}9BsrfUZuUHW$M0~trz~Q4mj#r$s?WR(-f-8mIFI+x%d>k! zc7s5>NnroDF0z~whn+thlUW?GX#dEiPCI{)TyzLXF5rG|?0<-lc%9IGda+m9C-}@{ z{!{#gRkFoBxPrg3Dpvjfng4vCtg@-kg6(*{pb^p~3h+kh5Z zQAUl8Lc6`MeXpm zDSBGF-&T;E?{>SJJl>8_K(U+GHd;o>#n0J$qch$;$~}veF2!FM|GasF3?hT8!~8YC z2>-Sj&F^U{e^bxoFTOAN*Fz#1MeHP%q>%^72J$d@ggi!`Ae+e+@-*2_o*_F)57|X_ zlU}li>?8ZhLGmIwL|!JZki+CB*xb?J$;C7q?_oY^l|zmeTr_S+vxN3C_P0l(JPk0mT{IT7Pn=drOM*B zge~hV8!SDRy_O@Ela_ZapIEM02U{mtQ>_cEwN};2tQ)OctOu>ftZ!RCwtgWb3FC!H zf1QDkh0z#EIf`afX;K=7@RXd~vZ@FE)$I#eld{)WwL{E#4{KC9V@Uh+D-SVz0PI z+$X*u9ubd;$Hgn+KP5@BN#mu-l2f`}Dv*k#QmImEl{%zuX}z>r+9K_c_DTDtm!!ke zQR$R)S~?^BR=O;`Fa25iRQgQ1D*au$CVeG~a*{kk9x0ELr^%^ujl4|u%dPSXxl`_z px60e(i}EG;1Nn3Ln*84cnlLFDI%$@uH_x|_$ zzwdwldyB$BRW}@tb0DCwzzP8(=|;L&r!G?>x~he$Q?*5l6~Cd^r1~QMMwOe(Qw=TL z8|2O%`|MswkfCBRmLP~GgrFgerHDX>fhd-t87*kVaf=sjoYyXci>K} z#a*}?_uyXKhjmzw4Y(g0@cL#DvOJf6%AvRVAKrOO#fU0-B}OTlU>J>n4R@vy;&dDm-S=Uvm4lrtUnvT2C_lyCN`Me%#zsSbjCt?yNBM(zB75OOOv+4Xh2{X7Q55<_xuM(7U%UsNZ z2j!?hC91fuhTH05{)O=37Cy^^9|0(+M+5R$I&-iL=46@7#oR25&vN+J!E(99$;Pt@ z{F=xnam!>jmCa(sY&M(2O1Q6-+sb18Dpt*E_{_;_Ssk0t7O;iP>9r^MqmhUbG78n8 zQsQe;xTPW38g499Ta-YR8Za8?Yf&SphLowHh9GzMF_ab~8sSqzof=eqx*BR&ptOXw zh*7LWLVV`659nNDaGfhvrP-q{SG>(;w1xF*Fz9L0G@~)3=z5JgEzp8mWPa?}GG8DN z3vmUP7BbA;ohUp;tBE2h0gA&8mbZqL1$v_|pf#7)*XxQ=S8L}7;E8^aN0SpxCQP(W#^2*AB+Z+Ks+X2oq#cmdt=Dz zI_c!Fz4qQ_+@gptpmK&|S?XOF=Sxh+>*B~_Zm)e{SL*V8{v{0&EgA~MDKdTYG{a}` zuE7tFZ_E!yBlGwXQ69UmFKTEyr>i_6l9^;Db+H(=@lEk$`z7FiA7Za-^qd*0*EsB` zt|SEZa0HyHUWwgvR3oCyR-06#HomXSXEc5bmyp2B z;Tm15W7U$V!_L#M)>2ghPnn%}2L7?hy=eTO*?qR-aqQr2t$lupC&q-Sy;4!)nOBt0 zvhB1mBiWJcz!`MlN$kW^wecnu;tEyA|0-t3ifwJ@3wBkPcuHe^+wMqtg#mU_+vapR z#wKTEIaYe@-l_Qo)20^|&6qi>c=nu<(z3bpJmnRYRn;}MzD53kQs2<1E?yFB3Tfe` z5#5L`Yi?;>p5e@NxwEo!avdo{Zpj-lZtR5dBS+OOXj?gP@{05+^B1P34I49QsCW3S zqm$3^oc3Wqp2Gn=kAwJWWr@cuCq9_>3rAO981yyhYzoU8I%S4Q2*+sm+WQwq`Tgrl zE6{jdhjb+{y~T+5^0i9mTKkCVpKJb5#d5f2?HLbXFKsrmG&uSazv>gkxMzW=3YV)9udX zI*fB?xw0MZTt`kOpJX^Q+*vtU&g|@jIwx>)!8Ik@fm1lmox83z^EAx5tK%9gde}@i z(h2Vzhj*UM;CS*F_#^FVeY|7h8DxUUab~)mxh|*E1mVhxe{woOT*Q04nUr|uL=E4f zpfXMMn|Gxz()t80;(hGmWp>rZTVkB`eJNkK)hpg(>J? z@Hv~y=C$Lm_>y^8#g7a656;-vto%n5{PzD*uv38Vc({MF${z|q$o~|;-py;DoL-^x z*QfNz(x{^Q0>1QcL~GE~{hD9Xoq;qp+^B_=bgsJ=jrbKk-K=Lly*^(0t{k&7UYTjUryK~9k~_tEIxNpxj#!Ra zE?Pdfd}~dz4zZ?Li>=kxCDzr}4c0Bz1Jq`uM+X{aD^3SKcolkPpj8HrSSI8)kFbTsDub!nVn_*|y!b f+qTbk(017N8`~+{Z_VlfD2mM zl`Rb+vLtPy^nAY8bN+zy!@176uls&o$I{wDTgRUakbzJC04x%Q5fBiSI;4C^5Oc&Z z^zb2%BZu^kA6Li9DXJe=Q#p0!I3`eu$Lh4W8CKC)F4Fg$tFz_>|A<)yl6iJ7*GhnB0GeUZ7Tud}WT!rFZd~tXeZ%KOPJmvsi(P@AYYD;R zuBY4OaKq97`>Vm&NMc23^!fbY;Hm)M@K}eN;fhhQA#dFs(nt{n(cWpX-ifjCNr`rE z0`xi~4aS4dK8#cD2#>fC?=v1@GaM0qEh(%uHXxaLp*b!xIEzu3M$Af2dmistbt&m# zQuL#gkcJd;9+lpfYF9){%E~3Sruy}y1U6D#u4RYT>(0F!MPtQPg+FQjuZjq_3U?PuPJhnM z94ohtzxC={{+X90wE5z&o3)wDn;FBEp)rVg9^|Q+r^x=B&W0q@) zkMBQydAn}Cn%do1(9l$}c=zm`rrVv34@z3c9yM%!yXQ>l{_*WW_^*bV@s6~G*7WTr za%We~mzKz_=AxSK|Ni}xJvd|<6YL)s9E6Dviz8wz zt?lucbI}-ojJgN7DtWcGb6%RC{S`f*=JhlQc0!a%xS3I1)6G#+1kFM82?y7`3b zV*~DAD`PiJ3w~Z|j|^XEk-n7lUFq3Lm+-cO`s%>J{A#CoXxp=`yg&6`_7G&J??r2wQSF!CLJo6g(=`j!gg0$!&c#ebY0cYe{Z&_X zvQ)kB#yzz2!aKjr&YX}6K1#sp`g#*C*?M7+?dcaIwY(?mvc6^V>O)Bs@qjkLQKj0T z#a_*IQnBr+VSF#2*2k>gJTfC*GimM4o##pG4__E2Z?=AVp8TZ?VU+Uq#nCSP_|e={ z-nHAc4|LZb^q$h&Y{_*R{qu&mcSNNZ=QyaiE<+hx9}qty`Wg)gq{zm1NSYrBVe%z# z6(kIpN^1{fBKF>VN&Rgr^Y8XAqq9)9I7FEP@+oA&G`G_@#TeL0qS2qVbCia44#Jd( z6IGRSWD7x+bGCDQz4Jv6O11mx4d_e|5yx$|O;NIN%GSniC-l}@K%c5~TXL$?zcO;KH%8{U4nQCEWTJ|1>A$No_GRjd&N)xe0wc-C&e2 z8hRZ5JBRc)Q#?u>gdD+^^15IUI8NW;GA0$nMSz$8!O3VQ($u~$@V^FV>U9g2IAjr> z<_$d}GGvvdEm%}kSErz&1F?^JUCa^eJYcTyn9P&6$%uN-vCtZLbmgK_;Gt2gkcqPY zbl4)c;{HMXibm7Z(dbmQ%8$yS%45@-7amVkZI^_qU9;9rwowzGY*y5KGBnyTDkRcC zfhqff@`yGQVwFUQgbM&ojhVQ9xY1Ohft(w&g%OP!HlJ;IbtQ~$A}Z>$s-phVsQ?bC zJECyc`tP;Zr7dv`>?Y0bnX&WrMfDin%udnD=n(Kt4(oVJ6@x)UJ+R!C~pW8l^W{9O?TCkL6n07;usm=^IK@0qrM`z@=V-Fw@!9+mxQ2=h6C zo(WHDb*QP2ZCv;H*6tp^C&EmJ-FN4)bt9CEG=>M?_qvXoQCtG?@`)QG@_;l{8~{!M z4l)!{{NWIB2B5eKM&mGP^Pe%?EEt4)tc=Fr7Ik>m>VZm$abAdeZS!sO#&FN|vr{k2 zT3Y%WqZ8M?IEuz?eHvT3^!wf`x?=5j>^H-`_GhNXT3T91H=~myxNV6hLNBx6qCcM@ zlsAk~!YrC5`TSeSIToOzZ6elAhX|FkU^ZFCyeuZva7q>h_V}c`Ba1q37buFkVSee$ z^$&md-gN<@*fa%y0`x?AH;Trj9*gwnjVSMxMm@^f%=P=bBi0X+CZ+LLa$s7!&nvc} zx+}6d3ek?j!fcvmstS(-7Q_u71O&+2l;gkxmnFUjSpvXMZdaRtwdW6LdUJW6c0Hq3 zZmPvqBYH}<*Iv2}JT7~>5sb~fHWFgdRH5^yz(lg0ZS5OVZ25Ib$?@q+_pzO_XS`JH z@j&TDqIvOkUM^&Fz{@_Sst_+Zt>3L0sl2Ny;EnZHn@vN4+3T8$%M0#y=|aU!_1hYq zYYvz9#HvGj>TUU`&Uf~>?ngh#@Nax)sy93RY`$43g)iKxcxJNxCq-t1l}Q{iWle3n zsWS`H{e&QeQG;Y|htaK5S!rAnY!=rcbUHeLQ>2z)a%d5qX){^P{osveYbRgy`Qq8R zRX43?j+@a5!`J73K3{4&8oipHyv|`b?6!-g<~VbiiZ5U@bq=P4@@unt=6Kc2U>@5P zS>9@-(Q3LJZ#6{TyBZ<4YP_k$$cpsayrFb+BCO}y{a=B zbtSgS`OjyXTat}~@8<1?9m}Wxb)Sq*yGg=*+}J|H6$}lLPUIw1B-RwvHk~f>2ZPW- z_a3hy#A3+{$n)AP8C_r6qs)(D3=ZY!fbY*HQ@PCuF^ky`(!ZXzGPdH!_viNy;v13= zWWqzA&8G3iKb?5LrDFx19zx}x#mPxkU)9Ip-orJ`s(}-spm}2^SjBr0j&JK3eL;uA z>Z(7w;5)HQ(3oDmv{Xa9!G@es&NSrN&(`t3TgeCi_BkK^e7kw)`454xUU!#HKgTcpH;Nv)W5epuP;hA7TY*qmj8Z1u-xS8o1EC_-GI*|pO z+)Y=}rf4KkblNBeyA)$>s(Au+0-b*IU50i&MZX+m$OXj>g8zsj`Vo*I1WJty^@IUC zlF9e)BVug@oEr?*A;kOO5C=g7uE!X?%V>l#8Ac?-&tMQ=j`G^8XU5e77qes%+cGch zW~OOpWr)XS)n^fv(o=}2)OucWIVhbgGs6R-L4fst0^MO{2fFi|+0ND*gh$tdkJHl= zj>2uWVSaez027|S3Zg4zmvCJ!As{Yda+~XcmaN=XMs5ce{P`-Sn+x3Qk@q4Y=jNUK zdxNz1TzNf%5a)6jf&mO&<>D|edQJr0!0;uqppgtnbQTDP2PDuCD-y&C4J*PSZHO>w zGCY-uID^fOVG*0rd>ez1Ev^EbRzVNGpoUcNyRG2wZUIP#4m-xZw3;ZjR=77oOob0ARrlKsbOB30B7etk-}$IOGHg ziAadudxgRtD^?FH)}FqoH(hKbQR0LxF;6V9&ITX-o#?k#j0>X%T9;VdwNhe1P&n`x zEo2HK;a39U1|Cs?Mf8ZqI}x}dvEiOW5O)q@-wA?Z(IfCkJO_?v0ueZ59p-9W*wqs9 z)udy5DQj2BcMC$WW+E(XE%Ch;9yi3dZ7_Mz*~!>Fud zm3`UZf$WOAi5K2aUr!r?FX&W8apD7UV15QHh72>t&(LItnSq*+MFlM)EXVC!(;0n zVF1R3bAG&xF6`hGl$)WS+g3jN_5VfgL2Wi5#H78fnFbfBJdvk?#E`N%wEi@24>D zr@Xu0b*Q2DUj3cD$fvX$Lg+(I2eOJos|x;kS0^kM{Uq6%Y46L;hC4{vCQivv?R! zc-R^KsEwm{iVQl1gIY7WIvL0}j04nL2I@13@|}ztB||}^CJ?($id=u0P~TGlGokYT zM&owL{1Z5o$JNItW*?uHY|^r7(#&nr9d0t*hkLRfWvn!-c{OQYZ-OwJF4I#n3@|Sq zT+ZeiBJfpjKmN*Y`GiB=Vgd*>AcoCAvOr<1rkp*H00R;6vGwS+mWcbPC`tZvlC7~` zt@@~cmhpH^l-wODx zm#wMSk&5jt)p}2F;o5KKw%^mkHA;e{c-m`tT3eFa-RSL}Eby^5Fb@E_ahw34N77?8c#;OvTdJ?=$yL#Xm++!YQ3XI@A-sRryHr$ zlK?)!N*-E=rEPP+VRW6eZOcpsVr@H744`5c>WSw0P3NBlo_a>Kk$6~I$pFNgg{WlB zG7#@b_x|uSp}di3WfqhdqKWNMBmjrEx$;Tao6H_aA@2wd^%&^BZ3_lrI>ZR>JR_`( zl^(2eukG31y`$;}aXNj(TkpRzvME(IipYn8@B zKsdegERZU_SJ#{9+0ie??)Mvk`0EeMZo{E;zIHm_UF)OP9evn_e(#O`X2=y2?f!!~ zr=v5EdaCh!EF7wzbN>jCg2%UNpa-Pz17ozooRPsRyhGxU7jlJsgBNnrMh;th4`x;l z;+cc5*9Lvi@JmI|U@xdS8|sXOxyP9&;(6CeeCv2ryEkeV@4QInDf$!HS~>h|Zg^sQ z_z~9kE)yi*J@io|z46b>NBYAF_~G7;;SO)-U$LjM)Jv?{pbL0EMF=991V>Nu|Dum= zG5MP@yxsce`zd3eN5*ydyn6Gek z03pve{ulFRtNQgwrTE^T*B{@E50H?}B!s5Vq-B+35MwfyHJQtq#J_*#F^VVyct!}^ z#oN(g@1a-Qxr!O^-0ex+D8JSYYM+d9@p&`W!kd1QpBgoF_OIw(Bob>Ne+SPUbZH_k z>Rp08BI&QprN8gabx!4vBGeXyH3dX;j79VXq<)g8gkH?hRD{3#3&$1;pZ+SY{#95@ zRz%lH>aobor~92b+-;C-Dd;sdMM0p1c=NIOrB0LQD9_T9tei8^{-x zERiA1gX9D!MH$oPB)k@#3*3g2&rTj%PkTfk`DA+)&DW ztyB=R*!UWC)kN_cm`8K|STp!|>k({w&x!qjQ_2wRhRJd0w~sUn>~?_4x7RAOF{guy zPA~PG{&Ym$44KzJfXZ%;r z6l{hoMVUZ@a9n+Qic7c;6YE0FhhyT5hf;O1OGd!t#*rXXFEcJ5swJV$GO*9m`?+Os ziJ9%Bnd5g{RGhwRocWTkrFWdApRmQ&yk*Cd?HyseyUjKOOEw~`<;G^@Lt$%_w(YfM z>q~6wo5D7=E;e0Mo8F*po_{t-b4NayJ->+4zS)73x9`s1C3}v%!%~pLY7l<&yTezg zE9Q&ckpjm(b*H~2&cn^lk{YhAA}$_p95Jb`rZD%I3ofTcoYh>Nwfet_FMl&IcQp!j zH7Rv1zrgEz%QN7O=gm@&nl~O8>9e`ZZdP4q;`%#_HS|m0xL@vfJ!|A~J=o($hDXr2 zhcems^%LJW%f3@0ezR}91WEJL3Vw46pe_;bUh~XFbKhB}_vjDrTcy4e{l0I1_-4rL z3St8cLIVE&@H1`+IO!II4FP{L*gO4}z%S}AdUj<}{6H3^S=YY{ncJKXhfWG^l1MOozdzwk#b?#-HfEwqTm@rcTmus4d4@7y8* zr;H34ql>#{*E8)UTZnv*ZV_*7im3!d%>-ec%xecu1!M*7ik(@qDpIg7tMvF9Fp%%6 zn>vZDG0s9uLr2QL%G+0Jmwr}XW2Z5UsYnT3s#0N%dEUwUmAVRc9@?=hpEq+w$Ex(4 z1dhfO1=WLdWlU)?FYzj(Ibo4qGN z*#h-v?w;+xS9;$)Anrw(!T!g$CrO+h;{(X1gSf)oTC-zSy#sb2o|9+)>=w#pmb*Ir z9O#eQ`QA5q->d72!Ly&fSi*xoooz(;wb6ytw8f8Mv7g4PEw9eoH)ut?W5&uaj!2w6 zNnCiqBMGw#lhkxV<^{`2_90cSM&q9LXvIf=|9tduJip=Z)h2$U=L1%zY3hs`u)aSN zw0uR61+moM8If!3`Z1GSkg*#Bq#*_FDp3S&!V5q5oi&?oyrxOV^^n2xOcqpVWxs}{ z!ojpy~TRMl7(hMPEw6!B3>yf0}>G( z0w6UJG#N>n`}*Rh*9e3vowQ+m@InN8ss{(d*x}P)B7<})pJvcC8p8B239u@hNpUXM z{?zbojCW_QY1{~MxS4Hwm@AD66~s2drBQ7xJ1EtwN`XhM#hvA8zm zg*_?!Rn758w$ngCt~U@cE=5>RN2&4_npYYfWXW+UvvHs*4KM8R(wi=Kfr&(y z*z+np->nf2d`o^y3A2>456~L95Md%#fMj)l8768_sK~E4#r8kLi&Vl;#OZCIY$bWwe*6i2 zTyKFv9n?r(ANe)g1)S|NT=om3>CFwwYc^(j_nTu91sKmfp1F}M!3XtgwNd8 zS+;(DJM2!?;L(SFc1G+!&c(9L3)15zoZPD}yz{?Wb#XSC$ z;(2=xdb&jFw}pSELS+HJK!@q!6}0Xv*)+Z&ECqf<3lQ|~M!h7TLBmNIDh+95yb?#; zjH~yn4xOgiSB*+kQj!5XWhr551PZfY3aYQN@p+5F-R}JoZ?{uC=N6FD?0!s3wRRw; z8`6wHsK$(-jzTjOCega`48S4;r~!#?wrNm9gM!x)rWYLU_o^atHMP%=E6c!@NpC@`l_CD;+CE;T?K*O8*J+0f;wDyc)!h zV*wZ-4WUmK{Yf72q*Gg`#TAJ#(^Fq^$irUor#6ZMA)%8(!TF0?ES!XK(_KiY}l+%xOaRmeK@%naSW{I5g^>s5V~o6_D$>5fScL_d}V~71)ZwH_7@Gu zn+oNzkZ$r8CixkQhZ;Cq-e#IST^H7*Yn-xe2x*PA^;9mD6;hGp_N3v$$;e<^ui1G} zE9rfsNYXmxLx^l!@5!z6#n0we&MZA`yc87~>NTq{*P{7!bnBuI86<|5<<4ErIDW4h z6;W?`IHm@nTaiWugtdW%C05e`^Gtilg77ZO(l8I?pJGRmS|VmDsvGAKMp~c$8vT;G zzwf8RUCx4AFw-Uez!9b%J;E(mn#PF#0spL6*WU8O%b>^rh)e>&eE`YAF~IN=Kq%je zreX5xLxTEmsU@X;FbYlP$+7`SSy9q`_R_dkWkv38$0(Cz`!B3?3-$`D7Ut&#DX2{k z;mcG@8}ouscBKvb!efv3*{$5Jk`NC&wNqH!5p+RaN80hqPRacd%85H^u>Tg08$7zA zaJiSAC7Q;I;()q_$dE33iqDrn%csBS+URF)chO!a@DRF|iEKIW=* z<0qAyx^Gw>PwL)ngnP&wdfBwnETUfp6P+W%c*tZ%u|N)9cwg!{{RuCa1ax)dK<`I; zWC9i_{HvgGzcDlZNZq&Y2hiH-Z)q*fcccCrc+%|qgNyO~_R+ClblsW zapukQxXve|Q701gcoaQA9kQGZTuRL$(GTaU1ul_~otp(A2j2=kM(3t11xhBhS!h0f zbS0u8P;$nbB2&bg(ZP8y3b$$x{EgT+L+W55b`u6IeRqoQq%5Dj{8Tg8A@;hE)F-ir z76XY}u>}+-MYZct=b5&+}C=y)!Nc!uoe4o|NXb;zn-67{Nni`>0Ouf zPscn1iD0Asl8NUD4WABhuPHCg7W6JBczScdE52KDZSM@exIfSTuwM10=cpkB|8Q^V`la7uS${VY8LCEM z{{#wHeZO^Na>4r)g(MkpIZWf}GKjkGkKT zyO@DSzbHmZbR(sEUHijbf7iR#Ah`cz2r`nkW6S!UO#Knj^((jQ_x-L@TokN$-H{XN zM~Lai%E9_{WBox&0O9EcrA#ShL<%u842|&4%DCW>=`sZj3YlCzk$LF|OpXYaFf$gh z1B=EPi&q*SYCh;Lo9I5g(JjNfJ3!>=w)GmT2gf95Iou zgokL;2wb!rOqKj9S(gd5B~y&%C~AWl!3?3kUdKm?YUQmXJAz12 zq6L)09RZkr0#vuzRDTj=uw-fkH8YksGc_|a4>Ge{>a3>P1rY z=XwqQm}+zN87udhc4V5>!Da$rwj8P}u1*J=uFs){x=^gOVNztMuLmtPAv3-$GqD`u zSPw<*nm8*#EfV_WO3XbOFne{2854_Oc}Pf{1+l~;yxAgh(jxl11*uZ+yu77{{)@N+ zXvPKofgtaJkQ57ttbwqGfrycTs0|A@0^AMA2$F}WG9YgkspcM3qC70A!y*x|j$Wdi zsT}E(je==IP08d ztGr38E8hnzd501?5L+@Vgh{pD=E{u(FIn}Y8)iGb}R`Ju;oX3bEWCqcILB{uiu!T0-Y8kb%Mw+(kJ zL4w5ff~GQjSX3Vz%oq=IErxTW)|k&g%B zGCl8ab;k7yigh{kg&lmb#O`IY-N>Zf*mpa&u>EUw`$-pj3&QBrU7Y_**^RC zl_M`ZMn>jF#{P`3rACvKM%`HUp;;q?4R$V5RL`jqR~BsC4zVd^pR6=CsSaCG9*!oD zHcs8N!DPs14a`dEZS#(QRUZFlHy-LSzR-a9rEkAm;^>2g?FBjfnRHy;7~fv9-%%eQ zm14(fbBB^>;Utn)gV+8Ndh`;>#s;u7BTT&QfL~taom-H(Hu2J&`Pz~7+LC?d)Q>Y*5ocA6 z2{ro(ji`yI$rIY|ZyGS1^E)Q=-%p%!6+TUOIb9Cc)}{qcQL%L3KSh<5auy!1kH( zZ0mR&La!bwlLcs+LyuxzO4Q+V)ft`|={gB8k8&5ACoXnxTpWJ5XaTNH3a)f@R~J`T zw+pU5ZE%lL*RxMty{jf|Iw$S%!iBi5@1`(qE?OWSYK}K{AVE5Zsd)R$I8J6{O6J@& z#b7Y~a2qYcDkI3p?L3w?XDoSEiRIP#*79KRZPe!5bA0d4h`T!(yo+>kzj(ntq0~Kv z;hucURh#{8@}qlH+G6j`2CZ#=Z? zrwUn94~O4g{N{NI;IXDt&-0BXZ_}9lhtFuw{F$Ke;h@g+=>T-*C9X^&9iE#G(XXEo z$e6nF*Q0TH=E1GBhkRb=#AhGpXEfQ*K8c!b&7U=@o5k(6-&Noa#leF}G~WbRWj=M- zHG_}brNu3?E&+{z^rm0dU6`iybuZ7hy*es1)y1$gHMyahi-Wf z_j`{ndym6>UMcuYnESj5et$aFXR6d^=84Z-zW0ku-l)H9+fA4Y9%h1px+sA?Rx<+2 z5y1@D8ItG>4_OioQ6Xgz#WS3;8lpT9(StC;5Umu;{+?@Zy z_u(sy_nW!jk6=F;lHYEr-`*3yKg;-4h3xv=c7H~%Kht;PJrpp66RI<~)o5NkfWR*J zyUzzFE2_j4Jb^$ksr+yr$lSjK)n{*Zh?V}RY8VK2`}ljArdejJc*PfW816xaoJK=k zNK5Xdv-u5N+bWa~BV^&wLJyjX#@t6WVTZc!l($0HiUc}SFi12_L-hmb&!66}`G;7tYm9PgZqHQaY z2lFe@2O-adLSr;T{Zr=#eL`JUeLcu9|A3W{pD+g^M3pU+)Usj?z#rd(Zi0IbXThEg z!=BC3q~&3rgYVN$tx|5R`Xgx>(W{xaSF&!b>edsz+g9_oX!*~dNkdl)nHiPRG+l2h z0SV8C()4l5?%OcywscJl*Z`Cs9+DOjy_RDL!^G)*&h?94B?f2Rt8B@rItaT753h#9 zYc#{_+`?~P49{svua|CZy}stn{Cu%(t&pLV^Adt3k_A=)x&JI488GCMFH!|0RMJiX zU^JcFi|W4yp-A5?f z7~;l@i%$pLXl|jd)vik*)*#;YJL;Xkx=Sk7z?GVxzI+GL~nc+qd5CuVz zjJ&*iGQ3Kn`2-O7C|JyD3)Tubjs{xi;k42%_woa%LpfFKW~TVf^G@|&B`?cB*yk~v z^D>ASn9;c-S~2qHzS6~WC{|e+#4KV0*Gqi%ZDRJ-L2`L{cExT`6^HvKfUH*HQq{^) zbBw*^5nDFJrIi_5!Q`%FeADLocA1!Ww?60oU{2#|&Qq@3;kMjnkK7gxPZz-3jp6OZ z@%9t)>Ird!3Ezk4-`iQd9c|w`S980#^17As%&fkzZS%6p@K=NA2^`-W4vIr8Uua8T z)V{Lhab+dp$|~c>=e8f;*cawGKR#@u7MS@2Ez}bJiZkJgmsK3{5q*bn@n1a`N&t

5Tu&Ao7uB+h?s`~vAKf{yx4|6R`?Yea{7(w&LuDE@EC#|nk41x`y8 z`6&si7z>6D7w%6LNsrAWoPNQ9W6l(4IqSfq5V$V^Mb z#Z$<_U&Jc0lzLa#2qbJQD{LwtlVhLu{Sm6mr2SG+5^{-wmx zm~3{ZG(n);r&=r-BzFFlSd3>`NMac=?OL8JUwooi{R@e^zsi!iucqjfH7kiVT3&r{ zhidjq{JMZd(e$ MAX_NODES) { - this._quantityOfNodes = MAX_NODES - } - - this.updateQuantityLabel(); - this.updateQuantityOfNodes(); - }, - updateQuantityLabel:function () { - if (this._quantityOfNodes != this._lastRenderedCount) { - var infoLabel = this.getChildByTag(TAG_INFO_LAYER); - var str = this._quantityOfNodes + " nodes"; - infoLabel.setString(str); - - this._lastRenderedCount = this._quantityOfNodes; - } - }, - getQuantityOfNodes:function () { - return this._quantityOfNodes; - } -}); - -//////////////////////////////////////////////////////// -// -// IterateSpriteSheet -// -//////////////////////////////////////////////////////// -var IterateSpriteSheet = NodeChildrenMainScene.extend({ - _batchNode:null, - _profilingTimer:null, - ctor:function () { - if (cc.ENABLE_PROFILERS) { - this._profilingTimer = new cc.ProfilingTimer(); - } - }, - updateQuantityOfNodes:function () { - var s = cc.Director.getInstance().getWinSize(); - - // increase nodes - if (this._currentQuantityOfNodes < this._quantityOfNodes) { - for (var i = 0; i < (this._quantityOfNodes - this._currentQuantityOfNodes); i++) { - var sprite = cc.Sprite.createWithTexture(this._batchNode.getTexture(), cc.rect(0, 0, 32, 32)); - this._batchNode.addChild(sprite); - sprite.setPosition(cc.p(cc.RANDOM_0_1() * s.width, cc.RANDOM_0_1() * s.height)); - } - } - - // decrease nodes - else if (this._currentQuantityOfNodes > this._quantityOfNodes) { - for (var i = 0; i < (this._currentQuantityOfNodes - this._quantityOfNodes); i++) { - var index = this._currentQuantityOfNodes - i - 1; - this._batchNode.removeChildAtIndex(index, true); - } - } - - this._currentQuantityOfNodes = this._quantityOfNodes; - }, - initWithQuantityOfNodes:function (nodes) { - this._batchNode = cc.SpriteBatchNode.create("Images/spritesheet1.png"); - this.addChild(this._batchNode); - - this._super(nodes); - - if (cc.ENABLE_PROFILERS) { - this._profilingTimer = cc.Profiler.timerWithName(this.profilerName(), this); - } - this.scheduleUpdate(); - }, - update:function (dt) { - }, - profilerName:function () { - return "none"; - } -}); - -//////////////////////////////////////////////////////// -// -// IterateSpriteSheetFastEnum -// -//////////////////////////////////////////////////////// -var IterateSpriteSheetFastEnum = IterateSpriteSheet.extend({ - update:function (dt) { - // iterate using fast enumeration protocol - var children = this._batchNode.getChildren(); - - if (cc.ENABLE_PROFILERS) { - cc.ProfilingBeginTimingBlock(this._profilingTimer); - } - - for (var i = 0; i < children.length; i++) { - var sprite = children[i]; - sprite.setVisible(false); - } - - if (cc.ENABLE_PROFILERS) { - cc.ProfilingEndTimingBlock(this._profilingTimer); - } - }, - - title:function () { - return "A - Iterate SpriteSheet"; - }, - subtitle:function () { - return "Iterate children using Fast Enum API. See console"; - }, - profilerName:function () { - return "iter fast enum"; - } -}); - -//////////////////////////////////////////////////////// -// -// IterateSpriteSheetCArray -// -//////////////////////////////////////////////////////// -var IterateSpriteSheetCArray = IterateSpriteSheet.extend({ - update:function (dt) { - // iterate using fast enumeration protocol - var children = this._batchNode.getChildren(); - - if (cc.ENABLE_PROFILERS) { - cc.ProfilingBeginTimingBlock(this._profilingTimer); - } - for (var i = 0; i < children.length; i++) { - var sprite = children[i]; - sprite.setVisible(false); - } - - if (cc.ENABLE_PROFILERS) { - cc.ProfilingEndTimingBlock(this._profilingTimer); - } - }, - - title:function () { - return "B - Iterate SpriteSheet"; - }, - subtitle:function () { - return "Iterate children using Array API. See console"; - }, - profilerName:function () { - return "iter c-array"; - } -}); - -//////////////////////////////////////////////////////// -// -// AddRemoveSpriteSheet -// -//////////////////////////////////////////////////////// -var AddRemoveSpriteSheet = NodeChildrenMainScene.extend({ - _batchNode:null, - ctor:function () { - if (cc.ENABLE_PROFILERS) { - this._profilingTimer = new cc.ProfilingTimer(); - } - }, - updateQuantityOfNodes:function () { - var s = cc.Director.getInstance().getWinSize(); - - // increase nodes - if (this._currentQuantityOfNodes < this._quantityOfNodes) { - for (var i = 0; i < (this._quantityOfNodes - this._currentQuantityOfNodes); i++) { - var sprite = cc.Sprite.createWithTexture(this._batchNode.getTexture(), cc.rect(0, 0, 32, 32)); - this._batchNode.addChild(sprite); - sprite.setPosition(cc.p(cc.RANDOM_0_1() * s.width, cc.RANDOM_0_1() * s.height)); - sprite.setVisible(false); - } - } - // decrease nodes - else if (this._currentQuantityOfNodes > this._quantityOfNodes) { - for (var i = 0; i < (this._currentQuantityOfNodes - this._quantityOfNodes); i++) { - var index = this._currentQuantityOfNodes - i - 1; - this._batchNode.removeChildAtIndex(index, true); - } - } - - this._currentQuantityOfNodes = this._quantityOfNodes; - }, - initWithQuantityOfNodes:function (nodes) { - this._batchNode = cc.SpriteBatchNode.create("Images/spritesheet1.png"); - this.addChild(this._batchNode); - - this._super(nodes); - - if (cc.ENABLE_PROFILERS) { - this._profilingTimer = cc.Profiler.timerWithName(this.profilerName(), this); - } - - this.scheduleUpdate(); - }, - update:function (dt) { - }, - profilerName:function () { - return "none"; - } -}); - -//////////////////////////////////////////////////////// -// -// AddSpriteSheet -// -//////////////////////////////////////////////////////// -var AddSpriteSheet = AddRemoveSpriteSheet.extend({ - update:function (dt) { - // reset seed - //srandom(0); - - // 15 percent - var totalToAdd = this._currentQuantityOfNodes * 0.15; - - if (totalToAdd > 0) { - var sprites = []; - var zs = []; - - // Don't include the sprite creation time and random as part of the profiling - for (var i = 0; i < totalToAdd; i++) { - var sprite = cc.Sprite.createWithTexture(this._batchNode.getTexture(), cc.rect(0, 0, 32, 32)); - sprites.push(sprite); - zs[i] = cc.RANDOM_MINUS1_1() * 50; - } - - // add them with random Z (very important!) - if (cc.ENABLE_PROFILERS) - cc.ProfilingBeginTimingBlock(this._profilingTimer); - } - - for (var i = 0; i < totalToAdd; i++) { - this._batchNode.addChild(sprites[i], zs[i], TAG_BASE + i); - } - - if (cc.ENABLE_PROFILERS) { - cc.ProfilingEndTimingBlock(this._profilingTimer); - } - - // remove them - for (var i = 0; i < totalToAdd; i++) { - this._batchNode.removeChildByTag(TAG_BASE + i, true); - } - - delete zs; - - }, - title:function () { - return "C - Add to spritesheet"; - }, - subtitle:function () { - return "Adds %10 of total sprites with random z. See console"; - }, - profilerName:function () { - return "add sprites"; - } - }) - ; - -//////////////////////////////////////////////////////// -// -// RemoveSpriteSheet -// -//////////////////////////////////////////////////////// -var RemoveSpriteSheet = AddRemoveSpriteSheet.extend({ - update:function (dt) { - //srandom(0); - - // 15 percent - var totalToAdd = this._currentQuantityOfNodes * 0.15; - - if (totalToAdd > 0) { - var sprites = []; - - // Don't include the sprite creation time as part of the profiling - for (var i = 0; i < totalToAdd; i++) { - var sprite = cc.Sprite.createWithTexture(this._batchNode.getTexture(), cc.rect(0, 0, 32, 32)); - sprites.push(sprite); - } - - // add them with random Z (very important!) - for (var i = 0; i < totalToAdd; i++) { - this._batchNode.addChild(sprites[i], cc.RANDOM_MINUS1_1() * 50, TAG_BASE + i); - } - - // remove them - if (cc.ENABLE_PROFILERS) { - cc.ProfilingBeginTimingBlock(this._profilingTimer); - } - - for (var i = 0; i < totalToAdd; i++) { - this._batchNode.removeChildByTag(TAG_BASE + i, true); - } - - if (cc.ENABLE_PROFILERS) { - cc.ProfilingEndTimingBlock(this._profilingTimer); - } - } - }, - title:function () { - return "D - Del from spritesheet"; - }, - subtitle:function () { - return "Remove %10 of total sprites placed randomly. See console"; - }, - profilerName:function () { - return "remove sprites"; - } -}); - -//////////////////////////////////////////////////////// -// -// ReorderSpriteSheet -// -//////////////////////////////////////////////////////// -var ReorderSpriteSheet = AddRemoveSpriteSheet.extend({ - - update:function (dt) { - //srandom(0); - - // 15 percent - var totalToAdd = this._currentQuantityOfNodes * 0.15; - - if (totalToAdd > 0) { - var sprites = []; - - // Don't include the sprite creation time as part of the profiling - for (var i = 0; i < totalToAdd; i++) { - var sprite = cc.Sprite.createWithTexture(this._batchNode.getTexture(), cc.rect(0, 0, 32, 32)); - sprites.push(sprite); - } - - // add them with random Z (very important!) - for (var i = 0; i < totalToAdd; i++) { - this._batchNode.addChild(sprites[i], cc.RANDOM_MINUS1_1() * 50, TAG_BASE + i); - } - - // [this._batchNode sortAllChildren]; - - // reorder them - if (cc.ENABLE_PROFILERS) { - cc.ProfilingBeginTimingBlock(this._profilingTimer); - } - - for (var i = 0; i < totalToAdd; i++) { - var node = this._batchNode.getChildren()[i]; - ; - this._batchNode.reorderChild(node, cc.RANDOM_MINUS1_1() * 50); - } - if (cc.ENABLE_PROFILERS) { - cc.ProfilingEndTimingBlock(this._profilingTimer); - } - } - - - // remove them - for (var i = 0; i < totalToAdd; i++) { - this._batchNode.removeChildByTag(TAG_BASE + i, true); - } - - }, - - title:function () { - return "E - Reorder from spritesheet"; - }, - subtitle:function () { - return "Reorder %10 of total sprites placed randomly. See console"; - }, - profilerName:function () { - return "reorder sprites"; - } -}); - -function runNodeChildrenTest() { - var scene = new IterateSpriteSheetCArray(); - scene.initWithQuantityOfNodes(NODES_INCREASE); - cc.Director.getInstance().replaceScene(scene); -} diff --git a/samples/TestJavascript/Resources/js/PerformanceTest/PerformanceParticleTest.js b/samples/TestJavascript/Resources/js/PerformanceTest/PerformanceParticleTest.js deleted file mode 100644 index 8e6c4afb7f..0000000000 --- a/samples/TestJavascript/Resources/js/PerformanceTest/PerformanceParticleTest.js +++ /dev/null @@ -1,515 +0,0 @@ -/**************************************************************************** - 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. - ****************************************************************************/ -var TAG_PARTICLE_SYSTEM = 3; -var TAG_LABEL_ATLAS = 4; -var MAX_PARTICLES = 1000; -var PARTICLE_NODES_INCREASE = 50; -var s_nParCurIdx = 0; -var TAG_PARTICLE_MENU_LAYER = 1000; - -//////////////////////////////////////////////////////// -// -// ParticleMenuLayer -// -//////////////////////////////////////////////////////// -var ParticleMenuLayer = PerformBasicLayer.extend({ - _maxCases:4, - showCurrentTest:function () { - var scene = this.getParent(); - var subTest = scene.getSubTestNum(); - var parNum = scene.getParticlesNum(); - - var newScene = null; - - switch (this._curCase) { - case 0: - newScene = new ParticlePerformTest1; - break; - case 1: - newScene = new ParticlePerformTest2; - break; - case 2: - newScene = new ParticlePerformTest3; - break; - case 3: - newScene = new ParticlePerformTest4; - break; - } - - s_nParCurIdx = this._curCase; - if (newScene) { - newScene.initWithSubTest(subTest, parNum); - cc.Director.getInstance().replaceScene(newScene); - } - } -}); - -//////////////////////////////////////////////////////// -// -// ParticleMainScene -// -//////////////////////////////////////////////////////// -var ParticleMainScene = cc.Scene.extend({ - _lastRenderedCount:null, - _quantityParticles:null, - _subtestNumber:null, - initWithSubTest:function (asubtest, particles) { - //srandom(0); - - this._subtestNumber = asubtest; - var s = cc.Director.getInstance().getWinSize(); - - this._lastRenderedCount = 0; - this._quantityParticles = particles; - - cc.MenuItemFont.setFontSize(65); - var decrease = cc.MenuItemFont.create(" - ", this, this.onDecrease); - decrease.setColor(cc.c3b(0, 200, 20)); - var increase = cc.MenuItemFont.create(" + ", this, this.onIncrease); - increase.setColor(cc.c3b(0, 200, 20)); - - var menu = cc.Menu.create(decrease, increase, null); - menu.alignItemsHorizontally(); - menu.setPosition(cc.p(s.width / 2, s.height / 2 + 15)); - this.addChild(menu, 1); - - var infoLabel = cc.LabelTTF.create("0 nodes", "Marker Felt", 30); - infoLabel.setColor(cc.c3b(0, 200, 20)); - infoLabel.setPosition(cc.p(s.width / 2, s.height - 90)); - this.addChild(infoLabel, 1, TAG_INFO_LAYER); - - // particles on stage - //var labelAtlas = cc.LabelAtlas.create("0000", "res/Images/fps_images.png", 16, 24, '.'); - var labelAtlas = cc.LabelTTF.create("0000", "Marker Felt", 30); - this.addChild(labelAtlas, 0, TAG_LABEL_ATLAS); - labelAtlas.setPosition(cc.p(s.width - 66, 50)); - - // Next Prev Test - var menu = new ParticleMenuLayer(true, 4, s_nParCurIdx); - this.addChild(menu, 1, TAG_PARTICLE_MENU_LAYER); - - // Sub Tests - cc.MenuItemFont.setFontSize(40); - var subMenu = cc.Menu.create(null); - for (var i = 1; i <= 3; ++i) { - var str = i.toString(); - var itemFont = cc.MenuItemFont.create(str, this, this.testNCallback); - itemFont.setTag(i); - subMenu.addChild(itemFont, 10); - - if (i <= 1) { - itemFont.setColor(cc.c3b(200, 20, 20)); - } - else { - itemFont.setColor(cc.c3b(0, 200, 20)); - } - } - subMenu.alignItemsHorizontally(); - subMenu.setPosition(cc.p(s.width / 2, 80)); - this.addChild(subMenu, 2); - - var label = cc.LabelTTF.create(this.title(), "Arial", 40); - this.addChild(label, 1); - label.setPosition(cc.p(s.width / 2, s.height - 32)); - label.setColor(cc.c3b(255, 255, 40)); - - this.updateQuantityLabel(); - this.createParticleSystem(); - - this.schedule(this.step); - }, - title:function () { - return "No title"; - }, - - step:function (dt) { - var atlas = this.getChildByTag(TAG_LABEL_ATLAS); - var emitter = this.getChildByTag(TAG_PARTICLE_SYSTEM); - - var str = emitter.getParticleCount(); - atlas.setString(str); - }, - createParticleSystem:function () { - var particleSystem = null; - - /* - * Tests: - * 1 Quad Particle System using 32-bit textures (PNG) - * 2: Quad Particle System using 16-bit textures (PNG) - * 3: Quad Particle System using 8-bit textures (PNG) - * 4: Quad Particle System using 4-bit textures (PVRTC) - */ - - this.removeChildByTag(TAG_PARTICLE_SYSTEM, true); - - //todo - // remove the "fire.png" from the TextureCache cache. - var texture = cc.TextureCache.getInstance().addImage("res/Images/fire.png"); - cc.TextureCache.getInstance().removeTexture(texture); - - particleSystem = new cc.ParticleSystemQuad(); - - switch (this._subtestNumber) { - case 1: - cc.Texture2D.setDefaultAlphaPixelFormat(cc.TEXTURE_2D_PIXEL_FORMAT_RGBA8888); - particleSystem.initWithTotalParticles(this._quantityParticles); - particleSystem.setTexture(cc.TextureCache.getInstance().addImage("res/Images/fire.png")); - break; - case 2: - cc.Texture2D.setDefaultAlphaPixelFormat(cc.TEXTURE_2D_PIXEL_FORMAT_RGBA4444); - particleSystem.initWithTotalParticles(this._quantityParticles); - particleSystem.setTexture(cc.TextureCache.getInstance().addImage("res/Images/fire.png")); - break; - case 3: - cc.Texture2D.setDefaultAlphaPixelFormat(cc.TEXTURE_2D_PIXEL_FORMAT_A8); - particleSystem.initWithTotalParticles(this._quantityParticles); - particleSystem.setTexture(cc.TextureCache.getInstance().addImage("res/Images/fire.png")); - break; - default: - particleSystem = null; - cc.log("Shall not happen!"); - break; - } - this.addChild(particleSystem, 0, TAG_PARTICLE_SYSTEM); - - this.doTest(); - - // restore the default pixel format - cc.Texture2D.setDefaultAlphaPixelFormat(cc.TEXTURE_2D_PIXEL_FORMAT_RGBA8888); - }, - onDecrease:function (sender) { - this._quantityParticles -= PARTICLE_NODES_INCREASE; - if (this._quantityParticles < 0) - this._quantityParticles = 0; - - this.updateQuantityLabel(); - this.createParticleSystem(); - }, - onIncrease:function (sender) { - this._quantityParticles += PARTICLE_NODES_INCREASE; - if (this._quantityParticles > MAX_PARTICLES) { - this._quantityParticles = MAX_PARTICLES; - } - this.updateQuantityLabel(); - this.createParticleSystem(); - }, - testNCallback:function (sender) { - this._subtestNumber = sender.getTag(); - var menu = this.getChildByTag(TAG_PARTICLE_MENU_LAYER); - menu.restartCallback(sender); - }, - updateQuantityLabel:function () { - if (this._quantityParticles != this._lastRenderedCount) { - var infoLabel = this.getChildByTag(TAG_INFO_LAYER); - var str = this._quantityParticles + " particles"; - infoLabel.setString(str); - - this._lastRenderedCount = this._quantityParticles; - } - }, - getSubTestNum:function () { - return this._subtestNumber; - }, - getParticlesNum:function () { - return this._quantityParticles; - }, - doTest:function () { - } -}); - -//////////////////////////////////////////////////////// -// -// ParticlePerformTest1 -// -//////////////////////////////////////////////////////// -var ParticlePerformTest1 = ParticleMainScene.extend({ - - title:function () { - return "A " + this._subtestNumber + " size=4"; - }, - doTest:function () { - var s = cc.Director.getInstance().getWinSize(); - var particleSystem = this.getChildByTag(TAG_PARTICLE_SYSTEM); - - // duration - particleSystem.setDuration(-1); - - // gravity - particleSystem.setGravity(cc.p(0, -90)); - - // angle - particleSystem.setAngle(90); - particleSystem.setAngleVar(0); - - // radial - particleSystem.setRadialAccel(0); - particleSystem.setRadialAccelVar(0); - - // speed of particles - particleSystem.setSpeed(180); - particleSystem.setSpeedVar(50); - - // emitter position - particleSystem.setPosition(cc.p(s.width / 2, 100)); - particleSystem.setPosVar(cc.p(s.width / 2, 0)); - - // life of particles - particleSystem.setLife(2.0); - particleSystem.setLifeVar(1); - - // emits per frame - particleSystem.setEmissionRate(particleSystem.getTotalParticles() / particleSystem.getLife()); - - // color of particles - var startColor = new cc.Color4F(0.5, 0.5, 0.5, 1.0); - particleSystem.setStartColor(startColor); - - var startColorVar = new cc.Color4F(0.5, 0.5, 0.5, 1.0); - particleSystem.setStartColorVar(startColorVar); - - var endColor = new cc.Color4F(0.1, 0.1, 0.1, 0.2); - particleSystem.setEndColor(endColor); - - var endColorVar = new cc.Color4F(0.1, 0.1, 0.1, 0.2); - particleSystem.setEndColorVar(endColorVar); - - // size, in pixels - particleSystem.setEndSize(4.0); - particleSystem.setStartSize(4.0); - particleSystem.setEndSizeVar(0); - particleSystem.setStartSizeVar(0); - - // additive - particleSystem.setBlendAdditive(false); - } -}); - -//////////////////////////////////////////////////////// -// -// ParticlePerformTest2 -// -//////////////////////////////////////////////////////// -var ParticlePerformTest2 = ParticleMainScene.extend({ - - title:function () { - return "B " + this._subtestNumber + " size=8"; - }, - doTest:function () { - var s = cc.Director.getInstance().getWinSize(); - var particleSystem = this.getChildByTag(TAG_PARTICLE_SYSTEM); - - // duration - particleSystem.setDuration(-1); - - // gravity - particleSystem.setGravity(cc.p(0, -90)); - - // angle - particleSystem.setAngle(90); - particleSystem.setAngleVar(0); - - // radial - particleSystem.setRadialAccel(0); - particleSystem.setRadialAccelVar(0); - - // speed of particles - particleSystem.setSpeed(180); - particleSystem.setSpeedVar(50); - - // emitter position - particleSystem.setPosition(cc.p(s.width / 2, 100)); - particleSystem.setPosVar(cc.p(s.width / 2, 0)); - - // life of particles - particleSystem.setLife(2.0); - particleSystem.setLifeVar(1); - - // emits per frame - particleSystem.setEmissionRate(particleSystem.getTotalParticles() / particleSystem.getLife()); - - // color of particles - var startColor = new cc.Color4F(0.5, 0.5, 0.5, 1.0); - particleSystem.setStartColor(startColor); - - var startColorVar = new cc.Color4F(0.5, 0.5, 0.5, 1.0); - particleSystem.setStartColorVar(startColorVar); - - var endColor = new cc.Color4F(0.1, 0.1, 0.1, 0.2); - particleSystem.setEndColor(endColor); - - var endColorVar = new cc.Color4F(0.1, 0.1, 0.1, 0.2); - particleSystem.setEndColorVar(endColorVar); - - // size, in pixels - particleSystem.setEndSize(8.0); - particleSystem.setStartSize(8.0); - particleSystem.setEndSizeVar(0); - particleSystem.setStartSizeVar(0); - - // additive - particleSystem.setBlendAdditive(false); - } -}); - -//////////////////////////////////////////////////////// -// -// ParticlePerformTest3 -// -//////////////////////////////////////////////////////// -var ParticlePerformTest3 = ParticleMainScene.extend({ - - title:function () { - return "C " + this._subtestNumber + " size=32"; - }, - doTest:function () { - var s = cc.Director.getInstance().getWinSize(); - var particleSystem = this.getChildByTag(TAG_PARTICLE_SYSTEM); - - // duration - particleSystem.setDuration(-1); - - // gravity - particleSystem.setGravity(cc.p(0, -90)); - - // angle - particleSystem.setAngle(90); - particleSystem.setAngleVar(0); - - // radial - particleSystem.setRadialAccel(0); - particleSystem.setRadialAccelVar(0); - - // speed of particles - particleSystem.setSpeed(180); - particleSystem.setSpeedVar(50); - - // emitter position - particleSystem.setPosition(cc.p(s.width / 2, 100)); - particleSystem.setPosVar(cc.p(s.width / 2, 0)); - - // life of particles - particleSystem.setLife(2.0); - particleSystem.setLifeVar(1); - - // emits per frame - particleSystem.setEmissionRate(particleSystem.getTotalParticles() / particleSystem.getLife()); - - // color of particles - var startColor = new cc.Color4F(0.5, 0.5, 0.5, 1.0); - particleSystem.setStartColor(startColor); - - var startColorVar = new cc.Color4F(0.5, 0.5, 0.5, 1.0); - particleSystem.setStartColorVar(startColorVar); - - var endColor = new cc.Color4F(0.1, 0.1, 0.1, 0.2); - particleSystem.setEndColor(endColor); - - var endColorVar = new cc.Color4F(0.1, 0.1, 0.1, 0.2); - particleSystem.setEndColorVar(endColorVar); - - // size, in pixels - particleSystem.setEndSize(32.0); - particleSystem.setStartSize(32.0); - particleSystem.setEndSizeVar(0); - particleSystem.setStartSizeVar(0); - - // additive - particleSystem.setBlendAdditive(false); - } -}); - -//////////////////////////////////////////////////////// -// -// ParticlePerformTest4 -// -//////////////////////////////////////////////////////// -var ParticlePerformTest4 = ParticleMainScene.extend({ - - title:function () { - return "D " + this._subtestNumber + " size=64"; - }, - doTest:function () { - var s = cc.Director.getInstance().getWinSize(); - var particleSystem = this.getChildByTag(TAG_PARTICLE_SYSTEM); - - // duration - particleSystem.setDuration(-1); - - // gravity - particleSystem.setGravity(cc.p(0, -90)); - - // angle - particleSystem.setAngle(90); - particleSystem.setAngleVar(0); - - // radial - particleSystem.setRadialAccel(0); - particleSystem.setRadialAccelVar(0); - - // speed of particles - particleSystem.setSpeed(180); - particleSystem.setSpeedVar(50); - - // emitter position - particleSystem.setPosition(cc.p(s.width / 2, 100)); - particleSystem.setPosVar(cc.p(s.width / 2, 0)); - - // life of particles - particleSystem.setLife(2.0); - particleSystem.setLifeVar(1); - - // emits per frame - particleSystem.setEmissionRate(particleSystem.getTotalParticles() / particleSystem.getLife()); - - // color of particles - var startColor = new cc.Color4F(0.5, 0.5, 0.5, 1.0); - particleSystem.setStartColor(startColor); - - var startColorVar = new cc.Color4F(0.5, 0.5, 0.5, 1.0); - particleSystem.setStartColorVar(startColorVar); - - var endColor = new cc.Color4F(0.1, 0.1, 0.1, 0.2); - particleSystem.setEndColor(endColor); - - var endColorVar = new cc.Color4F(0.1, 0.1, 0.1, 0.2); - particleSystem.setEndColorVar(endColorVar); - - // size, in pixels - particleSystem.setEndSize(64.0); - particleSystem.setStartSize(64.0); - particleSystem.setEndSizeVar(0); - particleSystem.setStartSizeVar(0); - - // additive - particleSystem.setBlendAdditive(false); - } -}); - -function runParticleTest() { - var scene = new ParticlePerformTest1; - scene.initWithSubTest(1, PARTICLE_NODES_INCREASE); - cc.Director.getInstance().replaceScene(scene); -} diff --git a/samples/TestJavascript/Resources/js/PerformanceTest/PerformanceSpriteTest.js b/samples/TestJavascript/Resources/js/PerformanceTest/PerformanceSpriteTest.js deleted file mode 100644 index c69ce71cb7..0000000000 --- a/samples/TestJavascript/Resources/js/PerformanceTest/PerformanceSpriteTest.js +++ /dev/null @@ -1,576 +0,0 @@ -/**************************************************************************** - 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. - ****************************************************************************/ -var MAX_SPRITES = 1000; -var SPRITES_INCREASE = 50; - -var TAG_INFO_LAYER = 1; -var TAG_MAIN_LAYER = 2; -var TAG_SPRITE_MENU_LAYER = (MAX_SPRITES + 1000); - -var s_nSpriteCurCase = 0; - -//////////////////////////////////////////////////////// -// -// SubTest -// -//////////////////////////////////////////////////////// -var SubTest = cc.Class.extend({ - _subtestNumber:null, - _batchNode:null, - _parent:null, - removeByTag:function (tag) { - switch (this._subtestNumber) { - case 1: - case 4: - case 7: - this._parent.removeChildByTag(tag + 100, true); - break; - case 2: - case 3: - case 5: - case 6: - case 8: - case 9: - this._batchNode.removeChildAtIndex(tag, true); - break; - default: - break; - } - }, - createSpriteWithTag:function (tag) { -// create - cc.Texture2D.setDefaultAlphaPixelFormat(cc.TEXTURE_PIXELFORMAT_RGBA8888); - - var sprite = null; - switch (this._subtestNumber) { - case 1: - { - sprite = cc.Sprite.create("Images/grossinis_sister1.png"); - this._parent.addChild(sprite, 0, tag + 100); - break; - } - case 2: - case 3: - { - sprite = cc.Sprite.createWithTexture(this._batchNode.getTexture(), cc.rect(0, 0, 52, 139)); - this._batchNode.addChild(sprite, 0, tag + 100); - break; - } - case 4: - { - var idx = parseInt(cc.RANDOM_0_1() * 14) + 1; - idx = idx < 10 ? "0" + idx : idx.toString(); - var str = "Images/grossini_dance_" + idx + ".png"; - sprite = cc.Sprite.create(str); - this._parent.addChild(sprite, 0, tag + 100); - break; - } - case 5: - case 6: - { - var idx = 0 | (cc.RANDOM_0_1() * 14); - var x = (idx % 5) * 85; - var y = (0 | (idx / 5)) * 121; - sprite = cc.Sprite.createWithTexture(this._batchNode.getTexture(), cc.rect(x, y, 85, 121)); - this._batchNode.addChild(sprite, 0, tag + 100); - break; - } - - case 7: - { - var y, x; - var r = 0 | (cc.RANDOM_0_1() * 64); - - y = parseInt(r / 8); - x = parseInt(r % 8); - - var str = "Images/sprites_test/sprite-" + x + "-" + y + ".png"; - sprite = cc.Sprite.create(str); - this._parent.addChild(sprite, 0, tag + 100); - break; - } - - case 8: - case 9: - { - var y, x; - var r = 0 | (cc.RANDOM_0_1() * 64); - - y = (0 | (r / 8)) * 32; - x = (r % 8) * 32; - sprite = cc.Sprite.createWithTexture(this._batchNode.getTexture(), cc.rect(x, y, 32, 32)); - this._batchNode.addChild(sprite, 0, tag + 100); - break; - } - - default: - break; - } - - cc.Texture2D.setDefaultAlphaPixelFormat(cc.TEXTURE_PIXELFORMAT_DEFAULT); - - return sprite; - }, - initWithSubTest:function (subTest, p) { - this._subtestNumber = subTest; - this._parent = p; - this._batchNode = null; - /* - * Tests: - * 1: 1 (32-bit) PNG sprite of 52 x 139 - * 2: 1 (32-bit) PNG Batch Node using 1 sprite of 52 x 139 - * 3: 1 (16-bit) PNG Batch Node using 1 sprite of 52 x 139 - * 4: 1 (4-bit) PVRTC Batch Node using 1 sprite of 52 x 139 - - * 5: 14 (32-bit) PNG sprites of 85 x 121 each - * 6: 14 (32-bit) PNG Batch Node of 85 x 121 each - * 7: 14 (16-bit) PNG Batch Node of 85 x 121 each - * 8: 14 (4-bit) PVRTC Batch Node of 85 x 121 each - - * 9: 64 (32-bit) sprites of 32 x 32 each - *10: 64 (32-bit) PNG Batch Node of 32 x 32 each - *11: 64 (16-bit) PNG Batch Node of 32 x 32 each - *12: 64 (4-bit) PVRTC Batch Node of 32 x 32 each - */ - - // purge textures - log("initWithSubTest 01"); - var mgr = cc.TextureCache.getInstance(); - log("initWithSubTest 02"); - // [mgr removeAllTextures]; - mgr.removeTexture(mgr.addImage("Images/grossinis_sister1.png")); - mgr.removeTexture(mgr.addImage("Images/grossini_dance_atlas.png")); - mgr.removeTexture(mgr.addImage("Images/spritesheet1.png")); - log("initWithSubTest 03"); - switch (this._subtestNumber) { - case 1: - case 4: - case 7: - break; - /// - case 2: - cc.Texture2D.setDefaultAlphaPixelFormat(cc.TEXTURE_PIXELFORMAT_RGBA8888); - this._batchNode = cc.SpriteBatchNode.create("Images/grossinis_sister1.png", 100); - p.addChild(this._batchNode, 0); - break; - case 3: - cc.Texture2D.setDefaultAlphaPixelFormat(cc.TEXTURE_PIXELFORMAT_RGBA4444); - this._batchNode = cc.SpriteBatchNode.create("Images/grossinis_sister1.png", 100); - p.addChild(this._batchNode, 0); - break; - - /// - case 5: - cc.Texture2D.setDefaultAlphaPixelFormat(cc.TEXTURE_PIXELFORMAT_RGBA8888); - this._batchNode = cc.SpriteBatchNode.create("Images/grossini_dance_atlas.png", 100); - p.addChild(this._batchNode, 0); - break; - case 6: - cc.Texture2D.setDefaultAlphaPixelFormat(cc.TEXTURE_PIXELFORMAT_RGBA4444); - this._batchNode = cc.SpriteBatchNode.create("Images/grossini_dance_atlas.png", 100); - p.addChild(this._batchNode, 0); - break; - - /// - case 8: - cc.Texture2D.setDefaultAlphaPixelFormat(cc.TEXTURE_PIXELFORMAT_RGBA8888); - this._batchNode = cc.SpriteBatchNode.create("Images/spritesheet1.png", 100); - p.addChild(this._batchNode, 0); - break; - case 9: - cc.Texture2D.setDefaultAlphaPixelFormat(cc.TEXTURE_PIXELFORMAT_RGBA4444); - this._batchNode = cc.SpriteBatchNode.create("Images/spritesheet1.png", 100); - p.addChild(this._batchNode, 0); - break; - - default: - break; - } - log("initWithSubTest 04"); - cc.Texture2D.setDefaultAlphaPixelFormat(cc.TEXTURE_PIXELFORMAT_DEFAULT); - log("initWithSubTest 05"); - } -}); - -//////////////////////////////////////////////////////// -// -// SpriteMenuLayer -// -//////////////////////////////////////////////////////// -var SpriteMenuLayer = PerformBasicLayer.extend({ - _maxCases:7, - showCurrentTest:function () { - var scene = null; - var preScene = this.getParent(); - var subTest = preScene.getSubTestNum(); - var nodes = preScene.getNodesNum(); - - switch (this._curCase) { - case 0: - scene = new SpritePerformTest1(); - break; - case 1: - scene = new SpritePerformTest2(); - break; - case 2: - scene = new SpritePerformTest3(); - break; - case 3: - scene = new SpritePerformTest4(); - break; - case 4: - scene = new SpritePerformTest5(); - break; - case 5: - scene = new SpritePerformTest6(); - break; - case 6: - scene = new SpritePerformTest7(); - break; - } - s_nSpriteCurCase = this._curCase; - - if (scene) { - scene.initWithSubTest(subTest, nodes); - cc.Director.getInstance().replaceScene(scene); - } - } -}); - -//////////////////////////////////////////////////////// -// -// SpriteMainScene -// -//////////////////////////////////////////////////////// -var SpriteMainScene = cc.Scene.extend({ - _lastRenderedCount:null, - _quantityNodes:null, - _subTest:null, - _subtestNumber:1, - - ctor:function () { - var parent = new cc.Scene(); - __associateObjWithNative(this, parent); - this.init(); - }, - - title:function () { - return "No title"; - }, - initWithSubTest:function (asubtest, nodes) { - this._subtestNumber = asubtest; - this._subTest = new SubTest(); - this._subTest.initWithSubTest(asubtest, this); - - var s = cc.Director.getInstance().getWinSize(); - - this._lastRenderedCount = 0; - this._quantityNodes = 0; - - // add title label - var label = cc.LabelTTF.create(this.title(), "Arial", 40); - this.addChild(label, 1); - label.setPosition(cc.p(s.width / 2, s.height - 32)); - label.setColor(cc.c3b(255, 255, 40)); - - cc.MenuItemFont.setFontSize(65); - var decrease = cc.MenuItemFont.create(" - ", this, this.onDecrease); - decrease.setColor(cc.c3b(0, 200, 20)); - var increase = cc.MenuItemFont.create(" + ", this, this.onIncrease); - increase.setColor(cc.c3b(0, 200, 20)); - - var menu = cc.Menu.create(decrease, increase); - menu.alignItemsHorizontally(); - - menu.setPosition(cc.p(s.width / 2, s.height - 65)); - this.addChild(menu, 1); - - var infoLabel = cc.LabelTTF.create("0 nodes", "Marker Felt", 30); - infoLabel.setColor(cc.c3b(0, 200, 20)); - infoLabel.setPosition(cc.p(s.width / 2, s.height - 90)); - this.addChild(infoLabel, 1, TAG_INFO_LAYER); - - // add menu - var menu = new SpriteMenuLayer(true, 7, s_nSpriteCurCase); - this.addChild(menu, 1, TAG_SPRITE_MENU_LAYER); - - // Sub Tests - cc.MenuItemFont.setFontSize(32); - var subMenu = cc.Menu.create(); - for (var i = 1; i <= 9; ++i) { - var text = i.toString(); - var itemFont = cc.MenuItemFont.create(text, this, this.testNCallback); - itemFont.setTag(i); - subMenu.addChild(itemFont, 10); - - if (i <= 3) - itemFont.setColor(cc.c3b(200, 20, 20)); - else if (i <= 6) - itemFont.setColor(cc.c3b(0, 200, 20)); - else - itemFont.setColor(cc.c3b(0, 20, 200)); - } - - subMenu.alignItemsHorizontally(); - subMenu.setPosition(cc.p(s.width / 2, 80)); - this.addChild(subMenu, 2); - - while (this._quantityNodes < nodes) { - this.onIncrease(this); - } - }, - updateNodes:function () { - if (this._quantityNodes != this._lastRenderedCount) { - var infoLabel = this.getChildByTag(TAG_INFO_LAYER); - var str = this._quantityNodes + " nodes"; - infoLabel.setString(str); - - this._lastRenderedCount = this._quantityNodes; - } - }, - testNCallback:function (sender) { - this._subtestNumber = sender.getTag(); - var menu = this.getChildByTag(TAG_SPRITE_MENU_LAYER); - menu.restartCallback(sender); - }, - onIncrease:function (sender) { - if (this._quantityNodes >= MAX_SPRITES) - return; - - for (var i = 0; i < SPRITES_INCREASE; i++) { - var sprite = this._subTest.createSpriteWithTag(this._quantityNodes); - this.doTest(sprite); - this._quantityNodes++; - } - - this.updateNodes(); - }, - onDecrease:function (sender) { - if (this._quantityNodes <= 0) - return; - - for (var i = 0; i < SPRITES_INCREASE; i++) { - this._quantityNodes--; - this._subTest.removeByTag(this._quantityNodes); - } - - this.updateNodes(); - }, - - doTest:function (sprite) { - - }, - - getSubTestNum:function () { - return this._subtestNumber - }, - getNodesNum:function () { - return this._quantityNodes - } -}); - - -//////////////////////////////////////////////////////// -// -// For test functions -// -//////////////////////////////////////////////////////// -function performanceActions(sprite) { - var size = cc.Director.getInstance().getWinSize(); - sprite.setPosition(cc.p(parseInt(Math.random() * size.width), parseInt(Math.random() * size.height))); - - var period = 0.5 + (Math.random() * 1000) / 500.0; - var rot = cc.RotateBy.create(period, 360.0 * cc.RANDOM_0_1()); - var rot_back = rot.reverse(); - var permanentRotation = cc.RepeatForever.create(cc.Sequence.create(rot, rot_back)); - sprite.runAction(permanentRotation); - - var growDuration = 0.5 + (Math.random() * 1000) / 500.0; - var grow = cc.ScaleBy.create(growDuration, 0.5, 0.5); - var permanentScaleLoop = cc.RepeatForever.create(cc.Sequence.create(grow, grow.reverse())); - sprite.runAction(permanentScaleLoop); -} - -function performanceActions20(sprite) { - var size = cc.Director.getInstance().getWinSize(); - if (cc.RANDOM_0_1() < 0.2) - sprite.setPosition(cc.p(parseInt(Math.random() * size.width), parseInt(Math.random() * size.height))); - else - sprite.setPosition(cc.p(-1000, -1000)); - - var period = 0.5 + (Math.random() * 1000) / 500.0; - var rot = cc.RotateBy.create(period, 360.0 * cc.RANDOM_0_1()); - var rot_back = rot.reverse(); - var permanentRotation = cc.RepeatForever.create(cc.Sequence.create(rot, rot_back)); - sprite.runAction(permanentRotation); - - var growDuration = 0.5 + (Math.random() * 1000) / 500.0; - var grow = cc.ScaleBy.create(growDuration, 0.5, 0.5); - var permanentScaleLoop = cc.RepeatForever.create(cc.Sequence.create(grow, grow.reverse())); - sprite.runAction(permanentScaleLoop); -} - -function performanceRotationScale(sprite) { - var size = cc.Director.getInstance().getWinSize(); - sprite.setPosition(cc.p(parseInt(Math.random() * size.width), parseInt(Math.random() * size.height))); - sprite.setRotation(cc.RANDOM_0_1() * 360); - sprite.setScale(cc.RANDOM_0_1() * 2); -} - -function performancePosition(sprite) { - var size = cc.Director.getInstance().getWinSize(); - log("performancePosition 01"); - sprite.setPosition(cc.p(parseInt(Math.random() * size.width), parseInt(Math.random() * size.height))); - log("performancePosition 02"); -} - -function performanceout20(sprite) { - var size = cc.Director.getInstance().getWinSize(); - - if (cc.RANDOM_0_1() < 0.2) - sprite.setPosition(cc.p(parseInt(Math.random() * size.width), parseInt(Math.random() * size.height))); - else - sprite.setPosition(cc.p(-1000, -1000)); -} - -function performanceOut100(sprite) { - sprite.setPosition(cc.p(-1000, -1000)); -} - -function performanceScale(sprite) { - var size = cc.Director.getInstance().getWinSize(); - sprite.setPosition(cc.p(parseInt(Math.random() * size.width), parseInt(Math.random() * size.height))); - sprite.setScale(cc.RANDOM_0_1() * 100 / 50); -} - - -//////////////////////////////////////////////////////// -// -// SpritePerformTest1 -// -//////////////////////////////////////////////////////// -var SpritePerformTest1 = SpriteMainScene.extend({ - doTest:function (sprite) { - performancePosition(sprite); - }, - title:function () { - return "A (" + this._subtestNumber + ") position"; - } -}); - -//////////////////////////////////////////////////////// -// -// SpritePerformTest2 -// -//////////////////////////////////////////////////////// -var SpritePerformTest2 = SpriteMainScene.extend({ - doTest:function (sprite) { - performanceScale(sprite); - }, - title:function () { - return "B (" + this._subtestNumber + ") scale"; - } -}); - -//////////////////////////////////////////////////////// -// -// SpritePerformTest3 -// -//////////////////////////////////////////////////////// -var SpritePerformTest3 = SpriteMainScene.extend({ - doTest:function (sprite) { - performanceRotationScale(sprite); - }, - title:function () { - return "C (" + this._subtestNumber + ") scale + rot"; - } -}); - -//////////////////////////////////////////////////////// -// -// SpritePerformTest4 -// -//////////////////////////////////////////////////////// -var SpritePerformTest4 = SpriteMainScene.extend({ - doTest:function (sprite) { - performanceOut100(sprite); - }, - title:function () { - return "D (" + this._subtestNumber + ") 100% out"; - } -}); - -//////////////////////////////////////////////////////// -// -// SpritePerformTest5 -// -//////////////////////////////////////////////////////// -var SpritePerformTest5 = SpriteMainScene.extend({ - doTest:function (sprite) { - performanceout20(sprite); - }, - title:function () { - return "E (" + this._subtestNumber + ") 80% out"; - } -}); - -//////////////////////////////////////////////////////// -// -// SpritePerformTest6 -// -//////////////////////////////////////////////////////// -var SpritePerformTest6 = SpriteMainScene.extend({ - doTest:function (sprite) { - performanceActions(sprite); - }, - title:function () { - return "F (" + this._subtestNumber + ") actions"; - } -}); - -//////////////////////////////////////////////////////// -// -// SpritePerformTest7 -// -//////////////////////////////////////////////////////// -var SpritePerformTest7 = SpriteMainScene.extend({ - doTest:function (sprite) { - performanceActions20(sprite); - }, - title:function () { - return "G (" + this._subtestNumber + ") actions 80% out"; - } -}); - -function runSpriteTest() { - log("runSpriteTest 01"); - var scene = new SpritePerformTest1; - log("runSpriteTest 02"); - scene.initWithSubTest(1, 50); - log("runSpriteTest 03"); - cc.Director.getInstance().replaceScene(scene); - log("runSpriteTest 04"); -} diff --git a/samples/TestJavascript/Resources/js/PerformanceTest/PerformanceTest.js b/samples/TestJavascript/Resources/js/PerformanceTest/PerformanceTest.js deleted file mode 100644 index 7ac2af723d..0000000000 --- a/samples/TestJavascript/Resources/js/PerformanceTest/PerformanceTest.js +++ /dev/null @@ -1,188 +0,0 @@ -/**************************************************************************** - 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. - ****************************************************************************/ -require("js/PerformanceTest/testResource.js"); -require("js/PerformanceTest/testbasic.js"); - -/* -require("js/PerformanceTest/PerformanceParticleTest.js"); -require("js/PerformanceTest/PerformanceTextureTest.js"); -*/ - -var ITEM_TAG_BASIC = 1000; -var nCurCase = 0; - -var PerformanceTests = [ - "PerformanceNodeChildrenTest", - "PerformanceParticleTest", - "PerformanceSpriteTest", - "PerformanceTextureTest", - "PerformanceTouchesTest" -]; -//////////////////////////////////////////////////////// -// -// PerformanceMainLayer -// -//////////////////////////////////////////////////////// -var PerformanceMainLayer = cc.Layer.extend({ - ctor:function () { - var parent = new cc.Layer(); - __associateObjWithNative(this, parent); - this.init(); - }, - - onEnter:function () { - //this._super(); - - var s = cc.Director.getInstance().getWinSize(); - - var menu = cc.Menu.create(); - menu.setPosition(cc.POINT_ZERO); - cc.MenuItemFont.setFontName("Arial"); - cc.MenuItemFont.setFontSize(24); - - for (var i = 0; i < PerformanceTests.length; i++) { - var pItem = cc.MenuItemFont.create(PerformanceTests[i], this, this.menuCallback); - pItem.setPosition(cc.p(s.width / 2, s.height - (i + 1) * LINE_SPACE)); - menu.addChild(pItem, ITEM_TAG_BASIC + i); - } - - this.addChild(menu); - }, - menuCallback:function (sender) { - var index = sender.getZOrder() - ITEM_TAG_BASIC; - - // create the test scene and run it - switch (index) { - case 0: - require("js/PerformanceTest/PerformanceNodeChildrenTest.js"); - runNodeChildrenTest(); - break; - case 1: - //runParticleTest(); - break; - case 2: - require("js/PerformanceTest/PerformanceSpriteTest.js"); - runSpriteTest(); - break; - case 3: - //runTextureTest(); - break; - case 4: - //runTouchesTest(); - break; - default: - break; - } - - } -}); - -//////////////////////////////////////////////////////// -// -// PerformBasicLayer -// -//////////////////////////////////////////////////////// -var PerformBasicLayer = cc.Layer.extend({ - _controlMenuVisible:true, - _maxCases:1, - _curCase:0, - ctor:function () { - this._curCase = nCurCase; - var parent = new cc.Layer(); - __associateObjWithNative(this, parent); - this.init(); - }, - onEnter:function () { - // this._super(); - - var s = cc.Director.getInstance().getWinSize(); - - cc.MenuItemFont.setFontName("Arial"); - cc.MenuItemFont.setFontSize(24); - var mainItem = cc.MenuItemFont.create("Back", this, this.toMainLayer); - mainItem.setPosition(cc.p(s.width - 50, 25)); - var menu = cc.Menu.create(mainItem); - menu.setPosition(cc.POINT_ZERO); - - if (this._controlMenuVisible) { - var item1 = cc.MenuItemImage.create(s_pathB1, s_pathB2, this, this.backCallback); - var item2 = cc.MenuItemImage.create(s_pathR1, s_pathR2, this, this.restartCallback); - var item3 = cc.MenuItemImage.create(s_pathF1, s_pathF2, this, this.nextCallback); - item1.setPosition(cc.p(s.width / 2 - 100, 30)); - item2.setPosition(cc.p(s.width / 2, 30)); - item3.setPosition(cc.p(s.width / 2 + 100, 30)); - - menu.addChild(item1, ITEM_TAG_BASIC); - menu.addChild(item2, ITEM_TAG_BASIC); - menu.addChild(item3, ITEM_TAG_BASIC); - } - this.addChild(menu); - }, - restartCallback:function (sender) { - this.showCurrentTest(); - }, - nextCallback:function (sender) { - this._curCase++; - this._curCase = this._curCase % this._maxCases; - nCurCase = this._curCase; - this.showCurrentTest(); - }, - backCallback:function (sender) { - this._curCase--; - if (this._curCase < 0) { - this._curCase += this._maxCases; - } - nCurCase = this._curCase; - this.showCurrentTest(); - }, - showCurrentTest:function (sender) { - }, - toMainLayer:function (sender) { - var scene = new PerformanceTestScene(); - scene.runThisTest(); - } -}); - -//////////////////////////////////////////////////////// -// -// PerformanceTestScene -// -//////////////////////////////////////////////////////// - -var PerformanceTestScene = TestScene.extend({ - runThisTest:function () { - var layer = new PerformanceMainLayer(); - this.addChild(layer); - cc.Director.getInstance().replaceScene(this); - } -}); - -function runPerformanceTest() { - var scene = new PerformanceTestScene(); - scene.runThisTest(); -} - -runPerformanceTest(); \ No newline at end of file diff --git a/samples/TestJavascript/Resources/js/PerformanceTest/PerformanceTextureTest.js b/samples/TestJavascript/Resources/js/PerformanceTest/PerformanceTextureTest.js deleted file mode 100644 index a9068a9ab9..0000000000 --- a/samples/TestJavascript/Resources/js/PerformanceTest/PerformanceTextureTest.js +++ /dev/null @@ -1,171 +0,0 @@ -/**************************************************************************** - 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. - ****************************************************************************/ - -var s_nTexCurCase = 0; -//////////////////////////////////////////////////////// -// -// TextureMenuLayer -// -//////////////////////////////////////////////////////// -var TextureMenuLayer = PerformBasicLayer.extend({ - showCurrentTest:function () { - var scene = null; - switch (this._curCase) { - case 0: - scene = TextureTest.scene(); - break; - } - s_nTexCurCase = this._curCase; - - if (scene) { - cc.Director.getInstance().replaceScene(scene); - } - }, - - onEnter:function () { - this._super(); - - var s = cc.Director.getInstance().getWinSize(); - - // Title - var label = cc.LabelTTF.create(this.title(), "Arial", 40); - this.addChild(label, 1); - label.setPosition(cc.p(s.width / 2, s.height - 32)); - label.setColor(cc.c3b(255, 255, 40)); - - // Subtitle - var strSubTitle = this.subtitle(); - if (strSubTitle.length) { - var l = cc.LabelTTF.create(strSubTitle, "Thonburi", 16); - this.addChild(l, 1); - l.setPosition(cc.p(s.width / 2, s.height - 80)); - } - - this.performTests(); - }, - title:function () { - return "no title"; - }, - subtitle:function () { - return "no subtitle"; - }, - performTests:function () { - - } -}) - -//////////////////////////////////////////////////////// -// -// TextureTest -// -//////////////////////////////////////////////////////// -var TextureTest = TextureMenuLayer.extend({ - performTests:function () { - cc.log("--------"); - cc.log("--- PNG 128x128 ---"); - this.performTestsPNG("res/Images/test_image.png"); - - cc.log("--- PNG 512x512 ---"); - this.performTestsPNG("res/Images/texture512x512.png"); - - cc.log("EMPTY IMAGE"); - cc.log("--- PNG 1024x1024 ---"); - this.performTestsPNG("res/Images/texture1024x1024.png"); - - cc.log("LANDSCAPE IMAGE"); - cc.log("--- PNG 1024x1024 ---"); - this.performTestsPNG("res/Images/landscape-1024x1024.png"); - }, - title:function () { - return "Texture Performance Test"; - }, - subtitle:function () { - return "See console for results"; - }, - performTestsPNG:function (filename) { - var now = cc.timeval(); - var texture; - var cache = cc.TextureCache.getInstance(); - - cc.log("RGBA 8888"); - cc.Texture2D.setDefaultAlphaPixelFormat(cc.TEXTURE_2D_PIXEL_FORMAT_RGBA8888); - var now = cc.Time.gettimeofdayCocos2d(); - texture = cache.addImage(filename); - if (texture) - cc.log(" ms:" + calculateDeltaTime(now)); - else - cc.log(" ERROR"); - cache.removeTexture(texture); - - cc.log("RGBA 4444"); - cc.Texture2D.setDefaultAlphaPixelFormat(cc.TEXTURE_2D_PIXEL_FORMAT_RGBA4444); - var now = cc.Time.gettimeofdayCocos2d(); - texture = cache.addImage(filename); - if (texture) - cc.log(" ms:" + calculateDeltaTime(now)); - else - cc.log(" ERROR"); - cache.removeTexture(texture); - - cc.log("RGBA 5551"); - cc.Texture2D.setDefaultAlphaPixelFormat(cc.TEXTURE_2D_PIXEL_FORMAT_RGB5A1); - var now = cc.Time.gettimeofdayCocos2d(); - texture = cache.addImage(filename); - if (texture) - cc.log(" ms:" + calculateDeltaTime(now)); - else - cc.log(" ERROR"); - cache.removeTexture(texture); - - cc.log("RGB 565"); - cc.Texture2D.setDefaultAlphaPixelFormat(cc.TEXTURE_2D_PIXEL_FORMAT_RGB565); - var now = cc.Time.gettimeofdayCocos2d(); - texture = cache.addImage(filename); - if (texture) - cc.log(" ms:" + calculateDeltaTime(now)); - else - cc.log(" ERROR"); - cache.removeTexture(texture); - } -}); - -TextureTest.scene = function () { - var scene = cc.Scene.create(); - var layer = new TextureTest(false, 1, s_nTexCurCase); - scene.addChild(layer); - return scene; -}; -function runTextureTest() { - s_nTexCurCase = 0; - var scene = TextureTest.scene(); - cc.Director.getInstance().replaceScene(scene); -} - -function calculateDeltaTime(lastUpdate) { - var now = cc.Time.gettimeofdayCocos2d(); - var dt = (now.tv_sec - lastUpdate.tv_sec) + (now.tv_usec - lastUpdate.tv_usec) / 1000000.0; - return dt; -} diff --git a/samples/TestJavascript/Resources/js/PerformanceTest/PerformanceTouchesTest.js b/samples/TestJavascript/Resources/js/PerformanceTest/PerformanceTouchesTest.js deleted file mode 100644 index e8053f177c..0000000000 --- a/samples/TestJavascript/Resources/js/PerformanceTest/PerformanceTouchesTest.js +++ /dev/null @@ -1,162 +0,0 @@ -/**************************************************************************** - 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. - ****************************************************************************/ -var s_nTouchCurCase = 0; - -var TouchesMainScene = PerformBasicLayer.extend({ - _maxCases:2, - _plabel:null, - _numberOfTouchesB:0, - _numberOfTouchesM:0, - _numberOfTouchesE:0, - _numberOfTouchesC:0, - _elapsedTime:null, - showCurrentTest:function () { - var layer = null; - switch (this._curCase) { - case 0: - layer = new TouchesPerformTest1(true, 2, this._curCase); - break; - case 1: - layer = new TouchesPerformTest2(true, 2, this._curCase); - break; - } - s_nTouchCurCase = this._curCase; - - if (layer) { - var scene = cc.Scene.create(); - scene.addChild(layer); - - cc.Director.getInstance().replaceScene(scene); - } - }, - onEnter:function () { - this._super(); - - var s = cc.Director.getInstance().getWinSize(); - - // add title - var label = cc.LabelTTF.create(this.title(), "Arial", 32); - this.addChild(label, 1); - label.setPosition(cc.p(s.width / 2, s.height - 50)); - - this.scheduleUpdate(); - - this._plabel = cc.LabelTTF.create("00.0", "Arial", 16); - this._plabel.setPosition(cc.p(s.width / 2, s.height / 2)); - this.addChild(this._plabel); - - this._elapsedTime = 0; - this._numberOfTouchesB = this._numberOfTouchesM = this._numberOfTouchesE = this._numberOfTouchesC = 0; - }, - title:function () { - return "No title"; - }, - update:function (dt) { - this._elapsedTime += dt; - - if (this._elapsedTime > 1.0) { - var frameRateB = (this._numberOfTouchesB / this._elapsedTime).toFixed(1); - var frameRateM = (this._numberOfTouchesM / this._elapsedTime).toFixed(1); - var frameRateE = (this._numberOfTouchesE / this._elapsedTime).toFixed(1); - var frameRateC = (this._numberOfTouchesC / this._elapsedTime).toFixed(1); - this._elapsedTime = 0; - this._numberOfTouchesB = this._numberOfTouchesM = this._numberOfTouchesE = this._numberOfTouchesC = 0; - - var str = frameRateB + " " + frameRateM + " " + frameRateE + " " + frameRateC; - this._plabel.setString(str); - } - } -}); - -//////////////////////////////////////////////////////// -// -// TouchesPerformTest1 -// -//////////////////////////////////////////////////////// -var TouchesPerformTest1 = TouchesMainScene.extend({ - onEnter:function () { - this._super(); - this.setTouchEnabled(true); - }, - title:function () { - return "Targeted touches"; - }, - registerWithTouchDispatcher:function () { - cc.Director.getInstance().getTouchDispatcher().addTargetedDelegate(this, 0, true); - }, - onTouchBegan:function (touch, event) { - this._numberOfTouchesB++; - return true; - }, - onTouchMoved:function (touch, event) { - this._numberOfTouchesM++; - }, - onTouchEnded:function (touch, event) { - this._numberOfTouchesE++; - }, - onTouchCancelled:function (touch, event) { - this._numberOfTouchesC++; - } -}); - -//////////////////////////////////////////////////////// -// -// TouchesPerformTest2 -// -//////////////////////////////////////////////////////// -var TouchesPerformTest2 = TouchesMainScene.extend({ - onEnter:function () { - this._super(); - this.setTouchEnabled(true); - }, - title:function () { - return "Standard touches"; - }, - registerWithTouchDispatcher:function () { - cc.Director.getInstance().getTouchDispatcher().addStandardDelegate(this, 0); - }, - - onTouchesBegan:function (touches, event) { - this._numberOfTouchesB += touches.length; - }, - onTouchesMoved:function (touches, event) { - this._numberOfTouchesM += touches.length; - }, - onTouchesEnded:function (touches, event) { - this._numberOfTouchesE += touches.length; - }, - onTouchesCancelled:function (touches, event) { - this._numberOfTouchesC += touches.length; - } -}); - -function runTouchesTest() { - s_nTouchCurCase = 0; - var scene = cc.Scene.create(); - var layer = new TouchesPerformTest1(true, 2, s_nTouchCurCase); - scene.addChild(layer); - cc.Director.getInstance().replaceScene(scene); -} diff --git a/samples/TestJavascript/Resources/js/PerformanceTest/testResource.js b/samples/TestJavascript/Resources/js/PerformanceTest/testResource.js deleted file mode 100644 index 2eee93492f..0000000000 --- a/samples/TestJavascript/Resources/js/PerformanceTest/testResource.js +++ /dev/null @@ -1,322 +0,0 @@ -var s_pathGrossini = "Images/grossini.png"; -var s_pathSister1 = "Images/grossinis_sister1.png"; -var s_pathSister2 = "Images/grossinis_sister2.png"; -var s_pathB1 = "Images/b1.png"; -var s_pathB2 = "Images/b2.png"; -var s_pathR1 = "Images/r1.png"; -var s_pathR2 = "Images/r2.png"; -var s_pathF1 = "Images/f1.png"; -var s_pathF2 = "Images/f2.png"; -var s_pathBlock = "Images/blocks.png"; -var s_back = "Images/background.png"; -var s_back1 = "Images/background1.png"; -var s_back2 = "Images/background2.png"; -var s_back3 = "Images/background3.png"; -var s_stars1 = "Images/stars.png"; -var s_stars2 = "Images/stars2.png"; -var s_fire = "Images/fire.png"; -var s_snow = "Images/snow.png"; -var s_streak = "Images/streak.png"; -var s_playNormal = "Images/btn-play-normal.png"; -var s_playSelect = "Images/btn-play-selected.png"; -var s_aboutNormal = "Images/btn-about-normal.png"; -var s_aboutSelect = "Images/btn-about-selected.png"; -var s_highNormal = "Images/btn-highscores-normal.png"; -var s_highSelect = "Images/btn-highscores-selected.png"; -var s_ball = "Images/ball.png"; -var s_paddle = "Images/paddle.png"; -var s_pathClose = "Images/close.png"; -var s_menuItem = "Images/menuitemsprite.png"; -var s_shapeModeMenuItem = "Images/shapemode.png"; -var s_textureModeMenuItem = "Images/texturemode.png"; -var s_MovementMenuItem = "Images/movement.png"; -var s_sendScore = "Images/SendScoreButton.png"; -var s_pressSendScore = "Images/SendScoreButtonPressed.png"; -var s_power = "Images/powered.png"; -var s_atlasTest = "Images/atlastest.png"; -var s_stars2Grayscale = "Images/stars2-grayscale.png"; -var s_starsGrayscale = "Images/stars-grayscale.png"; -var s_grossini_dance_atlas = "Images/grossini_dance_atlas.png"; -var s_piece = "Images/piece.png"; -var s_grossini_dance_atlas_mono = "Images/grossini_dance_atlas-mono.png"; - -var s_grossini = "animations/grossini.png"; -var s_grossini_gray = "animations/grossini_gray.png"; -var s_grossini_blue = "animations/grossini_blue.png"; -var s_grossini_aliases = "animations/grossini-aliases.png"; -var s_dragon_animation = "animations/dragon_animation.png"; -var s_ghosts = "animations/ghosts.png"; -var s_grossini_family = "animations/grossini_family.png"; - -var s_boilingFoamPlist = "Images/BoilingFoam.plist"; -var s_grossiniPlist = "animations/grossini.plist"; -var s_grossini_grayPlist = "animations/grossini_gray.plist"; -var s_grossini_bluePlist = "animations/grossini_blue.plist"; -var s_grossini_aliasesPlist = "animations/grossini-aliases.plist"; -var s_ghostsPlist = "animations/ghosts.plist"; -var s_grossini_familyPlist = "animations/grossini_family.plist"; -var s_animations2Plist = "animations/animations-2.plist"; -var s_animationsPlist = "animations/animations.plist"; - -var s_helloWorld = "Images/HelloWorld.png"; -var s_grossiniDance01 = "Images/grossini_dance_01.png"; -var s_grossiniDance02 = "Images/grossini_dance_02.png"; -var s_grossiniDance03 = "Images/grossini_dance_03.png"; -var s_grossiniDance04 = "Images/grossini_dance_04.png"; -var s_grossiniDance05 = "Images/grossini_dance_05.png"; -var s_grossiniDance06 = "Images/grossini_dance_06.png"; -var s_grossiniDance07 = "Images/grossini_dance_07.png"; -var s_grossiniDance08 = "Images/grossini_dance_08.png"; -var s_grossiniDance09 = "Images/grossini_dance_09.png"; -var s_grossiniDance10 = "Images/grossini_dance_10.png"; -var s_grossiniDance11 = "Images/grossini_dance_11.png"; -var s_grossiniDance12 = "Images/grossini_dance_12.png"; -var s_grossiniDance13 = "Images/grossini_dance_13.png"; -var s_grossiniDance14 = "Images/grossini_dance_14.png"; - -var s_arrows = "Images/arrows.png"; -var s_arrowsBar = "Images/arrowsBar.png"; -var s_arrows_hd = "Images/arrows-hd.png"; -var s_arrowsBar_hd = "Images/arrowsBar-hd.png"; - -// tilemaps resource -var s_tilesPng = "TileMaps/tiles.png"; -var s_levelMapTga = "TileMaps/levelmap.tga"; -var s_fixedOrthoTest2Png = "TileMaps/fixed-ortho-test2.png"; -var s_hexaTilesPng = "TileMaps/hexa-tiles.png"; -var s_isoTestPng = "TileMaps/iso-test.png"; -var s_isoTest2Png = "TileMaps/iso-test2.png"; -var s_isoPng = "TileMaps/iso.png"; -var s_orthoTest1BwPng = "TileMaps/ortho-test1_bw.png"; -var s_orthoTest1Png = "TileMaps/ortho-test1.png"; -var s_tilesHdPng = "TileMaps/tiles-hd.png"; -var s_tmwDesertSpacingHdPng = "TileMaps/tmw_desert_spacing-hd.png"; -var s_tmwDesertSpacingPng = "TileMaps/tmw_desert_spacing.png"; -var s_fnTuffyBoldItalicCharmapPng = "fonts/tuffy_bold_italic-charmap.png"; -var s_fpsImages = "fonts/fps_images.png"; - -var s_bitmapFontTest = "fonts/bitmapFontTest.png"; -var s_bitmapFontTest2 = "fonts/bitmapFontTest2.png"; -var s_bitmapFontTest3 = "fonts/bitmapFontTest3.png"; -var s_bitmapFontTest4 = "fonts/bitmapFontTest4.png"; -var s_bitmapFontTest5 = "fonts/bitmapFontTest5.png"; -var s_konqa32 = "fonts/konqa32.png"; -var s_konqa32_hd = "fonts/konqa32-hd.png"; -var s_bitmapFontChinese = "fonts/bitmapFontChinese.png"; -var s_arial16 = "fonts/arial16.png"; -var s_larabie_16 = "fonts/larabie-16.png"; -var s_larabie_16_hd = "fonts/larabie-16-hd.png"; -var s_futura48 = "fonts/futura-48.png"; -var s_arial_unicode_26 = "fonts/arial-unicode-26.png"; - -var s_bitmapFontTest_fnt = "fonts/bitmapFontTest.fnt"; -var s_bitmapFontTest2_fnt = "fonts/bitmapFontTest2.fnt"; -var s_bitmapFontTest3_fnt = "fonts/bitmapFontTest3.fnt"; -var s_bitmapFontTest4_fnt = "fonts/bitmapFontTest4.fnt"; -var s_bitmapFontTest5_fnt = "fonts/bitmapFontTest5.fnt"; -var s_konqa32_fnt = "fonts/konqa32.fnt"; -var s_konqa32_hd_fnt = "fonts/konqa32-hd.fnt"; -var s_bitmapFontChinese_fnt = "fonts/bitmapFontChinese.fnt"; -var s_arial16_fnt = "fonts/arial16.fnt"; -var s_futura48_fnt = "fonts/futura-48.fnt"; -var s_helvetica32_fnt = "fonts/helvetica-32.fnt"; -var s_geneva32_fnt = "fonts/geneva-32.fnt"; -var s_arial_unicode_26_fnt = "fonts/arial-unicode-26.fnt"; -var s_markerFelt_fnt = "fonts/markerFelt.fnt"; -var s_markerFelt_hd_fnt = "fonts/markerFelt-hd.fnt"; - -var s_larabie_16_plist = "fonts/larabie-16.plist"; -var s_larabie_16_hd_plist = "fonts/larabie-16-hd.plist"; -var s_tuffy_bold_italic_charmap = "fonts/tuffy_bold_italic-charmap.plist"; -var s_tuffy_bold_italic_charmap_hd = "fonts/tuffy_bold_italic-charmap-hd.plist"; - -var s_particles = "Images/particles.png"; -var s_particles_hd = "Images/particles-hd.png"; - -var g_ressources = [ - //image ressources - {type:"image", src:s_particles}, - {type:"image", src:s_particles_hd}, - - {type:"image", src:s_pathGrossini}, - {type:"image", src:s_fnTuffyBoldItalicCharmapPng}, - {type:"image", src:s_fpsImages}, - {type:"image", src:s_pathSister1}, - {type:"image", src:s_pathSister2}, - {type:"image", src:s_pathB1}, - {type:"image", src:s_pathB2}, - {type:"image", src:s_pathR1}, - {type:"image", src:s_pathR2}, - {type:"image", src:s_pathF1}, - {type:"image", src:s_pathF2}, - {type:"image", src:s_pathBlock}, - {type:"image", src:s_back}, - {type:"image", src:s_back1}, - {type:"image", src:s_back2}, - {type:"image", src:s_back3}, - {type:"image", src:s_stars1}, - {type:"image", src:s_stars2}, - {type:"image", src:s_fire}, - {type:"image", src:s_snow}, - {type:"image", src:s_playNormal}, - {type:"image", src:s_playSelect}, - {type:"image", src:s_aboutNormal}, - {type:"image", src:s_aboutSelect}, - {type:"image", src:s_highNormal}, - {type:"image", src:s_highSelect}, - {type:"image", src:s_ball}, - {type:"image", src:s_paddle}, - {type:"image", src:s_pathClose}, - {type:"image", src:s_menuItem}, - {type:"image", src:s_shapeModeMenuItem}, - {type:"image", src:s_textureModeMenuItem}, - {type:"image", src:s_MovementMenuItem}, - {type:"image", src:s_sendScore}, - {type:"image", src:s_pressSendScore}, - {type:"image", src:s_power}, - {type:"image", src:s_atlasTest}, - {type:"image", src:s_tilesPng}, - {type:"image", src:s_streak}, - {type:"image", src:s_starsGrayscale}, - {type:"image", src:s_stars2Grayscale}, - {type:"image", src:s_piece}, - {type:"image", src:s_grossini_dance_atlas_mono}, - - {type:"image", src:s_fixedOrthoTest2Png}, - {type:"image", src:s_hexaTilesPng}, - {type:"image", src:s_isoTestPng}, - {type:"image", src:s_isoTest2Png}, - {type:"image", src:s_isoPng}, - {type:"image", src:s_orthoTest1BwPng}, - {type:"image", src:s_orthoTest1Png}, - {type:"image", src:s_tilesHdPng}, - {type:"image", src:s_tmwDesertSpacingHdPng}, - {type:"image", src:s_tmwDesertSpacingPng}, - {type:"image", src:s_grossini}, - {type:"image", src:s_grossini_gray}, - {type:"image", src:s_grossini_blue}, - {type:"image", src:s_grossini_dance_atlas}, - {type:"image", src:s_grossini_aliases}, - {type:"image", src:s_dragon_animation}, - {type:"image", src:s_ghosts}, - {type:"image", src:s_grossini_family}, - - {type:"image", src:s_helloWorld}, - {type:"image", src:s_grossiniDance01}, - {type:"image", src:s_grossiniDance02}, - {type:"image", src:s_grossiniDance03}, - {type:"image", src:s_grossiniDance04}, - {type:"image", src:s_grossiniDance05}, - {type:"image", src:s_grossiniDance06}, - {type:"image", src:s_grossiniDance07}, - {type:"image", src:s_grossiniDance08}, - {type:"image", src:s_grossiniDance09}, - {type:"image", src:s_grossiniDance10}, - {type:"image", src:s_grossiniDance11}, - {type:"image", src:s_grossiniDance12}, - {type:"image", src:s_grossiniDance13}, - {type:"image", src:s_grossiniDance14}, - - {type:"image", src:s_bitmapFontTest}, - {type:"image", src:s_bitmapFontTest2}, - {type:"image", src:s_bitmapFontTest3}, - {type:"image", src:s_bitmapFontTest4}, - {type:"image", src:s_bitmapFontTest5}, - {type:"image", src:s_konqa32}, - {type:"image", src:s_konqa32_hd}, - {type:"image", src:s_bitmapFontChinese}, - {type:"image", src:s_arial16}, - {type:"image", src:s_larabie_16}, - {type:"image", src:s_larabie_16_hd}, - {type:"image", src:s_futura48}, - {type:"image", src:s_arial_unicode_26}, - - {type:"image", src:s_arrows}, - {type:"image", src:s_arrowsBar}, - {type:"image", src:s_arrows_hd}, - {type:"image", src:s_arrowsBar_hd}, - - {type:"plist", src:s_boilingFoamPlist}, - {type:"plist", src:s_animations2Plist}, - {type:"plist", src:s_animationsPlist}, - {type:"plist", src:s_grossiniPlist}, - {type:"plist", src:s_grossini_grayPlist}, - {type:"plist", src:s_grossini_bluePlist}, - {type:"plist", src:s_grossini_aliasesPlist}, - {type:"plist", src:s_ghostsPlist}, - {type:"plist", src:s_grossini_familyPlist}, - - {type:"plist", src:s_larabie_16_plist}, - {type:"plist", src:s_larabie_16_hd_plist}, - {type:"plist", src:s_tuffy_bold_italic_charmap}, - {type:"plist", src:s_tuffy_bold_italic_charmap_hd}, - - //tmx ressources - {type:"tmx", src:"TileMaps/orthogonal-test1.tmx"}, - {type:"tmx", src:"TileMaps/orthogonal-test1.tsx"}, - {type:"tmx", src:"TileMaps/orthogonal-test2.tmx"}, - {type:"tmx", src:"TileMaps/orthogonal-test3.tmx"}, - {type:"tmx", src:"TileMaps/orthogonal-test4.tmx"}, - {type:"tmx", src:"TileMaps/orthogonal-test4-hd.tmx"}, - {type:"tmx", src:"TileMaps/orthogonal-test5.tmx"}, - {type:"tmx", src:"TileMaps/orthogonal-test6.tmx"}, - {type:"tmx", src:"TileMaps/orthogonal-test6-hd.tmx"}, - {type:"tmx", src:"TileMaps/hexa-test.tmx"}, - {type:"tmx", src:"TileMaps/iso-test.tmx"}, - {type:"tmx", src:"TileMaps/iso-test1.tmx"}, - {type:"tmx", src:"TileMaps/iso-test2.tmx"}, - {type:"tmx", src:"TileMaps/iso-test2-uncompressed.tmx"}, - {type:"tmx", src:"TileMaps/ortho-objects.tmx"}, - {type:"tmx", src:"TileMaps/iso-test-objectgroup.tmx"}, - {type:"tmx", src:"TileMaps/iso-test-zorder.tmx"}, - {type:"tmx", src:"TileMaps/orthogonal-test-zorder.tmx"}, - {type:"tmx", src:"TileMaps/iso-test-vertexz.tmx"}, - {type:"tmx", src:"TileMaps/orthogonal-test-vertexz.tmx"}, - {type:"tmx", src:"TileMaps/iso-test-movelayer.tmx"}, - {type:"tmx", src:"TileMaps/orthogonal-test-movelayer.tmx"}, - {type:"tmx", src:"TileMaps/iso-test-bug787.tmx"}, - {type:"tmx", src:"TileMaps/test-object-layer.tmx"}, - {type:"tmx", src:"TileMaps/ortho-tile-property.tmx"}, - {type:"tmx", src:"TileMaps/ortho-rotation-test.tmx"}, - - //audio ressources - {type:"bgm", src:"background"}, - {type:"effect", src:"effect2"}, - - //tga ressources - {type:"tga", src:s_levelMapTga}, - - //fnt ressources - {type:"fnt", src:s_bitmapFontTest_fnt}, - {type:"fnt", src:s_bitmapFontTest2_fnt}, - {type:"fnt", src:s_bitmapFontTest3_fnt}, - {type:"fnt", src:s_bitmapFontTest4_fnt}, - {type:"fnt", src:s_bitmapFontTest5_fnt}, - {type:"fnt", src:s_konqa32_fnt}, - {type:"fnt", src:s_konqa32_hd_fnt}, - {type:"fnt", src:s_bitmapFontChinese_fnt}, - {type:"fnt", src:s_arial16_fnt}, - {type:"fnt", src:s_futura48_fnt}, - {type:"fnt", src:s_helvetica32_fnt}, - {type:"fnt", src:s_geneva32_fnt}, - {type:"fnt", src:s_arial_unicode_26_fnt}, - {type:"fnt", src:s_markerFelt_fnt}, - {type:"fnt", src:s_markerFelt_hd_fnt}, - - {type:"plist", src:"fonts/strings.xml"}, - {type:"plist", src:"Particles/BoilingFoam.plist"}, - {type:"plist", src:"Particles/BurstPipe.plist"}, - {type:"plist", src:"Particles/Comet.plist"}, - {type:"plist", src:"Particles/debian.plist"}, - {type:"plist", src:"Particles/ExplodingRing.plist"}, - {type:"plist", src:"Particles/Flower.plist"}, - {type:"plist", src:"Particles/Galaxy.plist"}, - {type:"plist", src:"Particles/LavaFlow.plist"}, - {type:"plist", src:"Particles/Phoenix.plist"}, - {type:"plist", src:"Particles/SmallSun.plist"}, - {type:"plist", src:"Particles/SpinningPeas.plist"}, - {type:"plist", src:"Particles/Spiral.plist"}, - {type:"plist", src:"Particles/SpookyPeas.plist"}, - {type:"plist", src:"Particles/TestPremultipliedAlpha.plist"}, - {type:"plist", src:"Particles/Upsidedown.plist"} -]; diff --git a/samples/TestJavascript/Resources/js/PerformanceTest/testbasic.js b/samples/TestJavascript/Resources/js/PerformanceTest/testbasic.js deleted file mode 100644 index 7554be9fd9..0000000000 --- a/samples/TestJavascript/Resources/js/PerformanceTest/testbasic.js +++ /dev/null @@ -1,330 +0,0 @@ -/**************************************************************************** - 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. - ****************************************************************************/ - -var TestScene = cc.Scene.extend({ - ctor:function (bPortrait) { - //this._super(); - var parent = new cc.Scene(); - __associateObjWithNative(this, parent); - this.init(); - }, - onEnter:function () { - //this._super(); - var label = cc.LabelTTF.create("MainMenu", "Arial", 20); - var menuItem = cc.MenuItemLabel.create(label, this, this.MainMenuCallback); - - var menu = cc.Menu.create(menuItem); - var s = cc.Director.getInstance().getWinSize(); - menu.setPosition(cc.POINT_ZERO); - menuItem.setPosition(cc.p(s.width - 50, 25)); - - this.addChild(menu, 1); - }, - runThisTest:function () { - - }, - MainMenuCallback:function () { - require("js/main.js"); - /* - var scene = cc.Scene.create(); - var layer = new TestController(); - scene.addChild(layer); - cc.Director.getInstance().replaceScene(scene); - */ - } -}); -//Controller stuff -var LINE_SPACE = 40; -var s_pathClose = null; -var curPos = cc.POINT_ZERO; - -var TestController = cc.Layer.extend({ - _itemMenu:null, - _beginPos:cc.POINT_ZERO, - isMouseDown:false, - ctor:function () { - var parent = new cc.Layer(); - __associateObjWithNative(this, parent); - this.init(); - - // add close menu - if (!s_pathClose) { - s_pathClose = cc.TextureCache.getInstance().textureForKey("CloseNormal.png"); - } - var closeItem = cc.MenuItemImage.create(s_pathClose, s_pathClose, this, this.closeCallback); - var menu = cc.Menu.create(closeItem);//pmenu is just a holder for the close button - var s = cc.Director.getInstance().getWinSize(); - menu.setPosition(cc.POINT_ZERO); - closeItem.setPosition(cc.p(s.width - 30, s.height - 30)); - - // add menu items for tests - this._itemMenu = cc.Menu.create();//item menu is where all the label goes, and the one gets scrolled - - for (var i = 0, len = testNames.length; i < len; i++) { - var label = cc.LabelTTF.create(testNames[i].title, "Arial", 24); - var menuItem = cc.MenuItemLabel.create(label, this, this.menuCallback); - this._itemMenu.addChild(menuItem, i + 10000); - menuItem.setPosition(cc.p(s.width / 2, (s.height - (i + 1) * LINE_SPACE))); - } - - this._itemMenu.setContentSize(cc.size(s.width, (testNames.length + 1) * LINE_SPACE)); - this._itemMenu.setPosition(curPos); - this.setTouchEnabled(true); - this.addChild(this._itemMenu); - this.addChild(menu, 1); - }, - menuCallback:function (sender) { - var idx = sender.getZOrder() - 10000; - // get the userdata, it's the index of the menu item clicked - // create the test scene and run it - var scene = testNames[idx].testScene(); - if (scene) { - scene.runThisTest(); - } - }, - closeCallback:function () { - history.go(-1); - }, - onTouchesBegan:function (touches, event) { - if (!this.isMouseDown) { - //this._beginPos = cc.p(touches[0].getLocation().x, touches[0].getLocation().y); - this._beginPos = touches[0].getLocation().y; - } - this.isMouseDown = true; - }, - onTouchesMoved:function (touches, event) { - if (this.isMouseDown) { - var touchLocation = touches[0].getLocation().y; - var nMoveY = touchLocation - this._beginPos; - curPos = cc.p(this._itemMenu.getPosition().x, this._itemMenu.getPosition().y); - - var nextPos = cc.p(curPos.x, curPos.y + nMoveY); - var winSize = cc.Director.getInstance().getWinSize(); - if (nextPos.y < 0.0) { - this._itemMenu.setPosition(cc.POINT_ZERO); - return; - } - - if (nextPos.y > ((testNames.length + 1) * LINE_SPACE - winSize.height)) { - this._itemMenu.setPosition(cc.p(0, ((testNames.length + 1) * LINE_SPACE - winSize.height))); - return; - } - this._itemMenu.setPosition(nextPos); - this._beginPos = cc.p(0, touchLocation).y; - curPos = nextPos; - } - }, - onTouchesEnded:function () { - this.isMouseDown = false; - } -}); - -var testNames = [ - //"Accelerometer", - { - title:"ActionManagerTest", - testScene:function () { - return new ActionManagerTestScene(); - } - }, - { - title:"ActionsTest", - testScene:function () { - return new ActionsTestScene(); - } - }, - { - title:"Box2DTest", - testScene:function () { - return new Box2DTestScene(); - } - }, - //"Box2dTestBed", - //"BugsTest", - //"ChipmunkTest", - { - title:"ClickAndMoveTest", - testScene:function () { - return new ClickAndMoveTestScene(); - } - }, - { - title:"CocosDenshionTest", - testScene:function () { - return new CocosDenshionTestScene(); - } - }, - { - title:"CocosNodeTest", - testScene:function () { - return new CocosNodeTestScene(); - } - }, - { - title:"CurrentLanguageTest", - testScene:function () { - return new CurrentLanguageTestScene(); - } - }, - //"CurlTest", - { - title:"DrawPrimitivesTest", - testScene:function () { - return new DrawPrimitivesTestScene(); - } - }, - { - title:"EaseActionsTest", - testScene:function () { - return new EaseActionsTestScene(); - } - }, - //"EffectsTest", - //"EffectAdvancedTest", - //"ExtensionsTest", - { - title:"FontTest", - testScene:function () { - return new FontTestScene(); - } - }, - //"HiResTest", - { - title:"IntervalTest", - testScene:function () { - return new IntervalTestScene(); - } - }, - //"KeyboardTest", - { - title:"LabelTest", - testScene:function () { - return new LabelTestScene(); - } - }, - { - title:"LayerTest", - testScene:function () { - return new LayerTestScene(); - } - }, - { - title:"MenuTest", - testScene:function () { - return new MenuTestScene(); - } - }, - { - title:"MultiTouchTest", - testScene:function () { - return new MultiTouchTestScene(); - } - }, - //"MotionStreakTest", - { - title:"ParallaxTest", - testScene:function () { - return new ParallaxTestScene(); - } - }, - { - title:"ParticleTest", - testScene:function () { - return new ParticleTestScene(); - } - }, - { - title:"PerformanceTest", - testScene:function () { - return new PerformanceTestScene(); - } - }, - { - title:"ProgressActionsTest", - testScene:function () { - return new ProgressActionsTestScene(); - } - }, - //"RenderTextureTest", - { - title:"RotateWorldTest", - testScene:function () { - return new RotateWorldTestScene(); - } - }, - { - title:"SceneTest", - testScene:function () { - return new SceneTestScene(); - } - }, - { - title:"SchedulerTest", - testScene:function () { - return new SchedulerTestScene(); - } - }, - { - title:"SpriteTest", - testScene:function () { - return new SpriteTestScene(); - } - }, - { - title:"TextInputTest", - testScene:function () { - return new TextInputTestScene(); - } - }, - //"Texture2DTest", - { - title:"TextureCacheTest", - testScene:function () { - return new TextureCacheTestScene(); - } - }, - { - title:"TileMapTest", - testScene:function () { - return new TileMapTestScene(); - } - }, - { - title:"TouchesTest", - testScene:function () { - return new TouchesTestScene(); - } - }, - { - title:"TransitionsTest", - testScene:function () { - return new TransitionsTestScene(); - } - } - //"UserDefaultTest", - //"ZwoptexTest", -]; diff --git a/samples/TestJavascript/Resources/js/game-main.js b/samples/TestJavascript/Resources/js/game-main.js deleted file mode 100644 index 40156ff6c2..0000000000 --- a/samples/TestJavascript/Resources/js/game-main.js +++ /dev/null @@ -1,1100 +0,0 @@ -// -// http://www.cocos2d-iphone.org -// http://www.chipmunk-physics.org -// -// Watermelon with Me -// A JS game using cocos2d and Chipmunk -// -// -// Physics code based on Space Patrol: -// https://github.com/slembcke/SpacePatrol -// -// Most of the comments in the physics code were copied+pased from Space Patrol -// -// -// LICENSE: -// -// 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. -// - -require("js/helper.js"); - -// Z Orders (grouped by parent) - -// parent is scroll batch node -Z_WATERMELON = 5; -Z_COIN = 8; -Z_FINISH = 9; -Z_CHASSIS = 10; -Z_WHEEL = 11; - -// parent is scroll node (parallax node) -Z_MOUNTAINS = 0; -Z_SPRITES = 10; -Z_TERRAIN = 20; -Z_DEBUG_PHYSICS = 50; - -// parent is game layer -Z_SCROLL = 10; -Z_SMOKE = 15; -Z_HUD = 20; -Z_LABEL = 30; -Z_DEBUG_MENU = 30; - -// Game state -STATE_PAUSE = 0; -STATE_PLAYING = 1; -STATE_GAME_OVER = 2; -STATE_LEVEL_COMPLETE = 3; - -audioEngine = cc.AudioEngine.getInstance(); -director = cc.Director.getInstance(); -winSize = director.getWinSize(); -centerPos = cc.p( winSize.width/2, winSize.height/2 ); - -sizeRatio = winSize.width / 480; - -// -// Levels -// -levels = []; - -// Level 0 -levels.push( {'coins' : [ {x:300,y:50},{x:350,y:50},{x:400,y:50},{x:450,y:50},{x:500,y:50},{x:550,y:50},{x:600,y:50}, - {x:1300,y:50},{x:1350,y:50},{x:1400,y:50},{x:1450,y:50},{x:1500,y:50},{x:1550,y:50},{x:1600,y:50}, - ], - - 'car' : {x:80, y:60}, - 'finish' : {x:3000, y:20}, - - // points relatives to the previous point - 'lines' : [ {x:0,y:0}, {x:850,y:0}, - {x:20, y:5},{x:20,y:-5}, {x:20, y:10},{x:20,y:-10}, {x:20, y:5},{x:20,y:-5}, - {x:500,y:0}, - {x:20, y:5},{x:20,y:-5}, {x:20, y:10},{x:20,y:-10}, {x:20, y:5},{x:20,y:-5}, - {x:500,y:0}, - {x:20, y:5},{x:20,y:-5}, {x:20, y:10},{x:20,y:-10}, {x:20, y:5},{x:20,y:-5}, - {x:500,y:0}, - {x:20, y:5},{x:20,y:-5}, {x:20, y:10},{x:20,y:-10}, {x:20, y:5},{x:20,y:-5}, - {x:300,y:0}, - ], - } - ); - -// Level 1 -levels.push( {'coins' : [ {x:1120,y:150}, {x:1160,y:140}, {x:1200,y:130}, {x:1240,y:120}, {x:1280,y:110}, - {x:2470,y:150}, {x:2510,y:140}, {x:2550,y:130}, {x:2590,y:120}, {x:2630,y:110}, - {x:2220,y:60}, {x:2260,y:70}, {x:2300,y:80}, {x:2340,y:90}, {x:2380,y:100}, - ], - - 'car' : {x:80, y:60}, - 'finish' : {x:3400, y:20}, - - // points relatives to the previous point - 'lines' : [ {x:0,y:0}, {x:350,y:10}, {x:20, y:5}, {x:500, y:-20}, {x:200, y:80}, {x:100, y:-40}, {x:200,y:-10}, {x:400, y:-50}, {x:300,y:0}, {x:400,y:100}, {x:200,y:-100}, {x:400,y:0}, {x:20,y:15}, {x:20,y:-15}, {x:400,y:0}, ], - } - ); - -// Level 2 -levels.push( {'coins' : [ {x:1120,y:150}, {x:1160,y:140}, {x:1200,y:130}, {x:1240,y:120}, {x:1280,y:110}, - ], - - 'car' : {x:80, y:60}, - 'finish' : {x:4100, y:-100}, - - // points relatives to the previous point - 'lines' : [ {x:0,y:0}, {x:350,y:0}, - {x:300, y:100}, {x:100, y:50}, {x:50, y:12}, {x:25, y:0}, {x:50,y:-12}, {x:100, y:-25}, {x:400, y:-200}, {x:500, y:0}, - {x:20, y:15},{x:20,y:-15}, {x:20, y:5},{x:20,y:-5}, - {x:300,y:0}, - {x:300, y:100}, {x:100, y:50}, {x:50, y:12}, {x:25, y:0}, {x:50,y:-12}, {x:100, y:-25}, {x:400, y:-200}, {x:500, y:0}, - {x:20, y:15},{x:20,y:-15}, {x:20, y:5},{x:20,y:-5}, - {x:300,y:0}, - ], - } - ); -// -// Physics constants -// - -INFINITY = 1e50; - -COLLISION_TYPE_CAR = 1; -COLLISION_TYPE_COIN = 2; -COLLISION_TYPE_WATERMELON = 3; -COLLISION_TYPE_FLOOR = 4; -COLLISION_TYPE_FINISH = 5; - -// Create some collision rules for fancy layer based filtering. -// There is more information about how this works in the Chipmunk docs. -COLLISION_RULE_TERRAIN_BUGGY = 1 << 0; -COLLISION_RULE_BUGGY_ONLY = 1 << 1; - -// Bitwise or the rules together to get the layers for a certain shape type. -COLLISION_LAYERS_TERRAIN = COLLISION_RULE_TERRAIN_BUGGY; -COLLISION_LAYERS_BUGGY = (COLLISION_RULE_TERRAIN_BUGGY | COLLISION_RULE_BUGGY_ONLY); - -// Some constants for controlling the car and world: -GRAVITY = 1200.0; -WHEEL_MASS = 0.25; -CHASSIS_MASS = 0.7; -FRONT_SPRING = 150.0; -FRONT_DAMPING = 3.0; -COG_ADJUSTMENT = cp.v(0.0, -10.0); -REAR_SPRING = 100.0; -REAR_DAMPING = 3.0; -ROLLING_FRICTION = 5e2; -ENGINE_MAX_TORQUE = 6.0e4; -ENGINE_MAX_W = 60; -BRAKING_TORQUE = 3.0e4; -DIFFERENTIAL_TORQUE = 0.5; - -// Groups -GROUP_BUGGY = 1; -GROUP_COIN = 2; - -WATERMELON_MASS = 0.05; - -// Node Tags (used by CocosBuilder) -SCORE_LABEL_TAG = 10; -TIME_LABEL_TAG = 11; -TITLE_TAG = 50; - -// -// Game Layer -// -var GameLayer = cc.LayerGradient.extend({ - - _space:null, - _motor:null, - _frontBrake:null, - _rearBrake:null, - _rearWheel:null, - _chassis:null, - _batch:null, - _shapesToRemove:[], - _score:0, - _scoreLabel:null, - _time:0, - _timeLabel:null, - _level:0, - _state:STATE_PAUSE, - _deferredState:null, - _debugNode:null, - _scrollNode:null, - _terrain:null, - _carSprite:null, - _carSmoke:null, - - ctor:function (level) { - - var parent = new cc.LayerGradient(); - __associateObjWithNative(this, parent); - this.init(cc.c4b(0, 0, 0, 255), cc.c4b(255, 255, 255, 255)); - - this.scheduleUpdate(); - - this.enableEvents( true ); - - cc.MenuItemFont.setFontSize(16 * sizeRatio ); - - var item1_pause = cc.MenuItemFont.create("Pause" ); - var item1_resume = cc.MenuItemFont.create("Resume" ); - var item1 = cc.MenuItemToggle.create( item1_pause, item1_resume ); - item1.setCallback( this, this.onPause); - var item2 = cc.MenuItemFont.create("Debug On/Off", this, this.onToggleDebug); - var menu = cc.Menu.create( item1, item2 ); - menu.alignItemsVertically(); - this.addChild( menu, Z_DEBUG_MENU ); - menu.setPosition( cc._p( winSize.width-(50*sizeRatio), winSize.height-(80*sizeRatio) ) ); - - var animCache = cc.AnimationCache.getInstance(); - animCache.addAnimations("coins_animation.plist"); - - // scrollng Node.. all game objects are children of this node (or one of its subchildre) - var scroll = cc.ParallaxNode.create(); - this.addChild( scroll, Z_SCROLL ); - this._scrollNode = scroll; - - // coin only needed to obtain the texture for the Batch Node - var coin = cc.Sprite.createWithSpriteFrameName("coin01.png"); - this._batch = cc.SpriteBatchNode.createWithTexture( coin.getTexture(), 100 ); - scroll.addChild( this._batch, Z_SPRITES, cc._p(1,1), cc.POINT_ZERO ); - - // "endless" background image - var background = cc.Sprite.create("Parallax.pvr.gz", cc.rect(0,0,4096,512) ); - scroll.addChild(background, Z_MOUNTAINS , cc._p(0.2, 0.2), cc._p(0,-150)); - background.setAnchorPoint( cc.POINT_ZERO ); - background.getTexture().setTexParameters(gl.LINEAR, gl.LINEAR, gl.REPEAT, gl.CLAMP_TO_EDGE); - - // Terrain - this._terrain = cc.DrawNode.create(); - scroll.addChild( this._terrain, Z_TERRAIN, cc._p(1,1), cc.POINT_ZERO ); -// this._terrain.setVisible( false ); - - // Smoke - this._carSmoke = cc.ParticleSystem.create( "car_smoke.plist" ); - this._carSmoke.setPosition( cc.POINT_ZERO ); - this.addChild( this._carSmoke, Z_SMOKE ); - this._carSmoke.setPositionType( cc.PARTICLE_TYPE_RELATIVE ); - - this._shapesToRemove = []; - - this.initHUD(); - - this._score = 0; - this._time = 0; - this._state = STATE_PAUSE; - this._level = level; - - }, - - // HUD stuff - initHUD:function() { - var hud = cc.Reader.load("HUD.ccbi", this); - this.addChild( hud, Z_HUD ); - this._scoreLabel = hud.getChildByTag( SCORE_LABEL_TAG ); - this._timeLabel = hud.getChildByTag( TIME_LABEL_TAG ); - - // bug in cocosbuilder - this._scoreLabel.setAnchorPoint( cc._p(1, 0.5) ); - this._timeLabel.setAnchorPoint( cc._p(0, 0.5) ); - }, - - addScore:function(value) { - this._score += value; - this._scoreLabel.setString( this._score ); - this._scoreLabel.stopAllActions(); - - var scaleUpTo = cc.ScaleTo.create(0.05, 1.2); - var scaleDownTo = cc.ScaleTo.create(0.05, 1.0); - var seq = cc.Sequence.create( scaleUpTo, scaleDownTo ); - this._scoreLabel.runAction( seq ); - - }, - - // - // Events - // - onRestart:function(sender) { - var scene = cc.Scene.create(); - var layer = new GameLayer(this._level); - scene.addChild( layer ); - director.replaceScene( cc.TransitionFade.create(1, scene) ); - }, - - onPause:function(sender) { - if( this._state == STATE_PAUSE ) - this._state = STATE_PLAYING; - else - this._state = STATE_PAUSE; - }, - - onNextLevel:function(sender) { - var scene = cc.Scene.create(); - var layer = new GameLayer(this._level+1); - scene.addChild( layer ); - director.replaceScene( cc.TransitionFade.create(1, scene) ); - }, - - onMainMenu:function(sender) { - var scene = cc.Scene.create(); - var layer = new MenuLayer(); - scene.addChild( layer ); - director.replaceScene( cc.TransitionProgressRadialCCW.create(1, scene) ); - }, - - onToggleDebug:function(sender) { - var state = this._debugNode.getVisible(); - this._debugNode.setVisible( !state ); - }, - - onMouseDown:function(event) { - this.setThrottle(1); - return true; - }, - onMouseUp:function(event) { - this.setThrottle(0); - return true; - }, - onTouchesBegan:function( touches, event) { - this.setThrottle(1); - return true; - }, - onTouchesEnded:function( touches, event) { - this.setThrottle(0); - return true; - }, - - onEnterTransitionDidFinish:function() { - - this.initPhysics(); - this.setupLevel(this._level); - - this._state = STATE_PLAYING; - - // Level Label - var label = cc.LabelBMFont.create("LEVEL " + this._level, "Abadi40.fnt" ); - label.setPosition( centerPos ); - this.addChild( label, Z_LABEL ); - var d = cc.DelayTime.create(1); - var scale = cc.ScaleBy.create(1.1, 5); - var fade = cc.FadeOut.create(1.1); - var s = cc.Spawn.create( scale, fade ); - var selfremove = cc.CallFunc.create(this, this.onRemoveMe ); - var seq = cc.Sequence.create(d, s, selfremove ); - label.runAction( seq ); - - }, - - onRemoveMe:function( sender ) { - sender.removeFromParentAndCleanup( true ); - }, - - onExit:function() { - - this.enableCollisionEvents( false ); - // XXX: Leak... all Shapes and Bodies should be freed - cp.spaceFree( this._space ); - }, - - // Coin and Car - onCollisionBeginCoin : function ( arbiter, space ) { - - var bodies = cp.arbiterGetBodies( arbiter ); - var shapes = cp.arbiterGetShapes( arbiter ); - var collTypeA = cp.shapeGetCollisionType( shapes[0] ); - var collTypeB = cp.shapeGetCollisionType( shapes[1] ); - - var shapeCoin = (collTypeA == COLLISION_TYPE_COIN) ? shapes[0] : shapes[1]; - - // XXX: hack to prevent double deletion... argh... - // Since shapeCoin in 64bits is a typedArray and in 32-bits is an integer - // a ad-hoc solution needs to be implemented - if( this._shapesToRemove.length == 0 ) { - // since Coin is a sensor, it can't be removed at PostStep. - // PostStep is not called for Sensors - this._shapesToRemove.push( shapeCoin ); - audioEngine.playEffect("pickup_coin.wav"); - -// cc.log("Adding shape: " + shapeCoin[0] + " : " + shapeCoin[1] ); - cc.log("Adding shape: " + shapeCoin ); - this.addScore(1); - } - return true; - }, - - // Floor and Watermelon - onCollisionBeginWatermelon : function ( arbiter, space ) { - this.setThrottle(0); - this.setGameStateDeferred( STATE_GAME_OVER ); - return true; - }, - - // Car and Finish line - onCollisionBeginFinish : function ( arbiter, space ) { - this.setThrottle(0); - this.setGameStateDeferred( STATE_LEVEL_COMPLETE ); - return true; - }, - - update:function(dt) { - - // update state if necessary - if( this._deferredState ) - this.setGameState( this._deferredState ); - - if( this._state == STATE_PLAYING ) { - // update time - this._time += dt; - this._timeLabel.setString( '' + this._time.toFixed(1) ); - } - - // Don't update physics on game over - if( this._state != STATE_PAUSE ) - cp.spaceStep( this._space, dt); - - // sync smoke with car - if( this._carSprite ) { - var p = this._carSprite.convertToWorldSpace( cc.POINT_ZERO ); - this._carSmoke.setPosition( p ); - } - - var l = this._shapesToRemove.length; - - for( var i=0; i < l; i++ ) { - var shape = this._shapesToRemove[i]; - -// cc.log("removing shape: " + shape[0] + " : " + shape[1] ); - cc.log("removing shape: " + shape ); - - cp.spaceRemoveStaticShape( this._space, shape ); - cp.shapeFree( shape ); - - var body = cp.shapeGetBody( shape ); - - var sprite = cp.bodyGetUserData( body ); - sprite.removeFromParentAndCleanup(true); - - cp.bodyFree( body ); - - } - - if( l > 0 ) - this._shapesToRemove = []; - }, - - // - // Level Setup - // - setupLevel : function(lvl) { - - var x = 0; - var y = 0; - var width = winSize.width; - var height = winSize.height; - - var level = levels[ lvl ]; - - // Coins - var coins = level['coins']; - for( var i=0;i < coins.length; i++) { - var coin = coins[i]; - this.createCoin( cc._p( coin.x, coin.y) ); - } - - // car - var car = level['car']; - this.createCar( cp.v( car.x, car.y) ); - - // finish - var finish = level['finish']; - this.createFinish( cp._v(finish.x, finish.y) ); - - //lines - var poly = []; - var p = {x:0, y:0}; - var lines = level['lines']; - - for( var i=0; i < lines.length; i++) { - var line = lines[i]; - if( i > 0 ) { - this.createSegment( cp._v(p.x, p.y), cp._v( p.x+line.x, p.y+line.y ) ); - this._terrain.drawSegment( cc._p(p.x, p.y), cc._p(p.x+line.x, p.y+line.y), 5, cc.c4f(0.43,0.39,0.34,1) ); - } - - p = {x:p.x+line.x, y:p.y+line.y}; - - poly.push( cc.p(p.x, p.y) ); - - // needed for world boundary - x = Math.min(x, p.x); - y = Math.min(y, p.y); - width = Math.max( width, p.x); - height = Math.max( height, p.y); - } - - poly.unshift( cc.p(x,y) ); - - // XXX: Bug in CCDrawNode: No tesselation, so "fill" is disabled - // XXX: CCDrawNode#drawPoly is super expensive... using drawSegment instead - // poly, fill color, border width, border color -// this._terrain.drawPoly( poly, cc.c4f(0,0,0,0 ), 1, cc.c4f(0.82,0.41,0.04,1) ); - - cc.log("World Boundary: " + x + " " + y + " " + width + " " + height ); - - var rect = cc.rect(x,y,width,height); - var a = cc.Follow.create( this._carSprite, rect ); - this._scrollNode.runAction( a ); - - this.createWorldBoundary( rect ); - }, - - createWorldBoundary:function( rect ) { - - var staticBody = cp.spaceGetStaticBody( this._space ); - - var x = rect.x; - var y = rect.y; - var w = rect.width; - var h = rect.height; - - // Walls - var walls =[cp.segmentShapeNew( staticBody, cp._v(x,y), cp._v(w,y), 0 ), // bottom - cp.segmentShapeNew( staticBody, cp._v(x,h), cp._v(w,h), 0), // top - cp.segmentShapeNew( staticBody, cp._v(x,y), cp._v(x,h), 0), // left - cp.segmentShapeNew( staticBody, cp._v(w,y), cp._v(w,h), 0) // right - ]; - for( var i=0; i < walls.length; i++ ) { - var wall = walls[i]; - cp.shapeSetElasticity(wall, 0); - cp.shapeSetFriction(wall, 0); - cp.shapeSetCollisionType(wall, COLLISION_TYPE_FLOOR); - cp.spaceAddStaticShape( this._space, wall ); - } - }, - - // - // Physics - // - initPhysics : function() { - this._space = cp.spaceNew(); - - // Gravity - cp.spaceSetGravity( this._space, cp._v(0, -GRAVITY) ); - - this.enableCollisionEvents( true ); - - // debug only - this._debugNode = cc.ChipmunkDebugNode.create( this._space ); - this._debugNode.setVisible( false ); - // Parallax ratio and offset - this._scrollNode.addChild( this._debugNode, Z_DEBUG_PHYSICS, cc._p(1,1), cc.POINT_ZERO ); - }, - - setThrottle : function( throttle ) { - if(throttle > 0){ - // The motor is modeled like an electric motor where the torque decreases inversely as the rate approaches the maximum. - // It's simple to code up and feels nice. - - // _motor.maxForce = cpfclamp01(1.0 - (_chassis.body.angVel - _rearWheel.body.angVel)/ENGINE_MAX_W)*ENGINE_MAX_TORQUE; - var maxForce = cp.fclamp01(1.0 - ( (cp.bodyGetAngVel(this._chassis) - cp.bodyGetAngVel(this._rearWheel)) / ENGINE_MAX_W)) * ENGINE_MAX_TORQUE; - cp.constraintSetMaxForce( this._motor, maxForce ); - - // Set the brakes to apply the baseline rolling friction torque. - cp.constraintSetMaxForce( this._frontBrake, ROLLING_FRICTION ); - cp.constraintSetMaxForce( this._rearBrake, ROLLING_FRICTION ); - } else if(throttle < 0){ - // Disable the motor. - cp.constraintSetMaxForce( this._motor, 0 ); - // It would be a pretty good idea to give the front and rear brakes different torques. - // The buggy as is now has a tendency to tip forward when braking hard. - cp.constraintSetMaxForce( this._frontBrake, BRAKING_TORQUE); - cp.constraintSetMaxForce( this._rearBrake, BRAKING_TORQUE); - } else { - // Disable the motor. - cp.constraintSetMaxForce( this._motor, 0 ); - // Set the brakes to apply the baseline rolling friction torque. - cp.constraintSetMaxForce( this._frontBrake, ROLLING_FRICTION ); - cp.constraintSetMaxForce( this._rearBrake, ROLLING_FRICTION ); - } - }, - - createCar : function(pos) { - var front = this.createWheel( cp.vadd(pos, cp._v(47,-25) ) ); - this._chassis = this.createChassis( cp.vadd( pos, COG_ADJUSTMENT ) ); - this._rearWheel = this.createWheel( cp.vadd( pos, cp._v(-35, -25) ) ); - this.createCarJoints( this._chassis, front, this._rearWheel ); - this.createCarFruits( pos ); - - this.setThrottle( 0 ); - }, - - createCarJoints: function( chassis, front, rear ) { - - // The front wheel strut telescopes, so we'll attach the center of the wheel to a groov joint on the chassis. - // I created the graphics specifically to have a 45 degree angle. So it's easy to just fudge the numbers. - var grv_a = cp.bodyWorld2Local( chassis, cp.bodyGetPos(front) ); - var grv_b = cp.vadd( grv_a, cp.vmult( cp._v(-1, 1), 7 ) ); - var frontJoint = cp.grooveJointNew( chassis, front, grv_a, grv_b, cp.vzero ); - - // Create the front zero-length spring. - var front_anchor = cp.bodyWorld2Local( chassis, cp.bodyGetPos(front) ); - var frontSpring = cp.dampedSpringNew( chassis, front, front_anchor, cp.vzero, 0, FRONT_SPRING, FRONT_DAMPING ); - - // The rear strut is a swinging arm that holds the wheel a at a certain distance from a pivot on the chassis. - // A perfect fit for a pin joint conected between the chassis and the wheel's center. - var rearJoint = cp.pinJointNew( chassis, rear, cp.vsub( cp._v(-14,-8), COG_ADJUSTMENT), cp.vzero ); - - // return cpvtoangle(cpvsub([_chassis.body local2world:_rearJoint.anchr1], _rearWheel.body.pos)); - var rearStrutRestAngle = cp.vtoangle( cp.vsub( - cp.bodyLocal2World( chassis, cp.pinJointGetAnchr1(rearJoint) ), - cp.bodyGetPos(rear) ) ); - - // Create the rear zero-length spring. - var rear_anchor = cp.bodyWorld2Local( chassis, cp.bodyGetPos( rear ) ); - var rearSpring = cp.dampedSpringNew( chassis, rear, rear_anchor, cp.vzero, 0, REAR_SPRING, REAR_DAMPING ); - - // Attach a slide joint to the wheel to limit it's range of motion. - var rearStrutLimit = cp.slideJointNew( chassis, rear, rear_anchor, cp.vzero, 0, 20 ); - - // The main motor that drives the buggy. - var motor = cp.simpleMotorNew( chassis, rear, ENGINE_MAX_W ); - cp.constraintSetMaxForce( motor, 0.0 ); - - // I don't know if "differential" is the correct word, but it transfers a fraction of the rear torque to the front wheels. - // In case the rear wheels are slipping. This makes the buggy less frustrating when climbing steep hills. - var differential = cp.simpleMotorNew( rear, front, 0 ); - cp.constraintSetMaxForce( differential, ENGINE_MAX_TORQUE*DIFFERENTIAL_TORQUE ); - - // Wheel brakes. - // While you could reuse the main motor for the brakes, it's easier not to. - // It won't cause a performance issue to have too many extra motors unless you have hundreds of buggies in the game. - // Even then, the motor constraints would be the least of your performance worries. - var frontBrake = cp.simpleMotorNew( chassis, front, 0 ); - cp.constraintSetMaxForce( frontBrake, ROLLING_FRICTION ); - var rearBrake = cp.simpleMotorNew( chassis, rear, 0 ); - cp.constraintSetMaxForce( rearBrake, ROLLING_FRICTION ); - - cp.spaceAddConstraint(this._space, frontJoint ); - cp.spaceAddConstraint(this._space, rearJoint ); - cp.spaceAddConstraint(this._space, rearSpring ); - cp.spaceAddConstraint(this._space, motor ); - cp.spaceAddConstraint(this._space, differential ); - cp.spaceAddConstraint(this._space, frontBrake ); - cp.spaceAddConstraint(this._space, rearBrake ); - - this._motor = motor; - this._frontBrake = frontBrake; - this._rearBrake = rearBrake; - }, - - createWheel : function( pos ) { - var sprite = cc.ChipmunkSprite.createWithSpriteFrameName("Wheel.png"); - var radius = 0.95 * sprite.getContentSize().width / 2; - - var body = cp.bodyNew(WHEEL_MASS, cp.momentForCircle(WHEEL_MASS, 0, radius, cp.vzero ) ); - cp.bodySetPos( body, pos ); - sprite.setBody( body ); - - var shape = cp.circleShapeNew( body, radius, cp.vzero ); - cp.shapeSetFriction( shape, 1 ); - cp.shapeSetGroup( shape, GROUP_BUGGY ); - cp.shapeSetLayers( shape, COLLISION_LAYERS_BUGGY ); - cp.shapeSetCollisionType( shape, COLLISION_TYPE_CAR ); - - cp.spaceAddBody( this._space, body ); - cp.spaceAddShape( this._space, shape ); - this._batch.addChild( sprite, Z_WHEEL); - - return body; - }, - - createChassis : function(pos) { - var sprite = cc.ChipmunkSprite.createWithSpriteFrameName("Chassis.png"); - var anchor = cp.vadd( sprite.getAnchorPointInPoints(), COG_ADJUSTMENT ); - var cs = sprite.getContentSize(); - sprite.setAnchorPoint( cc.p(anchor.x / cs.width, anchor.y/cs.height) ); - - // XXX: Space Patrol uses a nice poly for the chassis. - // XXX: Add something similar here, instead of a boxed chassis - - var body = cp.bodyNew( CHASSIS_MASS, cp.momentForBox(CHASSIS_MASS, cs.width, cs.height ) ); - cp.bodySetPos( body, pos ); - sprite.setBody( body ); - - cp.spaceAddBody( this._space, body ); - this._batch.addChild( sprite, Z_CHASSIS ); - this._carSprite = sprite; - - // bottom of chassis - var shape = cp.boxShapeNew( body, cs.width, 15 ); - cp.shapeSetFriction(shape, 0.3); - cp.shapeSetGroup( shape, GROUP_BUGGY ); - cp.shapeSetLayers( shape, COLLISION_LAYERS_BUGGY ); - cp.shapeSetCollisionType( shape, COLLISION_TYPE_CAR ); - - cp.spaceAddShape( this._space, shape ); - - // box for fruits (left) - var shape = cp.boxShapeNew2( body, cp.bBNew(-50,0, -46,30) ); - cp.shapeSetFriction(shape, 0.3); - cp.shapeSetGroup( shape, GROUP_BUGGY ); - cp.shapeSetLayers( shape, COLLISION_LAYERS_BUGGY ); - cp.shapeSetCollisionType( shape, COLLISION_TYPE_CAR ); - cp.spaceAddShape( this._space, shape ); - - // box for fruits (right) - var shape = cp.boxShapeNew2( body, cp.bBNew(8,0, 12,30) ); - cp.shapeSetFriction(shape, 0.3); - cp.shapeSetGroup( shape, GROUP_BUGGY ); - cp.shapeSetLayers( shape, COLLISION_LAYERS_BUGGY ); - cp.shapeSetCollisionType( shape, COLLISION_TYPE_CAR ); - cp.spaceAddShape( this._space, shape ); - - return body; - }, - - createCarFruits : function(pos) { - // create some fruits - for(var i=0; i < 4;i++) { - var sprite = cc.ChipmunkSprite.createWithSpriteFrameName("watermelon.png"); - var radius = 0.95 * sprite.getContentSize().width / 2; - - var body = cp.bodyNew(WATERMELON_MASS, cp.momentForCircle(WATERMELON_MASS, 0, radius, cp.vzero) ); - cp.bodySetPos( body, pos ); - sprite.setBody( body ); - - var shape = cp.circleShapeNew( body, radius, cp.vzero ); - cp.shapeSetFriction( shape, 1 ); - cp.shapeSetCollisionType( shape, COLLISION_TYPE_WATERMELON); - - cp.spaceAddShape( this._space, shape ); - cp.spaceAddBody( this._space, body ); - this._batch.addChild( sprite, Z_WATERMELON ); - } - }, - - createCoin: function( pos ) { - // coins are static bodies and sensors - var sprite = cc.ChipmunkSprite.createWithSpriteFrameName("coin01.png"); - var radius = 0.95 * sprite.getContentSize().width / 2; - - var body = cp.bodyNew(1, 1); - cp.bodyInitStatic(body); - cp.bodySetPos( body, pos ); - sprite.setBody( body ); - - var shape = cp.circleShapeNew( body, radius, cp.vzero ); - cp.shapeSetFriction( shape, 1 ); - cp.shapeSetGroup( shape, GROUP_COIN ); - cp.shapeSetCollisionType( shape, COLLISION_TYPE_COIN ); - cp.shapeSetSensor( shape, true ); - - cp.spaceAddStaticShape( this._space, shape ); - this._batch.addChild( sprite, Z_COIN); - - var animation = cc.AnimationCache.getInstance().getAnimation("coin"); - var animate = cc.Animate.create(animation); - var repeat = cc.RepeatForever.create( animate ); - sprite.runAction( repeat ); - - // Needed for deletion - cp.bodySetUserData( body, sprite ); - - return body; - }, - - createFinish:function( pos ) { - var sprite = cc.ChipmunkSprite.createWithSpriteFrameName("farmers-market.png"); - var cs = sprite.getContentSize(); - var body = cp.bodyNew( 1, 1); - cp.bodyInitStatic( body ); - sprite.setBody( body ); - cp.bodySetPos( body, pos ); - - var shape = cp.boxShapeNew( body, cs.width, cs.height ); - cp.shapeSetCollisionType( shape, COLLISION_TYPE_FINISH ); - cp.shapeSetSensor( shape, true ); - - cp.spaceAddStaticShape( this._space, shape ); - this._batch.addChild( sprite, Z_FINISH); - }, - - createSegment: function( src, dst) { - var staticBody = cp.spaceGetStaticBody( this._space ); - var segment = cp.segmentShapeNew( staticBody, src, dst, 5 ); - cp.shapeSetElasticity(segment, 1); - cp.shapeSetFriction(segment, 1); - cp.shapeSetCollisionType(segment, COLLISION_TYPE_FLOOR); - cp.spaceAddStaticShape( this._space, segment ); - }, - - // - // Game State - // - - // call the 'deferred' option if you want to modify Chipmunk's state from a Chipmunk's callback - setGameStateDeferred: function( state ) { - this._deferredState = state; - }, - - setGameState: function( state ) { - if( state != this._state ) { - - if( state == STATE_GAME_OVER ) - this.displayGameOver(); - - else if (state == STATE_LEVEL_COMPLETE ) - this.displayLevelComplete(); - - this._state = state; - } - this._deferredState = null; - }, - - displayLevelComplete:function() { - - - if( this._level+1 < levels.length ) { - cc.MenuItemFont.setFontSize(16 * sizeRatio ); - var item1 = cc.MenuItemFont.create("Next Level", this, this.onNextLevel); - var menu = cc.Menu.create( item1 ); - menu.alignItemsVertically(); - this.addChild( menu, Z_DEBUG_MENU ); - menu.setPosition( cc._p( winSize.width/2, winSize.height/3 ) ); - - var legend = "LEVEL COMPLETE"; - } else { - cc.MenuItemFont.setFontSize(16 * sizeRatio ); - var item1 = cc.MenuItemFont.create("Main Menu", this, this.onMainMenu); - var menu = cc.Menu.create( item1 ); - menu.alignItemsVertically(); - this.addChild( menu, Z_DEBUG_MENU ); - menu.setPosition( cc._p( winSize.width/2, winSize.height/3 ) ); - - var legend = "GAME COMPLETE"; - } - - var label = cc.LabelBMFont.create(legend, "Abadi40.fnt" ); - label.setPosition( centerPos ); - label.setScale(0.2); - var sa = cc.ScaleTo.create(0.5, 1.05 ); - var sb1 = cc.ScaleTo.create(0.5, 1 ); - var sb2 = cc.ScaleTo.create(0.5, 1.05); - var seq = cc.Sequence.create( sb1, sb2 ); - var rep = cc.Repeat.create( seq, 1000 ); - var all = cc.Sequence.create( sa, rep ); - label.runAction( all ); - this.addChild( label, Z_LABEL ); - - this.enableEvents( false ); - this.enableCollisionEvents( false ); - - audioEngine.playEffect("LevelComplete.wav"); - }, - - displayGameOver:function() { - var label = cc.LabelBMFont.create("GAME OVER", "Abadi40.fnt" ); - label.setPosition( centerPos ); - this.addChild( label, Z_LABEL ); - label.setScale(0.2); - var sa = cc.ScaleTo.create(0.5, 1.05 ); - var sb1 = cc.ScaleTo.create(0.5, 1 ); - var sb2 = cc.ScaleTo.create(0.5, 1.05); - var seq = cc.Sequence.create( sb1, sb2 ); - var rep = cc.Repeat.create( seq, 1000 ); - var all = cc.Sequence.create( sa, rep ); - label.runAction( all ); - - this.enableEvents( false ); - this.enableCollisionEvents( false ); - - audioEngine.playEffect("GameOver.wav"); - - cc.MenuItemFont.setFontSize(16 * sizeRatio ); - var item1 = cc.MenuItemFont.create("Play Again", this, this.onRestart); - var item2 = cc.MenuItemFont.create("Main Menu", this, this.onMainMenu); - var menu = cc.Menu.create( item1, item2 ); - menu.alignItemsVertically(); - this.addChild( menu, Z_DEBUG_MENU ); - menu.setPosition( cc._p( winSize.width/2, winSize.height/3 ) ); - }, - - - // - // Helpers - // - enableEvents:function(enabled) { - var platform = __getPlatform(); - if( platform.substring(0,7) == 'desktop' ) { - this.setMouseEnabled( enabled ); - } else if( platform.substring(0,6) == 'mobile' ) { - this.setTouchEnabled( enabled ); - } - }, - - enableCollisionEvents:function(enabled) { - if( enabled ) { - // collision handler - cp.spaceAddCollisionHandler( this._space, COLLISION_TYPE_CAR, COLLISION_TYPE_COIN, this, this.onCollisionBeginCoin, null, null, null ); - cp.spaceAddCollisionHandler( this._space, COLLISION_TYPE_CAR, COLLISION_TYPE_FINISH, this, this.onCollisionBeginFinish, null, null, null ); - cp.spaceAddCollisionHandler( this._space, COLLISION_TYPE_FLOOR, COLLISION_TYPE_WATERMELON, this, this.onCollisionBeginWatermelon, null, null, null ); - } else { - cp.spaceRemoveCollisionHandler( this._space, COLLISION_TYPE_FLOOR, COLLISION_TYPE_WATERMELON ); - cp.spaceRemoveCollisionHandler( this._space, COLLISION_TYPE_COIN, COLLISION_TYPE_CAR ); - cp.spaceRemoveCollisionHandler( this._space, COLLISION_TYPE_FINISH, COLLISION_TYPE_CAR ); - } - }, - - -}); - -// -// Boot Layer -// -var BootLayer = cc.Layer.extend({ - - ctor:function () { - - var parent = new cc.Layer(); - __associateObjWithNative(this, parent); - this.init(); - - // music - audioEngine.playBackgroundMusic("game-music.mp3"); - audioEngine.preloadEffect("pickup_coin.wav"); - - var cache = cc.SpriteFrameCache.getInstance(); - cache.addSpriteFrames( "coins.plist" ); - }, - - onEnter:function() { - var scene = cc.Scene.create(); - var layer = new MenuLayer(); - scene.addChild( layer ); - director.replaceScene( scene ); - }, -}); - -// -// Main Menu -// -var MenuLayer = cc.Layer.extend({ - - ctor:function () { - - var parent = new cc.Layer(); - __associateObjWithNative(this, parent); - this.init(); - - // background - var node = cc.Reader.load("MainMenu.ccbi", this, winSize); - this.addChild( node ); - var label = node.getChildByTag( TITLE_TAG ); - var o = label.getChildByTag( 8 ); - - var a_delay = cc.DelayTime.create(6); - var a_tint = cc.TintTo.create( 0.5, 0, 255, 0 ); - var a_rotate = cc.RotateBy.create( 4, 360 ); - var a_rep = cc.Repeat.create( a_rotate, 1000 ); - var a_seq = cc.Sequence.create( a_delay, a_tint, a_delay.copy(), a_rep ); - o.runAction( a_seq ); - - }, - - onPlay:function( sender) { - var scene = cc.Scene.create(); - var layer = new GameLayer(0); - scene.addChild( layer ); - director.replaceScene( cc.TransitionFade.create(1, scene) ); - }, - - onOptions:function( sender) { - var scene = cc.Scene.create(); - var layer = new OptionsLayer(); - scene.addChild( layer ); - director.replaceScene( cc.TransitionFlipY.create(1, scene) ); - }, - - onAbout:function( sender ) { - var scene = cc.Scene.create(); - var layer = new AboutLayer(); - scene.addChild( layer ); - director.replaceScene( cc.TransitionZoomFlipY.create(1, scene) ); - }, -}); - -// -// About -// -var AboutLayer = cc.Layer.extend({ - - ctor:function () { - var parent = new cc.LayerGradient(); - __associateObjWithNative(this, parent); - this.init(); - - var about = cc.Reader.load("About.ccbi", this); - this.addChild( about ) - - var back = cc.MenuItemFont.create("Back", this, this.onBack ); - back.setColor( cc.BLACK ); - var menu = cc.Menu.create( back ); - this.addChild( menu ); - menu.alignItemsVertically(); - menu.setPosition( cc._p( winSize.width - 50, 50) ); - - }, - - onBack:function( sender) { - var scene = cc.Scene.create(); - var layer = new MenuLayer(); - scene.addChild( layer ); - director.replaceScene( cc.TransitionFlipX.create(1, scene) ); - }, -}); - -// -// Options -// -var OptionsLayer = cc.LayerGradient.extend({ - - ctor:function () { - var parent = new cc.LayerGradient(); - __associateObjWithNative(this, parent); - this.init(cc.c4b(0, 0, 0, 255), cc.c4b(255, 255, 255, 255)); - - var label1 = cc.LabelBMFont.create("MUSIC ON", "konqa32.fnt" ); - var item1 = cc.MenuItemLabel.create(label1); - var label2 = cc.LabelBMFont.create("MUSIC OFF", "konqa32.fnt" ); - var item2 = cc.MenuItemLabel.create(label2); - var toggle = cc.MenuItemToggle.create( item1, item2 ); - toggle.setCallback( this, this.onMusicToggle); - - var back = cc.MenuItemFont.create("Back", this, this.onBack ); - var menu = cc.Menu.create( toggle, back ); - this.addChild( menu ); - menu.alignItemsVertically(); - menu.setPosition( centerPos ); - }, - - onBack:function( sender) { - var scene = cc.Scene.create(); - var layer = new MenuLayer(); - scene.addChild( layer ); - director.replaceScene( cc.TransitionFlipX.create(1, scene) ); - }, - - onMusicToggle:function( sender ) { - // music - if ( audioEngine.isBackgroundMusicPlaying() ) { - audioEngine.stopBackgroundMusic(); - } else { - audioEngine.playBackgroundMusic("game-music.mp3"); - } - }, -}); - -//------------------------------------------------------------------ -// -// Main entry point -// -//------------------------------------------------------------------ -function run() -{ - // update globals - winSize = director.getWinSize(); - centerPos = cc.p( winSize.width/2, winSize.height/2 ); - - var scene = cc.Scene.create(); - - // main menu - var menu = new BootLayer(); - scene.addChild( menu); - - var runningScene = director.getRunningScene(); - if( runningScene == null ) - director.runWithScene( scene ); - else - director.replaceScene( cc.TransitionFade.create(0.5, scene ) ); -} - -run(); - diff --git a/samples/TestJavascript/Resources/js/helper.js b/samples/TestJavascript/Resources/js/helper.js deleted file mode 100644 index fe10283c49..0000000000 --- a/samples/TestJavascript/Resources/js/helper.js +++ /dev/null @@ -1,437 +0,0 @@ -// cocos2d Helper - -cc.c3 = cc.c3 || function (r, g, b) { - return {r: r, g: g, b: b}; -}; - -cc.c3b = cc.c3; - -cc.c4 = cc.c4 || function (r, g, b, o) { - return {r: r, g: g, b: b, a: o}; -}; - -cc.c4b = cc.c4; - -cc.c4f = cc.c4f || function (r, g, b, o) { - return {r: r, g: g, b: b, a: o}; -}; - -cc.p = cc.p || function( x, y ) -{ - return {x:x, y:y}; -}; - -cc.g = cc.g || cc.p; -cc.log = cc.log || log; - -// -// cocos2d constants -// -cc.TEXTURE_PIXELFORMAT_RGBA8888 = 0; -cc.TEXTURE_PIXELFORMAT_RGB888 = 1; -cc.TEXTURE_PIXELFORMAT_RGB565 = 2; -cc.TEXTURE_PIXELFORMAT_A8 = 3; -cc.TEXTURE_PIXELFORMAT_I8 = 4; -cc.TEXTURE_PIXELFORMAT_AI88 = 5; -cc.TEXTURE_PIXELFORMAT_RGBA4444 = 6; -cc.TEXTURE_PIXELFORMAT_RGB5A1 = 7; -cc.TEXTURE_PIXELFORMAT_PVRTC4 = 8; -cc.TEXTURE_PIXELFORMAT_PVRTC4 = 9; -cc.TEXTURE_PIXELFORMAT_DEFAULT = cc.TEXTURE_PIXELFORMAT_RGBA8888; - -cc.TEXT_ALIGNMENT_LEFT = 0; -cc.TEXT_ALIGNMENT_CENTER = 1; -cc.TEXT_ALIGNMENT_RIGHT = 2; - -cc.VERTICAL_TEXT_ALIGNMENT_TOP = 0; -cc.VERTICAL_TEXT_ALIGNMENT_CENTER = 1; -cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM = 2; - -cc.IMAGE_FORMAT_JPEG = 0; -cc.IMAGE_FORMAT_PNG = 0; - -cc.PROGRESS_TIMER_TYPE_RADIAL = 0; -cc.PROGRESS_TIMER_TYPE_BAR = 1; - -cc.PARTICLE_TYPE_FREE = 0; -cc.PARTICLE_TYPE_RELATIVE = 1; -cc.PARTICLE_TYPE_GROUPED = 2; -cc.PARTICLE_DURATION_INFINITY = -1; -cc.PARTICLE_MODE_GRAVITY = 0; -cc.PARTICLE_MODE_RADIUS = 1; -cc.PARTICLE_START_SIZE_EQUAL_TO_END_SIZE = -1; -cc.PARTICLE_START_RADIUS_EQUAL_TO_END_RADIUS = -1; - -cc.RED = cc.c3(255,0,0); -cc.GREEN = cc.c3(0,255,0); -cc.BLUE = cc.c3(0,0,255); -cc.BLACK = cc.c3(0,0,0); -cc.WHITE = cc.c3(255,255,255); - -cc.POINT_ZERO = {x:0, y:0}; - -cc._reuse_p0 = {x:0, y:0}; -cc._reuse_p1 = {x:0, y:0}; -cc._reuse_p_index = 0; -cc._reuse_color3b = cc.c3(255, 255, 255 ); -cc._reuse_color4b = cc.c4(255, 255, 255, 255 ); -cc._reuse_grid = cc.g(0,0); - -// dump config info, but only in debug mode -cc.dumpConfig = function() -{ - if( cc.config.debug ) { - for(var i in cc.config) - cc.log( i + " = " + cc.config[i] ); - } -}; - -// -// Point -// -cc._p = function( x, y ) -{ - if( cc._reuse_p_index === 0 ) { - cc._reuse_p0.x = x; - cc._reuse_p0.y = y; - cc._reuse_p_index = 1; - return cc._reuse_p0; - } else { - cc._reuse_p1.x = x; - cc._reuse_p1.y = y; - cc._reuse_p_index = 0; - return cc._reuse_p1; - } -}; - -cc._to_p = function( point ) -{ - return point; -}; - -cc._from_p = function( size ) -{ - return size; -}; - -// -// Grid -// -cc._g = function( x, y ) -{ - cc._reuse_grid.x = x; - cc._reuse_grid.y = y; - return cc._reuse_grid; -} - -// -// Color -// -// -// Color 3B -// -cc.c3b = function( r, g, b ) -{ - return {r:r, g:g, b:b }; -}; -cc._c3b = function( r, g, b ) -{ - cc._reuse_color3b.r = r; - cc._reuse_color3b.g = g; - cc._reuse_color3b.b = b; - return cc._reuse_color3b; -}; -// compatibility -cc.c3 = cc.c3b; -cc._c3 = cc._c3b; - -// -// Color 4B -// -cc.c4b = function( r, g, b, a ) -{ - return {r:r, g:g, b:b, a:a }; -}; -cc._c4b = function( r, g, b, a ) -{ - cc._reuse_color4b.r = r; - cc._reuse_color4b.g = g; - cc._reuse_color4b.b = b; - cc._reuse_color4b.a = a; - return cc._reuse_color4b; -}; -// compatibility -cc.c4 = cc.c4b; -cc._c4 = cc._c4b; - - -// -// Size -// -cc.size = function(w,h) -{ - return {width:w, height:h}; -} - -cc._to_size = function( size ) -{ - return size; -} - -cc._from_size = function( size ) -{ - return size; -} - -// -// Rect -// -cc.rect = function(x,y,w,h) -{ - return {x:x, y:y, width:w, height:h}; -} - -cc._to_rect = function( rect ) -{ - return rect; -} - -cc._from_rect = function( rect ) -{ - return rect; -} - -// XXX Should be done in native -cc.rectIntersectsRect = function( rectA, rectB ) -{ - var bool = ! ( rectA.x > rectB.x + rectB.width || - rectA.x + rectA.width < rectB.x || - rectA.y > rectB.y +rectB.height || - rectA.y + rectA.height < rectB.y ); - - return bool; -} - -// point functions -cc.pAdd = cc.pAdd || function (p1, p2) { - return {x: p1.x + p2.x, y: p1.y + p2.y}; -}; - -cc.pSub = cc.pSub || function (p1, p2) { - return {x: p1.x - p2.x, y: p1.y - p2.y}; -} - -cc.pMult = cc.pMult || function (p1, s) { - return {x: p1.x * s, y: p1.y * s}; -}; - -/** - * Calculates dot product of two points. - * @param {cc.Point} v1 - * @param {cc.Point} v2 - * @return {Number} - */ -cc.pDot = function (v1, v2) { - return v1.x * v2.x + v1.y * v2.y; -}; - -/** - * Calculates the square length of a cc.Point (not calling sqrt() ) - * @param {cc.Point} v - *@return {cc.pDot} - */ -cc.pLengthSQ = function (v) { - return cc.pDot(v, v); -}; - -/** - * Calculates distance between point an origin - * @param {cc.Point} v - * @return {Number} - */ -cc.pLength = function (v) { - return Math.sqrt(cc.pLengthSQ(v)); -}; - -/** - * Calculates the distance between two points - * @param {cc.Point} v1 - * @param {cc.Point} v2 - * @return {cc.pLength} - */ -cc.pDistance = function (v1, v2) { - return cc.pLength(cc.pSub(v1, v2)); -}; - -/** - * returns a random float between 0 and 1 - * @return {Number} - * @function - */ -cc.RANDOM_0_1 = function () { - return Math.random(); -}; - - -// -// Array: for cocos2d-hmtl5 compatibility -// -cc.ArrayRemoveObject = function (arr, delObj) { - for (var i = 0; i < arr.length; i++) { - if (arr[i] == delObj) { - arr.splice(i, 1); - } - } -}; - -// -// Google "subclasses" -// borrowed from closure library -// -var goog = goog || {}; // Check to see if already defined in current scope -goog.inherits = function (childCtor, parentCtor) { - /** @constructor */ - function tempCtor() {}; - tempCtor.prototype = parentCtor.prototype; - childCtor.superClass_ = parentCtor.prototype; - childCtor.prototype = new tempCtor(); - childCtor.prototype.constructor = childCtor; - - // Copy "static" method, but doesn't generate subclasses. -// for( var i in parentCtor ) { -// childCtor[ i ] = parentCtor[ i ]; -// } -}; -goog.base = function(me, opt_methodName, var_args) { - var caller = arguments.callee.caller; - if (caller.superClass_) { - // This is a constructor. Call the superclass constructor. - ret = caller.superClass_.constructor.apply( me, Array.prototype.slice.call(arguments, 1)); - - // XXX: SpiderMonkey bindings extensions -// __associateObjWithNative( me, ret ); - return ret; - } - - var args = Array.prototype.slice.call(arguments, 2); - var foundCaller = false; - for (var ctor = me.constructor; - ctor; ctor = ctor.superClass_ && ctor.superClass_.constructor) { - if (ctor.prototype[opt_methodName] === caller) { - foundCaller = true; - } else if (foundCaller) { - return ctor.prototype[opt_methodName].apply(me, args); - } - } - - // If we did not find the caller in the prototype chain, - // then one of two things happened: - // 1) The caller is an instance method. - // 2) This method was not called by the right caller. - if (me[opt_methodName] === caller) { - return me.constructor.prototype[opt_methodName].apply(me, args); - } else { - throw Error( - 'goog.base called from a method of one name ' + - 'to a method of a different name'); - } -}; - - -// -// Simple subclass -// - -cc.Class = function(){}; - -cc.Class.extend = function (prop) { - var _super = this.prototype; - - // Instantiate a base class (but only create the instance, - // don't run the init constructor) - initializing = true; - var prototype = new this(); - initializing = false; - fnTest = /xyz/.test(function(){xyz;}) ? /\b_super\b/ : /.*/; - - // Copy the properties over onto the new prototype - for (var name in prop) { - // Check if we're overwriting an existing function - prototype[name] = typeof prop[name] == "function" && - typeof _super[name] == "function" && fnTest.test(prop[name]) ? - (function (name, fn) { - return function () { - var tmp = this._super; - - // Add a new ._super() method that is the same method - // but on the super-class - this._super = _super[name]; - - // The method only need to be bound temporarily, so we - // remove it when we're done executing - var ret = fn.apply(this, arguments); - this._super = tmp; - - return ret; - }; - })(name, prop[name]) : - prop[name]; - } - - // The dummy class constructor - function Class() { - // All construction is actually done in the init method - if (!initializing && this.ctor) - this.ctor.apply(this, arguments); - } - - // Populate our constructed prototype object - Class.prototype = prototype; - - // Enforce the constructor to be what we expect - Class.prototype.constructor = Class; - - // And make this class extendable - Class.extend = arguments.callee; - - return Class; -}; - -cc.Layer.extend = cc.Class.extend; -cc.Scene.extend = cc.Class.extend; -cc.LayerGradient.extend = cc.Class.extend; -cc.Sprite.extend = cc.Class.extend; -cc.MenuItemFont.extend = cc.Class.extend; - -// -// Chipmunk helpers -// -var cp = cp || {}; - -cp.v = cc.p; -cp._v = cc._p; -cp.vzero = cp.v(0,0); - -// -// OpenGL Helpers -// -var gl = gl || {}; -gl.NEAREST = 0x2600; -gl.LINEAR = 0x2601; -gl.REPEAT = 0x2901; -gl.CLAMP_TO_EDGE = 0x812F; -gl.CLAMP_TO_BORDER = 0x812D; -gl.LINEAR_MIPMAP_NEAREST = 0x2701; -gl.NEAREST_MIPMAP_NEAREST = 0x2700; -gl.ZERO = 0; -gl.ONE = 1; -gl.SRC_COLOR = 0x0300; -gl.ONE_MINUS_SRC_COLOR = 0x0301; -gl.SRC_ALPHA = 0x0302; -gl.ONE_MINUS_SRC_ALPHA = 0x0303; -gl.DST_ALPHA = 0x0304; -gl.ONE_MINUS_DST_ALPHA = 0x0305; -gl.DST_COLOR = 0x0306; -gl.ONE_MINUS_DST_COLOR = 0x0307; -gl.SRC_ALPHA_SATURATE = 0x0308; - diff --git a/samples/TestJavascript/Resources/js/helper.old.js b/samples/TestJavascript/Resources/js/helper.old.js deleted file mode 100644 index 7d5465a25c..0000000000 --- a/samples/TestJavascript/Resources/js/helper.old.js +++ /dev/null @@ -1,361 +0,0 @@ -// cocos2d Helper - -// -// cocos2d constants -// -cc.TEXTURE_PIXELFORMAT_RGBA8888 = 0; -cc.TEXTURE_PIXELFORMAT_RGB888 = 1; -cc.TEXTURE_PIXELFORMAT_RGB565 = 2; -cc.TEXTURE_PIXELFORMAT_A8 = 3; -cc.TEXTURE_PIXELFORMAT_I8 = 4; -cc.TEXTURE_PIXELFORMAT_AI88 = 5; -cc.TEXTURE_PIXELFORMAT_RGBA4444 = 6; -cc.TEXTURE_PIXELFORMAT_RGB5A1 = 7; -cc.TEXTURE_PIXELFORMAT_PVRTC4 = 8; -cc.TEXTURE_PIXELFORMAT_PVRTC4 = 9; -cc.TEXTURE_PIXELFORMAT_DEFAULT = cc.TEXTURE_PIXELFORMAT_RGBA8888; - -cc.TEXT_ALIGNMENT_LEFT = 0; -cc.TEXT_ALIGNMENT_CENTER = 1; -cc.TEXT_ALIGNMENT_RIGHT = 2; - -cc.VERTICAL_TEXT_ALIGNMENT_TOP = 0; -cc.VERTICAL_TEXT_ALIGNMENT_CENTER = 1; -cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM = 2; - -cc.IMAGE_FORMAT_JPEG = 0; -cc.IMAGE_FORMAT_PNG = 0; - -cc.PROGRESS_TIMER_TYPE_RADIAL = 0; -cc.PROGRESS_TIMER_TYPE_BAR = 1; - -cc.PARTICLE_TYPE_FREE = 0; -cc.PARTICLE_TYPE_RELATIVE = 1; -cc.PARTICLE_TYPE_GROUPED = 2; -cc.PARTICLE_DURATION_INFINITY = -1; -cc.PARTICLE_MODE_GRAVITY = 0; -cc.PARTICLE_MODE_RADIUS = 1; -cc.PARTICLE_START_SIZE_EQUAL_TO_END_SIZE = -1; -cc.PARTICLE_START_RADIUS_EQUAL_TO_END_RADIUS = -1; - -cc.RED = cc.c3(255,0,0); -cc.GREEN = cc.c3(0,255,0); -cc.BLUE = cc.c3(0,0,255); -cc.BLACK = cc.c3(0,0,0); -cc.WHITE = cc.c3(255,255,255); - -cc.POINT_ZERO = {x:0, y:0}; - -cc._reuse_p0 = {x:0, y:0}; -cc._reuse_p1 = {x:0, y:0}; -cc._reuse_p_index = 0; -cc._reuse_color3b = cc.c3(255, 255, 255 ); -cc._reuse_color4b = cc.c4(255, 255, 255, 255 ); -cc._reuse_grid = cc.g(0,0); - -// dump config info, but only in debug mode -cc.dumpConfig = function() -{ - if( cc.config.debug ) { - for( i in cc.config ) - cc.log( i + " = " + cc.config[i] ); - } -}; - -// -// Point -// -cc.p = function( x, y ) -{ - return {x:x, y:y}; -}; - -cc._p = function( x, y ) -{ - if( cc._reuse_p_index === 0 ) { - cc._reuse_p0.x = x; - cc._reuse_p0.y = y; - cc._reuse_p_index = 1; - return cc._reuse_p0; - } else { - cc._reuse_p1.x = x; - cc._reuse_p1.y = y; - cc._reuse_p_index = 0; - return cc._reuse_p1; - } -}; - -cc._to_p = function( point ) -{ - return point; -}; - -cc._from_p = function( size ) -{ - return size; -}; - -cc.c3 = function (r, g, b) { - var tmp = new Uint8Array(3); - tmp[0] = r; - tmp[1] = g; - tmp[2] = b; - return tmp; -}; - -cc.c4 = function (r, g, b, o) { - var tmp = new Uint8Array(4); - tmp[0] = r; - tmp[1] = g; - tmp[2] = b; - tmp[3] = o; - return tmp; -}; - -cc.c4f = function (r, g, b, o) { - var tmp = new Float32Array(4); - tmp[0] = r; - tmp[1] = g; - tmp[2] = b; - tmp[3] = o; - return tmp; -}; - -// -// Grid -// -cc._g = function( x, y ) -{ - cc._reuse_grid.x = x; - cc._reuse_grid.y = y; - return cc._reuse_grid; -} - -// -// Color -// -cc._c3 = function( r, g, b ) -{ - cc._reuse_color3b[0] = r; - cc._reuse_color3b[1] = g; - cc._reuse_color3b[2] = b; - return cc._reuse_color3b; -} - -cc._c4 = function( r, g, b, a ) -{ - cc._reuse_color4b[0] = r; - cc._reuse_color4b[1] = g; - cc._reuse_color4b[2] = b; - cc._reuse_color4b[3] = a; - return cc._reuse_color4b; -} - -// -// Size -// -cc.size = function(w,h) -{ - return {width:w, height:h}; -} - -cc._to_size = function( size ) -{ - return size; -} - -cc._from_size = function( size ) -{ - return size; -} - -// -// Rect -// -cc.rect = function(x,y,w,h) -{ - return {x:x, y:y, width:w, height:h}; -} - -cc._to_rect = function( rect ) -{ - return rect; -} - -cc._from_rect = function( rect ) -{ - return rect; -} - -// XXX Should be done in native -cc.rectIntersectsRect = function( rectA, rectB ) -{ - var bool = ! ( rectA.x > rectB.x + rectB.width || - rectA.x + rectA.width < rectB.x || - rectA.y > rectB.y +rectB.height || - rectA.y + rectA.height < rectB.y ); - - return bool; -} - -// -// Array: for cocos2d-hmtl5 compatibility -// -cc.ArrayRemoveObject = function (arr, delObj) { - for (var i = 0; i < arr.length; i++) { - if (arr[i] == delObj) { - arr.splice(i, 1); - } - } -}; - -// -// Google "subclasses" -// borrowed from closure library -// -var goog = goog || {}; // Check to see if already defined in current scope -goog.inherits = function (childCtor, parentCtor) { - /** @constructor */ - function tempCtor() {}; - tempCtor.prototype = parentCtor.prototype; - childCtor.superClass_ = parentCtor.prototype; - childCtor.prototype = new tempCtor(); - childCtor.prototype.constructor = childCtor; - - // Copy "static" method, but doesn't generate subclasses. -// for( var i in parentCtor ) { -// childCtor[ i ] = parentCtor[ i ]; -// } -}; -goog.base = function(me, opt_methodName, var_args) { - var caller = arguments.callee.caller; - if (caller.superClass_) { - // This is a constructor. Call the superclass constructor. - ret = caller.superClass_.constructor.apply( me, Array.prototype.slice.call(arguments, 1)); - - // XXX: SpiderMonkey bindings extensions -// __associateObjWithNative( me, ret ); - return ret; - } - - var args = Array.prototype.slice.call(arguments, 2); - var foundCaller = false; - for (var ctor = me.constructor; - ctor; ctor = ctor.superClass_ && ctor.superClass_.constructor) { - if (ctor.prototype[opt_methodName] === caller) { - foundCaller = true; - } else if (foundCaller) { - return ctor.prototype[opt_methodName].apply(me, args); - } - } - - // If we did not find the caller in the prototype chain, - // then one of two things happened: - // 1) The caller is an instance method. - // 2) This method was not called by the right caller. - if (me[opt_methodName] === caller) { - return me.constructor.prototype[opt_methodName].apply(me, args); - } else { - throw Error( - 'goog.base called from a method of one name ' + - 'to a method of a different name'); - } -}; - - -// -// Simple subclass -// - -cc.Class = function(){}; - -cc.Class.extend = function (prop) { - var _super = this.prototype; - - // Instantiate a base class (but only create the instance, - // don't run the init constructor) - initializing = true; - var prototype = new this(); - initializing = false; - fnTest = /xyz/.test(function(){xyz;}) ? /\b_super\b/ : /.*/; - - // Copy the properties over onto the new prototype - for (var name in prop) { - // Check if we're overwriting an existing function - prototype[name] = typeof prop[name] == "function" && - typeof _super[name] == "function" && fnTest.test(prop[name]) ? - (function (name, fn) { - return function () { - var tmp = this._super; - - // Add a new ._super() method that is the same method - // but on the super-class - this._super = _super[name]; - - // The method only need to be bound temporarily, so we - // remove it when we're done executing - var ret = fn.apply(this, arguments); - this._super = tmp; - - return ret; - }; - })(name, prop[name]) : - prop[name]; - } - - // The dummy class constructor - function Class() { - // All construction is actually done in the init method - if (!initializing && this.ctor) - this.ctor.apply(this, arguments); - } - - // Populate our constructed prototype object - Class.prototype = prototype; - - // Enforce the constructor to be what we expect - Class.prototype.constructor = Class; - - // And make this class extendable - Class.extend = arguments.callee; - - return Class; -}; - -cc.Layer.extend = cc.Class.extend; -cc.LayerGradient.extend = cc.Class.extend; -cc.Sprite.extend = cc.Class.extend; -cc.MenuItemFont.extend = cc.Class.extend; - -// -// Chipmunk helpers -// -//var cp = cp || {}; - -cp.v = cc.p; -cp._v = cc._p; -cp.vzero = cp.v(0,0); - -// -// OpenGL Helpers -// -var gl = gl || {}; -gl.NEAREST = 0x2600; -gl.LINEAR = 0x2601; -gl.REPEAT = 0x2901; -gl.CLAMP_TO_EDGE = 0x812F; -gl.CLAMP_TO_BORDER = 0x812D; -gl.LINEAR_MIPMAP_NEAREST = 0x2701; -gl.NEAREST_MIPMAP_NEAREST = 0x2700; -gl.ZERO = 0; -gl.ONE = 1; -gl.SRC_COLOR = 0x0300; -gl.ONE_MINUS_SRC_COLOR = 0x0301; -gl.SRC_ALPHA = 0x0302; -gl.ONE_MINUS_SRC_ALPHA = 0x0303; -gl.DST_ALPHA = 0x0304; -gl.ONE_MINUS_DST_ALPHA = 0x0305; -gl.DST_COLOR = 0x0306; -gl.ONE_MINUS_DST_COLOR = 0x0307; -gl.SRC_ALPHA_SATURATE = 0x0308; - diff --git a/samples/TestJavascript/Resources/js/main.js b/samples/TestJavascript/Resources/js/main.js deleted file mode 100644 index 27f4bf326f..0000000000 --- a/samples/TestJavascript/Resources/js/main.js +++ /dev/null @@ -1,219 +0,0 @@ -// -// http://www.cocos2d-iphone.org -// http://www.cocos2d-html5.org -// http://www.cocos2d-x.org -// -// Javascript + cocos2d actions tests -// - -require("js/helper.js"); - -director = cc.Director.getInstance(); -winSize = director.getWinSize(); -centerPos = cc.p( winSize.width/2, winSize.height/2 ); - -scenes = [] -currentScene = 0; - -nextScene = function () { - currentScene = currentScene + 1; - if( currentScene >= scenes.length ) - currentScene = 0; - - withTransition = true; - loadScene(currentScene); -}; - -previousScene = function () { - currentScene = currentScene -1; - if( currentScene < 0 ) - currentScene = scenes.length -1; - - withTransition = true; - loadScene(currentScene); -}; - -restartScene = function () { - loadScene( currentScene ); -}; - -loadScene = function (sceneIdx) -{ - winSize = director.getWinSize(); - centerPos = cc.p( winSize.width/2, winSize.height/2 ); - - var scene = new cc.Scene(); - scene.init(); - var layer = new scenes[ sceneIdx ](); - - scene.addChild( layer ); - -// scene.walkSceneGraph(0); - - director.replaceScene( scene ); -// __jsc__.garbageCollect(); -} - - - -// -// Base Layer -// - -BaseLayer = cc.LayerGradient.extend({ - - ctor:function () { - - var parent = new cc.LayerGradient(); - __associateObjWithNative(this, parent); - this.init(cc.c4b(0, 0, 0, 255), cc.c4b(0, 128, 255, 255)); - }, - - title:function () { - return "No Title"; - }, - - subtitle:function () { - return ""; - }, - - code:function () { - return ""; - }, - - restartCallback:function (sender) { - restartScene(); - }, - - nextCallback:function (sender) { - nextScene(); - }, - - backCallback:function (sender) { - previousScene(); - }, - - onEnter:function () { - // DO NOT CALL this._super() -// this._super(); - - // add title and subtitle - var label = cc.LabelTTF.create(this.title(), "Arial", 28); - this.addChild(label, 1); - label.setPosition( cc.p(winSize.width / 2, winSize.height - 40)); - - var strSubtitle = this.subtitle(); - if (strSubtitle != "") { - var l = cc.LabelTTF.create(strSubtitle, "Thonburi", 16); - this.addChild(l, 1); - l.setPosition( cc.p(winSize.width / 2, winSize.height - 70)); - } - - var strCode = this.code(); - if( strCode !="" ) { - var label = cc.LabelTTF.create(strCode, 'CourierNewPSMT', 16); - label.setPosition( cc.p( winSize.width/2, winSize.height-120) ); - this.addChild( label,10 ); - - var labelbg = cc.LabelTTF.create(strCode, 'CourierNewPSMT', 16); - labelbg.setColor( cc.c3b(10,10,255) ); - labelbg.setPosition( cc.p( winSize.width/2 +1, winSize.height-120 -1) ); - this.addChild( labelbg,9); - } - } -}); - - -//------------------------------------------------------------------ -// -// MainTest -// -//------------------------------------------------------------------ -MainTest = BaseLayer.extend({ - - _menu : null, - - onEnter:function () { - this._super(); - - cc.MenuItemFont.setFontSize(24); - var item1 = cc.MenuItemFont.create("Actions: Basic Tests", this, function() { require("js/test-actions.js"); } ); - var item2 = cc.MenuItemFont.create("Actions: Ease Tests", this, function() { require("js/test-easeactions.js"); } ); - var item3 = cc.MenuItemFont.create("Actions: Progress Tests", this, function() { require("js/test-actionsprogress.js"); } ); - var item4 = cc.MenuItemFont.create("Chipmunk Tests", this, function() { require("js/test-chipmunk.js"); } ); - var item5 = cc.MenuItemFont.create("Effects Tests", this, function() { require("js/test-effects.js"); } ); - var item6 = cc.MenuItemFont.create("Label Tests", this, function() { require("js/test-label.js"); } ); - var item7 = cc.MenuItemFont.create("Menu Tests", this, function() { require("js/test-menu.js"); } ); - var item8 = cc.MenuItemFont.create("Parallax Tests", this, function() { require("js/test-parallax.js"); } ); - var item9 = cc.MenuItemFont.create("Particle Tests", this, function() { require("js/test-particles.js"); } ); - var item10 = cc.MenuItemFont.create("RenderTexture Tests", this, function() { require("js/test-rendertexture.js"); } ); - var item11 = cc.MenuItemFont.create("Sprite Tests", this, function() { require("js/test-sprite.js"); } ); - var item12 = cc.MenuItemFont.create("Tilemap Tests", this, function() { require("js/test-tilemap.js"); } ); - var item13 = cc.MenuItemFont.create("CocosDenshion Tests", this, function() { require("js/test-cocosdenshion.js"); } ); - var item14 = cc.MenuItemFont.create("cocos2d presentation", this, function() { require("js/test-cocos2djs.js"); } ); - var item14 = cc.MenuItemFont.create("Performance test", this, function() { require("js/PerformanceTest/PerformanceTest.js"); } ); - - - this._menu = cc.Menu.create( item1, item2, item3, item4, item5, item6, item7, item8, item9, item10, item11, item12, item13, item14 ); - this._menu.alignItemsVertically(); - - this._menu.setPosition( cc.p( winSize.width/2, winSize.height/2) ); - - this.addChild( this._menu ); - - var platform = __getPlatform(); - if( platform.substring(0,7) == 'desktop' ) - this.setMouseEnabled( true ); - else if( platform.substring(0,6) == 'mobile' ) - this.setTouchEnabled( true ); - }, - - onTouchesMoved:function (touches, event) { - var delta = touches[0].getDelta(); - var current = this._menu.getPosition(); - this._menu.setPosition( cc.p( current.x, current.y + delta.y ) ); - return true; - }, - - onMouseDragged : function( event ) { - var delta = event.getDelta(); - var current = this._menu.getPosition(); - this._menu.setPosition( cc.p( current.x, current.y + delta.y ) ); - return true; - }, - - title:function () { - return "Javascript tests"; - }, - -}); - - -// -// Order of tests -// - -scenes.push( MainTest); - -//------------------------------------------------------------------ -// -// Main entry point -// -//------------------------------------------------------------------ -function run() -{ - var scene = cc.Scene.create(); - var layer = new scenes[currentScene](); - scene.addChild( layer ); - - var runningScene = director.getRunningScene(); - if( runningScene == null ) - director.runWithScene( scene ); - else - director.replaceScene( cc.TransitionSplitCols.create(1, scene ) ); - - director.setDisplayStats(true); -} - -run(); - diff --git a/samples/TestJavascript/Resources/js/old/main.js b/samples/TestJavascript/Resources/js/old/main.js deleted file mode 100644 index 8268bf1250..0000000000 --- a/samples/TestJavascript/Resources/js/old/main.js +++ /dev/null @@ -1,47 +0,0 @@ -require("js/helper.js"); - -var randColorComp = function () { - return Math.round(Math.random() * 255); -}; - -var director = cc.Director.getInstance(); -var audioEngine = cc.AudioEngine.getInstance(); -var _winSize = director.getWinSize(); -var winSize = {width:_winSize[0], height:_winSize[1]}; - -log("size: " + winSize.width + "," + winSize.height); - -var scene = cc.Scene.create(); -var layer = cc.LayerGradient.create(cc.c4(0, 0, 0, 255), cc.c4(0, 128, 255, 255)); -scene.addChild(layer, 0, 1337); - -for (var i=0; i < 30; i++) { - var sprite = cc.Sprite.create("Icon.png"); - var pos = cc.p(Math.random() * winSize.width, Math.random() * winSize.height); - sprite.setPosition(pos); - sprite.setColor(cc.c3(randColorComp(), randColorComp(), randColorComp())); - layer.addChild(sprite); -} - -var menu = cc.Menu.create(); -var label = cc.LabelTTF.create("Testing Label TTF", "Arial", 20.0); -label.func = function () { - log("menu action from label " + this); -} -var item = cc.MenuItemLabel.create(label, menu, label.func); -menu.addChild(item); -menu.setPosition(cc.p(winSize.width / 2, winSize.height / 2)); - -var touch = new cc.Touch(); -var pt = touch.locationInView(); -log("touch: " + touch.x + "," + touch.y); - -layer.addChild(menu); - -//audioEngine.setBackgroundMusicVolume(0.5); -//audioEngine.playBackgroundMusic("bgmusic.mp3", true); - -var testLayer = scene.getChildByTag(1337); -log("layer == testLayer: " + (layer == testLayer)); - -director.runWithScene(scene); diff --git a/samples/TestJavascript/Resources/js/old/main2.js b/samples/TestJavascript/Resources/js/old/main2.js deleted file mode 100644 index e41e22fc70..0000000000 --- a/samples/TestJavascript/Resources/js/old/main2.js +++ /dev/null @@ -1,227 +0,0 @@ -// -// http://www.cocos2d-iphone.org -// http://www.cocos2d-html5.org -// http://www.cocos2d-x.org -// -// Javascript + cocos2d actions tests -// - -require("js/helpers.js"); - -director = cc.Director.sharedDirector(); -_winSize = director.getWinSize(); -winSize = {width:_winSize[0], height:_winSize[1]}; -centerPos = cc.p( winSize.width/2, winSize.height/2 ); - -scenes = [] -currentScene = 0; - -cc.log("main2.js:1"); - -nextScene = function () { - currentScene = currentScene + 1; - if( currentScene >= scenes.length ) - currentScene = 0; - - withTransition = true; - loadScene(currentScene); -}; - -previousScene = function () { - currentScene = currentScene -1; - if( currentScene < 0 ) - currentScene = scenes.length -1; - - withTransition = true; - loadScene(currentScene); -}; - -restartScene = function () { - loadScene( currentScene ); -}; - -loadScene = function (sceneIdx) -{ - _winSize = director.getWinSize(); - winSize = {width:_winSize[0], height:_winSize[1]}; - centerPos = cc.p( winSize.width/2, winSize.height/2 ); - - var scene = new cc.Scene(); - scene.init(); - var layer = new scenes[ sceneIdx ](); - - scene.addChild( layer ); - -// scene.walkSceneGraph(0); - - director.replaceScene( scene ); -// __jsc__.garbageCollect(); -} - - -cc.log("main2.js:2"); - -// -// Base Layer -// - -BaseLayer = cc.LayerGradient.extend({ - - ctor:function () { - - var parent = new cc.LayerGradient(); - __associateObjWithNative(this, parent); - this.init(cc.c4(0, 0, 0, 255), cc.c4(0, 128, 255, 255)); - }, - - title:function () { - return "No Title"; - }, - - subtitle:function () { - return ""; - }, - - code:function () { - return ""; - }, - - restartCallback:function (sender) { - restartScene(); - }, - - nextCallback:function (sender) { - nextScene(); - }, - - backCallback:function (sender) { - previousScene(); - }, - - onEnter:function () { - // DO NOT CALL this._super() -// this._super(); - cc.log("baselayer.onenter"); - // add title and subtitle - var label = cc.LabelTTF.create(this.title(), "Arial", 28); - this.addChild(label, 1); - label.setPosition( cc.p(winSize.width / 2, winSize.height - 40)); - - var strSubtitle = this.subtitle(); - if (strSubtitle != "") { - var l = cc.LabelTTF.create(strSubtitle, "Thonburi", 16); - this.addChild(l, 1); - l.setPosition( cc.p(winSize.width / 2, winSize.height - 70)); - } - - var strCode = this.code(); - if( strCode !="" ) { - var label = cc.LabelTTF.create(strCode, 'CourierNewPSMT', 16); - label.setPosition( cc.p( winSize.width/2, winSize.height-120) ); - this.addChild( label,10 ); - - var labelbg = cc.LabelTTF.create(strCode, 'CourierNewPSMT', 16); - labelbg.setColor( cc.c3(10,10,255) ); - labelbg.setPosition( cc.p( winSize.width/2 +1, winSize.height-120 -1) ); - this.addChild( labelbg,9); - } - } -}); - - -cc.log("main2.js:3"); - -//------------------------------------------------------------------ -// -// MainTest -// -//------------------------------------------------------------------ -MainTest = BaseLayer.extend({ - - _menu : null, - - onEnter:function () { - this._super(); - - cc.MenuItemFont.setFontSize(24); - var item1 = cc.MenuItemFont.create("Actions: Basic Tests", this, function() { require("js/test-actions.js"); } ); - var item2 = cc.MenuItemFont.create("Actions: Ease Tests", this, function() { require("js/test-easeactions.js"); } ); - var item3 = cc.MenuItemFont.create("Actions: Progress Tests", this, function() { require("js/test-actionsprogress.js"); } ); - var item4 = cc.MenuItemFont.create("Chipmunk Tests", this, function() { require("js/test-chipmunk.js"); } ); - var item5 = cc.MenuItemFont.create("Effects Tests", this, function() { require("js/test-effects.js"); } ); - var item6 = cc.MenuItemFont.create("Label Tests", this, function() { require("js/test-label.js"); } ); - var item7 = cc.MenuItemFont.create("Menu Tests", this, function() { require("js/test-menu.js"); } ); - var item8 = cc.MenuItemFont.create("Parallax Tests", this, function() { require("js/test-parallax.js"); } ); - var item9 = cc.MenuItemFont.create("Particle Tests", this, function() { require("js/test-particles.js"); } ); - var item10 = cc.MenuItemFont.create("RenderTexture Tests", this, function() { require("js/test-rendertexture.js"); } ); - var item11 = cc.MenuItemFont.create("Sprite Tests", this, function() { require("js/test-sprite.js"); } ); - var item12 = cc.MenuItemFont.create("Tilemap Tests", this, function() { require("js/test-tilemap.js"); } ); - var item13 = cc.MenuItemFont.create("CocosDenshion Tests", this, function() { require("js/test-cocosdenshion.js"); } ); - var item14 = cc.MenuItemFont.create("cocos2d presentation", this, function() { require("js/test-cocos2djs.js"); } ); - - - this._menu = cc.Menu.create(item1, item2, item3, item4, item5, item6, item7, item8, item9, item10, item11, item12, item13, item14); - this._menu.alignItemsVertically(); - - this._menu.setPosition( cc.p( winSize.width/2, winSize.height/2) ); - - this.addChild( this._menu ); - - var platform = __getPlatform(); - if( platform.substring(0,7) == 'desktop' ) - this.setMouseEnabled( true ); - else if( platform.substring(0,6) == 'mobile' ) - this.setTouchEnabled( true ); - }, - - onTouchesMoved:function (touches, event) { - var delta = touches[0].getDelta(); - var current = this._menu.getPosition(); - this._menu.setPosition( cc.p( current[0], current[1] + delta[1] ) ); - return true; - }, - - onMouseDragged : function( event ) { - var delta = event.getDelta(); - var current = this._menu.getPosition(); - this._menu.setPosition( cc.p( current[0], current[1] + delta[1] ) ); - return true; - }, - - title:function () { - return "Javascript tests"; - }, - -}); - -cc.log("main2.js:4"); - -// -// Order of tests -// - -scenes.push( MainTest); - -//------------------------------------------------------------------ -// -// Main entry point -// -//------------------------------------------------------------------ -function run() -{ - var scene = cc.Scene.create(); - var layer = new scenes[currentScene](); - scene.addChild( layer ); - - var runningScene = director.getRunningScene(); - if( runningScene == null ) - director.runWithScene( scene ); - else - director.replaceScene( cc.TransitionSplitCols.create(1, scene, cc.c3(0, 0, 0) ) ); - - director.setDisplayStats(true); -} - -cc.log("main2.js:5"); -run(); -cc.log("main2.js:6"); diff --git a/samples/TestJavascript/Resources/js/old/simpletest.js b/samples/TestJavascript/Resources/js/old/simpletest.js deleted file mode 100644 index 3c9a2894fa..0000000000 --- a/samples/TestJavascript/Resources/js/old/simpletest.js +++ /dev/null @@ -1,2 +0,0 @@ -var s = new SimpleNativeClass(); -s.doSomeProcessing("hello", "world"); diff --git a/samples/TestJavascript/Resources/js/old/test-sprite.js b/samples/TestJavascript/Resources/js/old/test-sprite.js deleted file mode 100644 index 63e125e437..0000000000 --- a/samples/TestJavascript/Resources/js/old/test-sprite.js +++ /dev/null @@ -1,784 +0,0 @@ -// -// http://www.cocos2d-iphone.org -// -// Javascript + cocos2d sprite tests -// - -require("js/helpers.js"); - -director = cc.Director.sharedDirector(); -_winSize = director.getWinSize(); -winSize = {width:_winSize[0], height:_winSize[1]}; -centerPos = cc.p( winSize.width/2, winSize.height/2 ); - -var scenes = [] -var currentScene = 0; - -var nextSpriteTestAction = function () { - currentScene = currentScene + 1; - if( currentScene >= scenes.length ) - currentScene = 0; - - loadScene(currentScene); -}; -var backSpriteTestAction = function () { - currentScene = currentScene -1; - if( currentScene < 0 ) - currentScene = scenes.length -1; - - loadScene(currentScene); -}; -var restartSpriteTestAction = function () { - loadScene( currentScene ); -}; - -var loadScene = function (sceneIdx) -{ - _winSize = director.getWinSize(); - winSize = {width:_winSize[0], height:_winSize[1]}; - centerPos = cc.p( winSize.width/2, winSize.height/2 ); - - var scene = new cc.Scene(); - scene.init(); - var layer = new scenes[ sceneIdx ](); - - scene.addChild( layer ); - -// scene.walkSceneGraph(0); - - director.replaceScene( scene ); -// __jsc__.garbageCollect(); -} - -//------------------------------------------------------------------ -// -// BaseLayer -// -//------------------------------------------------------------------ -var BaseLayer = function() { - - // - // VERY IMPORTANT - // - // Only subclasses of a native classes MUST call __associateObjectWithNative - // Failure to do so, it will crash. - // - var parent = goog.base(this); - __associateObjWithNative( this, parent ); - this.init(); - - this.title = function () { - return "No title"; - } - - this.subtitle = function () { - return "No Subtitle"; - } - -} -goog.inherits(BaseLayer, cc.Layer ); - -// -// Instance 'base' methods -// XXX: Should be defined after "goog.inherits" -// -BaseLayer.prototype.onEnter = function() { - var label = cc.LabelTTF.create(this.title(), "Arial", 28); - this.addChild(label, 1); - label.setPosition( cc.p(winSize.width / 2, winSize.height - 50)); - - var strSubtitle = this.subtitle(); - if (strSubtitle != "") { - var l = cc.LabelTTF.create(strSubtitle, "Thonburi", 16); - this.addChild(l, 1); - l.setPosition( cc.p(winSize.width / 2, winSize.height - 80)); - } - - // Menu - var item1 = cc.MenuItemImage.create("b1.png", "b2.png", this, this.backCallback); - var item2 = cc.MenuItemImage.create("r1.png", "r2.png", this, this.restartCallback); - var item3 = cc.MenuItemImage.create("f1.png", "f2.png", this, this.nextCallback); - var item4 = cc.MenuItemFont.create("back", function() { require("js/main.js"); }, this ); - item4.setFontSizeObj( 22 ); - - var menu = cc.Menu.create(item1, item2, item3, item4 ); - - menu.setPosition( cc.p(0,0) ); - item1.setPosition( cc.p(winSize.width / 2 - 100, 30)); - item2.setPosition( cc.p(winSize.width / 2, 30)); - item3.setPosition( cc.p(winSize.width / 2 + 100, 30)); - item4.setPosition( cc.p(winSize.width - 60, winSize.height - 30 ) ); - - this.addChild(menu, 1); -} - -BaseLayer.prototype.restartCallback = function (sender) { - cc.log("restart called"); - restartSpriteTestAction(); -} - -BaseLayer.prototype.nextCallback = function (sender) { - cc.log("next called"); - nextSpriteTestAction(); -} - -BaseLayer.prototype.backCallback = function (sender) { - cc.log("back called"); - backSpriteTestAction(); -} - -//------------------------------------------------------------------ -// -// Sprite Touch test -// -//------------------------------------------------------------------ -var SpriteTouchTest = function() { - - goog.base(this); - - this.initialize = function() { - var platform = __getPlatform(); - if( platform.substring(0,7) == 'desktop' ) - this.setMouseEnabled( true ); - else if( platform.substring(0,6) == 'mobile' ) - this.setTouchEnabled( true ); - this.addSprite( centerPos ); - } - - this.addSprite = function(pos) { - var sprite = this.createSprite( pos ); - this.addChild( sprite ); - } - - this.title = function () { - return "Sprite: Simple action test"; - } - - this.subtitle = function () { - return "Tap screen to add more sprites"; - } - - this.initialize(); -} -goog.inherits(SpriteTouchTest, BaseLayer ); - -SpriteTouchTest.prototype.onMouseDown = function( event ) { - this.addSprite( event.getLocation() ); -} - -SpriteTouchTest.prototype.onTouchesEnded = function( touches, event ) { - var l = touches.length; - for( var i=0; i < l; i++) { - this.addSprite( touches[i].getLocation() ); - } -} - - -SpriteTouchTest.prototype.createSprite = function( pos ) { - var idx = Math.random() * 1400 / 100; - idx = Math.floor( idx ); - var x = Math.floor(idx%5) * 85; - var y = Math.floor(idx/5) * 121; - - var sprite = cc.Sprite.create("grossini_dance_atlas.png", cc.rect(x,y,85,121) ); - sprite.setPosition( pos ); - - var rand = Math.random(); - - var action; - if( rand < 0.20 ) { - action = cc.ScaleBy.create(3, 2 ); - } else if(rand < 0.40) { - action = cc.RotateBy.create(3, 360 ); - } else if( rand < 0.60) { - action = cc.Blink.create(1, 3 ); - } else if( rand < 0.8 ) { - action = cc.TintBy.create(2, 0, -255, -255 ); - } else { - action = cc.FadeOut.create( 2 ); - } - var action_back = action.reverse(); - var seq = cc.Sequence.create(action, action_back); - - sprite.runAction( cc.RepeatForever.create( seq ) ); - - return sprite; -} - - -//------------------------------------------------------------------ -// -// Sprite Batch Touch test -// -//------------------------------------------------------------------ -var SpriteBatchTouchTest = function() { - - goog.base(this); - - this.initialize = function() { - this.batch = cc.SpriteBatchNode.create("grossini_dance_atlas.png", 50 ); - this.addChild( this.batch ); - - var platform = __getPlatform(); - if( platform == 'OSX' ) { - this.setIsMouseEnabled( true ); - } else if( platform == 'iOS' ) { - this.setIsTouchEnabled( true ); - } - } - - this.addSprite = function(pos) { - var sprite = this.createSprite( pos ); - this.batch.addChild( sprite ); - } - - this.title = function () { - return "SpriteBatch: Simple action test"; - } - - this.subtitle = function () { - return "Tap screen to add more sprites"; - } - - this.initialize(); -} -goog.inherits( SpriteBatchTouchTest, SpriteTouchTest ); - -//------------------------------------------------------------------ -// -// Sprite vs. SpriteBatch Animation -// -//------------------------------------------------------------------ -var SpriteFrameTest = function() { - - goog.base(this); - - this.initialize = function() { - var cache = cc.SpriteFrameCache.sharedSpriteFrameCache(); - cache.addSpriteFramesWithFile( "grossini.plist" ); - cache.addSpriteFramesWithFile( "grossini_gray.plist", "grossini_gray.png" ); - cache.addSpriteFramesWithFile( "grossini_blue.plist", "grossini_blue.png" ); - - // - // Animation using Sprite batch - // - // A CCSpriteBatchNode can reference one and only one texture (one .png file) - // Sprites that are contained in that texture can be instantiatied as CCSprites and then added to the CCSpriteBatchNode - // All CCSprites added to a CCSpriteBatchNode are drawn in one OpenGL ES draw call - // If the CCSprites are not added to a CCSpriteBatchNode then an OpenGL ES draw call will be needed for each one, which is less efficient - // - // When you animate a sprite, CCAnimation changes the frame of the sprite using setDisplayFrame: (this is why the animation must be in the same texture) - // When setDisplayFrame: is used in the CCAnimation it changes the frame to one specified by the CCSpriteFrames that were added to the animation, - // but texture id is still the same and so the sprite is still a child of the CCSpriteBatchNode, - // and therefore all the animation sprites are also drawn as part of the CCSpriteBatchNode - // - - var sprite1 = cc.Sprite.createWithSpriteFrameName("grossini_dance_01.png"); - sprite1.setPosition( cc.p( winSize.width/2-80, winSize.height/2) ); - - var spritebatch = cc.SpriteBatchNode.create("grossini.pvr.gz"); - spritebatch.addChild(sprite1); - this.addChild( spritebatch ); - - var frames = [] - for( var i = 1; i < 15; i++) { - - if( i < 10 ) { - var name = "grossini_dance_0" + i + ".png"; - } else { - var name = "grossini_dance_" + i + ".png"; - } - - var frame = cache.spriteFrameByName( name ); - frames.push( frame ); - } - - var animation = cc.Animation.create( frames, 0.3 ); - // 14 frames * 1sec = 14 seconds - sprite1.runAction( cc.RepeatForever.create( cc.Animate.create( animation ) ) ); - - - // - // Animation using standard Sprite - // - // - var sprite2 = cc.Sprite.createWithSpriteFrameName( "grossini_dance_01.png" ); - sprite2.setPosition( cc.p( winSize.width/2 + 80, winSize.height/2) ); - this.addChild( sprite2 ); - - var moreFrames = [] - for(var i = 1; i < 15; i++) { - if( i < 10 ) { - var name = "grossini_dance_gray_0" + i + ".png"; - } else { - var name = "grossini_dance_gray_" + i + ".png"; - } - var frame = cache.spriteFrameByName( name ); - moreFrames.push( frame ); - } - for( var i = 1; i < 5; i++) { - var name = "grossini_blue_0" + i + ".png"; - var frame = cache.spriteFrameByName( name ); - moreFrames.push( frame ); - } - - - moreFrames.concat( frames ); - var animMixed = cc.Animation.create( moreFrames, 0.3 ); - - // 32 frames * 1 seconds = 32 seconds - sprite2.runAction( cc.RepeatForever.create( cc.Animate.create( animMixed ) ) ); - - // to test issue #732, uncomment the following line - sprite2.setFlipX( false ); - sprite2.setFlipY( false ); - } - - this.title = function () { - return "Sprite vs. SpriteBatchNode animation"; - } - - this.subtitle = function () { - return "Testing issue #792"; - } - - this.initialize(); -} -goog.inherits( SpriteFrameTest, BaseLayer ); - -//------------------------------------------------------------------ -// -// SpriteAnchorPoint -// -//------------------------------------------------------------------ -var SpriteAnchorPoint = function() { - - goog.base(this); - - this.initialize = function() { - for(var i=0;i<3;i++) { - var sprite = cc.Sprite.create("grossini_dance_atlas.png", cc.rect(85*i, 121*1, 85, 121) ); - sprite.setPosition( cc.p( winSize.width/4*(i+1), winSize.height/2) ); - - var point = cc.Sprite.create( "r1.png" ); - point.setScale( 0.25 ); - point.setPosition( sprite.getPosition() ); - this.addChild( point, 10 ); - - if( i == 0 ) { - sprite.setAnchorPoint( cc.p( 0, 0) ); - } else if( i == 1 ) { - sprite.setAnchorPoint( cc.p(0.5, 0.5) ); - } else if( i == 2 ) { - sprite.setAnchorPoint( cc.p(1,1) ); - } - - point.setPosition( sprite.getPosition() ); - - var rotate = cc.RotateBy.create(10, 360); - var action = cc.RepeatForever.create( rotate ); - - sprite.runAction( action ); - this.addChild( sprite, i ); - } - } - - this.title = function () { - return "Sprite: anchor point"; - } - - this.subtitle = function () { - return "Testing 3 different anchor points"; - } - - this.initialize(); -} -goog.inherits( SpriteAnchorPoint, BaseLayer ); - -//------------------------------------------------------------------ -// -// SpriteBatchAnchorPoint -// -//------------------------------------------------------------------ -var SpriteBatchAnchorPoint = function() { - - goog.base(this); - - this.initialize = function() { - var batch = cc.SpriteBatchNode.create( "grossini_dance_atlas.png" ); - for(var i=0;i<3;i++) { - var sprite = cc.Sprite.create("grossini_dance_atlas.png", cc.rect(85*i, 121*1, 85, 121) ); - sprite.setPosition( cc.p( winSize.width/4*(i+1), winSize.height/2) ); - - var point = cc.Sprite.create( "r1.png" ); - point.setScale( 0.25 ); - point.setPosition( sprite.getPosition() ); - this.addChild( point, 10 ); - - if( i == 0 ) { - sprite.setAnchorPoint( cc.p( 0, 0) ); - } else if( i == 1 ) { - sprite.setAnchorPoint( cc.p(0.5, 0.5) ); - } else if( i == 2 ) { - sprite.setAnchorPoint( cc.p(1,1) ); - } - - point.setPosition( sprite.getPosition() ); - - var rotate = cc.RotateBy.create(10, 360); - var action = cc.RepeatForever.create( rotate ); - - sprite.runAction( action ); - batch.addChild( sprite, i ); - } - this.addChild( batch ); - } - - this.title = function () { - return "Sprite Batch: anchor point"; - } - - this.subtitle = function () { - return "Testing 3 different anchor points"; - } - - this.initialize(); -} -goog.inherits( SpriteBatchAnchorPoint, BaseLayer ); - -//------------------------------------------------------------------ -// -// SpriteOffsetAnchorFlip -// -//------------------------------------------------------------------ -var SpriteOffsetAnchorFlip = function() { - - goog.base(this); - - this.initialize = function() { - var cache = cc.SpriteFrameCache.sharedSpriteFrameCache(); - cache.addSpriteFramesWithFile("grossini.plist"); - cache.addSpriteFramesWithFile("grossini_gray.plist", "grossini_gray.png"); - - for(var i=0;i<3;i++) { - var sprite = cc.Sprite.create("grossini_dance_atlas.png", cc.rect(85*i, 121*1, 85, 121) ); - sprite.setPosition( cc.p( winSize.width/4*(i+1), winSize.height/2) ); - - var point = cc.Sprite.create( "r1.png" ); - point.setScale( 0.25 ); - point.setPosition( sprite.getPosition() ); - this.addChild( point, 10 ); - - if( i == 0 ) { - sprite.setAnchorPoint( cc.p( 0, 0) ); - } else if( i == 1 ) { - sprite.setAnchorPoint( cc.p(0.5, 0.5) ); - } else if( i == 2 ) { - sprite.setAnchorPoint( cc.p(1,1) ); - } - - point.setPosition( sprite.getPosition() ); - - var frames = [] - for( var j = 1; j < 15; j++) { - - if( j < 10 ) { - var name = "grossini_dance_0" + j + ".png"; - } else { - var name = "grossini_dance_" + j + ".png"; - } - - var frame = cache.spriteFrameByName( name ); - frames.push( frame ); - } - - var animation = cc.Animation.create( frames, 0.3 ); - sprite.runAction( cc.RepeatForever.create( cc.Animate.create( animation ) ) ); - - var flip = cc.FlipY.create( true ); - var flip_back = cc.FlipY.create( false ); - var delay = cc.DelayTime.create( 1 ); - var delay2 = cc.DelayTime.create( 1 ); - var seq = cc.Sequence.create( delay, flip, delay2, flip_back ); - sprite.runAction( cc.RepeatForever.create( seq ) ); - - this.addChild( sprite ); - } - } - - this.title = function () { - return "Sprite offset + anchor + flip"; - } - - this.subtitle = function () { - return "issue #1078"; - } - - this.initialize(); -} -goog.inherits( SpriteOffsetAnchorFlip, BaseLayer ); - -//------------------------------------------------------------------ -// -// SpriteBatchOffsetAnchorFlip -// -//------------------------------------------------------------------ -var SpriteBatchOffsetAnchorFlip = function() { - - goog.base(this); - - this.initialize = function() { - var cache = cc.SpriteFrameCache.sharedSpriteFrameCache(); - cache.addSpriteFramesWithFile("grossini.plist"); - cache.addSpriteFramesWithFile("grossini_gray.plist", "grossini_gray.png"); - - var batch = cc.SpriteBatchNode.create("grossini.pvr.gz"); - - for(var i=0;i<3;i++) { - var sprite = cc.Sprite.createWithSpriteFrameName("grossini_dance_01.png"); - sprite.setPosition( cc.p( winSize.width/4*(i+1), winSize.height/2) ); - - var point = cc.Sprite.create( "r1.png" ); - point.setScale( 0.25 ); - point.setPosition( sprite.getPosition() ); - this.addChild( point, 10 ); - - if( i == 0 ) { - sprite.setAnchorPoint( cc.p( 0, 0) ); - } else if( i == 1 ) { - sprite.setAnchorPoint( cc.p(0.5, 0.5) ); - } else if( i == 2 ) { - sprite.setAnchorPoint( cc.p(1,1) ); - } - - point.setPosition( sprite.getPosition() ); - - var frames = [] - for( var j = 1; j < 15; j++) { - - if( j < 10 ) { - var name = "grossini_dance_0" + j + ".png"; - } else { - var name = "grossini_dance_" + j + ".png"; - } - - var frame = cache.spriteFrameByName( name ); - frames.push( frame ); - } - - var animation = cc.Animation.create( frames, 0.3 ); - sprite.runAction( cc.RepeatForever.create( cc.Animate.create( animation ) ) ); - - var flip = cc.FlipY.create( true ); - var flip_back = cc.FlipY.create( false ); - var delay = cc.DelayTime.create( 1 ); - var delay2 = cc.DelayTime.create( 1 ); - var seq = cc.Sequence.create( delay, flip, delay2, flip_back ); - sprite.runAction( cc.RepeatForever.create( seq ) ); - - batch.addChild( sprite ); - } - this.addChild(batch); - } - - this.title = function () { - return "SpriteBatch offset + anchor + flip"; - } - - this.subtitle = function () { - return "issue #1078"; - } - - this.initialize(); -} -goog.inherits( SpriteBatchOffsetAnchorFlip, BaseLayer ); - - -//------------------------------------------------------------------ -// -// SpriteColorOpacity -// -//------------------------------------------------------------------ -var SpriteColorOpacity = function() { - - goog.base(this); - - this.initialize = function() { - var sprite1 = cc.Sprite.create('grossini_dance_atlas.png', cc.rect(85 * 0, 121 * 1, 85, 121)); - var sprite2 = cc.Sprite.create('grossini_dance_atlas.png', cc.rect(85 * 1, 121 * 1, 85, 121)); - var sprite3 = cc.Sprite.create('grossini_dance_atlas.png', cc.rect(85 * 2, 121 * 1, 85, 121)); - var sprite4 = cc.Sprite.create('grossini_dance_atlas.png', cc.rect(85 * 3, 121 * 1, 85, 121)); - var sprite5 = cc.Sprite.create('grossini_dance_atlas.png', cc.rect(85 * 0, 121 * 1, 85, 121)); - var sprite6 = cc.Sprite.create('grossini_dance_atlas.png', cc.rect(85 * 1, 121 * 1, 85, 121)); - var sprite7 = cc.Sprite.create('grossini_dance_atlas.png', cc.rect(85 * 2, 121 * 1, 85, 121)); - var sprite8 = cc.Sprite.create('grossini_dance_atlas.png', cc.rect(85 * 3, 121 * 1, 85, 121)); - - sprite1.setPosition(cc.p((winSize.width / 5) * 1, (winSize.height / 3) * 1)); - sprite2.setPosition(cc.p((winSize.width / 5) * 2, (winSize.height / 3) * 1)); - sprite3.setPosition(cc.p((winSize.width / 5) * 3, (winSize.height / 3) * 1)); - sprite4.setPosition(cc.p((winSize.width / 5) * 4, (winSize.height / 3) * 1)); - sprite5.setPosition(cc.p((winSize.width / 5) * 1, (winSize.height / 3) * 2)); - sprite6.setPosition(cc.p((winSize.width / 5) * 2, (winSize.height / 3) * 2)); - sprite7.setPosition(cc.p((winSize.width / 5) * 3, (winSize.height / 3) * 2)); - sprite8.setPosition(cc.p((winSize.width / 5) * 4, (winSize.height / 3) * 2)); - - var action = cc.FadeIn.create(2); - var action_back = action.reverse(); - var fade = cc.RepeatForever.create( cc.Sequence.create( action, action_back ) ); - - var tintRed = cc.TintBy.create(2, 0, -255, -255); - // var tintRed = cc.RotateBy.create(2, 360 ); - var tintRedBack = tintRed.reverse(); - var red = cc.RepeatForever.create(cc.Sequence.create( tintRed, tintRedBack ) ); - - var tintGreen = cc.TintBy.create(2, -255, 0, -255); - var tintGreenBack = tintGreen.reverse(); - var green = cc.RepeatForever.create(cc.Sequence.create( tintGreen, tintGreenBack ) ); - - var tintBlue = cc.TintBy.create(2, -255, -255, 0); - var tintBlueBack = tintBlue.reverse(); - var blue = cc.RepeatForever.create(cc.Sequence.create( tintBlue, tintBlueBack ) ); - - sprite5.runAction(red); - sprite6.runAction(green); - sprite7.runAction(blue); - sprite8.runAction(fade); - - // late add: test dirtyColor and dirtyPosition - this.addChild(sprite1); - this.addChild(sprite2); - this.addChild(sprite3); - this.addChild(sprite4); - this.addChild(sprite5); - this.addChild(sprite6); - this.addChild(sprite7); - this.addChild(sprite8); - } - - // - // Instance methods - // - this.title = function () { - return "Sprite: Color & Opacity"; - } - - this.subtitle = function () { - return "testing opacity and color"; - } - - this.initialize(); -} -goog.inherits(SpriteColorOpacity, BaseLayer ); - -//------------------------------------------------------------------ -// -// SpriteBatchColorOpacity -// -//------------------------------------------------------------------ -var SpriteBatchColorOpacity = function() { - - goog.base(this); - - this.initialize = function() { - var batch = cc.SpriteBatchNode.create('grossini_dance_atlas.png', 10); - var sprite1 = cc.Sprite.create('grossini_dance_atlas.png', cc.rect(85 * 0, 121 * 1, 85, 121)); - var sprite2 = cc.Sprite.create('grossini_dance_atlas.png', cc.rect(85 * 1, 121 * 1, 85, 121)); - var sprite3 = cc.Sprite.create('grossini_dance_atlas.png', cc.rect(85 * 2, 121 * 1, 85, 121)); - var sprite4 = cc.Sprite.create('grossini_dance_atlas.png', cc.rect(85 * 3, 121 * 1, 85, 121)); - var sprite5 = cc.Sprite.create('grossini_dance_atlas.png', cc.rect(85 * 0, 121 * 1, 85, 121)); - var sprite6 = cc.Sprite.create('grossini_dance_atlas.png', cc.rect(85 * 1, 121 * 1, 85, 121)); - var sprite7 = cc.Sprite.create('grossini_dance_atlas.png', cc.rect(85 * 2, 121 * 1, 85, 121)); - var sprite8 = cc.Sprite.create('grossini_dance_atlas.png', cc.rect(85 * 3, 121 * 1, 85, 121)); - - sprite1.setPosition(cc.p((winSize.width / 5) * 1, (winSize.height / 3) * 1)); - sprite2.setPosition(cc.p((winSize.width / 5) * 2, (winSize.height / 3) * 1)); - sprite3.setPosition(cc.p((winSize.width / 5) * 3, (winSize.height / 3) * 1)); - sprite4.setPosition(cc.p((winSize.width / 5) * 4, (winSize.height / 3) * 1)); - sprite5.setPosition(cc.p((winSize.width / 5) * 1, (winSize.height / 3) * 2)); - sprite6.setPosition(cc.p((winSize.width / 5) * 2, (winSize.height / 3) * 2)); - sprite7.setPosition(cc.p((winSize.width / 5) * 3, (winSize.height / 3) * 2)); - sprite8.setPosition(cc.p((winSize.width / 5) * 4, (winSize.height / 3) * 2)); - - var action = cc.FadeIn.create(2); - var action_back = action.reverse(); - var fade = cc.RepeatForever.create( cc.Sequence.create( action, action_back ) ); - - var tintRed = cc.TintBy.create(2, 0, -255, -255); - // var tintRed = cc.RotateBy.create(2, 360 ); - var tintRedBack = tintRed.reverse(); - var red = cc.RepeatForever.create(cc.Sequence.create( tintRed, tintRedBack ) ); - - var tintGreen = cc.TintBy.create(2, -255, 0, -255); - var tintGreenBack = tintGreen.reverse(); - var green = cc.RepeatForever.create(cc.Sequence.create( tintGreen, tintGreenBack ) ); - - var tintBlue = cc.TintBy.create(2, -255, -255, 0); - var tintBlueBack = tintBlue.reverse(); - var blue = cc.RepeatForever.create(cc.Sequence.create( tintBlue, tintBlueBack ) ); - - sprite5.runAction(red); - sprite6.runAction(green); - sprite7.runAction(blue); - sprite8.runAction(fade); - - // late add: test dirtyColor and dirtyPosition - this.addChild(batch); - batch.addChild(sprite1); - batch.addChild(sprite2); - batch.addChild(sprite3); - batch.addChild(sprite4); - batch.addChild(sprite5); - batch.addChild(sprite6); - batch.addChild(sprite7); - batch.addChild(sprite8); - } - - // - // Instance methods - // - this.title = function () { - return "Sprite Batch: Color & Opacity"; - } - - this.subtitle = function () { - return "testing opacity and color with batches"; - } - - this.initialize(); -} -goog.inherits(SpriteBatchColorOpacity, BaseLayer ); - -// -// Order of tests -// -scenes.push( SpriteTouchTest ); scenes.push( SpriteBatchTouchTest ); - -scenes.push( SpriteFrameTest ); - -scenes.push( SpriteAnchorPoint ); scenes.push( SpriteBatchAnchorPoint ); - -scenes.push( SpriteOffsetAnchorFlip ); scenes.push( SpriteBatchOffsetAnchorFlip ); - -scenes.push( SpriteColorOpacity ); scenes.push( SpriteBatchColorOpacity ); - - -//------------------------------------------------------------------ -// -// Main entry point -// -//------------------------------------------------------------------ -function run() -{ - var scene = cc.Scene.create(); - var layer = new scenes[currentScene](); - scene.addChild( layer ); - - var runningScene = director.getRunningScene(); - if( runningScene == null ) { - director.runWithScene( scene ); - } else { - director.replaceScene( cc.TransitionFade.create(0.5, scene, cc.c3(0, 0, 0) ) ); - } -} - -run(); diff --git a/samples/TestJavascript/Resources/js/old/test1.js b/samples/TestJavascript/Resources/js/old/test1.js deleted file mode 100644 index 730dfea2b9..0000000000 --- a/samples/TestJavascript/Resources/js/old/test1.js +++ /dev/null @@ -1,313 +0,0 @@ -// -// http://www.cocos2d-iphone.org -// http://www.cocos2d-html5.org -// http://www.cocos2d-x.org -// -// Javascript + CocosDenshion tests -// -// -require("js/helpers.js"); - -var director = cc.Director.sharedDirector(); -var audioEngine = cc.SimpleAudioEngine.sharedEngine(); -var _winSize = director.getWinSize(); -var winSize = {width:_winSize[0], height:_winSize[1]}; -var centerPos = cc.p( winSize.width/2, winSize.height/2 ); - -var MUSIC_FILE = "bgmusic.mp3"; -var EFFECT_FILE = "cowbell.wav"; - -var DenshionTests = [ - { - title:"playBackgroundMusic", - playFunc:function () { - return new playBackgroundMusic(); - } - }, - { - title:"stopBackgroundMusic", - playFunc:function () { - return new stopBackgroundMusic(); - } - }, - { - title:"pauseBackgroundMusic", - playFunc:function () { - return new pauseBackgroundMusic(); - } - }, - { - title:"resumeBackgroundMusic", - playFunc:function () { - return new resumeBackgroundMusic(); - } - }, - { - title:"rewindBackgroundMusic", - playFunc:function () { - return new rewindBackgroundMusic(); - } - }, - { - title:"isBackgroundMusicPlaying", - playFunc:function () { - return new isBackgroundMusicPlaying(); - } - }, - { - title:"playEffect", - playFunc:function () { - return new playEffect(); - } - }, - { - title:"playEffectRepeatly", - playFunc:function () { - return new playEffectRepeatly(); - } - }, - { - title:"stopEffect", - playFunc:function () { - return new stopEffect(); - } - }, - { - title:"unloadEffect", - playFunc:function () { - return new unloadEffect(); - } - }, - { - title:"addBackgroundMusicVolume", - playFunc:function () { - return new addBackgroundMusicVolume(); - } - }, - - { - title:"subBackgroundMusicVolume", - playFunc:function () { - return new subBackgroundMusicVolume(); - } - }, - - { - title:"addEffectsVolume", - playFunc:function () { - return new addEffectsVolume(); - } - }, - - { - title:"subEffectsVolume", - playFunc:function () { - return new subEffectsVolume(); - } - }, - - { - title:"pauseEffect", - playFunc:function () { - return new pauseEffect(); - } - }, - - { - title:"resumeEffect", - playFunc:function () { - return new resumeEffect(); - } - }, - - { - title:"pauseAllEffects", - playFunc:function () { - return new pauseAllEffects(); - } - }, - - { - title:"resumeAllEffects", - playFunc:function () { - return new resumeAllEffects(); - } - }, - - { - title:"stopAllEffects", - playFunc:function () { - return new stopAllEffects(); - } - } - -]; - -CocosDenshionTest = cc.LayerGradient.extend({ - _menu:null, - ctor:function () { - - var parent = new cc.LayerGradient(); - __associateObjWithNative(this, parent); - this.init(cc.c4(0, 0, 0, 255), cc.c4(0, 128, 255, 255)); - this.setTouchEnabled(true); - - // add menu items for tests - this._menu = cc.Menu.create(); - var s = winSize; - for (var i = 0; i < DenshionTests.length; i++) { - var label = cc.LabelTTF.create(DenshionTests[i].title, "Arial", 20); - var menuItem = cc.MenuItemLabel.create(label, this.menuCallback); - this._menu.addChild(menuItem, i + 10000); - } - this._menu.setPosition(cc.p(winSize.width/2, winSize.height/2) ); - this._menu.alignItemsVertically() - this.addChild(this._menu); - - // set default volume - audioEngine.setEffectsVolume(0.5); - audioEngine.setBackgroundMusicVolume(0.5); - - // Back button - var itemBack = cc.MenuItemFont.create("back", function() { require("js/main.js"); } ); - itemBack.setPosition( cc.p(winSize.width - 60, winSize.height - 30 ) ); - itemBack.setFontSizeObj( 22 ); - var menuBack = cc.Menu.create(); - menuBack.addChild(itemBack); - menuBack.setPosition( cc.p(0,0) ); - this.addChild( menuBack, 10 ); - }, - ccTouchBegan: function (touch) { - cc.log("touch: " + touch[0] + ": " + Date.now()); - }, - ccTouchMoved: function (touch) { - cc.log("touch moved: " + touch[0] + ": " + Date.now()); - }, - menuCallback:function (sender) { - var idx = sender.getZOrder() - 10000; - // create the test scene and run it - var scene = DenshionTests[idx].playFunc(); - }, - -}); - -var soundId = null; - -var playBackgroundMusic = function () { - cc.log("play background music"); - audioEngine.playBackgroundMusic(MUSIC_FILE, false); -}; - -var stopBackgroundMusic = function () { - cc.log("stop background music"); - audioEngine.stopBackgroundMusic(); -}; - -var pauseBackgroundMusic = function () { - cc.log("pause background music"); - audioEngine.pauseBackgroundMusic(); -}; - -var resumeBackgroundMusic = function () { - cc.log("resume background music"); - audioEngine.resumeBackgroundMusic(); -}; - -var rewindBackgroundMusic = function () { - cc.log("rewind background music"); - audioEngine.rewindBackgroundMusic(); -}; - -// is background music playing -var isBackgroundMusicPlaying = function () { - if (audioEngine.isBackgroundMusicPlaying()) { - cc.log("background music is playing"); - } - else { - cc.log("background music is not playing"); - } -}; - -var playEffect = function () { - cc.log("play effect"); - soundId = audioEngine.playEffect(EFFECT_FILE, false); -}; - -var playEffectRepeatly = function () { - cc.log("play effect repeatly"); - soundId = audioEngine.playEffect(EFFECT_FILE, true); -}; - -var stopEffect = function () { - cc.log("stop effect"); - audioEngine.stopEffect(soundId); -}; - -var unloadEffect = function () { - cc.log("unload effect"); - audioEngine.unloadEffect(EFFECT_FILE); -}; - -var addBackgroundMusicVolume = function () { - cc.log("add bakcground music volume"); - audioEngine.setBackgroundMusicVolume(audioEngine.getBackgroundMusicVolume() + 0.1); -}; - -var subBackgroundMusicVolume = function () { - cc.log("sub backgroud music volume"); - audioEngine.setBackgroundMusicVolume(audioEngine.getBackgroundMusicVolume() - 0.1); -}; - -var addEffectsVolume = function () { - cc.log("add effects volume"); - audioEngine.setEffectsVolume(audioEngine.getEffectsVolume() + 0.1); -}; - -var subEffectsVolume = function () { - cc.log("sub effects volume"); - audioEngine.setEffectsVolume(audioEngine.getEffectsVolume() - 0.1); -}; - -var pauseEffect = function () { - cc.log("pause effect"); - audioEngine.pauseEffect(soundId); -}; - -var resumeEffect = function () { - cc.log("resume effect"); - audioEngine.resumeEffect(soundId); -}; - -var pauseAllEffects = function () { - cc.log("pause all effects"); - audioEngine.pauseAllEffects(); -}; -var resumeAllEffects = function () { - cc.log("resume all effects"); - audioEngine.resumeAllEffects(); -}; -var stopAllEffects = function () { - cc.log("stop all effects"); - audioEngine.stopAllEffects(); -}; - - -//------------------------------------------------------------------ -// -// Main entry point -// -//------------------------------------------------------------------ -function run() -{ - var scene = cc.Scene.create(); - var layer = new CocosDenshionTest(); - scene.addChild( layer ); - - var runningScene = director.getRunningScene(); - if( runningScene == null ) - director.runWithScene( scene ); - else - director.replaceScene( cc.TransitionSplitCols.create(1, scene ) ); -} - -run(); diff --git a/samples/TestJavascript/Resources/js/playground.js b/samples/TestJavascript/Resources/js/playground.js deleted file mode 100644 index 3fec6c3f08..0000000000 --- a/samples/TestJavascript/Resources/js/playground.js +++ /dev/null @@ -1,232 +0,0 @@ -// -// http://www.cocos2d-iphone.org -// http://www.cocos2d-html5.org -// http://www.cocos2d-x.org -// -// Javascript + cocos2d actions tests -// - -require("js/helper.js"); - -director = cc.Director.getInstance(); -_winSize = director.getWinSize(); -winSize = {width:_winSize[0], height:_winSize[1]}; -centerPos = cc.p( winSize.width/2, winSize.height/2 ); - -var scenes = [] -var currentScene = 0; - -var nextScene = function () { - currentScene = currentScene + 1; - if( currentScene >= scenes.length ) - currentScene = 0; - - withTransition = true; - loadScene(currentScene); -}; - -var previousScene = function () { - currentScene = currentScene -1; - if( currentScene < 0 ) - currentScene = scenes.length -1; - - withTransition = true; - loadScene(currentScene); -}; - -var restartScene = function () { - loadScene( currentScene ); -}; - -var loadScene = function (sceneIdx) -{ - _winSize = director.getWinSize(); - winSize = {width:_winSize[0], height:_winSize[1]}; - centerPos = cc.p( winSize.width/2, winSize.height/2 ); - - var scene = new cc.Scene(); - scene.init(); - var layer = new scenes[ sceneIdx ](); - - scene.addChild( layer ); - -// scene.walkSceneGraph(0); - - director.replaceScene( scene ); - __jsc__.dumpRoot(); - __jsc__.garbageCollect(); -} - - -// -// Base Layer -// - -var MyMenuItemFont = cc.MenuItemFont.extend({ - - ctor:function () { - var parent = new cc.MenuItemFont(); - __associateObjWithNative(this, parent); - this.init( "hello", this, this.callback ); - }, - - callback:function(sender) { - cc.log("Button clicked"); - }, -}); - -var BaseLayer = cc.LayerGradient.extend({ - - ctor:function () { - - var parent = new cc.LayerGradient(); - __associateObjWithNative(this, parent); - this.init(cc.c4b(0, 0, 0, 255), cc.c4b(0, 128, 255, 255)); - - - var item = new MyMenuItemFont(); - var menu = cc.Menu.create( item ); - this.addChild( menu ); - menu.setPosition( centerPos ); - }, - - title:function () { - return "No Title"; - }, - - subtitle:function () { - return ""; - }, - - code:function () { - return ""; - }, - - restartCallback:function (sender) { - restartScene(); - }, - - nextCallback:function (sender) { - nextScene(); - }, - - backCallback:function (sender) { -// previousScene(); - cc.log("3"); - __jsc__.dumpRoot(); - __jsc__.garbageCollect(); - }, - - onEnter:function () { - // DO NOT CALL this._super() -// this._super(); - - // add title and subtitle - var label = cc.LabelTTF.create(this.title(), "Arial", 28); - this.addChild(label, 1); - label.setPosition( cc.p(winSize.width / 2, winSize.height - 40)); - - var strSubtitle = this.subtitle(); - if (strSubtitle != "") { - var l = cc.LabelTTF.create(strSubtitle, "Thonburi", 16); - this.addChild(l, 1); - l.setPosition( cc.p(winSize.width / 2, winSize.height - 70)); - } - - var strCode = this.code(); - if( strCode !="" ) { - var label = cc.LabelTTF.create(strCode, 'CourierNewPSMT', 16); - label.setPosition( cc.p( winSize.width/2, winSize.height-120) ); - this.addChild( label,10 ); - - var labelbg = cc.LabelTTF.create(strCode, 'CourierNewPSMT', 16); - labelbg.setColor( cc.c3b(10,10,255) ); - labelbg.setPosition( cc.p( winSize.width/2 +1, winSize.height-120 -1) ); - this.addChild( labelbg,9); - } - - // Menu - var item1 = cc.MenuItemImage.create("b1.png", "b2.png", this, this.backCallback); - var item2 = cc.MenuItemImage.create("r1.png", "r2.png", this, this.restartCallback); - var item3 = cc.MenuItemImage.create("f1.png", "f2.png", this, this.nextCallback); -// var item4 = cc.MenuItemFont.create("back", this, function() { require("js/main.js"); } ); -// item4.setFontSize( 22 ); - -// var menu = cc.Menu.create(item1, item2, item3, item4 ); - var menu = cc.Menu.create(item1, item2, item3 ); - - menu.setPosition( cc.p(0,0) ); - item1.setPosition( cc.p(winSize.width / 2 - 100, 30)); - item2.setPosition( cc.p(winSize.width / 2, 30)); - item3.setPosition( cc.p(winSize.width / 2 + 100, 30)); -// item4.setPosition( cc.p(winSize.width - 60, winSize.height - 30 ) ); - - this.addChild(menu, 1); - - cc.log("2"); - __jsc__.dumpRoot(); - } -}); - -//------------------------------------------------------------------ -// -// Playground -// -//------------------------------------------------------------------ -var Playground = BaseLayer.extend({ - onEnter:function () { - this._super(); - - var platform = __getPlatform(); - if( platform.substring(0,6) == 'mobile' ) { - var accel = cc.Accelerometer.getInstance(); - accel.setCallback( this, this.onAccelerometer ); - - // 2 times per second - accel.setUpdateInterval( 1/2 ); - } - }, - - onAccelerometer:function(x,y,z,timestamp) { - cc.log('Accel: '+ x + ' ' + y + ' ' + z ); - }, - - title:function () { - return "Testing Accelerometer"; - }, - - subtitle:function () { - return "See console on device"; - }, - code:function () { - return ""; - } -}); - -// -// Order of tests -// - -scenes.push( Playground ); - -//------------------------------------------------------------------ -// -// Main entry point -// -//------------------------------------------------------------------ -function run() -{ - var scene = cc.Scene.create(); - var layer = new scenes[currentScene](); - scene.addChild( layer ); - - var runningScene = director.getRunningScene(); - if( runningScene == null ) - director.runWithScene( scene ); - else - director.replaceScene( cc.TransitionFade.create(0.5, scene ) ); -} - -run(); - - diff --git a/samples/TestJavascript/Resources/js/playground_gc.js b/samples/TestJavascript/Resources/js/playground_gc.js deleted file mode 100644 index 999fe319d0..0000000000 --- a/samples/TestJavascript/Resources/js/playground_gc.js +++ /dev/null @@ -1,25 +0,0 @@ - -director = cc.Director.getInstance(); - -cc.log("**** 1 ****"); -__jsc__.dumpRoot(); -__jsc__.garbageCollect(); - -scene = cc.Scene.create(); -layer = cc.LayerGradient.create( cc.c4b(0, 0, 0, 255), cc.c4b(0, 128, 255, 255) ); - -layer.onEnter = function() { - cc.log("On Enter!!"); - - cc.log("**** 2 ****"); - __jsc__.dumpRoot(); - // __jsc__.garbageCollect(); -}; - -scene.addChild( layer ); -director.runWithScene( scene ); - -cc.log("**** 5 ****"); -__jsc__.dumpRoot(); -__jsc__.garbageCollect(); - diff --git a/samples/TestJavascript/Resources/js/test-actions.js b/samples/TestJavascript/Resources/js/test-actions.js deleted file mode 100644 index c6ee271b1a..0000000000 --- a/samples/TestJavascript/Resources/js/test-actions.js +++ /dev/null @@ -1,1514 +0,0 @@ -// -// http://www.cocos2d-iphone.org -// http://www.cocos2d-html5.org -// http://www.cocos2d-x.org -// -// Javascript + cocos2d actions tests -// - -require("js/helper.js"); - -director = cc.Director.getInstance(); -winSize = director.getWinSize(); -centerPos = cc.p( winSize.width/2, winSize.height/2 ); - -var scenes = [] -var currentScene = 0; - -var nextScene = function () { - currentScene = currentScene + 1; - if( currentScene >= scenes.length ) - currentScene = 0; - - withTransition = true; - loadScene(currentScene); -}; - -var previousScene = function () { - currentScene = currentScene -1; - if( currentScene < 0 ) - currentScene = scenes.length -1; - - withTransition = true; - loadScene(currentScene); -}; - -var restartScene = function () { - loadScene( currentScene ); -}; - -var loadScene = function (sceneIdx) -{ - winSize = director.getWinSize(); - centerPos = cc.p( winSize.width/2, winSize.height/2 ); - - var scene = new cc.Scene(); - scene.init(); - var layer = new scenes[ sceneIdx ](); - - scene.addChild( layer ); - -// scene.walkSceneGraph(0); - - director.replaceScene( scene ); - __jsc__.dumpRoot(); - __jsc__.garbageCollect(); -} - - -// -// Base Layer -// - -var BaseLayer = cc.LayerGradient.extend({ - - ctor:function () { - - var parent = new cc.LayerGradient(); - __associateObjWithNative(this, parent); - this.init(cc.c4b(0, 0, 0, 255), cc.c4b(0, 128, 255, 255)); - }, - - centerSprites : function (numberOfSprites) { - - if (numberOfSprites == 0) { - this._tamara.setVisible(false); - this._kathia.setVisible(false); - this._grossini.setVisible(false); - } - else if (numberOfSprites == 1) { - this._tamara.setVisible(false); - this._kathia.setVisible(false); - this._grossini.setPosition(cc.p(winSize.width / 2, winSize.height / 2)); - } - else if (numberOfSprites == 2) { - this._kathia.setPosition(cc.p(winSize.width / 3, winSize.height / 2)); - this._tamara.setPosition(cc.p(2 * winSize.width / 3, winSize.height / 2)); - this._grossini.setVisible(false); - } - else if (numberOfSprites == 3) { - this._grossini.setPosition(cc.p(winSize.width / 2, winSize.height / 2)); - this._tamara.setPosition(cc.p(winSize.width / 4, winSize.height / 2)); - this._kathia.setPosition(cc.p(3 * winSize.width / 4, winSize.height / 2)); - } - }, - - alignSpritesLeft : function (numberOfSprites) { - - if (numberOfSprites == 1) { - this._tamara.setVisible(false); - this._kathia.setVisible(false); - this._grossini.setPosition(cc.p(60, winSize.height / 2)); - } - else if (numberOfSprites == 2) { - this._kathia.setPosition(cc.p(60, winSize.height / 3)); - this._tamara.setPosition(cc.p(60, 2 * winSize.height / 3)); - this._grossini.setVisible(false); - } - else if (numberOfSprites == 3) { - this._grossini.setPosition(cc.p(60, winSize.height / 2)); - this._tamara.setPosition(cc.p(60, 2 * winSize.height / 3)); - this._kathia.setPosition(cc.p(60, winSize.height / 3)); - } - }, - - title:function () { - return "No Title"; - }, - - subtitle:function () { - return ""; - }, - - code:function () { - return ""; - }, - - restartCallback:function (sender) { - restartScene(); - }, - - nextCallback:function (sender) { - nextScene(); - }, - - backCallback:function (sender) { - previousScene(); - }, - - onEnter:function () { -// this._super(); - - // add title and subtitle - var label = cc.LabelTTF.create(this.title(), "Arial", 28); - this.addChild(label, 1); - label.setPosition( cc.p(winSize.width / 2, winSize.height - 40)); - - var strSubtitle = this.subtitle(); - if (strSubtitle != "") { - var l = cc.LabelTTF.create(strSubtitle, "Thonburi", 16); - this.addChild(l, 1); - l.setPosition( cc.p(winSize.width / 2, winSize.height - 70)); - } - - var strCode = this.code(); - if( strCode !="" ) { - var label = cc.LabelTTF.create(strCode, 'CourierNewPSMT', 16); - label.setPosition( cc.p( winSize.width/2, winSize.height-120) ); - this.addChild( label,10 ); - - var labelbg = cc.LabelTTF.create(strCode, 'CourierNewPSMT', 16); - labelbg.setColor( cc.c3b(10,10,255) ); - labelbg.setPosition( cc.p( winSize.width/2 +1, winSize.height-120 -1) ); - this.addChild( labelbg,9); - } - - // Menu - var item1 = cc.MenuItemImage.create("Images/b1.png", "Images/b2.png", this, this.backCallback); - var item2 = cc.MenuItemImage.create("Images/r1.png", "Images/r2.png", this, this.restartCallback); - var item3 = cc.MenuItemImage.create("Images/f1.png", "Images/f2.png", this, this.nextCallback); - var item4 = cc.MenuItemFont.create("back", this, function() { require("js/main.js"); } ); - item4.setFontSize( 22 ); - - var menu = cc.Menu.create(item1, item2, item3, item4 ); - - menu.setPosition( cc.p(0,0) ); - item1.setPosition( cc.p(winSize.width / 2 - 100, 30)); - item2.setPosition( cc.p(winSize.width / 2, 30)); - item3.setPosition( cc.p(winSize.width / 2 + 100, 30)); - item4.setPosition( cc.p(winSize.width - 60, winSize.height - 30 ) ); - - this.addChild(menu, 1); - - // Setup Sprites for this:w - this._grossini = cc.Sprite.create("Images/grossini.png"); - this._tamara = cc.Sprite.create("Images/grossinis_sister1.png"); - this._kathia = cc.Sprite.create("Images/grossinis_sister2.png"); - this.addChild(this._grossini, 1); - this.addChild(this._tamara, 2); - this.addChild(this._kathia, 3); - this._grossini.setPosition(cc.p(winSize.width / 2, winSize.height / 3)); - this._tamara.setPosition(cc.p(winSize.width / 2, 2 * winSize.height / 3)); - this._kathia.setPosition(cc.p(winSize.width / 2, winSize.height / 2)); - } -}); - -//------------------------------------------------------------------ -// -// ActionManual -// -//------------------------------------------------------------------ -var ActionManual = BaseLayer.extend({ - onEnter:function () { - this._super(); - - this._tamara.setScaleX(2.5); - //window.tam = this._tamara; - this._tamara.setScaleY(-1.0); - this._tamara.setPosition(cc.p(100, 70)); - this._tamara.setOpacity(128); - - this._grossini.setRotation(120); - this._grossini.setPosition(cc.p(winSize.width / 2, winSize.height / 2)); - this._grossini.setColor( cc.c3b(255, 0, 0) ); - - this._kathia.setPosition(cc.p(winSize.width - 100, winSize.height / 2)); - this._kathia.setColor(cc.c3b(0,0,255) ); - - }, - title:function () { - return "Manual Transformation"; - }, - code:function () { - return "sprite.setPosition( cc.p(10,20) );\n" + - "sprite.setRotation( 90 );\n" + - "sprite.setScale( 2 );"; - } - -}); - - -//------------------------------------------------------------------ -// -// ActionMove -// -//------------------------------------------------------------------ -var ActionMove = BaseLayer.extend({ - onEnter:function () { - this._super(); - - this.centerSprites(3); - - var actionTo = cc.MoveTo.create(2, cc.p(winSize.width - 40, winSize.height - 40)); - - var actionBy = cc.MoveBy.create(2, cc.p(80, 80)); - var actionByBack = actionBy.reverse(); - - this._tamara.runAction(actionTo); - this._grossini.runAction(cc.Sequence.create(actionBy, actionByBack)); - this._kathia.runAction(cc.MoveTo.create(1, cc.p(40, 40))); - }, - title:function () { - return "MoveTo / MoveBy"; - }, - code:function () { - return "a = cc.MoveBy.create( time, cc.p(x,y) );\n" + - "a = cc.MoveTo.create( time, cc.p(x,y) );"; - }, -}); - -//------------------------------------------------------------------ -// -// ActionScale -// -//------------------------------------------------------------------ -var ActionScale = BaseLayer.extend({ - onEnter:function () { - this._super(); - - this.centerSprites(3); - - var actionTo = cc.ScaleTo.create(2, 0.5); - var actionBy = cc.ScaleBy.create(2, 2); - var actionBy2 = cc.ScaleBy.create(2, 0.25, 4.5); - var actionByBack = actionBy.reverse(); - var actionBy2Back = actionBy2.reverse(); - - this._tamara.runAction(actionTo); - this._kathia.runAction(cc.Sequence.create(actionBy2, actionBy2Back) ); - this._grossini.runAction(cc.Sequence.create(actionBy, actionByBack) ); - - }, - title:function () { - return "ScaleTo / ScaleBy"; - }, - code:function () { - return "a = cc.ScaleBy.create( time, scale );\n" + - "a = cc.ScaleTo.create( time, scaleX, scaleY );"; - }, -}); - -//------------------------------------------------------------------ -// -// ActionSkew -// -//------------------------------------------------------------------ -var ActionSkew = BaseLayer.extend({ - onEnter:function () { - this._super(); - this.centerSprites(3); - var actionTo = cc.SkewTo.create(2, 37.2, -37.2); - var actionToBack = cc.SkewTo.create(2, 0, 0); - var actionBy = cc.SkewBy.create(2, 0, -90); - var actionBy2 = cc.SkewBy.create(2, 45.0, 45.0); - var actionByBack = actionBy.reverse(); - var actionBy2Back = actionBy2.reverse(); - - - this._tamara.runAction(cc.Sequence.create(actionTo, actionToBack )); - this._grossini.runAction(cc.Sequence.create(actionBy, actionByBack )); - - this._kathia.runAction(cc.Sequence.create(actionBy2, actionBy2Back )); - - - }, - title:function () { - return "SkewTo / SkewBy"; - }, - code:function () { - return "a = cc.SkewBy.create( time, skew );\n" + - "a = cc.SkewTo.create( time, skewX, skewY );"; - }, -}); - -//------------------------------------------------------------------ -// -// ActionSkewRotateScale -// -//------------------------------------------------------------------ -var ActionSkewRotateScale = BaseLayer.extend({ - onEnter:function () { - this._super(); - this._tamara.removeFromParentAndCleanup(true); - this._grossini.removeFromParentAndCleanup(true); - this._kathia.removeFromParentAndCleanup(true); - - var boxSize = cc.size(100.0, 100.0); - var box = cc.LayerColor.create(cc.c4b(255, 255, 0, 255)); - box.setAnchorPoint(cc.p(0, 0)); - box.setPosition(cc.p((winSize.width - boxSize.width) / 2, (winSize.height - boxSize.height) / 2)); - box.setContentSize(boxSize); - - var markrside = 10.0; - var uL = cc.LayerColor.create(cc.c4b(255, 0, 0, 255)); - box.addChild(uL); - uL.setContentSize(cc.size(markrside, markrside)); - uL.setPosition(cc.p(0, boxSize.height - markrside)); - uL.setAnchorPoint(cc.p(0, 0)); - - var uR = cc.LayerColor.create(cc.c4b(0, 0, 255, 255)); - box.addChild(uR); - uR.setContentSize(cc.size(markrside, markrside)); - uR.setPosition(cc.p(boxSize.width - markrside, boxSize.height - markrside)); - uR.setAnchorPoint(cc.p(0, 0)); - - - this.addChild(box); - var actionTo = cc.SkewTo.create(2, 0., 2.); - var rotateTo = cc.RotateTo.create(2, 61.0); - var actionScaleTo = cc.ScaleTo.create(2, -0.44, 0.47); - - var actionScaleToBack = cc.ScaleTo.create(2, 1.0, 1.0); - var rotateToBack = cc.RotateTo.create(2, 0); - var actionToBack = cc.SkewTo.create(2, 0, 0); - - box.runAction(cc.Sequence.create(actionTo, actionToBack )); - box.runAction(cc.Sequence.create(rotateTo, rotateToBack )); - box.runAction(cc.Sequence.create(actionScaleTo, actionScaleToBack )); - }, - title:function () { - return "Skew + Rotate + Scale"; - }, -}); - -//------------------------------------------------------------------ -// -// ActionRotate -// -//------------------------------------------------------------------ -var ActionRotate = BaseLayer.extend({ - onEnter:function () { - this._super(); - this.centerSprites(3); - var actionTo = cc.RotateTo.create(2, 45); - var actionTo2 = cc.RotateTo.create(2, -45); - var actionTo0 = cc.RotateTo.create(2, 0); - this._tamara.runAction(cc.Sequence.create(actionTo, actionTo0)); - - var actionBy = cc.RotateBy.create(2, 360); - var actionByBack = actionBy.reverse(); - this._grossini.runAction(cc.Sequence.create(actionBy, actionByBack )); - - this._kathia.runAction(cc.Sequence.create(actionTo2, actionTo0.copy() )); - - }, - title:function () { - return "RotateTo / RotateBy"; - }, - code:function () { - return "a = cc.RotateBy.create( time, degrees );\n" + - "a = cc.RotateTo.create( time, degrees );"; - }, -}); - - -//------------------------------------------------------------------ -// -// ActionJump -// -//------------------------------------------------------------------ -var ActionJump = BaseLayer.extend({ - onEnter:function () { - this._super(); - this.centerSprites(3); - - var actionTo = cc.JumpTo.create(2, cc.p(300, 300), 50, 4); - var actionBy = cc.JumpBy.create(2, cc.p(300, 0), 50, 4); - var actionUp = cc.JumpBy.create(2, cc.p(0, 0), 80, 4); - var actionByBack = actionBy.reverse(); - - this._tamara.runAction(actionTo); - this._grossini.runAction(cc.Sequence.create(actionBy, actionByBack )); - this._kathia.runAction(cc.RepeatForever.create(actionUp)); - - }, - title:function () { - return "JumpTo / JumpBy"; - }, - code:function () { - return "a = cc.JumpBy.create( time, point, height, #_of_jumps );\n" + - "a = cc.JumpTo.create( time, point, height, #_of_jumps );"; - }, -}); - -//------------------------------------------------------------------ -// -// ActionBezier -// -//------------------------------------------------------------------ -var ActionBezier = BaseLayer.extend({ - onEnter:function () { - this._super(); - - // - // startPosition can be any coordinate, but since the movement - // is relative to the Bezier curve, make it (0,0) - // - - this.centerSprites(3); - - // sprite 1 - var bezier = new cc.BezierConfig(); - bezier.controlPoint_1 = cc.p(0, winSize.height / 2); - bezier.controlPoint_2 = cc.p(300, -winSize.height / 2); - bezier.endPosition = cc.p(300, 100); - - var bezierForward = cc.BezierBy.create(3, bezier); - var bezierBack = bezierForward.reverse(); - var rep = cc.RepeatForever.create(cc.Sequence.create(bezierForward, bezierBack )); - - - // sprite 2 - this._tamara.setPosition(cc.p(80, 160)); - var bezier2 = new cc.BezierConfig(); - bezier2.controlPoint_1 = cc.p(100, winSize.height / 2); - bezier2.controlPoint_2 = cc.p(200, -winSize.height / 2); - bezier2.endPosition = cc.p(240, 160); - - var bezierTo1 = cc.BezierTo.create(2, bezier2); - - // sprite 3 - this._kathia.setPosition(cc.p(400, 160)); - var bezierTo2 = cc.BezierTo.create(2, bezier2); - - this._grossini.id = "gro"; - this._tamara.id = "tam"; - this._kathia.id = "kat"; - - this._grossini.runAction(rep); - this._tamara.runAction(bezierTo1); - this._kathia.runAction(bezierTo2); - - }, - title:function () { - return "BezierBy / BezierTo"; - } -}); -//------------------------------------------------------------------ -// -// ActionBlink -// -//------------------------------------------------------------------ -var ActionBlink = BaseLayer.extend({ - onEnter:function () { - this._super(); - this.centerSprites(2); - - var action1 = cc.Blink.create(2, 10); - var action2 = cc.Blink.create(2, 5); - - this._tamara.runAction(action1); - this._kathia.runAction(action2); - - }, - title:function () { - return "Blink"; - }, - code:function () { - return "a = cc.Blink.create( time, #_of_blinks );\n"; - }, -}); -//------------------------------------------------------------------ -// -// ActionFade -// -//------------------------------------------------------------------ -var ActionFade = BaseLayer.extend({ - onEnter:function () { - this._super(); - this.centerSprites(2); - this._tamara.setOpacity(0); - var action1 = cc.FadeIn.create(1.0); - var action1Back = action1.reverse(); - - var action2 = cc.FadeOut.create(1.0); - var action2Back = action2.reverse(); - - this._tamara.runAction(cc.Sequence.create(action1, action1Back )); - this._kathia.runAction(cc.Sequence.create(action2, action2Back )); - - - }, - title:function () { - return "FadeIn / FadeOut"; - }, - code:function () { - return "" + - "a = cc.FadeIn.create( time );\n" + - "a = cc.FadeOut.create( time );\n" - }, -}); -//------------------------------------------------------------------ -// -// ActionTint -// -//------------------------------------------------------------------ -var ActionTint = BaseLayer.extend({ - onEnter:function () { - this._super(); - this.centerSprites(2); - - var action1 = cc.TintTo.create(2, 255, 0, 255); - var action2 = cc.TintBy.create(2, -127, -255, -127); - var action2Back = action2.reverse(); - - this._tamara.runAction(action1); - this._kathia.runAction(cc.Sequence.create(action2, action2Back)); - - }, - title:function () { - return "TintTo / TintBy"; - }, - code:function () { - return "" + - "a = cc.TintBy.create( time, red, green, blue );\n" + - "a = cc.TintTo.create( time, red, green, blue );\n" - }, -}); - -//------------------------------------------------------------------ -// -// ActionAnimate -// -//------------------------------------------------------------------ -var ActionAnimate = BaseLayer.extend({ - onEnter:function () { - this._super(); - this.centerSprites(3); - - // - // Manual animation - // - var animation = cc.Animation.create(); - for (var i = 1; i < 15; i++) { - var frameName = "Images/grossini_dance_" + ((i < 10) ? ("0" + i) : i) + ".png"; - animation.addSpriteFrameWithFilename(frameName); - } - animation.setDelayPerUnit(2.8 / 14); - animation.setRestoreOriginalFrame(true); - - var action = cc.Animate.create(animation); - this._grossini.runAction(cc.Sequence.create(action, action.reverse())); - - // - // File animation - // - // With 2 loops and reverse - var animCache = cc.AnimationCache.getInstance(); - - animCache.addAnimations("animations/animations-2.plist"); - var animation2 = animCache.getAnimation("dance_1"); - - var action2 = cc.Animate.create(animation2); - this._tamara.runAction(cc.Sequence.create(action2, action2.reverse())); - - // - // File animation - // - // with 4 loops - var animation3 = animation2.copy(); - animation3.setLoops(4); - - var action3 = cc.Animate.create(animation3); - this._kathia.runAction(action3); - }, - - title:function () { - return "Animation"; - }, - - subtitle:function () { - return "Center: Manual animation. Border: using file format animation"; - } -}); - -//------------------------------------------------------------------ -// -// ActionSequence -// -//------------------------------------------------------------------ -var ActionSequence = BaseLayer.extend({ - onEnter:function () { - this._super(); - this.alignSpritesLeft(1); - - var action = cc.Sequence.create( - cc.MoveBy.create(2, cc.p(240, 0)), - cc.RotateBy.create(2, 540) ); - - this._grossini.runAction(action); - - }, - title:function () { - return "Sequence: Move + Rotate"; - }, - code:function () { - return "" + - "a = cc.Sequence.create( a1, a2, a3,..., aN);\n"; - }, -}); -//------------------------------------------------------------------ -// -// ActionSequence2 -// -//------------------------------------------------------------------ -var ActionSequence2 = BaseLayer.extend({ - onEnter:function () { - this._super(); - this.centerSprites(1); - this._grossini.setVisible(false); - var action = cc.Sequence.create( - cc.Place.create(cc.p(200, 200)), - cc.Show.create(), - cc.MoveBy.create(1, cc.p(100, 0)), - cc.CallFunc.create(this, this.callback1), - cc.CallFunc.create(this, this.callback2), - cc.CallFunc.create(this, this.callback3) ); - this._grossini.runAction(action); - - }, - callback1:function () { - var label = cc.LabelTTF.create("callback 1 called", "Marker Felt", 16); - label.setPosition(cc.p(winSize.width / 4 * 1, winSize.height / 2)); - - this.addChild(label); - }, - callback2:function () { - var label = cc.LabelTTF.create("callback 2 called", "Marker Felt", 16); - label.setPosition(cc.p(winSize.width / 4 * 2, winSize.height / 2)); - - this.addChild(label); - }, - callback3:function () { - var label = cc.LabelTTF.create("callback 3 called", "Marker Felt", 16); - label.setPosition(cc.p(winSize.width / 4 * 3, winSize.height / 2)); - - this.addChild(label); - }, - title:function () { - return "Sequence of InstantActions"; - } -}); -//------------------------------------------------------------------ -// -// ActionCallFunc -// -//------------------------------------------------------------------ -var ActionCallFunc = BaseLayer.extend({ - onEnter:function () { - this._super(); - this.centerSprites(3); - - var action = cc.Sequence.create( - cc.MoveBy.create(2, cc.p(200, 0)), - cc.CallFunc.create(this, this.callback1) - ); - - var action2 = cc.Sequence.create( - cc.ScaleBy.create(2, 2), - cc.FadeOut.create(2), - cc.CallFunc.create(this, this.callback2) - ); - - var action3 = cc.Sequence.create( - cc.RotateBy.create(3, 360), - cc.FadeOut.create(2), - cc.CallFunc.create(this, this.callback3, 0xbebabeba) - ); - - this._grossini.runAction(action); - this._tamara.runAction(action2); - this._kathia.runAction(action3); - - }, - callback1:function () { - var label = cc.LabelTTF.create("callback 1 called", "Marker Felt", 16); - label.setPosition(cc.p(winSize.width / 4 * 1, winSize.height / 2)); - this.addChild(label); - }, - callback2:function () { - var label = cc.LabelTTF.create("callback 2 called", "Marker Felt", 16); - label.setPosition(cc.p(winSize.width / 4 * 2, winSize.height / 2)); - - this.addChild(label); - }, - callback3:function () { - var label = cc.LabelTTF.create("callback 3 called", "Marker Felt", 16); - label.setPosition(cc.p(winSize.width / 4 * 3, winSize.height / 2)); - this.addChild(label); - }, - title:function () { - return "Callbacks: CallFunc and friends"; - }, - code:function () { - return "" + - "a = cc.CallFunc.create( this, this.callback );\n" + - "a = cc.CallFunc.create( this, this.callback, optional_arg );"; - }, -}); -//------------------------------------------------------------------ -// -// ActionCallFuncND -// -//------------------------------------------------------------------ -var ActionCallFuncND = BaseLayer.extend({ - onEnter:function () { - this._super(); - this.centerSprites(1); - - var action = cc.Sequence.create(cc.MoveBy.create(2.0, cc.p(200, 0)), - cc.CallFunc.create(this, this.removeGrossini, this._grossini) ); - - this._grossini.runAction(action); - - }, - - removeGrossini : function( spriteToRemove ) { - spriteToRemove.removeFromParentAndCleanup( true ); - }, - - title:function () { - return "CallFunc + auto remove"; - }, - subtitle:function () { - return "CallFunc + removeFromParentAndCleanup. Grossini dissapears in 2s"; - }, - code:function () { - return "" + - "a = cc.CallFunc.create( this, this.callback );\n" + - "a = cc.CallFunc.create( this, this.callback, optional_arg );"; - }, -}); -//------------------------------------------------------------------ -// -// ActionSpawn -// -//------------------------------------------------------------------ -var ActionSpawn = BaseLayer.extend({ - onEnter:function () { - this._super(); - this.alignSpritesLeft(1); - - var action = cc.Spawn.create( - cc.JumpBy.create(2, cc.p(300, 0), 50, 4), - cc.RotateBy.create(2, 720) ); - - this._grossini.runAction(action); - - }, - title:function () { - return "Spawn: Jump + Rotate"; - }, - code:function () { - return "" + - "a = cc.Spawn.create( a1, a2, ..., aN );"; - }, -}); -//------------------------------------------------------------------ -// -// ActionRepeatForever -// -//------------------------------------------------------------------ -var ActionRepeatForever = BaseLayer.extend({ - onEnter:function () { - this._super(); - this.centerSprites(1); - var action = cc.Sequence.create( - cc.DelayTime.create(1), - cc.CallFunc.create(this, this.repeatForever) ); - - this._grossini.runAction(action); - - - }, - repeatForever:function (sender) { - var repeat = cc.RepeatForever.create(cc.RotateBy.create(1.0, 360)); - sender.runAction(repeat) - }, - title:function () { - return "CallFunc + RepeatForever"; - }, - code:function () { - return "" + - "a = cc.RepeatForever.create( action_to_repeat );"; - }, -}); -//------------------------------------------------------------------ -// -// ActionRotateToRepeat -// -//------------------------------------------------------------------ -var ActionRotateToRepeat = BaseLayer.extend({ - onEnter:function () { - this._super(); - this.centerSprites(2); - - var act1 = cc.RotateTo.create(1, 90); - var act2 = cc.RotateTo.create(1, 0); - var seq = cc.Sequence.create(act1, act2); - var rep1 = cc.RepeatForever.create(seq); - var rep2 = cc.Repeat.create((seq.copy()), 10); - - this._tamara.runAction(rep1); - this._kathia.runAction(rep2); - - }, - title:function () { - return "Repeat/RepeatForever + RotateTo"; - }, - code:function () { - return "" + - "a = cc.Repeat.create( action_to_repeat, #_of_times );"; - }, -}); -//------------------------------------------------------------------ -// -// ActionRotateJerk -// -//------------------------------------------------------------------ -var ActionRotateJerk = BaseLayer.extend({ - onEnter:function () { - this._super(); - this.centerSprites(2); - var seq = cc.Sequence.create( - cc.RotateTo.create(0.5, -20), - cc.RotateTo.create(0.5, 20) ); - - var rep1 = cc.Repeat.create(seq, 10); - var rep2 = cc.RepeatForever.create((seq.copy())); - - this._tamara.runAction(rep1); - this._kathia.runAction(rep2); - }, - title:function () { - return "RepeatForever / Repeat + Rotate"; - } -}); -//------------------------------------------------------------------ -// -// ActionReverse -// -//------------------------------------------------------------------ -var ActionReverse = BaseLayer.extend({ - onEnter:function () { - this._super(); - this.alignSpritesLeft(1); - - var jump = cc.JumpBy.create(2, cc.p(300, 0), 50, 4); - var action = cc.Sequence.create(jump, jump.reverse() ); - - this._grossini.runAction(action); - }, - title:function () { - return "Reverse an action"; - }, - code:function () { - return "" + - "a = action.reverse();"; - }, -}); -//------------------------------------------------------------------ -// -// ActionDelayTime -// -//------------------------------------------------------------------ -var ActionDelayTime = BaseLayer.extend({ - onEnter:function () { - this._super(); - this.alignSpritesLeft(1); - - var move = cc.MoveBy.create(1, cc.p(150, 0)); - var action = cc.Sequence.create(move, cc.DelayTime.create(2), move ); - - this._grossini.runAction(action); - }, - title:function () { - return "DelayTime: m + delay + m"; - }, - code:function () { - return "" + - "a = cc.DelayTime.create( time );"; - }, -}); -//------------------------------------------------------------------ -// -// ActionReverseSequence -// -//------------------------------------------------------------------ -var ActionReverseSequence = BaseLayer.extend({ - onEnter:function () { - this._super(); - this.alignSpritesLeft(1); - - var move1 = cc.MoveBy.create(1, cc.p(250, 0)); - var move2 = cc.MoveBy.create(1, cc.p(0, 50)); - var seq = cc.Sequence.create(move1, move2, move1.reverse() ); - var action = cc.Sequence.create(seq, seq.reverse() ); - - this._grossini.runAction(action); - - }, - title:function () { - return "Reverse a sequence"; - } -}); -//------------------------------------------------------------------ -// -// ActionReverseSequence2 -// -//------------------------------------------------------------------ -var ActionReverseSequence2 = BaseLayer.extend({ - onEnter:function () { - this._super(); - this.alignSpritesLeft(2); - - - // Test: - // Sequence should work both with IntervalAction and InstantActions - var move1 = cc.MoveBy.create(3, cc.p(250, 0)); - var move2 = cc.MoveBy.create(3, cc.p(0, 50)); - var tog1 = cc.ToggleVisibility.create(); - var tog2 = cc.ToggleVisibility.create(); - var seq = cc.Sequence.create(move1, tog1, move2, tog2, move1.reverse() ); - var action = cc.Repeat.create( - cc.Sequence.create( - seq, - seq.reverse() - ), - 3 - ); - - - // Test: - // Also test that the reverse of Hide is Show, and vice-versa - this._kathia.runAction(action); - - var move_tamara = cc.MoveBy.create(1, cc.p(100, 0)); - var move_tamara2 = cc.MoveBy.create(1, cc.p(50, 0)); - var hide = cc.Hide.create() - var seq_tamara = cc.Sequence.create(move_tamara, hide, move_tamara2 ); - var seq_back = seq_tamara.reverse(); - this._tamara.runAction(cc.Sequence.create(seq_tamara, seq_back )); - }, - title:function () { - return "Reverse sequence 2"; - } -}); -//------------------------------------------------------------------ -// -// ActionRepeat -// -//------------------------------------------------------------------ -var ActionRepeat = BaseLayer.extend({ - onEnter:function () { - this._super(); - this.alignSpritesLeft(2); - - - var a1 = cc.MoveBy.create(1, cc.p(150, 0)); - var action1 = cc.Repeat.create( - cc.Sequence.create(cc.Place.create(cc.p(60, 60)), a1 ), - 3); - var action2 = cc.RepeatForever.create( - (cc.Sequence.create((a1.copy()), a1.reverse() )) - ); - - this._kathia.runAction(action1); - this._tamara.runAction(action2); - }, - title:function () { - return "Repeat / RepeatForever actions"; - } -}); -//------------------------------------------------------------------ -// -// ActionOrbit -// -//------------------------------------------------------------------ -var ActionOrbit = BaseLayer.extend({ - onEnter:function () { - this._super(); - this.centerSprites(3); - - var orbit1 = cc.OrbitCamera.create(2, 1, 0, 0, 180, 0, 0); - var action1 = cc.Sequence.create( - orbit1, - orbit1.reverse()); - - var orbit2 = cc.OrbitCamera.create(2, 1, 0, 0, 180, -45, 0); - var action2 = cc.Sequence.create( - orbit2, - orbit2.reverse()); - - var orbit3 = cc.OrbitCamera.create(2, 1, 0, 0, 180, 90, 0); - var action3 = cc.Sequence.create( - orbit3, - orbit3.reverse() ); - - this._kathia.runAction(cc.RepeatForever.create(action1)); - this._tamara.runAction(cc.RepeatForever.create(action2)); - this._grossini.runAction(cc.RepeatForever.create(action3)); - - var move = cc.MoveBy.create(3, cc.p(100, -100)); - var move_back = move.reverse(); - var seq = cc.Sequence.create(move, move_back ); - var rfe = cc.RepeatForever.create(seq); - this._kathia.runAction(rfe); - this._tamara.runAction((rfe.copy())); - this._grossini.runAction((rfe.copy())); - - }, - title:function () { - return "OrbitCamera action"; - } -}); -//------------------------------------------------------------------ -// -// ActionFollow -// -//------------------------------------------------------------------ -var ActionFollow = BaseLayer.extend({ - onEnter:function () { - this._super(); - this.centerSprites(1); - - this._grossini.setPosition(cc.p(-200, winSize.height / 2)); - var move = cc.MoveBy.create(2, cc.p(winSize.width * 3, 0)); - var move_back = move.reverse(); - var seq = cc.Sequence.create(move, move_back ); - var rep = cc.RepeatForever.create(seq); - - this._grossini.runAction(rep); - - this.runAction(cc.Follow.create(this._grossini, cc.rect(0, 0, winSize.width * 2 - 100, winSize.height))); - }, - title:function () { - return "Follow action"; - } -}); - -//------------------------------------------------------------------ -// -// ActionCardinalSpline -// -//------------------------------------------------------------------ -var ActionCardinalSpline = BaseLayer.extend({ - - onEnter:function () { - this._super(); - - this.centerSprites(2); - - var array = cc.PointArray.create(10); - - array.addControlPoint(cc.p(0, 0)); - array.addControlPoint(cc.p(winSize.width / 2 - 30, 0)); - array.addControlPoint(cc.p(winSize.width / 2 - 30, winSize.height - 80)); - array.addControlPoint(cc.p(0, winSize.height - 80)); - array.addControlPoint(cc.p(0, 0)); - - // - // sprite 1 (By) - // - // Spline with no tension (tension==0) - // - var action1 = cc.CardinalSplineBy.create(3, array, 0); - var reverse1 = action1.reverse(); - var seq = cc.Sequence.create(action1, reverse1); - - this._tamara.setPosition(cc.p(50, 50)); - this._tamara.runAction(seq); - - // - // sprite 2 (By) - // - // Spline with high tension (tension==1) - // - var action2 = cc.CardinalSplineBy.create(3, array, 1); - var reverse2 = action2.reverse(); - var seq2 = cc.Sequence.create(action2, reverse2); - - this._kathia.setPosition(cc.p(winSize.width / 2, 50)); - this._kathia.runAction(seq2); - }, - - subtitle:function () { - return "Cardinal Spline paths. Testing different tensions for one array"; - }, - title:function () { - return "CardinalSplineBy / CardinalSplineAt"; - }, - code:function() { - return "" + - " a = cc.CadinalSplineBy.create( time, array_of_points, tension );\n" + - " a = cc.CadinalSplineTo.create( time, array_of_points, tension );\n"; - - }, -}); - -//------------------------------------------------------------------ -// -// ActionCatmullRom -// -//------------------------------------------------------------------ -var ActionCatmullRom = BaseLayer.extend({ - - onEnter:function () { - this._super(); - - this.centerSprites(2); - - var array1 = cc.PointArray.create( 10 ); - var array2 = cc.PointArray.create( 10 ); - - // - // sprite 1 (By) - // - // startPosition can be any coordinate, but since the movement - // is relative to the Catmull Rom curve, it is better to start with (0,0). - // - this._tamara.setPosition(cc.p(50, 50)); - - array1.addControlPoint(cc.p(0, 0)); - array1.addControlPoint(cc.p(80, 80)); - array1.addControlPoint(cc.p(winSize.width - 80, 80)); - array1.addControlPoint(cc.p(winSize.width - 80, winSize.height - 80)); - array1.addControlPoint(cc.p(80, winSize.height - 80)); - array1.addControlPoint(cc.p(80, 80)); - array1.addControlPoint(cc.p(winSize.width / 2, winSize.height / 2)); - - var action1 = cc.CatmullRomBy.create(3, array1); - var reverse1 = action1.reverse(); - var seq1 = cc.Sequence.create(action1, reverse1); - - this._tamara.runAction(seq1); - - // - // sprite 2 (To) - // - // The startPosition is not important here, because it uses a "To" action. - // The initial position will be the 1st point of the Catmull Rom path - // - array2.addControlPoint(cc.p(winSize.width / 2, 30)); - array2.addControlPoint(cc.p(winSize.width - 80, 30)); - array2.addControlPoint(cc.p(winSize.width - 80, winSize.height - 80)); - array2.addControlPoint(cc.p(winSize.width / 2, winSize.height - 80)); - array2.addControlPoint(cc.p(winSize.width / 2, 30)); - - var action2 = cc.CatmullRomTo.create(3, array2); - var reverse2 = action2.reverse(); - - var seq2 = cc.Sequence.create(action2, reverse2); - - this._kathia.runAction(seq2); - }, - subtitle:function () { - return "Catmull Rom spline paths. Testing reverse too"; - }, - title:function () { - return "CatmullRomBy / CatmullRomTo"; - }, - code:function() { - return "" + - " a = cc.CatmullRomBy.create( time, array_of_points );\n" + - " a = cc.CatmullRomTo.create( time, array_of_points );\n"; - }, -}); - -var ActionTargeted = BaseLayer.extend({ - onEnter:function () { - this._super(); - this.centerSprites(2); - - var jump1 = cc.JumpBy.create(2, cc.p(0,0), 100, 3); - var jump2 = jump1.copy(); - var rot1 = cc.RotateBy.create(1, 360); - var rot2 = rot1.copy(); - - var t1 = cc.TargetedAction.create(this._kathia, jump2); - var t2 = cc.TargetedAction.create(this._kathia, rot2); - - var seq = cc.Sequence.create(jump1, t1, rot1, t2); - var always = cc.RepeatForever.create(seq); - - this._tamara.runAction(always); - }, - subtitle:function () { - return "Action that runs on another target. Useful for sequences"; - }, - title:function () { - return "Targeted Action"; - }, - code:function () { - return "a = cc.TargetedAction.create( target, action );"; - }, -}); - -var PauseResumeActions = BaseLayer.extend({ - _pausedTargets:[], - _elapsedTime : 0, - _calledResume : false, - _calledPause : false, - onEnter:function () { - this._super(); - this.centerSprites(2); - - this._tamara.runAction(cc.RepeatForever.create(cc.RotateBy.create(3, 360))); - this._grossini.runAction(cc.RepeatForever.create(cc.RotateBy.create(3, -360))); - this._kathia.runAction(cc.RepeatForever.create(cc.RotateBy.create(3, 360))); - - this.scheduleUpdate(); - }, - - update:function (dt) { - this._elapsedTime += dt; - if( this._elapsedTime > 3 && ! this._calledPause ) { - this.pause(); - this._calledPause = true; - } - if( this._elapsedTime > 5 && ! this._calledResume) { - this.resume(); - this._calledResume = true; - } - }, - - pause:function () { - cc.log("Pausing"); - this._pausedTargets = director.getActionManager().pauseAllRunningActions(); - }, - - resume:function () { - cc.log("Resuming"); - director.getActionManager().resumeTargets(this._pausedTargets); - }, - - title:function () { - return "PauseResumeActions"; - }, - subtitle:function () { - return "All actions pause at 3s and resume at 5s"; - } -}); - -var Issue1305 = BaseLayer.extend({ - _spriteTemp:null, - _elapsedTime:0, - onEnter:function () { - this._super(); - this.centerSprites(0); - - this._spriteTmp = cc.Sprite.create("Images/grossini.png"); - /* c++ can't support block, so we use CCCallFuncN instead. - [spriteTmp_ runAction:[CCCallBlockN actionWithBlock:^(CCNode* node) { - NSLog(@"This message SHALL ONLY appear when the sprite is added to the scene, NOT BEFORE"); - }] ]; - */ - - this._spriteTmp.runAction(cc.CallFunc.create(this, this.log)); - this.scheduleUpdate(); - }, - onExit:function () { - this._super(); - }, - log:function (pSender) { - cc.log("This message SHALL ONLY appear when the sprite is added to the scene, NOT BEFORE"); - }, - update:function (dt) { - this._elapsedTime += dt; - if( this._elapsedTime > 2 ) { - this.addSprite(); - this.unscheduleUpdate(); - } - }, - addSprite:function () { - this._spriteTmp.setPosition(cc.p(250,250)); - this.addChild(this._spriteTmp); - }, - title:function () { - return "Issue 1305"; - }, - subtitle:function () { - return "In two seconds you should see a message on the console. NOT BEFORE."; - } -}); - -var Issue1305_2 = BaseLayer.extend({ - onEnter:function () { - this._super(); - this.centerSprites(0); - - var spr = cc.Sprite.create("Images/grossini.png"); - spr.setPosition(cc.p(200,200)); - this.addChild(spr); - - var act1 = cc.MoveBy.create(2 ,cc.p(0, 100)); - - var act2 = cc.CallFunc.create(this, this.log1) ; - var act3 = cc.MoveBy.create(2, cc.p(0, -100)); - var act4 = cc.CallFunc.create(this, this.log2) ; - var act5 = cc.MoveBy.create(2, cc.p(100, -100)); - var act6 = cc.CallFunc.create(this, this.log3) ; - var act7 = cc.MoveBy.create(2, cc.p(-100, 0)); - var act8 = cc.CallFunc.create(this, this.log4) ; - - var actF = cc.Sequence.create(act1, act2, act3, act4, act5, act6, act7, act8); - - // [spr runAction:actF]; - director.getActionManager().addAction(actF ,spr, false); - }, - log1:function () { - cc.log("1st block"); - }, - log2:function () { - cc.log("2nd block"); - }, - log3:function () { - cc.log("3rd block"); - }, - log4:function () { - cc.log("4th block"); - }, - title:function () { - return "Issue 1305 #2"; - }, - subtitle:function () { - return "See console. You should only see one message for each block"; - } -}); - -var Issue1288 = BaseLayer.extend({ - onEnter:function () { - this._super(); - this.centerSprites(0); - - var spr = cc.Sprite.create("Images/grossini.png"); - spr.setPosition(cc.p(100, 100)); - this.addChild(spr); - - var act1 = cc.MoveBy.create(0.5, cc.p(100, 0)); - var act2 = act1.reverse(); - var act3 = cc.Sequence.create(act1, act2); - var act4 = cc.Repeat.create(act3, 2); - - spr.runAction(act4); - }, - title:function () { - return "Issue 1288"; - }, - subtitle:function () { - return "Sprite should end at the position where it started."; - } -}); - -var Issue1288_2 = BaseLayer.extend({ - onEnter:function () { - this._super(); - this.centerSprites(0); - - var spr = cc.Sprite.create("Images/grossini.png"); - spr.setPosition(cc.p(100, 100)); - this.addChild(spr); - - var act1 = cc.MoveBy.create(0.5, cc.p(100, 0)); - spr.runAction(cc.Repeat.create(act1, 1)); - }, - title:function () { - return "Issue 1288 #2"; - }, - subtitle:function () { - return "Sprite should move 100 pixels, and stay there"; - } -}); - -var Issue1327 = BaseLayer.extend({ - onEnter:function () { - this._super(); - this.centerSprites(0); - - var spr = cc.Sprite.create("Images/grossini.png"); - spr.setPosition(cc.p(100, 100)); - this.addChild(spr); - - var act1 = cc.CallFunc.create(this, this.logSprRotation); - var act2 = cc.RotateBy.create(0.25, 45); - var act3 = cc.CallFunc.create(this, this.logSprRotation); - var act4 = cc.RotateBy.create(0.25, 45); - var act5 = cc.CallFunc.create(this, this.logSprRotation); - var act6 = cc.RotateBy.create(0.25, 45); - var act7 = cc.CallFunc.create(this, this.logSprRotation); - var act8 = cc.RotateBy.create(0.25, 45); - var act9 = cc.CallFunc.create(this, this.logSprRotation); - - var actF = cc.Sequence.create(act1, act2, act3, act4, act5, act6, act7, act8, act9); - spr.runAction(actF); - }, - logSprRotation:function (pSender) { - cc.log(pSender.getRotation()); - }, - title:function () { - return "Issue 1327"; - }, - subtitle:function () { - return "See console: You should see: 0, 45, 90, 135, 180"; - } -}); -// -// Order of tests -// - -scenes.push( ActionManual ); -scenes.push( ActionMove ); -scenes.push( ActionScale ); -scenes.push( ActionRotate ); -scenes.push( ActionSkew ); -scenes.push( ActionSkewRotateScale ); -scenes.push( ActionJump ); -//scenes.push( ActionBezier ); -scenes.push( ActionCardinalSpline ); -scenes.push( ActionCatmullRom ); -scenes.push( ActionBlink ); -scenes.push( ActionFade ); -scenes.push( ActionTint ); -scenes.push( ActionSequence ); -scenes.push( ActionSequence2 ); -scenes.push( ActionSpawn ); -scenes.push( ActionReverse ); -scenes.push( ActionDelayTime ); -scenes.push( ActionRepeat ); -scenes.push( ActionRepeatForever ); -scenes.push( ActionRotateToRepeat ); -scenes.push( ActionRotateJerk ); -scenes.push( ActionCallFunc ); -scenes.push( ActionCallFuncND ); -scenes.push( ActionReverseSequence ); -scenes.push( ActionReverseSequence2 ); -scenes.push( ActionAnimate ); -scenes.push( ActionTargeted ); -scenes.push( PauseResumeActions ); -scenes.push( Issue1305 ); -scenes.push( Issue1305_2 ); -scenes.push( Issue1288 ); -scenes.push( Issue1288_2 ); -scenes.push( Issue1327 ); - -//------------------------------------------------------------------ -// -// Main entry point -// -//------------------------------------------------------------------ -function run() -{ - var scene = cc.Scene.create(); - var layer = new scenes[currentScene](); - scene.addChild( layer ); - - var runningScene = director.getRunningScene(); - if( runningScene == null ) - director.runWithScene( scene ); - else - director.replaceScene( cc.TransitionFade.create(0.5, scene ) ); -} - -run(); - - diff --git a/samples/TestJavascript/Resources/js/test-actionsprogress.js b/samples/TestJavascript/Resources/js/test-actionsprogress.js deleted file mode 100644 index e1f74f2d38..0000000000 --- a/samples/TestJavascript/Resources/js/test-actionsprogress.js +++ /dev/null @@ -1,461 +0,0 @@ -// -// http://www.cocos2d-iphone.org -// http://www.cocos2d-html5.org -// http://www.cocos2d-x.org -// -// Javascript + cocos2d actions tests -// - -require("js/helper.js"); - -director = cc.Director.getInstance(); -winSize = director.getWinSize(); -centerPos = cc.p( winSize.width/2, winSize.height/2 ); -spriteFrameCache = cc.SpriteFrameCache.getInstance(); - -var scenes = []; -var currentScene = 0; - -var nextScene = function () { - currentScene = currentScene + 1; - if( currentScene >= scenes.length ) - currentScene = 0; - - withTransition = true; - loadScene(currentScene); -}; - -var previousScene = function () { - currentScene = currentScene -1; - if( currentScene < 0 ) - currentScene = scenes.length -1; - - withTransition = true; - loadScene(currentScene); -}; - -var restartScene = function () { - loadScene( currentScene ); -}; - -var loadScene = function (sceneIdx) -{ - winSize = director.getWinSize(); - centerPos = cc.p( winSize.width/2, winSize.height/2 ); - - var scene = new cc.Scene(); - scene.init(); - var layer = new scenes[ sceneIdx ](); - - scene.addChild( layer ); - -// scene.walkSceneGraph(0); - - director.replaceScene( scene ); -// __jsc__.garbageCollect(); -} - -var s_pathSister1 = "Images/grossinis_sister1.png"; -var s_pathSister2 = "Images/grossinis_sister2.png"; -var s_pathBlock = "Images/blocks.png"; -var s_grossiniPlist = "animations/grossini.plist"; - -// -// Base Layer -// - -var BaseLayer = cc.LayerGradient.extend({ - - ctor:function () { - - var parent = new cc.LayerGradient(); - __associateObjWithNative(this, parent); - this.init(cc.c4b(0, 0, 0, 255), cc.c4b(0, 128, 255, 255)); - }, - - title:function () { - return "Progress Actions"; - }, - - subtitle:function () { - return ""; - }, - - code:function () { - return ""; - }, - - restartCallback:function (sender) { - restartScene(); - }, - - nextCallback:function (sender) { - nextScene(); - }, - - backCallback:function (sender) { - previousScene(); - }, - - onEnter:function () { - // DO NOT CALL this._super() -// this._super(); - - // add title and subtitle - var label = cc.LabelTTF.create(this.title(), "Arial", 28); - this.addChild(label, 1); - label.setPosition( cc.p(winSize.width / 2, winSize.height - 40)); - - var strSubtitle = this.subtitle(); - if (strSubtitle != "") { - var l = cc.LabelTTF.create(strSubtitle, "Thonburi", 16); - this.addChild(l, 1); - l.setPosition( cc.p(winSize.width / 2, winSize.height - 70)); - } - - var strCode = this.code(); - if( strCode !="" ) { - var label = cc.LabelTTF.create(strCode, 'CourierNewPSMT', 16); - label.setPosition( cc.p( winSize.width/2, winSize.height-120) ); - this.addChild( label,10 ); - - var labelbg = cc.LabelTTF.create(strCode, 'CourierNewPSMT', 16); - labelbg.setColor( cc.c3b(10,10,255) ); - labelbg.setPosition( cc.p( winSize.width/2 +1, winSize.height-120 -1) ); - this.addChild( labelbg,9); - } - - // Menu - var item1 = cc.MenuItemImage.create("Images/b1.png", "Images/b2.png", this, this.backCallback); - var item2 = cc.MenuItemImage.create("Images/r1.png", "Images/r2.png", this, this.restartCallback); - var item3 = cc.MenuItemImage.create("Images/f1.png", "Images/f2.png", this, this.nextCallback); - var item4 = cc.MenuItemFont.create("back", this, function() { require("js/main.js"); } ); - item4.setFontSize( 22 ); - - var menu = cc.Menu.create(item1, item2, item3, item4 ); - - menu.setPosition( cc.p(0,0) ); - item1.setPosition( cc.p(winSize.width / 2 - 100, 30)); - item2.setPosition( cc.p(winSize.width / 2, 30)); - item3.setPosition( cc.p(winSize.width / 2 + 100, 30)); - item4.setPosition( cc.p(winSize.width - 60, winSize.height - 30 ) ); - - this.addChild(menu, 1); - } -}); - -//------------------------------------------------------------------ -// -// Tests -// -//------------------------------------------------------------------ -var SpriteProgressToRadial = BaseLayer.extend({ - onEnter:function () { - this._super(); - - var to1 = cc.ProgressTo.create(2, 100); - var to2 = cc.ProgressTo.create(2, 100); - - var left = cc.ProgressTimer.create(cc.Sprite.create(s_pathSister1)); - left.setType(cc.PROGRESS_TIMER_TYPE_RADIAL); - this.addChild(left); - left.setPosition(cc.p(200, winSize.height / 2)); - left.runAction(cc.RepeatForever.create(to1)); - - var right = cc.ProgressTimer.create(cc.Sprite.create(s_pathBlock)); - right.setType(cc.PROGRESS_TIMER_TYPE_RADIAL); - - right.setReverseDirection(true); - - this.addChild(right); - right.setPosition(cc.p(winSize.width - 200, winSize.height / 2)); - right.runAction(cc.RepeatForever.create(to2)); - }, - - subtitle:function () { - return "ProgressTo Radial"; - } -}); - -var SpriteProgressToHorizontal = BaseLayer.extend({ - onEnter:function () { - this._super(); - - var to1 = cc.ProgressTo.create(2, 100); - var to2 = cc.ProgressTo.create(2, 100); - - var left = cc.ProgressTimer.create(cc.Sprite.create(s_pathSister1)); - left.setType(cc.PROGRESS_TIMER_TYPE_BAR); - // Setup for a bar starting from the left since the midpoint is 0 for the x - left.setMidpoint(cc.p(0, 0)); - // Setup for a horizontal bar since the bar change rate is 0 for y meaning no vertical change - left.setBarChangeRate(cc.p(1, 0)); - this.addChild(left); - left.setPosition(cc.p(200, winSize.height / 2)); - left.runAction(cc.RepeatForever.create(to1)); - - var right = cc.ProgressTimer.create(cc.Sprite.create(s_pathSister2)); - right.setType(cc.PROGRESS_TIMER_TYPE_BAR); - // Setup for a bar starting from the left since the midpoint is 1 for the x - right.setMidpoint(cc.p(1, 0)); - // Setup for a horizontal bar since the bar change rate is 0 for y meaning no vertical change - right.setBarChangeRate(cc.p(1, 0)); - this.addChild(right); - right.setPosition(cc.p(winSize.width - 200, winSize.height / 2)); - right.runAction(cc.RepeatForever.create(to2)); - }, - subtitle:function () { - return "ProgressTo Horizontal"; - } -}); - -var SpriteProgressToVertical = BaseLayer.extend({ - onEnter:function () { - this._super(); - - var to1 = cc.ProgressTo.create(2, 100); - var to2 = cc.ProgressTo.create(2, 100); - - var left = cc.ProgressTimer.create(cc.Sprite.create(s_pathSister1)); - left.setType(cc.PROGRESS_TIMER_TYPE_BAR); - // Setup for a bar starting from the bottom since the midpoint is 0 for the y - left.setMidpoint(cc.p(0, 0)); - // Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change - left.setBarChangeRate(cc.p(0, 1)); - this.addChild(left); - left.setPosition(cc.p(200, winSize.height / 2)); - left.runAction(cc.RepeatForever.create(to1)); - - var right = cc.ProgressTimer.create(cc.Sprite.create(s_pathSister2)); - right.setType(cc.PROGRESS_TIMER_TYPE_BAR); - // Setup for a bar starting from the bottom since the midpoint is 0 for the y - right.setMidpoint(cc.p(0, 1)); - // Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change - right.setBarChangeRate(cc.p(0, 1)); - this.addChild(right); - right.setPosition(cc.p(winSize.width - 200, winSize.height / 2)); - right.runAction(cc.RepeatForever.create(to2)); - }, - subtitle:function () { - return "ProgressTo Vertical"; - } -}); - -var SpriteProgressToRadialMidpointChanged = BaseLayer.extend({ - onEnter:function () { - this._super(); - - var action = cc.ProgressTo.create(2, 100); - - /** - * Our image on the left should be a radial progress indicator, clockwise - */ - var left = cc.ProgressTimer.create(cc.Sprite.create(s_pathBlock)); - left.setType(cc.PROGRESS_TIMER_TYPE_RADIAL); - this.addChild(left); - left.setMidpoint(cc.p(0.25, 0.75)); - left.setPosition(cc.p(200, winSize.height / 2)); - left.runAction(cc.RepeatForever.create(action.copy())); - - /** - * Our image on the left should be a radial progress indicator, counter clockwise - */ - var right = cc.ProgressTimer.create(cc.Sprite.create(s_pathBlock)); - right.setType(cc.PROGRESS_TIMER_TYPE_RADIAL); - right.setMidpoint(cc.p(0.75, 0.25)); - /** - * Note the reverse property (default=NO) is only added to the right image. That's how - * we get a counter clockwise progress. - */ - this.addChild(right); - right.setPosition(cc.p(winSize.width - 200, winSize.height / 2)); - right.runAction(cc.RepeatForever.create(action.copy())); - }, - - subtitle:function () { - return "Radial w/ Different Midpoints"; - } -}); - -var SpriteProgressBarVarious = BaseLayer.extend({ - onEnter:function () { - this._super(); - - var to = cc.ProgressTo.create(2, 100); - - var left = cc.ProgressTimer.create(cc.Sprite.create(s_pathSister1)); - left.setType(cc.PROGRESS_TIMER_TYPE_BAR); - - // Setup for a bar starting from the bottom since the midpoint is 0 for the y - left.setMidpoint(cc.p(0.5, 0.5)); - // Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change - left.setBarChangeRate(cc.p(1, 0)); - this.addChild(left); - left.setPosition(cc.p(150, winSize.height / 2)); - left.runAction(cc.RepeatForever.create(to.copy())); - - var middle = cc.ProgressTimer.create(cc.Sprite.create(s_pathSister2)); - middle.setType(cc.PROGRESS_TIMER_TYPE_BAR); - // Setup for a bar starting from the bottom since the midpoint is 0 for the y - middle.setMidpoint(cc.p(0.5, 0.5)); - // Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change - middle.setBarChangeRate(cc.p(1, 1)); - this.addChild(middle); - middle.setPosition(cc.p(winSize.width / 2, winSize.height / 2)); - middle.runAction(cc.RepeatForever.create(to.copy())); - - var right = cc.ProgressTimer.create(cc.Sprite.create(s_pathSister2)); - right.setType(cc.PROGRESS_TIMER_TYPE_BAR); - // Setup for a bar starting from the bottom since the midpoint is 0 for the y - right.setMidpoint(cc.p(0.5, 0.5)); - // Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change - right.setBarChangeRate(cc.p(0, 1)); - this.addChild(right); - right.setPosition(cc.p(winSize.width - 150, winSize.height / 2)); - right.runAction(cc.RepeatForever.create(to.copy())); - }, - - subtitle:function () { - return "ProgressTo Bar Mid"; - } -}); - -var SpriteProgressBarTintAndFade = BaseLayer.extend({ - onEnter:function () { - this._super(); - - var to = cc.ProgressTo.create(6, 100); - var tint = cc.Sequence.create(cc.TintTo.create(1, 255, 0, 0), - cc.TintTo.create(1, 0, 255, 0), - cc.TintTo.create(1, 0, 0, 255)); - - var fade = cc.Sequence.create(cc.FadeTo.create(1.0, 0), cc.FadeTo.create(1.0, 255)); - - var left = cc.ProgressTimer.create(cc.Sprite.create(s_pathSister1)); - left.setType(cc.PROGRESS_TIMER_TYPE_BAR); - - // Setup for a bar starting from the bottom since the midpoint is 0 for the y - left.setMidpoint(cc.p(0.5, 0.5)); - // Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change - left.setBarChangeRate(cc.p(1, 0)); - this.addChild(left); - left.setPosition(cc.p(150, winSize.height / 2)); - left.runAction(cc.RepeatForever.create(to.copy())); - left.runAction(cc.RepeatForever.create(tint.copy())); - - left.addChild(cc.LabelTTF.create("Tint", "Marker Felt", 20.0)); - - var middle = cc.ProgressTimer.create(cc.Sprite.create(s_pathSister2)); - middle.setType(cc.PROGRESS_TIMER_TYPE_BAR); - // Setup for a bar starting from the bottom since the midpoint is 0 for the y - middle.setMidpoint(cc.p(0.5, 0.5)); - // Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change - middle.setBarChangeRate(cc.p(1, 1)); - this.addChild(middle); - middle.setPosition(cc.p(winSize.width / 2, winSize.height / 2)); - middle.runAction(cc.RepeatForever.create(to.copy())); - middle.runAction(cc.RepeatForever.create(fade.copy())); - - middle.addChild(cc.LabelTTF.create("Fade", "Marker Felt", 20.0)); - - var right = cc.ProgressTimer.create(cc.Sprite.create(s_pathSister2)); - right.setType(cc.PROGRESS_TIMER_TYPE_BAR); - // Setup for a bar starting from the bottom since the midpoint is 0 for the y - right.setMidpoint(cc.p(0.5, 0.5)); - // Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change - right.setBarChangeRate(cc.p(0, 1)); - this.addChild(right); - right.setPosition(cc.p(winSize.width - 150, winSize.height / 2)); - right.runAction(cc.RepeatForever.create(to.copy())); - right.runAction(cc.RepeatForever.create(tint.copy())); - right.runAction(cc.RepeatForever.create(fade.copy())); - - right.addChild(cc.LabelTTF.create("Tint and Fade", "Marker Felt", 20.0)); - }, - - subtitle:function () { - return "ProgressTo Bar Mid"; - } -}); - -var SpriteProgressWithSpriteFrame = BaseLayer.extend({ - onEnter:function () { - this._super(); - - var to = cc.ProgressTo.create(6, 100); - - // XXX-riq: We should simplify the API in this case. -// spriteFrameCache.addSpriteFramesWithFile(s_grossiniPlist); - spriteFrameCache.addSpriteFrames(s_grossiniPlist); - - // XXX-riq: This is incorrect. It is creating the Sprite with a FrameName, not a Frame -// var left = cc.ProgressTimer.create(cc.Sprite.createWithSpriteFrame("grossini_dance_01.png")); - var left = cc.ProgressTimer.create(cc.Sprite.createWithSpriteFrameName("grossini_dance_01.png")); - - left.setType(cc.PROGRESS_TIMER_TYPE_BAR); - // Setup for a bar starting from the bottom since the midpoint is 0 for the y - left.setMidpoint(cc.p(0.5, 0.5)); - // Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change - left.setBarChangeRate(cc.p(1, 0)); - this.addChild(left); - left.setPosition(cc.p(150, winSize.height / 2)); - left.runAction(cc.RepeatForever.create(to.copy())); - - var middle = cc.ProgressTimer.create(cc.Sprite.createWithSpriteFrameName("grossini_dance_02.png")); - middle.setType(cc.PROGRESS_TIMER_TYPE_BAR); - // Setup for a bar starting from the bottom since the midpoint is 0 for the y - middle.setMidpoint(cc.p(0.5, 0.5)); - // Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change - middle.setBarChangeRate(cc.p(1, 1)); - this.addChild(middle); - middle.setPosition(cc.p(winSize.width / 2, winSize.height / 2)); - middle.runAction(cc.RepeatForever.create(to.copy())); - - var right = cc.ProgressTimer.create(cc.Sprite.createWithSpriteFrameName("grossini_dance_03.png")); - right.setType(cc.PROGRESS_TIMER_TYPE_RADIAL); - // Setup for a bar starting from the bottom since the midpoint is 0 for the y - right.setMidpoint(cc.p(0.5, 0.5)); - // Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change - right.setBarChangeRate(cc.p(0, 1)); - this.addChild(right); - right.setPosition(cc.p(winSize.width - 150, winSize.height / 2)); - right.runAction(cc.RepeatForever.create(to.copy())); - }, - - subtitle:function () { - return "Progress With Sprite Frame"; - } -}); -// -// Order of tests -// - -scenes.push( SpriteProgressToRadial ); -scenes.push( SpriteProgressToHorizontal ); -scenes.push( SpriteProgressToVertical ); -scenes.push( SpriteProgressToRadialMidpointChanged ); -scenes.push( SpriteProgressBarVarious ); -scenes.push( SpriteProgressBarTintAndFade ); -scenes.push( SpriteProgressWithSpriteFrame ); - -//------------------------------------------------------------------ -// -// Main entry point -// -//------------------------------------------------------------------ -function run() -{ - var scene = cc.Scene.create(); - var layer = new scenes[currentScene](); - scene.addChild( layer ); - - var runningScene = director.getRunningScene(); - if( runningScene == null ) - director.runWithScene( scene ); - else - director.replaceScene( cc.TransitionFade.create(0.5, scene ) ); -} - -run(); - - diff --git a/samples/TestJavascript/Resources/js/test-chipmunk.js b/samples/TestJavascript/Resources/js/test-chipmunk.js deleted file mode 100644 index f459071866..0000000000 --- a/samples/TestJavascript/Resources/js/test-chipmunk.js +++ /dev/null @@ -1,455 +0,0 @@ -// -// http://www.cocos2d-iphone.org -// -// Javascript + chipmunk tests -// - -require("js/helper.js"); - -director = cc.Director.getInstance(); -winSize = director.getWinSize(); -centerPos = cc.p( winSize.width/2, winSize.height/2 ); - -var scenes = [] -var currentScene = 0; - -var nextSpriteTestAction = function () { - currentScene = currentScene + 1; - if( currentScene >= scenes.length ) - currentScene = 0; - - loadScene(currentScene); -}; -var backSpriteTestAction = function () { - currentScene = currentScene -1; - if( currentScene < 0 ) - currentScene = scenes.length -1; - - loadScene(currentScene); -}; -var restartSpriteTestAction = function () { - loadScene( currentScene ); -}; - -var loadScene = function (sceneIdx) -{ - winSize = director.getWinSize(); - centerPos = cc.p( winSize.width/2, winSize.height/2 ); - - var scene = new cc.Scene(); - scene.init(); - var layer = new scenes[ sceneIdx ](); - - scene.addChild( layer ); - -// scene.walkSceneGraph(0); - - director.replaceScene( scene ); -// __jsc__.garbageCollect(); -} - -//------------------------------------------------------------------ -// -// BaseLayer -// -//------------------------------------------------------------------ -var BaseLayer = function() { - - // - // VERY IMPORTANT - // - // Only subclasses of a native classes MUST call __associateObjectWithNative - // Failure to do so, it will crash. - // - var parent = goog.base(this); - __associateObjWithNative( this, parent ); - this.init(); - - this.title = function () { - return "No title"; - } - - this.subtitle = function () { - return "No Subtitle"; - } - -} -goog.inherits(BaseLayer, cc.Layer ); - -// -// Instance 'base' methods -// XXX: Should be defined after "goog.inherits" -// -BaseLayer.prototype.onEnter = function() { - var label = cc.LabelTTF.create(this.title(), "Arial", 28); - this.addChild(label, 1); - label.setPosition( cc.p(winSize.width / 2, winSize.height - 50)); - - var strSubtitle = this.subtitle(); - if (strSubtitle != "") { - var l = cc.LabelTTF.create(strSubtitle, "Thonburi", 16); - this.addChild(l, 1); - l.setPosition( cc.p(winSize.width / 2, winSize.height - 80)); - } - - // Menu - var item1 = cc.MenuItemImage.create("Images/b1.png", "Images/b2.png", this, this.backCallback); - var item2 = cc.MenuItemImage.create("Images/r1.png", "Images/r2.png", this, this.restartCallback); - var item3 = cc.MenuItemImage.create("Images/f1.png", "Images/f2.png", this, this.nextCallback); - var item4 = cc.MenuItemFont.create("back", this, function() { require("js/main.js"); } ); - item4.setFontSize( 22 ); - - var menu = cc.Menu.create(item1, item2, item3, item4 ); - - menu.setPosition( cc.p(0,0) ); - item1.setPosition( cc.p(winSize.width / 2 - 100, 30)); - item2.setPosition( cc.p(winSize.width / 2, 30)); - item3.setPosition( cc.p(winSize.width / 2 + 100, 30)); - item4.setPosition( cc.p(winSize.width - 60, winSize.height - 30 ) ); - - this.addChild(menu, 1); -} - -BaseLayer.prototype.restartCallback = function (sender) { - cc.log("restart called"); - restartSpriteTestAction(); -} - -BaseLayer.prototype.nextCallback = function (sender) { - cc.log("next called"); - nextSpriteTestAction(); -} - -BaseLayer.prototype.backCallback = function (sender) { - cc.log("back called"); - backSpriteTestAction(); -} - - -//------------------------------------------------------------------ -// -// Chipmunk + Sprite -// -//------------------------------------------------------------------ -var ChipmunkSpriteTest = function() { - - goog.base(this); - - this.addSprite = function( pos ) { - var sprite = this.createPhysicsSprite( pos ); - this.addChild( sprite ); - } - - this.title = function() { - return 'Chipmunk Sprite Test'; - } - - this.subtitle = function() { - return 'Chipmunk + cocos2d sprites tests. Tap screen.'; - } - - this.initPhysics(); -} -goog.inherits( ChipmunkSpriteTest, BaseLayer ); - -// -// Instance 'base' methods -// XXX: Should be defined after "goog.inherits" -// - -// init physics -ChipmunkSpriteTest.prototype.initPhysics = function() { - this.space = cp.spaceNew(); - var staticBody = cp.spaceGetStaticBody( this.space ); - - // Walls - var walls = [cp.segmentShapeNew( staticBody, cp.v(0,0), cp.v(winSize.width,0), 0 ), // bottom - cp.segmentShapeNew( staticBody, cp.v(0,winSize.height), cp.v(winSize.width,winSize.height), 0), // top - cp.segmentShapeNew( staticBody, cp.v(0,0), cp.v(0,winSize.height), 0), // left - cp.segmentShapeNew( staticBody, cp.v(winSize.width,0), cp.v(winSize.width,winSize.height), 0) // right - ]; - for( var i=0; i < walls.length; i++ ) { - var wall = walls[i]; - cp.shapeSetElasticity(wall, 1); - cp.shapeSetFriction(wall, 1); - cp.spaceAddStaticShape( this.space, wall ); - } - - // Gravity - cp.spaceSetGravity( this.space, cp.v(0, -100) ); -} - -ChipmunkSpriteTest.prototype.createPhysicsSprite = function( pos ) { - var body = cp.bodyNew(1, cp.momentForBox(1, 48, 108) ); - cp.bodySetPos( body, pos ); - cp.spaceAddBody( this.space, body ); - var shape = cp.boxShapeNew( body, 48, 108); - cp.shapeSetElasticity( shape, 0.5 ); - cp.shapeSetFriction( shape, 0.5 ); - cp.spaceAddShape( this.space, shape ); - - var sprite = cc.PhysicsSprite.create("Images/grossini.png"); - sprite.setBody( body ); - return sprite; -} - -ChipmunkSpriteTest.prototype.onEnter = function () { - - goog.base(this, 'onEnter'); - - this.scheduleUpdate(); - for(var i=0; i<10; i++) { - this.addSprite( cp.v(winSize.width/2, winSize.height/2) ); - } - - var platform = __getPlatform(); - if( platform.substring(0,7) == 'desktop' ) { - this.setMouseEnabled( true ); - } else if( platform.substring(0,6) == 'mobile' ) { - this.setTouchEnabled( true ); - } -} - -ChipmunkSpriteTest.prototype.update = function( delta ) { - cp.spaceStep( this.space, delta ); -} - -ChipmunkSpriteTest.prototype.onMouseDown = function( event ) { - this.addSprite( event.getLocation() ); -} - -ChipmunkSpriteTest.prototype.onTouchesEnded = function( touches, event ) { - var l = touches.length; - for( var i=0; i < l; i++) { - this.addSprite( touches[i].getLocation() ); - } -} - -//------------------------------------------------------------------ -// -// Chipmunk + Sprite + Batch -// -//------------------------------------------------------------------ -var ChipmunkSpriteBatchTest = function() { - - goog.base(this); - - // batch node - this.batch = cc.SpriteBatchNode.create('Images/grossini.png', 50 ); - this.addChild( this.batch ); - - this.addSprite = function( pos ) { - var sprite = this.createPhysicsSprite( pos ); - this.batch.addChild( sprite ); - } - - this.title = function() { - return 'Chipmunk SpriteBatch Test'; - } - - this.subtitle = function() { - return 'Chipmunk + cocos2d sprite batch tests. Tap screen.'; - } -} -goog.inherits( ChipmunkSpriteBatchTest, ChipmunkSpriteTest ); - -//------------------------------------------------------------------ -// -// Chipmunk Collision Test -// -//------------------------------------------------------------------ -var ChipmunkCollisionTest = function() { - - goog.base(this); - - this.messageDisplayed = false; - - this.title = function() { - return 'Chipmunk Collision Test'; - } - - this.subtitle = function() { - return 'Testing collision callback'; - } - - // init physics - this.initPhysics = function() { - this.space = cp.spaceNew(); - var staticBody = cp.spaceGetStaticBody( this.space ); - - // Walls - var walls = [cp.segmentShapeNew( staticBody, cp.v(0,0), cp.v(winSize.width,0), 0 ), // bottom - cp.segmentShapeNew( staticBody, cp.v(0,winSize.height), cp.v(winSize.width,winSize.height), 0), // top - cp.segmentShapeNew( staticBody, cp.v(0,0), cp.v(0,winSize.height), 0), // left - cp.segmentShapeNew( staticBody, cp.v(winSize.width,0), cp.v(winSize.width,winSize.height), 0) // right - ]; - for( var i=0; i < walls.length; i++ ) { - var wall = walls[i]; - cp.shapeSetElasticity(wall, 1); - cp.shapeSetFriction(wall, 1); - cp.spaceAddStaticShape( this.space, wall ); - } - - // Gravity - cp.spaceSetGravity( this.space, cp.v(0, -30) ); - } - - this.createPhysicsSprite = function( pos, file, collision_type ) { - var body = cp.bodyNew(1, cp.momentForBox(1, 48, 108) ); - cp.bodySetPos( body, pos ); - cp.spaceAddBody( this.space, body ); - var shape = cp.boxShapeNew( body, 48, 108); - cp.shapeSetElasticity( shape, 0.5 ); - cp.shapeSetFriction( shape, 0.5 ); - cp.shapeSetCollisionType( shape, collision_type ); - cp.spaceAddShape( this.space, shape ); - - var sprite = cc.PhysicsSprite.create(file); - sprite.setBody( body ); - return sprite; - } - - this.onEnter = function () { - goog.base(this, 'onEnter'); - - this.initPhysics(); - this.scheduleUpdate(); - - var sprite1 = this.createPhysicsSprite( cc.p(winSize.width/2, winSize.height-20), "Images/grossini.png", 1); - var sprite2 = this.createPhysicsSprite( cc.p(winSize.width/2, 50), "Images/grossinis_sister1.png", 2); - - this.addChild( sprite1 ); - this.addChild( sprite2 ); - - cp.spaceAddCollisionHandler( this.space, 1, 2, this, this.collisionBegin, this.collisionPre, this.collisionPost, this.collisionSeparate ); - } - - this.onExit = function() { - cp.spaceRemoveCollisionHandler( this.space, 1, 2 ); - cp.spaceFree( this.space ); - } - - this.update = function( delta ) { - cp.spaceStep( this.space, delta ); - } - - this.collisionBegin = function ( arbiter, space ) { - - if( ! this.messageDisplayed ) { - var label = cc.LabelBMFont.create("Collision Detected", "Fonts/bitmapFontTest5.fnt"); - this.addChild( label ); - label.setPosition( centerPos ); - this.messageDisplayed = true; - } - cc.log('collision begin'); - var bodies = cp.arbiterGetBodies( arbiter ); - var shapes = cp.arbiterGetShapes( arbiter ); - var collTypeA = cp.shapeGetCollisionType( shapes[0] ); - var collTypeB = cp.shapeGetCollisionType( shapes[1] ); - cc.log( 'Collision Type A:' + collTypeA ); - cc.log( 'Collision Type B:' + collTypeB ); - return true - } - - this.collisionPre = function ( arbiter, space ) { - cc.log('collision pre'); - return true; - } - - this.collisionPost = function ( arbiter, space ) { - cc.log('collision post'); - } - - this.collisionSeparate = function ( arbiter, space ) { - cc.log('collision separate'); - } - -} -goog.inherits( ChipmunkCollisionTest, BaseLayer ); - -//------------------------------------------------------------------ -// -// Chipmunk Collision Memory Leak Test -// -//------------------------------------------------------------------ -var ChipmunkCollisionMemoryLeakTest = function() { - - goog.base(this); - - this.title = function() { - return 'Chipmunk Memory Leak Test'; - } - - this.subtitle = function() { - return 'Testing possible memory leak on the collision handler. No visual feedback'; - } - - this.collisionBegin = function ( arbiter, space ) { - return true - } - - this.collisionPre = function ( arbiter, space ) { - return true; - } - - this.collisionPost = function ( arbiter, space ) { - cc.log('collision post'); - } - - this.collisionSeparate = function ( arbiter, space ) { - cc.log('collision separate'); - } - - this.onEnter = function() { - goog.base(this, 'onEnter'); - this.space = cp.spaceNew(); - - for( var i=1 ; i < 100 ; i++ ) - cp.spaceAddCollisionHandler( this.space, i, i+1, this, this.collisionBegin, this.collisionPre, this.collisionPost, this.collisionSeparate ); - - } - - this.onExit = function() { - - for( var i=1 ; i < 100 ; i++ ) - cp.spaceRemoveCollisionHandler( this.space, i, i+1 ); - - cp.spaceFree( this.space ); - } -} -goog.inherits( ChipmunkCollisionMemoryLeakTest, BaseLayer ); -// -// Instance 'base' methods -// XXX: Should be defined after "goog.inherits" -// - - - -// -// Order of tests -// - -scenes.push( ChipmunkSpriteTest ); scenes.push( ChipmunkSpriteBatchTest ); -scenes.push( ChipmunkCollisionTest ); -scenes.push( ChipmunkCollisionMemoryLeakTest ); - - -//------------------------------------------------------------------ -// -// Main entry point -// -//------------------------------------------------------------------ -function run() -{ - var scene = cc.Scene.create(); - var layer = new scenes[currentScene](); - scene.addChild( layer ); - - var runningScene = director.getRunningScene(); - if( runningScene == null ) - director.runWithScene( scene ); - else - director.replaceScene( cc.TransitionFade.create(0.5, scene ) ); -} - -run(); diff --git a/samples/TestJavascript/Resources/js/test-cocos2djs.js b/samples/TestJavascript/Resources/js/test-cocos2djs.js deleted file mode 100644 index 30b5a6cac7..0000000000 --- a/samples/TestJavascript/Resources/js/test-cocos2djs.js +++ /dev/null @@ -1,749 +0,0 @@ -// -// http://www.cocos2d-iphone.org -// -// Javascript + chipmunk tests -// - -require("js/helper.js"); - -director = cc.Director.getInstance(); -winSize = director.getWinSize(); -centerPos = cc.p( winSize.width/2, winSize.height/2 ); - -var scenes = [] -var currentScene = 0; -var withTransition = false; - -var nextScene = function () { - currentScene = currentScene + 1; - if( currentScene >= scenes.length ) - currentScene = 0; - - withTransition = true; - loadScene(currentScene); -}; -var previousScene = function () { - currentScene = currentScene -1; - if( currentScene < 0 ) - currentScene = scenes.length -1; - - withTransition = true; - loadScene(currentScene); -}; -var restartScene = function () { - loadScene( currentScene ); -}; - -var loadScene = function (sceneIdx) -{ - winSize = director.getWinSize(); - centerPos = cc.p( winSize.width/2, winSize.height/2 ); - - var scene = new cc.Scene(); - scene.init(); - var layer = new scenes[ sceneIdx ](); - - scene.addChild( layer ); - -// scene.walkSceneGraph(0); - - var transitions = [ cc.TransitionSplitCols, cc.TransitionSplitRows, - cc.TransitionSlideInL, cc.TransitionSlideInR, cc.TransitionSlideInT, cc.TransitionSlideInB, - cc.TransitionFade, cc.TransitionCrossFade, - cc.TransitionFlipX, cc.TransitionFlipY, - cc.TransitionProgressRadialCCW, cc.TransitionProgressRadialCW, cc.TransitionProgressVertical, cc.TransitionProgressHorizontal, - cc.TransitionShrinkGrow, - ]; - var idx = Math.floor( Math.random() * transitions.length ); - var transition = transitions[ idx ]; - - if( withTransition == true ) - director.replaceScene( transition.create( 0.9, scene ) ); - else - director.replaceScene( scene ); - - withTransition = false; -// __jsc__.garbageCollect(); -} - -//------------------------------------------------------------------ -// -// BaseLayer -// -//------------------------------------------------------------------ -var BaseLayer = function() { - - // - // VERY IMPORTANT - // - // Only subclasses of a native classes MUST call __associateObjectWithNative - // Failure to do so, it will crash. - // - var parent = goog.base(this); - __associateObjWithNative( this, parent ); - this.init( cc.c4b(0,0,0,255), cc.c4b(0,128,255,255)); - - this.title = "No title"; - this.subtitle = "No Subtitle"; - this.isMainTitle = false; - -} -goog.inherits(BaseLayer, cc.LayerGradient ); - -// -// Instance 'base' methods -// XXX: Should be defined after "goog.inherits" -// -BaseLayer.prototype.onEnter = function() { - - var fontSize = 36; - var tl = this.title.length; - fontSize = (winSize.width / tl) * 1.60; - if( fontSize/winSize.width > 0.09 ) { - fontSize = winSize.width * 0.09; - } - - this.label = cc.LabelTTF.create(this.title, "Gill Sans", fontSize); - this.addChild(this.label, 100); - - var isMain = this.isMainTitle; - - if( isMain == true ) - this.label.setPosition( centerPos ); - else - this.label.setPosition( cc.p(winSize.width / 2, winSize.height*11/12) ); - - var subStr = this.subtitle; - if (subStr != "") { - tl = this.subtitle.length; - var subfontSize = (winSize.width / tl) * 1.3; - if( subfontSize > fontSize *0.6 ) { - subfontSize = fontSize *0.6; - } - - this.sublabel = cc.LabelTTF.create(subStr, "Thonburi", subfontSize); - this.addChild(this.sublabel, 90); - if( isMain ) - this.sublabel.setPosition( cc.p(winSize.width / 2, winSize.height*3/8 )); - else - this.sublabel.setPosition( cc.p(winSize.width / 2, winSize.height*5/6 )); - } else - this.sublabel = null; - - // Menu - var item1 = cc.MenuItemImage.create("b1.png", "b2.png", this, this.backCallback); - var item2 = cc.MenuItemImage.create("r1.png", "r2.png", this, this.restartCallback); - var item3 = cc.MenuItemImage.create("f1.png", "f2.png", this, this.nextCallback); - var item4 = cc.MenuItemFont.create("back", this, function() { require("js/main.js"); } ); - item4.setFontSize( 22 ); - - [item1, item2, item3 ].forEach( function(item) { - item.normalImage().setOpacity(45); - item.selectedImage().setOpacity(45); - } ); - - var menu = cc.Menu.create( item1, item2, item3, item4 ); - - menu.setPosition( cc.p(0,0) ); - item1.setPosition( cc.p(winSize.width / 2 - 100, 30)); - item2.setPosition( cc.p(winSize.width / 2, 30)); - item3.setPosition( cc.p(winSize.width / 2 + 100, 30)); - item4.setPosition( cc.p(winSize.width - 60, winSize.height - 30 ) ); - - this.addChild(menu, 80); -} - -BaseLayer.prototype.createBulletList = function () { - var str = ""; - for(var i=0; i= scenes.length ) - currentScene = 0; - - withTransition = true; - loadScene(currentScene); -}; - -var previousScene = function () { - currentScene = currentScene -1; - if( currentScene < 0 ) - currentScene = scenes.length -1; - - withTransition = true; - loadScene(currentScene); -}; - -var restartScene = function () { - loadScene( currentScene ); -}; - -var loadScene = function (sceneIdx) -{ - winSize = director.getWinSize(); - centerPos = cc.p( winSize.width/2, winSize.height/2 ); - - var scene = new cc.Scene(); - scene.init(); - var layer = new scenes[ sceneIdx ](); - - scene.addChild( layer ); - -// scene.walkSceneGraph(0); - - director.replaceScene( scene ); -// __jsc__.garbageCollect(); -} - - -// -// Base Layer -// - -var BaseLayer = cc.LayerGradient.extend({ - - ctor:function () { - - var parent = new cc.LayerGradient(); - __associateObjWithNative(this, parent); - this.init(cc.c4b(0, 0, 0, 255), cc.c4b(0, 128, 255, 255)); - }, - - title:function () { - return "No Title"; - }, - - subtitle:function () { - return ""; - }, - - code:function () { - return ""; - }, - - restartCallback:function (sender) { - restartScene(); - }, - - nextCallback:function (sender) { - nextScene(); - }, - - backCallback:function (sender) { - previousScene(); - }, - - positionForTwo:function () { - this._grossini.setPosition(cc.p(60, winSize.height*2/3)); - this._tamara.setPosition(cc.p(60, winSize.height*1/3)); - this._kathia.setVisible(false); - }, - - onEnter:function () { - // DO NOT CALL this._super() -// this._super(); - - // add title and subtitle - var label = cc.LabelTTF.create(this.title(), "Arial", 28); - this.addChild(label, 1); - label.setPosition( cc.p(winSize.width / 2, winSize.height - 50)); - - var strSubtitle = this.subtitle(); - if (strSubtitle != "") { - var l = cc.LabelTTF.create(strSubtitle, "Thonburi", 16); - this.addChild(l, 1); - l.setPosition( cc.p(winSize.width / 2, winSize.height - 80)); - } - - var strCode = this.code(); - if( strCode !="" ) { - var label = cc.LabelTTF.create(strCode, 'CourierNewPSMT', 16); - label.setPosition( cc.p( winSize.width/2, winSize.height-100) ); - this.addChild( label,10 ); - - var labelbg = cc.LabelTTF.create(strCode, 'CourierNewPSMT', 16); - labelbg.setColor( cc.c3b(10,10,255) ); - labelbg.setPosition( cc.p( winSize.width/2 +1, winSize.height-100 -1) ); - this.addChild( labelbg,9); - } - // Menu - var item1 = cc.MenuItemImage.create("Images/b1.png", "Images/b2.png", this, this.backCallback); - var item2 = cc.MenuItemImage.create("Images/r1.png", "Images/r2.png", this, this.restartCallback); - var item3 = cc.MenuItemImage.create("Images/f1.png", "Images/f2.png", this, this.nextCallback); - var item4 = cc.MenuItemFont.create("back", this, function() { require("js/main.js"); } ); - item4.setFontSize( 22 ); - - var menu = cc.Menu.create(item1, item2, item3, item4 ); - - menu.setPosition( cc.p(0,0) ); - item1.setPosition( cc.p(winSize.width / 2 - 100, 30)); - item2.setPosition( cc.p(winSize.width / 2, 30)); - item3.setPosition( cc.p(winSize.width / 2 + 100, 30)); - item4.setPosition( cc.p(winSize.width - 60, winSize.height - 30 ) ); - - - this.addChild(menu, 1); - - // Setup Sprites for this:w - this._grossini = cc.Sprite.create("Images/grossini.png"); - this._tamara = cc.Sprite.create("Images/grossinis_sister1.png"); - this._kathia = cc.Sprite.create("Images/grossinis_sister2.png"); - this.addChild(this._grossini, 1); - this.addChild(this._tamara, 2); - this.addChild(this._kathia, 3); - this._grossini.setPosition(cc.p(60, winSize.height*3/4)); - this._kathia.setPosition(cc.p(60, winSize.height*2/4)); - this._tamara.setPosition(cc.p(60, winSize.height*1/4)); - } -}); - - -//------------------------------------------------------------------ -// -// SpriteEase -// -//------------------------------------------------------------------ -var SpriteEase = BaseLayer.extend({ - - elapsedTime: 0, - - onEnter:function () { - this._super(); - - var move = cc.MoveBy.create(3, cc.p(winSize.width-80, 0)); - var move_back = move.reverse(); - - var move_ease_in = cc.EaseIn.create(move.copy(), 3.0); - var move_ease_in_back = move_ease_in.reverse(); - - var move_ease_out = cc.EaseOut.create(move.copy(), 3.0); - var move_ease_out_back = move_ease_out.reverse(); - - - var seq1 = cc.Sequence.create(move, move_back ); - var seq2 = cc.Sequence.create(move_ease_in, move_ease_in_back ); - var seq3 = cc.Sequence.create(move_ease_out, move_ease_out_back ); - - - var a2 = this._grossini.runAction(cc.RepeatForever.create(seq1)); - a2.setTag(1); - - var a1 = this._tamara.runAction(cc.RepeatForever.create(seq2)); - a1.setTag(1); - - var a = this._kathia.runAction(cc.RepeatForever.create(seq3)); - a.setTag(1); - - this.scheduleUpdate(); - }, - title:function () { - return "EaseIn - EaseOut - Stop"; - }, - - code:function () { - return "var actionIn = cc.EaseIn.create( action, rate );\n" + - "var actionOut = cc.EaseOut.create( action, rate );"; - }, - - testStopAction:function (dt) { - elapsedTime += dt; - - if( dt > 6 ) { - this.unscheduleUpdate(); - this._tamara.stopActionByTag(1); - this._kathia.stopActionByTag(1); - this._grossini.stopActionByTag(1); - } - } -}); - -//------------------------------------------------------------------ -// -// SpriteEaseInOut -// -//------------------------------------------------------------------ -var SpriteEaseInOut = BaseLayer.extend({ - - onEnter:function () { - this._super(); - - var move = cc.MoveBy.create(3, cc.p(winSize.width-80, 0)); - // id move_back = move.reverse(); - - var move_ease_inout1 = cc.EaseInOut.create(move.copy(), 2.0); - var move_ease_inout_back1 = move_ease_inout1.reverse(); - - var move_ease_inout2 = cc.EaseInOut.create(move.copy(), 3.0); - var move_ease_inout_back2 = move_ease_inout2.reverse(); - - var move_ease_inout3 = cc.EaseInOut.create(move.copy(), 4.0); - var move_ease_inout_back3 = move_ease_inout3.reverse(); - - - var seq1 = cc.Sequence.create(move_ease_inout1, move_ease_inout_back1 ); - var seq2 = cc.Sequence.create(move_ease_inout2, move_ease_inout_back2 ); - var seq3 = cc.Sequence.create(move_ease_inout3, move_ease_inout_back3 ); - - this._tamara.runAction(cc.RepeatForever.create(seq1)); - this._kathia.runAction(cc.RepeatForever.create(seq2)); - this._grossini.runAction(cc.RepeatForever.create(seq3)); - }, - title:function () { - return "EaseInOut and rates"; - }, - - code:function () { - return "var actionInOut = cc.EaseInOut.create( action, rate );"; - }, -}); - -//------------------------------------------------------------------ -// -// SpriteEaseExponential -// -//------------------------------------------------------------------ -var SpriteEaseExponential = BaseLayer.extend({ - - onEnter:function () { - this._super(); - - var move = cc.MoveBy.create(3, cc.p(winSize.width-80, 0)); - var move_back = move.reverse(); - - var move_ease_in = cc.EaseExponentialIn.create(move.copy()); - var move_ease_in_back = move_ease_in.reverse(); - - var move_ease_out = cc.EaseExponentialOut.create(move.copy()); - var move_ease_out_back = move_ease_out.reverse(); - - - var seq1 = cc.Sequence.create(move, move_back ); - var seq2 = cc.Sequence.create(move_ease_in, move_ease_in_back ); - var seq3 = cc.Sequence.create(move_ease_out, move_ease_out_back ); - - - this._grossini.runAction(cc.RepeatForever.create(seq1)); - this._tamara.runAction(cc.RepeatForever.create(seq2)); - this._kathia.runAction(cc.RepeatForever.create(seq3)); - }, - title:function () { - return "ExpIn - ExpOut actions"; - }, - - code:function () { - return "var actionIn = cc.EaseExponentialIn.create( action );\n" + - "var actionOut = cc.EaseExponentialOut.create( action );"; - }, -}); - -//------------------------------------------------------------------ -// -// SpriteEaseExponentialInOut -// -//------------------------------------------------------------------ -var SpriteEaseExponentialInOut = BaseLayer.extend({ - - onEnter:function () { - this._super(); - - var move = cc.MoveBy.create(3, cc.p(winSize.width-80, 0)); - var move_back = move.reverse(); - - var move_ease = cc.EaseExponentialInOut.create(move.copy()); - var move_ease_back = move_ease.reverse(); //-. reverse() - - var seq1 = cc.Sequence.create(move, move_back ); - var seq2 = cc.Sequence.create(move_ease, move_ease_back ); - - this.positionForTwo(); - - this._grossini.runAction(cc.RepeatForever.create(seq1)); - this._tamara.runAction(cc.RepeatForever.create(seq2)); - }, - title:function () { - return "EaseExponentialInOut action"; - }, - code:function () { - return "var actionIn = cc.EaseExponentialInOut.create( action );"; - }, -}); - -//------------------------------------------------------------------ -// -// SpriteEaseSine -// -//------------------------------------------------------------------ -var SpriteEaseSine = BaseLayer.extend({ - onEnter:function () { - this._super(); - - var move = cc.MoveBy.create(3, cc.p(winSize.width-80, 0)); - var move_back = move.reverse(); - - var move_ease_in = cc.EaseSineIn.create(move.copy()); - var move_ease_in_back = move_ease_in.reverse(); - - var move_ease_out = cc.EaseSineOut.create(move.copy()); - var move_ease_out_back = move_ease_out.reverse(); - - - var seq1 = cc.Sequence.create(move, move_back ); - var seq2 = cc.Sequence.create(move_ease_in, move_ease_in_back ); - var seq3 = cc.Sequence.create(move_ease_out, move_ease_out_back ); - - - this._grossini.runAction(cc.RepeatForever.create(seq1)); - this._tamara.runAction(cc.RepeatForever.create(seq2)); - this._kathia.runAction(cc.RepeatForever.create(seq3)); - - }, - title:function () { - return "EaseSineIn - EaseSineOut"; - } -}); - -//------------------------------------------------------------------ -// -// SpriteEaseSineInOut -// -//------------------------------------------------------------------ -var SpriteEaseSineInOut = BaseLayer.extend({ - onEnter:function () { - this._super(); - - var move = cc.MoveBy.create(3, cc.p(winSize.width-80, 0)); - var move_back = move.reverse(); - - var move_ease = cc.EaseSineInOut.create(move.copy()); - var move_ease_back = move_ease.reverse(); - - var seq1 = cc.Sequence.create(move, move_back ); - var seq2 = cc.Sequence.create(move_ease, move_ease_back ); - - this.positionForTwo(); - - this._grossini.runAction(cc.RepeatForever.create(seq1)); - this._tamara.runAction(cc.RepeatForever.create(seq2)); - }, - title:function () { - return "EaseSineInOut action"; - } -}); - -//------------------------------------------------------------------ -// -// SpriteEaseElastic -// -//------------------------------------------------------------------ -var SpriteEaseElastic = BaseLayer.extend({ - onEnter:function () { - this._super(); - - var move = cc.MoveBy.create(3, cc.p(winSize.width-80, 0)); - var move_back = move.reverse(); - - var move_ease_in = cc.EaseElasticIn.create(move.copy()); - var move_ease_in_back = move_ease_in.reverse(); - - var move_ease_out = cc.EaseElasticOut.create(move.copy()); - var move_ease_out_back = move_ease_out.reverse(); - - var seq1 = cc.Sequence.create(move, move_back ); - var seq2 = cc.Sequence.create(move_ease_in, move_ease_in_back ); - var seq3 = cc.Sequence.create(move_ease_out, move_ease_out_back ); - - this._grossini.runAction(cc.RepeatForever.create(seq1)); - this._tamara.runAction(cc.RepeatForever.create(seq2)); - this._kathia.runAction(cc.RepeatForever.create(seq3)); - }, - title:function () { - return "Elastic In - Out actions"; - } -}); - -//------------------------------------------------------------------ -// -// SpriteEaseElasticInOut -// -//------------------------------------------------------------------ -var SpriteEaseElasticInOut = BaseLayer.extend({ - onEnter:function () { - this._super(); - - var move = cc.MoveBy.create(3, cc.p(winSize.width-80, 0)); - - var move_ease_inout1 = cc.EaseElasticInOut.create(move.copy(), 0.3); - var move_ease_inout_back1 = move_ease_inout1.reverse(); - - var move_ease_inout2 = cc.EaseElasticInOut.create(move.copy(), 0.45); - var move_ease_inout_back2 = move_ease_inout2.reverse(); - - var move_ease_inout3 = cc.EaseElasticInOut.create(move.copy(), 0.6); - var move_ease_inout_back3 = move_ease_inout3.reverse(); - - - var seq1 = cc.Sequence.create(move_ease_inout1, move_ease_inout_back1 ); - var seq2 = cc.Sequence.create(move_ease_inout2, move_ease_inout_back2 ); - var seq3 = cc.Sequence.create(move_ease_inout3, move_ease_inout_back3 ); - - this._tamara.runAction(cc.RepeatForever.create(seq1)); - this._kathia.runAction(cc.RepeatForever.create(seq2)); - this._grossini.runAction(cc.RepeatForever.create(seq3)); - }, - title:function () { - return "EaseElasticInOut action"; - } -}); - -//------------------------------------------------------------------ -// -// SpriteEaseBounce -// -//------------------------------------------------------------------ -var SpriteEaseBounce = BaseLayer.extend({ - onEnter:function () { - this._super(); - - var move = cc.MoveBy.create(3, cc.p(winSize.width-80, 0)); - var move_back = move.reverse(); - - var move_ease_in = cc.EaseBounceIn.create(move.copy()); - var move_ease_in_back = move_ease_in.reverse(); - - var move_ease_out = cc.EaseBounceOut.create(move.copy()); - var move_ease_out_back = move_ease_out.reverse(); - - var seq1 = cc.Sequence.create(move, move_back ); - var seq2 = cc.Sequence.create(move_ease_in, move_ease_in_back ); - var seq3 = cc.Sequence.create(move_ease_out, move_ease_out_back ); - - this._grossini.runAction(cc.RepeatForever.create(seq1)); - this._tamara.runAction(cc.RepeatForever.create(seq2)); - this._kathia.runAction(cc.RepeatForever.create(seq3)); - }, - title:function () { - return "Bounce In - Out actions"; - } -}); - -//------------------------------------------------------------------ -// -// SpriteEaseBounceInOut -// -//------------------------------------------------------------------ -var SpriteEaseBounceInOut = BaseLayer.extend({ - onEnter:function () { - this._super(); - - var move = cc.MoveBy.create(3, cc.p(winSize.width-80, 0)); - var move_back = move.reverse(); - - var move_ease = cc.EaseBounceInOut.create(move.copy()); - var move_ease_back = move_ease.reverse(); - - var seq1 = cc.Sequence.create(move, move_back ); - var seq2 = cc.Sequence.create(move_ease, move_ease_back ); - - this.positionForTwo(); - - this._grossini.runAction(cc.RepeatForever.create(seq1)); - this._tamara.runAction(cc.RepeatForever.create(seq2)); - }, - title:function () { - return "EaseBounceInOut action"; - } -}); - -//------------------------------------------------------------------ -// -// SpriteEaseBack -// -//------------------------------------------------------------------ -var SpriteEaseBack = BaseLayer.extend({ - onEnter:function () { - this._super(); - - var move = cc.MoveBy.create(3, cc.p(winSize.width-80, 0)); - var move_back = move.reverse(); - - var move_ease_in = cc.EaseBackIn.create(move.copy()); - var move_ease_in_back = move_ease_in.reverse(); - - var move_ease_out = cc.EaseBackOut.create(move.copy()); - var move_ease_out_back = move_ease_out.reverse(); - - var seq1 = cc.Sequence.create(move, move_back ); - var seq2 = cc.Sequence.create(move_ease_in, move_ease_in_back ); - var seq3 = cc.Sequence.create(move_ease_out, move_ease_out_back ); - - this._grossini.runAction(cc.RepeatForever.create(seq1)); - this._tamara.runAction(cc.RepeatForever.create(seq2)); - this._kathia.runAction(cc.RepeatForever.create(seq3)); - }, - title:function () { - return "Back In - Out actions"; - } -}); - -//------------------------------------------------------------------ -// -// SpriteEaseBackInOut -// -//------------------------------------------------------------------ -var SpriteEaseBackInOut = BaseLayer.extend({ - onEnter:function () { - this._super(); - - var move = cc.MoveBy.create(3, cc.p(winSize.width-80, 0)); - var move_back = move.reverse(); - - var move_ease = cc.EaseBackInOut.create(move.copy()); - var move_ease_back = move_ease.reverse(); - - var seq1 = cc.Sequence.create(move, move_back ); - var seq2 = cc.Sequence.create(move_ease, move_ease_back ); - - this.positionForTwo(); - - this._grossini.runAction(cc.RepeatForever.create(seq1)); - this._tamara.runAction(cc.RepeatForever.create(seq2)); - }, - title:function () { - return "EaseBackInOut action"; - } -}); - -var SpeedTest = BaseLayer.extend({ - onEnter:function () { - this._super(); - - // rotate and jump - var jump1 = cc.JumpBy.create(4, cc.p(-400, 0), 100, 4); - var jump2 = jump1.reverse(); - var rot1 = cc.RotateBy.create(4, 360 * 2); - var rot2 = rot1.reverse(); - - var seq3_1 = cc.Sequence.create(jump2, jump1 ); - var seq3_2 = cc.Sequence.create(rot1, rot2 ); - var spawn = cc.Spawn.create(seq3_1, seq3_2 ); - var action = cc.Speed.create(cc.RepeatForever.create(spawn), 1.0); - action.setTag(TAG_ACTION1_EASE_ACTIONS); - - var action2 = action.copy(); - var action3 = action.copy(); - - action2.setTag(TAG_ACTION1_EASE_ACTIONS); - action3.setTag(TAG_ACTION1_EASE_ACTIONS); - - this._grossini.runAction(action2); - this._tamara.runAction(action3); - this._kathia.runAction(action); - - this.schedule(this.altertime, 1.0);//:@selector(altertime:) interval:1.0]; - }, - title:function () { - return "Speed action"; - }, - - altertime:function (dt) { - var action1 = this._grossini.getActionByTag(TAG_ACTION1_EASE_ACTIONS); - var action2 = this._tamara.getActionByTag(TAG_ACTION1_EASE_ACTIONS); - var action3 = this._kathia.getActionByTag(TAG_ACTION1_EASE_ACTIONS); - - action1.setSpeed(cc.RANDOM_0_1() * 2); - action2.setSpeed(cc.RANDOM_0_1() * 2); - action3.setSpeed(cc.RANDOM_0_1() * 2); - } -}); - -// -// Order of tests -// -scenes.push( SpriteEase ); -scenes.push( SpriteEaseInOut ); -scenes.push( SpriteEaseExponential ); -scenes.push( SpriteEaseExponentialInOut ); -scenes.push( SpriteEaseSine ); -scenes.push( SpriteEaseSineInOut ); -scenes.push( SpriteEaseElastic ); -scenes.push( SpriteEaseElasticInOut ); -scenes.push( SpriteEaseBounce ); -scenes.push( SpriteEaseBounceInOut ); -scenes.push( SpriteEaseBack ); -scenes.push( SpriteEaseBackInOut ); -scenes.push( SpeedTest ); - -//------------------------------------------------------------------ -// -// Main entry point -// -//------------------------------------------------------------------ -function run() -{ - var scene = cc.Scene.create(); - var layer = new scenes[currentScene](); - scene.addChild( layer ); - - var runningScene = director.getRunningScene(); - if( runningScene == null ) - director.runWithScene( scene ); - else - director.replaceScene( cc.TransitionFade.create(0.5, scene ) ); -} - -run(); - diff --git a/samples/TestJavascript/Resources/js/test-effects.js b/samples/TestJavascript/Resources/js/test-effects.js deleted file mode 100644 index 7251d5da71..0000000000 --- a/samples/TestJavascript/Resources/js/test-effects.js +++ /dev/null @@ -1,266 +0,0 @@ -// -// http://www.cocos2d-iphone.org -// http://www.cocos2d-html5.org -// http://www.cocos2d-x.org -// -// Javascript + cocos2d actions tests -// - -require("js/helper.js"); - -director = cc.Director.getInstance(); -winSize = director.getWinSize(); -centerPos = cc.p( winSize.width/2, winSize.height/2 ); -spriteFrameCache = cc.SpriteFrameCache.getInstance(); - -var scenes = []; -var currentScene = 0; - -var nextScene = function () { - currentScene = currentScene + 1; - if( currentScene >= scenes.length ) - currentScene = 0; - - withTransition = true; - loadScene(currentScene); -}; - -var previousScene = function () { - currentScene = currentScene -1; - if( currentScene < 0 ) - currentScene = scenes.length -1; - - withTransition = true; - loadScene(currentScene); -}; - -var restartScene = function () { - loadScene( currentScene ); -}; - -var loadScene = function (sceneIdx) -{ - winSize = director.getWinSize(); - centerPos = cc.p( winSize.width/2, winSize.height/2 ); - - var scene = new cc.Scene(); - scene.init(); - var layer = new scenes[ sceneIdx ](); - - scene.addChild( layer ); - -// scene.walkSceneGraph(0); - - director.replaceScene( scene ); -// __jsc__.garbageCollect(); -} - -var s_pathSister1 = "Images/grossinis_sister1.png"; -var s_pathSister2 = "Images/grossinis_sister2.png"; -var s_pathBlock = "Images/blocks.png"; -var s_grossiniPlist = "animations/grossini.plist"; - -// -// Base Layer -// - -var BaseLayer = cc.LayerGradient.extend({ - - ctor:function () { - - var parent = new cc.LayerGradient(); - __associateObjWithNative(this, parent); - this.init(cc.c4b(0, 0, 0, 255), cc.c4b(0, 128, 255, 255)); - }, - - title:function () { - return "Effects Test"; - }, - - subtitle:function () { - return ""; - }, - - code:function () { - return ""; - }, - - restartCallback:function (sender) { - restartScene(); - }, - - nextCallback:function (sender) { - nextScene(); - }, - - backCallback:function (sender) { - previousScene(); - }, - - onEnter:function () { - // DO NOT CALL this._super() -// this._super(); - - // add title and subtitle - var label = cc.LabelTTF.create(this.title(), "Arial", 28); - this.addChild(label, 10); - label.setPosition( cc.p(winSize.width / 2, winSize.height - 40)); - - var strSubtitle = this.subtitle(); - if (strSubtitle != "") { - var l = cc.LabelTTF.create(strSubtitle, "Thonburi", 16); - this.addChild(l, 10); - l.setPosition( cc.p(winSize.width / 2, winSize.height - 70)); - } - - var strCode = this.code(); - if( strCode !="" ) { - var label = cc.LabelTTF.create(strCode, 'CourierNewPSMT', 16); - label.setPosition( cc.p( winSize.width/2, winSize.height-120) ); - this.addChild( label,10 ); - - var labelbg = cc.LabelTTF.create(strCode, 'CourierNewPSMT', 16); - labelbg.setColor( cc.c3b(10,10,255) ); - labelbg.setPosition( cc.p( winSize.width/2 +1, winSize.height-120 -1) ); - this.addChild( labelbg,9); - } - - // Menu - var item1 = cc.MenuItemImage.create("Images/b1.png", "Images/b2.png", this, this.backCallback); - var item2 = cc.MenuItemImage.create("Images/r1.png", "Images/r2.png", this, this.restartCallback); - var item3 = cc.MenuItemImage.create("Images/f1.png", "Images/f2.png", this, this.nextCallback); - var item4 = cc.MenuItemFont.create("back", this, function() { require("js/main.js"); } ); - item4.setFontSize( 22 ); - - var menu = cc.Menu.create(item1, item2, item3, item4 ); - - menu.setPosition( cc.p(0,0) ); - item1.setPosition( cc.p(winSize.width / 2 - 100, 30)); - item2.setPosition( cc.p(winSize.width / 2, 30)); - item3.setPosition( cc.p(winSize.width / 2 + 100, 30)); - item4.setPosition( cc.p(winSize.width - 60, winSize.height - 30 ) ); - - this.addChild(menu, 10); - - - // Specific to Effects - - var node = cc.Node.create(); - node.runAction( this.getEffect(3) ); - this.addChild( node ); - - var bg = cc.Sprite.create("Images/background3.png"); - bg.setPosition( cc._p( winSize.width/2, winSize.height/2) ); - node.addChild( bg ); - - var sister1 = cc.Sprite.create("Images/grossinis_sister1.png"); - sister1.setPosition( cc._p( winSize.width/3, winSize.height/2 ) ); - node.addChild( sister1, 1 ); - - var sister2 = cc.Sprite.create("Images/grossinis_sister2.png"); - sister2.setPosition( cc._p( winSize.width*2/3, winSize.height/2 ) ); - node.addChild( sister2, 1 ); - - var sc = cc.ScaleBy.create(2, 5); - var sc_back = sc.reverse(); - var seq = cc.Sequence.create( sc, sc_back ); - var repeat = cc.RepeatForever.create( seq ); - - sister1.runAction( repeat ); - sister2.runAction( repeat.copy() ); - }, - - getEffect:function(duration) { - // override me - return cc.MoveBy.create(2, cc._p(10,10) ); - }, -}); - -//------------------------------------------------------------------ -// -// Tests -// -//------------------------------------------------------------------ -var Shaky3DTest = BaseLayer.extend({ - subtitle:function () { - return "Shaky 3D"; - }, - code:function () { - return "a = cc.Shaky3D.create(range, shakeZ, gridSize, duration )"; - }, - getEffect:function(duration) { - return cc.Shaky3D.create(5, false, cc.g(15,10), duration ); - }, -}); - -var Waves3DTest = BaseLayer.extend({ - subtitle:function () { - return "Waves 3D"; - }, - code:function () { - return "a = cc.Waves3D.create(range, shakeZ, gridSize, duration )"; - }, - getEffect:function(duration) { - return cc.Waves3D.create(5, 40, cc.g(15,10), duration ); - }, -}); - -var FlipXTest = BaseLayer.extend({ - subtitle:function () { - return "FlipX3D"; - }, - code:function () { - return "a = cc.FlipX3D.create(duration )"; - }, - getEffect:function(duration) { - var a = cc.FlipX3D.create(duration ); - var delay = cc.DelayTime.create(2); - var r = a.reverse(); - return cc.Sequence.create( a, delay, r ); - }, -}); - -var FlipYTest = BaseLayer.extend({ - subtitle:function () { - return "FlipY3D"; - }, - code:function () { - return "a = cc.FlipY3D.create(duration )"; - }, - getEffect:function(duration) { - var a = cc.FlipY3D.create(duration ); - var delay = cc.DelayTime.create(2); - var r = a.reverse(); - return cc.Sequence.create( a, delay, r ); - }, -}); - -// -// Order of tests -// -scenes.push( Shaky3DTest ); -scenes.push( Waves3DTest ); -scenes.push( FlipXTest ); -scenes.push( FlipYTest ); - -//------------------------------------------------------------------ -// -// Main entry point -// -//------------------------------------------------------------------ -function run() -{ - var scene = cc.Scene.create(); - var layer = new scenes[currentScene](); - scene.addChild( layer ); - - var runningScene = director.getRunningScene(); - if( runningScene == null ) - director.runWithScene( scene ); - else - director.replaceScene( cc.TransitionFade.create(0.5, scene ) ); -} - -run(); - - diff --git a/samples/TestJavascript/Resources/js/test-label.js b/samples/TestJavascript/Resources/js/test-label.js deleted file mode 100644 index d5ffc3f055..0000000000 --- a/samples/TestJavascript/Resources/js/test-label.js +++ /dev/null @@ -1,245 +0,0 @@ -// -// http://www.cocos2d-iphone.org -// -// Javascript + cocos2d label tests -// - -require("js/helper.js"); - -director = cc.Director.getInstance(); -winSize = director.getWinSize(); -centerPos = cc.p( winSize.width/2, winSize.height/2 ); - -var scenes = [] -var currentScene = 0; - -var nextSpriteTestAction = function () { - currentScene = currentScene + 1; - if( currentScene >= scenes.length ) - currentScene = 0; - - loadScene(currentScene); -}; -var backSpriteTestAction = function () { - currentScene = currentScene -1; - if( currentScene < 0 ) - currentScene = scenes.length -1; - - loadScene(currentScene); -}; -var restartSpriteTestAction = function () { - loadScene( currentScene ); -}; - -var loadScene = function (sceneIdx) -{ - winSize = director.getWinSize(); - centerPos = cc.p( winSize.width/2, winSize.height/2 ); - - var scene = new cc.Scene(); - scene.init(); - var layer = new scenes[ sceneIdx ](); - - scene.addChild( layer ); - -// scene.walkSceneGraph(0); - - director.replaceScene( scene ); -// __jsc__.garbageCollect(); -} - -//------------------------------------------------------------------ -// -// BaseLayer -// -//------------------------------------------------------------------ -var BaseLayer = function() { - - // - // VERY IMPORTANT - // - // Only subclasses of a native classes MUST call __associateObjectWithNative - // Failure to do so, it will crash. - // - var parent = goog.base(this); - __associateObjWithNative( this, parent ); - this.init(); - - this.title = function () { - return "No title"; - } - - this.subtitle = function () { - return "No Subtitle"; - } - -} -goog.inherits(BaseLayer, cc.Layer ); - -// -// Instance 'base' methods -// XXX: Should be defined after "goog.inherits" -// -BaseLayer.prototype.onEnter = function() { - var label = cc.LabelTTF.create(this.title(), "Arial", 28); - this.addChild(label, 1); - label.setPosition( cc.p(winSize.width / 2, winSize.height - 50)); - - var strSubtitle = this.subtitle(); - if (strSubtitle != "") { - var l = cc.LabelTTF.create(strSubtitle, "Thonburi", 16); - this.addChild(l, 1); - l.setPosition( cc.p(winSize.width / 2, winSize.height - 80)); - } - - // Menu - var item1 = cc.MenuItemImage.create("Images/b1.png", "Images/b2.png", this, this.backCallback); - var item2 = cc.MenuItemImage.create("Images/r1.png", "Images/r2.png", this, this.restartCallback); - var item3 = cc.MenuItemImage.create("Images/f1.png", "Images/f2.png", this, this.nextCallback); - var item4 = cc.MenuItemFont.create("back", this, function() { require("js/main.js"); } ); - cc.MenuItemFont.setFontSize( 22 ); - - var menu = cc.Menu.create(item1, item2, item3, item4 ); - - menu.setPosition( cc.p(0,0) ); - item1.setPosition( cc.p(winSize.width / 2 - 100, 30)); - item2.setPosition( cc.p(winSize.width / 2, 30)); - item3.setPosition( cc.p(winSize.width / 2 + 100, 30)); - item4.setPosition( cc.p(winSize.width - 60, winSize.height - 30 ) ); - - this.addChild(menu, 1); -} - -BaseLayer.prototype.restartCallback = function (sender) { - cc.log("restart called"); - restartSpriteTestAction(); -} - -BaseLayer.prototype.nextCallback = function (sender) { - cc.log("next called"); - nextSpriteTestAction(); -} - -BaseLayer.prototype.backCallback = function (sender) { - cc.log("back called"); - backSpriteTestAction(); -} - -//------------------------------------------------------------------ -// -// Label Atlas Test -// -//------------------------------------------------------------------ -var LabelAtlasTest = function(file) { - - goog.base(this); - - this.initialize = function() { - - this.label1 = cc.LabelAtlas.create("123 Test", "Fonts/tuffy_bold_italic-charmap.plist"); - this.addChild( this.label1 ); - this.label1.setPosition( cc.p(10,100) ); - this.label1.setOpacity( 200 ); - - this.label2 = cc.LabelAtlas.create( "0123456789", "Fonts/tuffy_bold_italic-charmap.plist" ); - this.addChild( this.label2 ); - this.label2.setPosition( cc.p(10,200) ); - this.label2.setOpacity( 32 ); - - this.scheduleUpdate(); - - - this.time = 0; - } - - this.title = function () { - return "LabelAtlas"; - } - - this.subtitle = function () { - return "Updating label should be fast"; - } - - this.update = function( delta ) { - this.time += delta; - var num = this.time.toFixed(2); - var string = '' + num + ' test' - this.label1.setString( string ); - - string = '' + Math.floor( this.time); - this.label2.setString( string ); - } - - this.initialize(); -} -goog.inherits(LabelAtlasTest, BaseLayer ); - -//------------------------------------------------------------------ -// -// BMFontColorTest -// -//------------------------------------------------------------------ -var BMFontColorTest = function(file) { - - goog.base(this); - - this.initialize = function() { - - var label = cc.LabelBMFont.create("Blue", "Fonts/bitmapFontTest5.fnt"); - this.addChild( label ); - label.setColor( cc.c3b(0,0,255) ); - label.setPosition( cc.p( winSize.width/2, 1*winSize.height/4) ); - label.setAnchorPoint( cc.p(0.5, 0.5) ); - - label = cc.LabelBMFont.create("Red", "Fonts/bitmapFontTest5.fnt"); - this.addChild( label ); - label.setColor( cc.c3b(255,0,0) ); - label.setPosition( cc.p( winSize.width/2, 2*winSize.height/4) ); - label.setAnchorPoint( cc.p(0.5, 0.5) ); - - label = cc.LabelBMFont.create("Red", "Fonts/bitmapFontTest5.fnt"); - this.addChild( label ); - label.setColor( cc.c3b(0,255,0) ); - label.setPosition( cc.p( winSize.width/2, 3*winSize.height/4) ); - label.setAnchorPoint( cc.p(0.5, 0.5) ); - } - - this.title = function () { - return "LabelBMFont"; - } - - this.subtitle = function () { - return "Testing color"; - } - - this.initialize(); -} -goog.inherits(BMFontColorTest, BaseLayer ); - - -// -// Order of tests -// -scenes.push( LabelAtlasTest ); -scenes.push( BMFontColorTest ); - -//------------------------------------------------------------------ -// -// Main entry point -// -//------------------------------------------------------------------ -function run() -{ - var scene = cc.Scene.create(); - var layer = new scenes[currentScene](); - scene.addChild( layer ); - - var runningScene = director.getRunningScene(); - if( runningScene == null ) - director.runWithScene( scene ); - else - director.replaceScene( cc.TransitionFade.create(0.5, scene ) ); -} - -run(); - diff --git a/samples/TestJavascript/Resources/js/test-menu.js b/samples/TestJavascript/Resources/js/test-menu.js deleted file mode 100644 index 3ad1e07931..0000000000 --- a/samples/TestJavascript/Resources/js/test-menu.js +++ /dev/null @@ -1,510 +0,0 @@ -// -// http://www.cocos2d-iphone.org -// http://www.cocos2d-html5.org -// http://www.cocos2d-x.org -// -// Javascript + cocos2d actions tests -// - -require("js/helper.js"); - -director = cc.Director.getInstance(); -winSize = director.getWinSize(); -centerPos = cc.p( winSize.width/2, winSize.height/2 ); - -var scenes = [] -var currentScene = 0; - -var nextScene = function () { - currentScene = currentScene + 1; - if( currentScene >= scenes.length ) - currentScene = 0; - - withTransition = true; - loadScene(currentScene); -}; - -var previousScene = function () { - currentScene = currentScene -1; - if( currentScene < 0 ) - currentScene = scenes.length -1; - - withTransition = true; - loadScene(currentScene); -}; - -var restartScene = function () { - loadScene( currentScene ); -}; - -var loadScene = function (sceneIdx) -{ - winSize = director.getWinSize(); - centerPos = cc.p( winSize.width/2, winSize.height/2 ); - - var scene = new cc.Scene(); - scene.init(); - var layer = new scenes[ sceneIdx ](); - - scene.addChild( layer ); - -// scene.walkSceneGraph(0); - - director.replaceScene( scene ); -// __jsc__.garbageCollect(); -} - - - -// -// Base Layer -// - -var BaseLayer = cc.LayerGradient.extend({ - - ctor:function () { - - var parent = new cc.LayerGradient(); - __associateObjWithNative(this, parent); - this.init(cc.c4b(0, 0, 0, 255), cc.c4b(0, 128, 255, 255)); - }, - - title:function () { - return "No Title"; - }, - - subtitle:function () { - return ""; - }, - - code:function () { - return ""; - }, - - restartCallback:function (sender) { - restartScene(); - }, - - nextCallback:function (sender) { - nextScene(); - }, - - backCallback:function (sender) { - previousScene(); - }, - - onEnter:function () { - // DO NOT CALL this._super() -// this._super(); - - // add title and subtitle - var label = cc.LabelTTF.create(this.title(), "Arial", 28); - this.addChild(label, 1); - label.setPosition( cc.p(winSize.width / 2, winSize.height - 40)); - - var strSubtitle = this.subtitle(); - if (strSubtitle != "") { - var l = cc.LabelTTF.create(strSubtitle, "Thonburi", 16); - this.addChild(l, 1); - l.setPosition( cc.p(winSize.width / 2, winSize.height - 70)); - } - - var strCode = this.code(); - if( strCode !="" ) { - var label = cc.LabelTTF.create(strCode, 'CourierNewPSMT', 16); - label.setPosition( cc.p( winSize.width/2, winSize.height-120) ); - this.addChild( label,10 ); - - var labelbg = cc.LabelTTF.create(strCode, 'CourierNewPSMT', 16); - labelbg.setColor( cc.c3b(10,10,255) ); - labelbg.setPosition( cc.p( winSize.width/2 +1, winSize.height-120 -1) ); - this.addChild( labelbg,9); - } - - // Menu - var item1 = cc.MenuItemImage.create("Images/b1.png", "Images/b2.png", this, this.backCallback); - var item2 = cc.MenuItemImage.create("Images/r1.png", "Images/r2.png", this, this.restartCallback); - var item3 = cc.MenuItemImage.create("Images/f1.png", "Images/f2.png", this, this.nextCallback); - var item4 = cc.MenuItemFont.create("back", this, function() { require("js/main.js"); } ); - item4.setFontSize( 22 ); - - var menu = cc.Menu.create(item1, item2, item3, item4 ); - - menu.setPosition( cc.p(0,0) ); - item1.setPosition( cc.p(winSize.width / 2 - 100, 30)); - item2.setPosition( cc.p(winSize.width / 2, 30)); - item3.setPosition( cc.p(winSize.width / 2 + 100, 30)); - item4.setPosition( cc.p(winSize.width - 60, winSize.height - 30 ) ); - - this.addChild(menu, 1); - - - // back menu - } -}); - -//------------------------------------------------------------------ -// -// MenuItemFontTest -// -//------------------------------------------------------------------ -var MenuItemFontTest = BaseLayer.extend({ - onEnter:function () { - this._super(); - - var item1 = cc.MenuItemFont.create("Item 1. Should be RED"); - var item2 = cc.MenuItemFont.create("This item is bigger", this, this.item_cb); - var item3 = cc.MenuItemFont.create("This item should be disabled", this, this.item_cb); - - // callback function can be modified in runtime - item1.setCallback( this, this.item_cb ); - - // font color can be changed in runtime - item1.setColor( cc.c3b(255,0,0) ); - - // font size can be changed in runtime (it is faster to do it before creating the item) - item2.setFontSize( 48 ); - - // font name can be changed in runtime (it is faster to do it before creating the item) - item3.setFontName( "Courier New"); - - // item could be enabled / disabled in runtime - item3.setEnabled( false ); - - var menu = cc.Menu.create( item1, item2, item3 ); - menu.alignItemsVertically(); - - menu.setPosition( cc.p( winSize.width/2, winSize.height/2) ); - - this.addChild( menu ); - }, - - title:function () { - return "Menu Item Font"; - }, - subtitle:function () { - return "3 items. 3rd should be disabled. Smaller font"; - }, - code:function () { - return "item = cc.MenuItemFont.create('Press me', this, this.callback)"; - }, - - // callback - item_cb:function(sender) { - cc.log("Item " + sender + " pressed"); - }, - - -}); - -//------------------------------------------------------------------ -// -// MenuItemImage -// -//------------------------------------------------------------------ -var MenuItemImageTest = BaseLayer.extend({ - - _vertically : true, - - _menu : null, - - onEnter:function () { - this._super(); - - var item1 = cc.MenuItemImage.create("Images/btn-play-normal.png", "Images/btn-play-selected.png" ); - var item2 = cc.MenuItemImage.create("Images/btn-highscores-normal.png", "Images/btn-highscores-selected.png", this, this.item_cb ); - var item3 = cc.MenuItemImage.create("Images/btn-about-normal.png", "Images/btn-about-selected.png", this, this.item_cb ); - - // callback function can be modified in runtime - item1.setCallback( this, this.item_cb ); - - // item could be enabled / disabled in runtime - item3.setEnabled( false ); - - this._menu = cc.Menu.create( item1, item2, item3 ); - this._menu.alignItemsVertically(); - - this._menu.setPosition( cc.p( winSize.width/2, winSize.height/2) ); - - this.addChild( this._menu ); - }, - - - title:function () { - return "Menu Item Image"; - }, - subtitle:function () { - return "3 items. 3rd should be disabled."; - }, - code:function () { - return "item = cc.MenuItemImage.create('Images/normal.png', 'Images/selected.png' , 'Images/disabled.png', this, this.cb )"; - }, - - // callback - item_cb:function(sender) { - cc.log("Item " + sender + " pressed"); - if( this._vertically ) - this._menu.alignItemsHorizontally(); - else - this._menu.alignItemsVertically(); - - this._vertically = ! this._vertically; - - }, - -}); - -//------------------------------------------------------------------ -// -// MenuItemSpriteTest -// -//------------------------------------------------------------------ -var MenuItemSpriteTest = BaseLayer.extend({ - - _vertically : true, - _menu : null, - - onEnter:function () { - this._super(); - - // Sprites can't be reused since they are children of MenuItem - // If you want to reuse them, use "MenuItemImage" instead - var sprite1_1 = cc.Sprite.create("Images/menuitemsprite.png", cc.rect(0, 23*2, 115, 23) ); - var sprite2_1 = cc.Sprite.create("Images/menuitemsprite.png", cc.rect(0, 23*1, 115, 23) ); - var sprite1_2 = cc.Sprite.create("Images/menuitemsprite.png", cc.rect(0, 23*2, 115, 23) ); - var sprite2_2 = cc.Sprite.create("Images/menuitemsprite.png", cc.rect(0, 23*1, 115, 23) ); - var sprite3_2 = cc.Sprite.create("Images/menuitemsprite.png", cc.rect(0, 23*0, 115, 23) ); - var sprite1_3 = cc.Sprite.create("Images/menuitemsprite.png", cc.rect(0, 23*2, 115, 23) ); - var sprite2_3 = cc.Sprite.create("Images/menuitemsprite.png", cc.rect(0, 23*1, 115, 23) ); - var sprite3_3 = cc.Sprite.create("Images/menuitemsprite.png", cc.rect(0, 23*0, 115, 23) ); - - var item1 = cc.MenuItemSprite.create(sprite1_1, sprite2_1); - var item2 = cc.MenuItemSprite.create(sprite1_2, sprite2_2, sprite3_2, this, this.item_cb); - var item3 = cc.MenuItemSprite.create(sprite1_3, sprite2_3, sprite3_3, this, this.item_cb); - - // callback function can be modified in runtime - item1.setCallback( this, this.item_cb ); - - // item could be enabled / disabled in runtime - item3.setEnabled( false ); - - this._menu = cc.Menu.create( item1, item2, item3 ); - this._menu.alignItemsVertically(); - - this._menu.setPosition( cc.p( winSize.width/2, winSize.height/2) ); - - this.addChild( this._menu ); - }, - - title:function () { - return "Menu Item Sprite"; - }, - subtitle:function () { - return "3 items. 3rd should be disabled."; - }, - code:function () { - return "item = cc.MenuItemSprite.create(spr_normal, spr_selected, spr_disabled, this, this.cb )"; - }, - - // callback - item_cb:function(sender) { - cc.log("Item " + sender + " pressed"); - if( this._vertically ) - this._menu.alignItemsHorizontally(); - else - this._menu.alignItemsVertically(); - - this._vertically = ! this._vertically; - - }, - -}); - - -//------------------------------------------------------------------ -// -// MenuItemLabelTest -// -//------------------------------------------------------------------ -var MenuItemLabelTest = BaseLayer.extend({ - - _vertically : true, - _menu : null, - - onEnter:function () { - this._super(); - - var label1 = cc.LabelTTF.create("This is a LabelTTF item", "Arial", 24 ); - var label2 = cc.LabelBMFont.create("And this is a LabelBMFont item", "Fonts/futura-48.fnt" ); - var label3 = cc.LabelTTF.create("Disabled Item", "Arial", 24 ); - - var item1 = cc.MenuItemLabel.create(label1); - var item2 = cc.MenuItemLabel.create(label2, this, this.item_cb); - var item3 = cc.MenuItemLabel.create(label3, this, this.item_cb); - - // callback function can be modified in runtime - item1.setCallback( this, this.item_cb ); - - // item could be enabled / disabled in runtime - item3.setEnabled( false ); - - this._menu = cc.Menu.create( item1, item2, item3 ); - this._menu.alignItemsVertically(); - - this._menu.setPosition( cc.p( winSize.width/2, winSize.height/2) ); - - this.addChild( this._menu ); - }, - - title:function () { - return "Menu Item Label"; - }, - subtitle:function () { - return "3 items. 3rd should be disabled."; - }, - code:function () { - return "item = cc.MenuItemLabel.create(label, this, this.cb )"; - }, - - // callback - item_cb:function(sender) { - cc.log("Item " + sender + " pressed"); - if( this._vertically ) - this._menu.alignItemsHorizontally(); - else - this._menu.alignItemsVertically(); - - this._vertically = ! this._vertically; - - }, - -}); - -//------------------------------------------------------------------ -// -// MenuItemToggleTest -// -//------------------------------------------------------------------ -var MenuItemToggleTest = BaseLayer.extend({ - - _vertically : true, - _menu : null, - - onEnter:function () { - this._super(); - - var label1 = cc.LabelBMFont.create("Volume Off", "Fonts/futura-48.fnt" ); - var item1 = cc.MenuItemLabel.create(label1); - var label2 = cc.LabelBMFont.create("Volume On", "Fonts/futura-48.fnt" ); - var item2 = cc.MenuItemLabel.create(label2); - - var itema = cc.MenuItemFont.create("Sound Off"); - var itemb = cc.MenuItemFont.create("Sound 50%"); - var itemc = cc.MenuItemFont.create("Sound 100%"); - - var toggle1 = cc.MenuItemToggle.create( item1, item2 ); - var toggle2 = cc.MenuItemToggle.create( itema, itemb, itemc ); - - toggle1.setCallback( this, this.item_cb); - toggle2.setCallback( this, this.item_cb); - - this._menu = cc.Menu.create( toggle1, toggle2 ); - this._menu.alignItemsVertically(); - this._menu.setPosition( cc.p( winSize.width/2, winSize.height/2) ); - - this.addChild( this._menu ); - }, - - title:function () { - return "Menu Item Toggle"; - }, - subtitle:function () { - return "2 Toggle Items"; - }, - code:function () { - return "item = cc.MenuItemToggle.create( item1, item2, item3 );"; - }, - - // callback - item_cb:function(sender) { - cc.log("toggle pressed"); - }, -}); - -//------------------------------------------------------------------ -// -// MenuItemSubclass -// -//------------------------------------------------------------------ - -var MyMenuItemFont = cc.MenuItemFont.extend({ - - ctor:function( label ) { - var parent = new cc.MenuItemFont(); - __associateObjWithNative(this, parent); - this.init( label, this, this.callback ); - }, - - callback:function(sender) { - cc.log("Button clicked"); - }, -}); - -var MenuItemSubclass = BaseLayer.extend({ - - _vertically : true, - _menu : null, - - onEnter:function () { - this._super(); - - var item1 = new MyMenuItemFont("Item 1"); - var item2 = new MyMenuItemFont("Item 2"); - - this._menu = cc.Menu.create( item1, item2 ); - this._menu.alignItemsVertically(); - this._menu.setPosition( cc.p( winSize.width/2, winSize.height/2) ); - - this.addChild( this._menu ); - }, - - title:function () { - return "Menu Item Subclass"; - }, - subtitle:function () { - return "2 items should appear"; - }, -}); - - -// -// Order of tests -// - -scenes.push( MenuItemFontTest ); -scenes.push( MenuItemImageTest ); -scenes.push( MenuItemSpriteTest ); -scenes.push( MenuItemLabelTest ); -scenes.push( MenuItemToggleTest ); -scenes.push( MenuItemSubclass ); - -//------------------------------------------------------------------ -// -// Main entry point -// -//------------------------------------------------------------------ -function run() -{ - var scene = cc.Scene.create(); - var layer = new scenes[currentScene](); - scene.addChild( layer ); - - var runningScene = director.getRunningScene(); - if( runningScene == null ) - director.runWithScene( scene ); - else - director.replaceScene( cc.TransitionFade.create(0.5, scene ) ); -} - -run(); - diff --git a/samples/TestJavascript/Resources/js/test-parallax.js b/samples/TestJavascript/Resources/js/test-parallax.js deleted file mode 100644 index 752a559ed9..0000000000 --- a/samples/TestJavascript/Resources/js/test-parallax.js +++ /dev/null @@ -1,322 +0,0 @@ -// -// http://www.cocos2d-iphone.org -// http://www.cocos2d-html5.org -// http://www.cocos2d-x.org -// -// Javascript + cocos2d actions tests -// - -require("js/helper.js"); - -director = cc.Director.getInstance(); -winSize = director.getWinSize(); -centerPos = cc.p( winSize.width/2, winSize.height/2 ); - -var scenes = [] -var currentScene = 0; - -var nextScene = function () { - currentScene = currentScene + 1; - if( currentScene >= scenes.length ) - currentScene = 0; - - withTransition = true; - loadScene(currentScene); -}; - -var previousScene = function () { - currentScene = currentScene -1; - if( currentScene < 0 ) - currentScene = scenes.length -1; - - withTransition = true; - loadScene(currentScene); -}; - -var restartScene = function () { - loadScene( currentScene ); -}; - -var loadScene = function (sceneIdx) -{ - winSize = director.getWinSize(); - centerPos = cc.p( winSize.width/2, winSize.height/2 ); - - var scene = new cc.Scene(); - scene.init(); - var layer = new scenes[ sceneIdx ](); - - scene.addChild( layer ); - -// scene.walkSceneGraph(0); - - director.replaceScene( scene ); -// __jsc__.garbageCollect(); -} - -var TAG_NODE = 100; - - -// -// Base Layer -// - -var BaseLayer = cc.LayerGradient.extend({ - - ctor:function () { - - var parent = new cc.LayerGradient(); - __associateObjWithNative(this, parent); - this.init(cc.c4b(0, 0, 0, 255), cc.c4b(0, 128, 255, 255)); - }, - - title:function () { - return "No Title"; - }, - - subtitle:function () { - return ""; - }, - - code:function () { - return ""; - }, - - restartCallback:function (sender) { - restartScene(); - }, - - nextCallback:function (sender) { - nextScene(); - }, - - backCallback:function (sender) { - previousScene(); - }, - - onEnter:function () { - // DO NOT CALL this._super() -// this._super(); - - // add title and subtitle - var label = cc.LabelTTF.create(this.title(), "Arial", 28); - this.addChild(label, 1); - label.setPosition( cc.p(winSize.width / 2, winSize.height - 40)); - - var strSubtitle = this.subtitle(); - if (strSubtitle != "") { - var l = cc.LabelTTF.create(strSubtitle, "Thonburi", 16); - this.addChild(l, 1); - l.setPosition( cc.p(winSize.width / 2, winSize.height - 70)); - } - - var strCode = this.code(); - if( strCode !="" ) { - var label = cc.LabelTTF.create(strCode, 'CourierNewPSMT', 16); - label.setPosition( cc.p( winSize.width/2, winSize.height-120) ); - this.addChild( label,10 ); - - var labelbg = cc.LabelTTF.create(strCode, 'CourierNewPSMT', 16); - labelbg.setColor( cc.c3b(10,10,255) ); - labelbg.setPosition( cc.p( winSize.width/2 +1, winSize.height-120 -1) ); - this.addChild( labelbg,9); - } - - // Menu - var item1 = cc.MenuItemImage.create("Images/b1.png", "Images/b2.png", this, this.backCallback); - var item2 = cc.MenuItemImage.create("Images/r1.png", "Images/r2.png", this, this.restartCallback); - var item3 = cc.MenuItemImage.create("Images/f1.png", "Images/f2.png", this, this.nextCallback); - var item4 = cc.MenuItemFont.create("back", this, function() { require("js/main.js"); } ); - item4.setFontSize( 22 ); - - var menu = cc.Menu.create(item1, item2, item3, item4 ); - - menu.setPosition( cc.p(0,0) ); - item1.setPosition( cc.p(winSize.width / 2 - 100, 30)); - item2.setPosition( cc.p(winSize.width / 2, 30)); - item3.setPosition( cc.p(winSize.width / 2 + 100, 30)); - item4.setPosition( cc.p(winSize.width - 60, winSize.height - 30 ) ); - - this.addChild(menu, 1); - - - // back menu - } -}); - -// -// Parallax 1 -// -ParallaxTest1 = BaseLayer.extend({ - - _root:null, - _target:null, - _streak:null, - - - ctor:function () { - this._super(); - - // Top Layer, a simple image - var cocosImage = cc.Sprite.create("Images/powered.png"); - // scale the image (optional) - cocosImage.setScale(1.5); - // change the transform anchor point to 0,0 (optional) - cocosImage.setAnchorPoint(cc.p(0, 0)); - - // Middle layer: a Tile map atlas -// var tilemap = cc.TMXTiledMap.create("TileMaps/orthogonal-test2.tmx"); - var tilemap = cc.TileMapAtlas.create("TileMaps/tiles.png", "TileMaps/levelmap.tga", 16, 16); - - // change the transform anchor to 0,0 (optional) - tilemap.setAnchorPoint(cc.p(0, 0)); - - // Anti Aliased images - tilemap.getTexture().setAntiAliasTexParameters(); - - // background layer: another image - var background = cc.Sprite.create("Images/background.png"); - // scale the image (optional) - background.setScale(1.5); - // change the transform anchor point (optional) - background.setAnchorPoint(cc.p(0, 0)); - - - // create a void node, a parent node - var voidNode = cc.ParallaxNode.create(); - - // NOW add the 3 layers to the 'void' node - - // background image is moved at a ratio of 0.4x, 0.5y - voidNode.addChild(background, -1, cc.p(0.4, 0.5), cc.p(0,0)); - - // tiles are moved at a ratio of 2.2x, 1.0y - voidNode.addChild(tilemap, 1, cc.p(2.2, 1.0), cc.p(0, -200)); - - // top image is moved at a ratio of 3.0x, 2.5y - voidNode.addChild(cocosImage, 2, cc.p(3.0, 2.5), cc.p(200, 800)); - - - // now create some actions that will move the 'void' node - // and the children of the 'void' node will move at different - // speed, thus, simulation the 3D environment - var goUp = cc.MoveBy.create(4, cc.p(0, -500)); - var goDown = goUp.reverse(); - var go = cc.MoveBy.create(8, cc.p(-1000, 0)); - var goBack = go.reverse(); - var seq = cc.Sequence.create(goUp, go, goDown, goBack ); - voidNode.runAction((cc.RepeatForever.create(seq) )); - - this.addChild(voidNode); - }, - - title:function () { - return "Parallax: parent and 3 children"; - } -}); - - -// -// Parallax 2 -// -ParallaxTest2 = BaseLayer.extend({ - - _root:null, - _target:null, - _streak:null, - - - ctor:function () { - this._super(); - - var platform = __getPlatform(); - if( platform.substring(0,7) == 'desktop' ) - this.setMouseEnabled( true ); - else if( platform.substring(0,6) == 'mobile' ) - this.setTouchEnabled( true ); - - // Top Layer, a simple image - var cocosImage = cc.Sprite.create("Images/powered.png"); - // scale the image (optional) - cocosImage.setScale(1.5); - // change the transform anchor point to 0,0 (optional) - cocosImage.setAnchorPoint(cc.p(0, 0)); - - - // Middle layer: a Tile map atlas - var tilemap = cc.TileMapAtlas.create("TileMaps/tiles.png", "TileMaps/levelmap.tga", 16, 16); - - // change the transform anchor to 0,0 (optional) - tilemap.setAnchorPoint( cc.p(0, 0) ); - - // Anti Aliased images - tilemap.getTexture().setAntiAliasTexParameters(); - - - // background layer: another image - var background = cc.Sprite.create("Images/background.png"); - // scale the image (optional) - background.setScale(1.5); - // change the transform anchor point (optional) - background.setAnchorPoint(cc.p(0, 0)); - - // create a void node, a parent node - var voidNode = cc.ParallaxNode.create(); - - // NOW add the 3 layers to the 'void' node - - // background image is moved at a ratio of 0.4x, 0.5y - voidNode.addChild(background, -1, cc.p(0.4, 0.5), cc.p(0,0)); - - // tiles are moved at a ratio of 2.2x, 1.0y - voidNode.addChild(tilemap, 1, cc.p(2.2, 1.0), cc.p(0, -200)); - - // top image is moved at a ratio of 3.0x, 2.5y - voidNode.addChild(cocosImage, 2, cc.p(3.0, 2.5), cc.p(200, 800)); - this.addChild(voidNode, 0, TAG_NODE); - - }, - - onTouchesMoved:function (touches, event) { - var node = this.getChildByTag(TAG_NODE); - var currentPos = node.getPosition(); - node.setPosition( cc.pAdd( currentPos, touches[0].getDelta() ) ); - }, - - onMouseDragged : function( event ) { - var node = this.getChildByTag(TAG_NODE); - var currentPos = node.getPosition(); - node.setPosition( cc.pAdd( currentPos, event.getDelta() ) ); - }, - - title:function () { - return "Parallax: drag screen"; - } -}); - -// -// Order of tests -// -scenes.push( ParallaxTest1 ); -scenes.push( ParallaxTest2 ); - -//------------------------------------------------------------------ -// -// Main entry point -// -//------------------------------------------------------------------ -function run() -{ - var scene = cc.Scene.create(); - var layer = new scenes[currentScene](); - scene.addChild( layer ); - - var runningScene = director.getRunningScene(); - if( runningScene == null ) - director.runWithScene( scene ); - else - director.replaceScene( cc.TransitionFade.create(0.5, scene ) ); -} - -run(); - diff --git a/samples/TestJavascript/Resources/js/test-particles.js b/samples/TestJavascript/Resources/js/test-particles.js deleted file mode 100644 index 151e1ae6ba..0000000000 --- a/samples/TestJavascript/Resources/js/test-particles.js +++ /dev/null @@ -1,1155 +0,0 @@ -// -// http://www.cocos2d-iphone.org -// http://www.cocos2d-html5.org -// http://www.cocos2d-x.org -// -// Javascript + cocos2d particles tests -// - -require("js/helper.js"); - -director = cc.Director.getInstance(); -winSize = director.getWinSize(); -centerPos = cc.p( winSize.width/2, winSize.height/2 ); - -var scenes = [] -var currentScene = 0; - -var nextScene = function () { - currentScene = currentScene + 1; - if( currentScene >= scenes.length ) - currentScene = 0; - - withTransition = true; - loadScene(currentScene); -}; - -var previousScene = function () { - currentScene = currentScene -1; - if( currentScene < 0 ) - currentScene = scenes.length -1; - - withTransition = true; - loadScene(currentScene); -}; - -var restartScene = function () { - loadScene( currentScene ); -}; - -var loadScene = function (sceneIdx) -{ - winSize = director.getWinSize(); - centerPos = cc.p( winSize.width/2, winSize.height/2 ); - - var scene = cc.Scene.create(); - var layer = new scenes[ sceneIdx ](); - - scene.addChild( layer ); - -// scene.walkSceneGraph(0); - - director.replaceScene( scene ); -// __jsc__.garbageCollect(); -} - - - -// -// Globals -// -var TAG_LABEL_ATLAS = 100; - -var s_stars1 = 'Images/stars.png'; -var s_stars2 = 'Images/stars2.png'; -var s_starsGrayscale = 'Images/stars-grayscale.png'; -var s_fire = 'Images/fire.png'; -var s_smoke = 'Images/smoke.png'; -var s_snow = 'Images/snow.png'; - -// -// Base Layer -// - -var BaseLayer = cc.LayerGradient.extend({ - _emitter:null, - _background:null, - _shapeModeButton:null, - _textureModeButton:null, - - ctor:function () { - var parent = new cc.LayerGradient(); - __associateObjWithNative(this, parent); - this.init(cc.c4b(0, 0, 0, 255), cc.c4b(0, 128, 255, 255)); - - this._emitter = null; - - - var platform = __getPlatform(); - if( platform.substring(0,7) == 'desktop' ) - this.setMouseEnabled( true ); - else if( platform.substring(0,6) == 'mobile' ) - this.setTouchEnabled( true ); - - var label = cc.LabelTTF.create(this.title(), "Arial", 28); - this.addChild(label, 100, 1000); - label.setPosition(cc.p(winSize.width / 2, winSize.height - 50)); - - var tapScreen = cc.LabelTTF.create("(Tap the Screen)", "Arial", 20); - tapScreen.setPosition( cc.p(winSize.width / 2, winSize.height - 80)); - this.addChild(tapScreen, 100); - var selfPoint = this; - - - var itemFree = cc.MenuItemFont.create("Free movement"); - var itemRel = cc.MenuItemFont.create("Relative movement"); - var itemGroup = cc.MenuItemFont.create("Group movement"); - var toggle = cc.MenuItemToggle.create( itemFree, itemRel, itemGroup ); - toggle.setCallback( this, this.toggleCB ); - - var menu = cc.Menu.create( toggle ); - menu.alignItemsVertically(); - menu.setPosition( cc.p( 100, 100 ) ); - this.addChild(menu, 1); - - // Menu - var item1 = cc.MenuItemImage.create("Images/b1.png", "Images/b2.png", this, this.backCallback); - var item2 = cc.MenuItemImage.create("Images/r1.png", "Images/r2.png", this, this.restartCallback); - var item3 = cc.MenuItemImage.create("Images/f1.png", "Images/f2.png", this, this.nextCallback); - var item4 = cc.MenuItemFont.create("back", this, function() { require("js/main.js"); } ); - cc.MenuItemFont.setFontSize( 22 ); - - var menu = cc.Menu.create(item1, item2, item3, item4 ); - - menu.setPosition( cc.p(0,0) ); - item1.setPosition( cc.p(winSize.width / 2 - 100, 30)); - item2.setPosition( cc.p(winSize.width / 2, 30)); - item3.setPosition( cc.p(winSize.width / 2 + 100, 30)); - item4.setPosition( cc.p(winSize.width - 60, winSize.height - 30 ) ); - - this.addChild(menu, 10); - - - //TODO - var labelAtlas = cc.LabelAtlas.create("0000", "Fonts/fps_images.plist"); - this.addChild(labelAtlas, 100, TAG_LABEL_ATLAS); - labelAtlas.setPosition( cc.p( winSize.width - 66, 50)); - - // moving background - this._background = cc.Sprite.create("Images/background3.png"); - this.addChild(this._background, 5); - this._background.setPosition(cc.p(winSize.width / 2, winSize.height - 180)); - - var move = cc.MoveBy.create(4, cc.p(300, 0)); - var move_back = move.reverse(); - var seq = cc.Sequence.create(move, move_back); - this._background.runAction(cc.RepeatForever.create(seq)); - - this.scheduleUpdate(); - }, - - toggleCB:function(sender) { - var type = this._emitter.getPositionType(); - if( type == cc.PARTICLE_TYPE_GROUPED ) - this._emitter.setPositionType( cc.PARTICLE_TYPE_FREE ); - else if( type == cc.PARTICLE_TYPE_FREE ) - this._emitter.setPositionType( cc.PARTICLE_TYPE_RELATIVE ); - else if( type == cc.PARTICLE_TYPE_RELATIVE ) - this._emitter.setPositionType( cc.PARTICLE_TYPE_GROUPED ); - }, - - onEnter:function () { - // don't call super_.this() - var pLabel = this.getChildByTag(1000); - pLabel.setString(this.title()); - }, - title:function () { - return "No title"; - }, - - restartCallback:function (sender) { - restartScene(); - }, - - nextCallback:function (sender) { - nextScene(); - }, - - backCallback:function (sender) { - previousScene(); - }, - - toggleCallback:function (sender) { - if (this._emitter.getPositionType() == cc.PARTICLE_TYPE_GROUPED ) - this._emitter.setPositionType( cc.PARTICLE_TYPE_FREE ); - else if (this._emitter.getPositionType() == cc.PARTICLE_TYPE_FREE ) - this._emitter.setPositionType( cc.PARTICLE_TYPE_RELATIVE ); - else if (this._emitter.getPositionType() == cc.PARTICLE_TYPE_RELATIVE ) - this._emitter.setPositionType( cc.PARTICLE_TYPE_GROUPED ); - }, - - onTouchesBegan:function (touches, event) { - return this.onTouchesEnded( touches, event ); - }, - - onTouchesMoved:function (touches, event) { - return this.onTouchesEnded(touches, event); - }, - - onTouchesEnded:function (touches, event) { - var location = touches[0].getLocation(); - - var pos = cc.p( 0, 0 ); - if (this._background) - pos = this._background.convertToWorldSpace( cc.p(0,0) ); - if (this._emitter) { - this._emitter.setPosition(cc.pSub(location, pos)); - } - }, - - onMouseDown : function( event ) { - return this.onMouseEnded( event ); - }, - - onMouseDragged : function( event ) { - return this.onMouseEnded( event ); - }, - - onMouseEnded: function( event ) { - var location = event.getLocation(); - var pos = cc.p(0,0); - if (this._background) - pos = this._background.convertToWorldSpace( cc.p(0,0) ); - - this._emitter.setPosition(cc.pSub(location, pos)); - return true; - }, - - update:function (dt) { - if (this._emitter) { - var atlas = this.getChildByTag(TAG_LABEL_ATLAS); - atlas.setString(this._emitter.getParticleCount().toFixed(0)); - } - }, - setEmitterPosition:function () { - var p = this._emitter.getSourcePosition(); - if( p.x==0 && p.y==0 ) - this._emitter.setPosition( cc.p(200, 70) ); - } -}); - -var DemoFirework = BaseLayer.extend({ - onEnter:function () { - //this._super(); - - this._emitter = cc.ParticleFireworks.create(); - this._background.addChild(this._emitter, 10); - var myTexture = cc.TextureCache.getInstance().addImage(s_stars1); - this._emitter.setTexture(myTexture); - this.setEmitterPosition(); - }, - title:function () { - return "ParticleFireworks"; - } -}); - -var DemoFire = BaseLayer.extend({ - onEnter:function () { - //this._super(); - - this._emitter = cc.ParticleFire.create(); - this._background.addChild(this._emitter, 10); - - this._emitter.setTexture(cc.TextureCache.getInstance().addImage(s_fire));//.pvr"]; - var p = this._emitter.getPosition(); - this._emitter.setPosition(cc.p(p.x, 100)); - - this.setEmitterPosition(); - }, - title:function () { - return "ParticleFire"; - } -}); - -var DemoSun = BaseLayer.extend({ - onEnter:function () { - //this._super(); - - this._emitter = cc.ParticleSun.create(); - this._background.addChild(this._emitter, 10); - var myTexture = cc.TextureCache.getInstance().addImage(s_fire); - this._emitter.setTexture(myTexture); - this.setEmitterPosition(); - }, - title:function () { - return "ParticleSun"; - } -}); - -var DemoGalaxy = BaseLayer.extend({ - onEnter:function () { - //this._super(); - - this._emitter = cc.ParticleGalaxy.create(); - this._background.addChild(this._emitter, 10); - var myTexture = cc.TextureCache.getInstance().addImage(s_fire); - this._emitter.setTexture(myTexture); - this.setEmitterPosition(); - }, - title:function () { - return "ParticleGalaxy"; - } -}); - -var DemoFlower = BaseLayer.extend({ - ctor:function () { - this._super(); - }, - onEnter:function () { - //this._super(); - - this._emitter = cc.ParticleFlower.create(); - this._background.addChild(this._emitter, 10); - - var myTexture = cc.TextureCache.getInstance().addImage(s_stars1); - this._emitter.setTexture(myTexture); - this.setEmitterPosition(); - }, - title:function () { - return "ParticleFlower"; - } -}); - -var DemoBigFlower = BaseLayer.extend({ - onEnter:function () { - //this._super(); - - this._emitter = cc.ParticleSystem.createWithTotalParticles(50); - //this._emitter.autorelease(); - - this._background.addChild(this._emitter, 10); - this._emitter.setTexture(cc.TextureCache.getInstance().addImage(s_stars1)); - this._emitter.setDuration(-1); - - // gravity - this._emitter.setGravity(cc.p(0,0)); - - // angle - this._emitter.setAngle(90); - this._emitter.setAngleVar(360); - - // speed of particles - this._emitter.setSpeed(160); - this._emitter.setSpeedVar(20); - - // radial - this._emitter.setRadialAccel(-120); - this._emitter.setRadialAccelVar(0); - - // tagential - this._emitter.setTangentialAccel(30); - this._emitter.setTangentialAccelVar(0); - - // emitter position - this._emitter.setPosition(cc.p(160, 240)); - this._emitter.setPosVar(cc.p(0,0)); - - // life of particles - this._emitter.setLife(4); - this._emitter.setLifeVar(1); - - // spin of particles - this._emitter.setStartSpin(0); - this._emitter.setStartSizeVar(0); - this._emitter.setEndSpin(0); - this._emitter.setEndSpinVar(0); - - // color of particles - var startColor = cc.c4f(0.5, 0.5, 0.5, 1.0); - this._emitter.setStartColor(startColor); - - var startColorVar = cc.c4f(0.5, 0.5, 0.5, 1.0); - this._emitter.setStartColorVar(startColorVar); - - var endColor = cc.c4f(0.1, 0.1, 0.1, 0.2); - this._emitter.setEndColor(endColor); - - var endColorVar = cc.c4f(0.1, 0.1, 0.1, 0.2); - this._emitter.setEndColorVar(endColorVar); - - // size, in pixels - this._emitter.setStartSize(80.0); - this._emitter.setStartSizeVar(40.0); - this._emitter.setEndSize(cc.PARTICLE_START_SIZE_EQUAL_TO_END_SIZE); - - // emits per second - this._emitter.setEmissionRate(this._emitter.getTotalParticles() / this._emitter.getLife()); - - // additive - this._emitter.setBlendAdditive(true); - - this.setEmitterPosition(); - }, - title:function () { - return "ParticleBigFlower"; - } -}); - -var DemoRotFlower = BaseLayer.extend({ - onEnter:function () { - //this._super(); - - this._emitter = cc.ParticleSystem.createWithTotalParticles( 150 ); - - this._background.addChild(this._emitter, 10); - this._emitter.setTexture(cc.TextureCache.getInstance().addImage(s_stars2)); - // duration - this._emitter.setDuration(-1); - - // gravity - this._emitter.setGravity(cc.p(0,0)); - - // angle - this._emitter.setAngle(90); - this._emitter.setAngleVar(360); - - // speed of particles - this._emitter.setSpeed(160); - this._emitter.setSpeedVar(20); - - // radial - this._emitter.setRadialAccel(-120); - this._emitter.setRadialAccelVar(0); - - // tagential - this._emitter.setTangentialAccel(30); - this._emitter.setTangentialAccelVar(0); - - // emitter position - this._emitter.setPosition(cc.p(160, 240)); - this._emitter.setPosVar(cc.p(0,0)); - - // life of particles - this._emitter.setLife(3); - this._emitter.setLifeVar(1); - - // spin of particles - this._emitter.setStartSpin(0); - this._emitter.setStartSpinVar(0); - this._emitter.setEndSpin(0); - this._emitter.setEndSpinVar(2000); - - var startColor = cc.c4f(0.5, 0.5, 0.5, 1.0); - this._emitter.setStartColor(startColor); - - var startColorVar = cc.c4f(0.5, 0.5, 0.5, 1.0); - this._emitter.setStartColorVar(startColorVar); - - var endColor = cc.c4f(0.1, 0.1, 0.1, 0.2); - this._emitter.setEndColor(endColor); - - var endColorVar = cc.c4f(0.1, 0.1, 0.1, 0.2); - this._emitter.setEndColorVar(endColorVar); - - // size, in pixels - this._emitter.setStartSize(30.0); - this._emitter.setStartSizeVar(0); - this._emitter.setEndSize(cc.PARTICLE_START_SIZE_EQUAL_TO_END_SIZE); - - // emits per second - this._emitter.setEmissionRate(this._emitter.getTotalParticles() / this._emitter.getLife()); - - // additive - this._emitter.setBlendAdditive(false); - - this.setEmitterPosition(); - }, - title:function () { - return "ParticleRotFlower"; - } -}); - -var DemoMeteor = BaseLayer.extend({ - onEnter:function () { - //this._super(); - - this._emitter = cc.ParticleMeteor.create(); - this._background.addChild(this._emitter, 10); - - this._emitter.setTexture(cc.TextureCache.getInstance().addImage(s_fire)); - this.setEmitterPosition(); - }, - title:function () { - return "ParticleMeteor"; - } -}); - -var DemoSpiral = BaseLayer.extend({ - onEnter:function () { - //this._super(); - - this._emitter = cc.ParticleSpiral.create(); - this._background.addChild(this._emitter, 10); - - this._emitter.setTexture(cc.TextureCache.getInstance().addImage(s_fire)); - this.setEmitterPosition(); - }, - title:function () { - return "ParticleSpiral"; - } -}); - -var DemoExplosion = BaseLayer.extend({ - onEnter:function () { - //this._super(); - - this._emitter = cc.ParticleExplosion.create(); - this._background.addChild(this._emitter, 10); - - this._emitter.setTexture(cc.TextureCache.getInstance().addImage(s_stars1)); - this._emitter.setAutoRemoveOnFinish(true); - - this.setEmitterPosition(); - }, - title:function () { - return "ParticleExplosion"; - } -}); - -var DemoSmoke = BaseLayer.extend({ - onEnter:function () { - //this._super(); - - this._emitter = cc.ParticleSmoke.create(); - this._background.addChild(this._emitter, 10); - this._emitter.setTexture(cc.TextureCache.getInstance().addImage(s_fire)); - - var p = this._emitter.getPosition(); - this._emitter.setPosition(cc.p(p.x, 100)); - - this.setEmitterPosition(); - }, - title:function () { - return "ParticleSmoke"; - } -}); - -var DemoSnow = BaseLayer.extend({ - onEnter:function () { - //this._super(); - - this._emitter = cc.ParticleSnow.create(); - this._background.addChild(this._emitter, 10); - - var p = this._emitter.getPosition(); - this._emitter.setPosition(cc.p(p.x, p.y - 110)); - this._emitter.setLife(3); - this._emitter.setLifeVar(1); - - // gravity - this._emitter.setGravity(cc.p(0, -10)); - - // speed of particles - this._emitter.setSpeed(130); - this._emitter.setSpeedVar(30); - - - var startColor = this._emitter.getStartColor(); - startColor.r = 0.9; - startColor.g = 0.9; - startColor.b = 0.9; - this._emitter.setStartColor(startColor); - - var startColorVar = this._emitter.getStartColorVar(); - startColorVar.b = 0.1; - this._emitter.setStartColorVar(startColorVar); - - this._emitter.setEmissionRate(this._emitter.getTotalParticles() / this._emitter.getLife()); - - this._emitter.setTexture(cc.TextureCache.getInstance().addImage(s_snow)); - - this.setEmitterPosition(); - }, - title:function () { - return "ParticleSnow"; - } -}); - -var DemoRain = BaseLayer.extend({ - onEnter:function () { - //this._super(); - - this._emitter = cc.ParticleRain.create(); - this._background.addChild(this._emitter, 10); - - var p = this._emitter.getPosition(); - this._emitter.setPosition(cc.p(p.x, p.y - 100)); - this._emitter.setLife(4); - - this._emitter.setTexture(cc.TextureCache.getInstance().addImage(s_fire)); - this.setEmitterPosition(); - }, - title:function () { - return "ParticleRain"; - } -}); - -var DemoModernArt = BaseLayer.extend({ - onEnter:function () { - //this._super(); - - this._emitter = cc.ParticleSystem.createWithTotalParticles( 200 ); - - this._background.addChild(this._emitter, 10); - - // duration - this._emitter.setDuration(-1); - - // gravity - this._emitter.setGravity(cc.p(0, 0)); - - // angle - this._emitter.setAngle(0); - this._emitter.setAngleVar(360); - - // radial - this._emitter.setRadialAccel(70); - this._emitter.setRadialAccelVar(10); - - // tagential - this._emitter.setTangentialAccel(80); - this._emitter.setTangentialAccelVar(0); - - // speed of particles - this._emitter.setSpeed(50); - this._emitter.setSpeedVar(10); - - // emitter position - this._emitter.setPosition(cc.p(winSize.width / 2, winSize.height / 2)); - this._emitter.setPosVar(cc.p(0,0)); - - // life of particles - this._emitter.setLife(2.0); - this._emitter.setLifeVar(0.3); - - // emits per frame - this._emitter.setEmissionRate(this._emitter.getTotalParticles() / this._emitter.getLife()); - - // color of particles - var startColor = cc.c4f(0.5, 0.5, 0.5, 1.0); - this._emitter.setStartColor(startColor); - - var startColorVar = cc.c4f(0.5, 0.5, 0.5, 1.0); - this._emitter.setStartColorVar(startColorVar); - - var endColor = cc.c4f(0.1, 0.1, 0.1, 0.2); - this._emitter.setEndColor(endColor); - - var endColorVar = cc.c4f(0.1, 0.1, 0.1, 0.2); - this._emitter.setEndColorVar(endColorVar); - - // size, in pixels - this._emitter.setStartSize(1.0); - this._emitter.setStartSizeVar(1.0); - this._emitter.setEndSize(32.0); - this._emitter.setEndSizeVar(8.0); - - // texture - this._emitter.setTexture(cc.TextureCache.getInstance().addImage(s_fire)); - // additive - this._emitter.setBlendAdditive(false); - - this.setEmitterPosition(); - }, - title:function () { - return "Varying size"; - } -}); - -var DemoRing = BaseLayer.extend({ - onEnter:function () { - //this._super(); - - this._emitter = cc.ParticleFlower.create(); - - this._background.addChild(this._emitter, 10); - - this._emitter.setTexture(cc.TextureCache.getInstance().addImage(s_stars1)); - - this._emitter.setLifeVar(0); - this._emitter.setLife(10); - this._emitter.setSpeed(100); - this._emitter.setSpeedVar(0); - this._emitter.setEmissionRate(10000); - - this.setEmitterPosition(); - }, - title:function () { - return "Ring Demo"; - } -}); - -var ParallaxParticle = BaseLayer.extend({ - onEnter:function () { - //this._super(); - - this._background.getParent().removeChild(this._background, true); - this._background = null; - - //TODO - var p = cc.ParallaxNode.create(); - this.addChild(p, 5); - - var p1 = cc.Sprite.create("Images/background3.png"); - var p2 = cc.Sprite.create("Images/background3.png"); - - p.addChild(p1, 1, cc.p(0.5, 1), cc.p(0, 250)); - p.addChild(p2, 2, cc.p(1.5, 1), cc.p(0, 50)); - - this._emitter = cc.ParticleFlower.create(); - this._emitter.setTexture(cc.TextureCache.getInstance().addImage(s_fire)); - - p1.addChild(this._emitter, 10); - this._emitter.setPosition(cc.p(250, 200)); - - var par = cc.ParticleSun.create(); - p2.addChild(par, 10); - par.setTexture(cc.TextureCache.getInstance().addImage(s_fire)); - - var move = cc.MoveBy.create(4, cc.p(300, 0)); - var move_back = move.reverse(); - var seq = cc.Sequence.create(move, move_back); - p.runAction( cc.RepeatForever.create(seq) ); - }, - title:function () { - return "Parallax + Particles"; - } -}); - -var DemoFileParticle = BaseLayer.extend({ - _title:"", - ctor:function (filename) { - this._title = filename; - this._super(); - }, - onEnter:function () { - //this._super(); - - this.removeChild(this._background, true); - this._background = null; - - var filename = "Particles/" + this._title + ".plist"; - this._emitter = cc.ParticleSystemQuad.create( filename ); - this.addChild(this._emitter, 10); - - this.setEmitterPosition(); - }, - title:function () { - return this._title; - } -}); - -var DemoFileBoilingFoam = DemoFileParticle.extend({ - ctor:function () { - this._super("BoilingFoam"); - }, -}); - -var DemoFileBurstPipe = DemoFileParticle.extend({ - ctor:function () { - this._super("BurstPipe"); - }, -}); - -var DemoFileComet = DemoFileParticle.extend({ - ctor:function () { - this._super("Comet"); - }, -}); - -var DemoFileDebian = DemoFileParticle.extend({ - ctor:function () { - this._super("debian"); - }, -}); - -var DemoFileExplodingRing = DemoFileParticle.extend({ - ctor:function () { - this._super("ExplodingRing"); - }, -}); - -var DemoFileLavaFlow = DemoFileParticle.extend({ - ctor:function () { - this._super("LavaFlow"); - }, -}); - -var DemoFileSpinningPeas = DemoFileParticle.extend({ - ctor:function () { - this._super("SpinningPeas"); - }, -}); - -var DemoFileSpookyPeas = DemoFileParticle.extend({ - ctor:function () { - this._super("SpookyPeas"); - }, -}); - -var DemoFileUpsidedown= DemoFileParticle.extend({ - ctor:function () { - this._super("Upsidedown"); - }, -}); - -var DemoFileUpsidedown= DemoFileParticle.extend({ - ctor:function () { - this._super("Upsidedown"); - }, -}); - -var DemoFileFlower = DemoFileParticle.extend({ - ctor:function () { - this._super("Flower"); - }, -}); - -var DemoFileSpiral= DemoFileParticle.extend({ - ctor:function () { - this._super("Spiral"); - }, -}); - -var DemoFileGalaxy= DemoFileParticle.extend({ - ctor:function () { - this._super("Galaxy"); - }, -}); - -var RadiusMode1 = BaseLayer.extend({ - onEnter:function () { - //this._super(); - - this.removeChild(this._background, true); - this._background = null; - - this._emitter = cc.ParticleSystem.createWithTotalParticles( 150 ); - this.addChild(this._emitter, 10); - this._emitter.setTexture(cc.TextureCache.getInstance().addImage(s_starsGrayscale)); - - // duration - this._emitter.setDuration(cc.PARTICLE_DURATION_INFINITY); - - // radius mode - this._emitter.setEmitterMode(cc.PARTICLE_MODE_RADIUS); - - // radius mode: start and end radius in pixels - this._emitter.setStartRadius(0); - this._emitter.setStartRadiusVar(0); - this._emitter.setEndRadius(160); - this._emitter.setEndRadiusVar(0); - - // radius mode: degrees per second - this._emitter.setRotatePerSecond(180); - this._emitter.setRotatePerSecondVar(0); - - - // angle - this._emitter.setAngle(90); - this._emitter.setAngleVar(0); - - // emitter position - this._emitter.setPosition(cc.p(winSize.width / 2, winSize.height / 2)); - this._emitter.setPosVar(cc.p(0,0)); - - // life of particles - this._emitter.setLife(5); - this._emitter.setLifeVar(0); - - // spin of particles - this._emitter.setStartSpin(0); - this._emitter.setStartSpinVar(0); - this._emitter.setEndSpin(0); - this._emitter.setEndSpinVar(0); - - // color of particles - var startColor = cc.c4f(0.5, 0.5, 0.5, 1.0); - this._emitter.setStartColor(startColor); - - var startColorVar = cc.c4f(0.5, 0.5, 0.5, 1.0); - this._emitter.setStartColorVar(startColorVar); - - var endColor = cc.c4f(0.1, 0.1, 0.1, 0.2); - this._emitter.setEndColor(endColor); - - var endColorVar = cc.c4f(0.1, 0.1, 0.1, 0.2); - this._emitter.setEndColorVar(endColorVar); - - // size, in pixels - this._emitter.setStartSize(32); - this._emitter.setStartSizeVar(0); - this._emitter.setEndSize(cc.PARTICLE_START_SIZE_EQUAL_TO_END_SIZE); - - // emits per second - this._emitter.setEmissionRate(this._emitter.getTotalParticles() / this._emitter.getLife()); - - // additive - this._emitter.setBlendAdditive(false); - }, - title:function () { - return "Radius Mode: Spiral"; - } -}); - -var RadiusMode2 = BaseLayer.extend({ - onEnter:function () { - //this._super(); - - this.removeChild(this._background, true); - this._background = null; - - this._emitter = cc.ParticleSystem.createWithTotalParticles( 200 ); - this.addChild(this._emitter, 10); - this._emitter.setTexture(cc.TextureCache.getInstance().addImage(s_starsGrayscale)); - - // duration - this._emitter.setDuration(cc.PARTICLE_DURATION_INFINITY); - - // radius mode - this._emitter.setEmitterMode(cc.PARTICLE_MODE_RADIUS); - - // radius mode: start and end radius in pixels - this._emitter.setStartRadius(100); - this._emitter.setStartRadiusVar(0); - this._emitter.setEndRadius(cc.PARTICLE_START_RADIUS_EQUAL_TO_END_RADIUS); - this._emitter.setEndRadiusVar(0); - - // radius mode: degrees per second - this._emitter.setRotatePerSecond(45); - this._emitter.setRotatePerSecondVar(0); - - - // angle - this._emitter.setAngle(90); - this._emitter.setAngleVar(0); - - // emitter position - this._emitter.setPosition(cc.p(winSize.width / 2, winSize.height / 2)); - this._emitter.setPosVar(cc.p(0,0)); - - // life of particles - this._emitter.setLife(4); - this._emitter.setLifeVar(0); - - // spin of particles - this._emitter.setStartSpin(0); - this._emitter.setStartSpinVar(0); - this._emitter.setEndSpin(0); - this._emitter.setEndSpinVar(0); - - // color of particles - var startColor = cc.c4f(0.5, 0.5, 0.5, 1.0); - this._emitter.setStartColor(startColor); - - var startColorVar = cc.c4f(0.5, 0.5, 0.5, 1.0); - this._emitter.setStartColorVar(startColorVar); - - var endColor = cc.c4f(0.1, 0.1, 0.1, 0.2); - this._emitter.setEndColor(endColor); - - var endColorVar = cc.c4f(0.1, 0.1, 0.1, 0.2); - this._emitter.setEndColorVar(endColorVar); - - // size, in pixels - this._emitter.setStartSize(32); - this._emitter.setStartSizeVar(0); - this._emitter.setEndSize(cc.PARTICLE_START_SIZE_EQUAL_TO_END_SIZE); - - // emits per second - this._emitter.setEmissionRate(this._emitter.getTotalParticles() / this._emitter.getLife()); - - // additive - this._emitter.setBlendAdditive(false); - }, - title:function () { - return "Radius Mode: Semi Circle"; - } -}); - -var Issue704 = BaseLayer.extend({ - onEnter:function () { - //this._super(); - - this.removeChild(this._background, true); - this._background = null; - - this._emitter = cc.ParticleSystem.createWithTotalParticles( 100 ); - - this.addChild(this._emitter, 10); - this._emitter.setTexture(cc.TextureCache.getInstance().addImage(s_fire)); - // duration - this._emitter.setDuration(cc.PARTICLE_DURATION_INFINITY); - - // radius mode - this._emitter.setEmitterMode(cc.PARTICLE_MODE_RADIUS); - - // radius mode: start and end radius in pixels - this._emitter.setStartRadius(50); - this._emitter.setStartRadiusVar(0); - this._emitter.setEndRadius(cc.PARTICLE_START_RADIUS_EQUAL_TO_END_RADIUS); - this._emitter.setEndRadiusVar(0); - - // radius mode: degrees per second - this._emitter.setRotatePerSecond(0); - this._emitter.setRotatePerSecondVar(0); - - - // angle - this._emitter.setAngle(90); - this._emitter.setAngleVar(0); - - // emitter position - this._emitter.setPosition(cc.p(winSize.width / 2, winSize.height / 2)); - this._emitter.setPosVar(cc.p(0,0)); - - // life of particles - this._emitter.setLife(5); - this._emitter.setLifeVar(0); - - // spin of particles - this._emitter.setStartSpin(0); - this._emitter.setStartSpinVar(0); - this._emitter.setEndSpin(0); - this._emitter.setEndSpinVar(0); - - // color of particles - var startColor = cc.c4f(0.5, 0.5, 0.5, 1.0); - this._emitter.setStartColor(startColor); - - var startColorVar = cc.c4f(0.5, 0.5, 0.5, 1.0); - this._emitter.setStartColorVar(startColorVar); - - var endColor = cc.c4f(0.1, 0.1, 0.1, 0.2); - this._emitter.setEndColor(endColor); - - var endColorVar = cc.c4f(0.1, 0.1, 0.1, 0.2); - this._emitter.setEndColorVar(endColorVar); - - // size, in pixels - this._emitter.setStartSize(16); - this._emitter.setStartSizeVar(0); - this._emitter.setEndSize(cc.PARTICLE_START_SIZE_EQUAL_TO_END_SIZE); - - // emits per second - this._emitter.setEmissionRate(this._emitter.getTotalParticles() / this._emitter.getLife()); - - // additive - this._emitter.setBlendAdditive(false); - - var rot = cc.RotateBy.create(16, 360); - this._emitter.runAction(cc.RepeatForever.create(rot)); - }, - title:function () { - return "Issue 704. Free + Rot"; - }, - subtitle:function () { - return "Emitted particles should not rotate"; - } -}); - -var Issue870 = BaseLayer.extend({ - _index:0, - _elapsedTime:0, - onEnter:function () { - //this._super(); - - this.removeChild(this._background, true); - this._background = null; - - var system = cc.ParticleSystemQuad.create( "Particles/SpinningPeas.plist" ); - system.setTextureWithRect(cc.TextureCache.getInstance().addImage("Images/particles.png"), cc.rect(0, 0, 32, 32)); - this.addChild(system, 10); - this._emitter = system; - - this._index = 0; - }, - title:function () { - return "Issue 870. SubRect"; - }, - subtitle:function () { - return "Every 2 seconds the particle should change"; - }, - update:function (dt) { - - this._super(dt); - - this._elapsedTime += dt; - if( this._elapsedTime > 2 ) { - this._index = (this._index + 1) % 4; - var rect = cc.rect(this._index * 32, 0, 32, 32); - this._emitter.setTextureWithRect(this._emitter.getTexture(), rect); - - this._elapsedTime = 0; - } - } -}); - -// -// Order of tests -// - -scenes.push( DemoFlower ); -scenes.push( DemoGalaxy ); -scenes.push( DemoFirework ); -scenes.push( DemoSpiral ); -scenes.push( DemoSun ); -scenes.push( DemoMeteor ); -scenes.push( DemoFire ); -scenes.push( DemoSmoke ); -scenes.push( DemoExplosion ); -scenes.push( DemoSnow ); -scenes.push( DemoRain ); -scenes.push( DemoBigFlower ); -scenes.push( DemoRotFlower ); -scenes.push( DemoModernArt ); -scenes.push( DemoRing ); -scenes.push( ParallaxParticle ); -scenes.push( DemoFileBoilingFoam ); -scenes.push( DemoFileBurstPipe ); -scenes.push( DemoFileComet ); -scenes.push( DemoFileDebian ); -scenes.push( DemoFileExplodingRing ); -scenes.push( DemoFileLavaFlow ); -scenes.push( DemoFileSpinningPeas ); -scenes.push( DemoFileSpookyPeas ); -scenes.push( DemoFileUpsidedown ); -scenes.push( DemoFileFlower ); -scenes.push( DemoFileSpiral ); -scenes.push( DemoFileGalaxy ); -scenes.push( RadiusMode1 ); -scenes.push( RadiusMode2 ); -scenes.push( Issue704 ); -scenes.push( Issue870 ); - -//------------------------------------------------------------------ -// -// Main entry point -// -//------------------------------------------------------------------ -function run() -{ - var scene = cc.Scene.create(); - var layer = new scenes[currentScene](); - scene.addChild( layer ); - - var runningScene = director.getRunningScene(); - if( runningScene == null ) - director.runWithScene( scene ); - else - director.replaceScene( cc.TransitionFade.create(0.5, scene ) ); -} - -run(); - - diff --git a/samples/TestJavascript/Resources/js/test-performance.js b/samples/TestJavascript/Resources/js/test-performance.js deleted file mode 100644 index e7294bd3be..0000000000 --- a/samples/TestJavascript/Resources/js/test-performance.js +++ /dev/null @@ -1,122 +0,0 @@ -// -// -// Performance tests -// -// - -// force garbage collect before running -__jsc__.garbageCollect(); - -// dump config info -cc.log('----------------'); -cc.log('Config info:'); -for( i in cc.config ) - cc.log( i + " = " + cc.config[i] ); -cc.log('----------------'); - -// -// Testing creating Points in Native -// -var startMSec = Date.now(); -var n=50000; -for( var i=0; i < n; i++ ) - var p = cc._native_p(i, i); - -var endMSec = Date.now(); -var elapsed = (endMSec - startMSec) / 1000; - -cc.log("It took " + elapsed + " seconds to create " + n + " points in Native using cc._native_p(10,10)" ); - -// -// Testing creating Points in JS -// -var startMSec = Date.now(); -var n=50000; -for( var i=0; i < n; i++ ) - var p = {x:i,y:i}; - -var endMSec = Date.now(); -var elapsed = (endMSec - startMSec) / 1000; - -cc.log("It took " + elapsed + " seconds to create " + n + " points in JS using {x:10, y:10}" ); - -// -// Testing creating Points in JS Using Typed Arrays -// -var startMSec = Date.now(); -var n=50000; -for( var i=0; i < n; i++ ) { - var p = new Float32Array(2); - p[0] = i; - p[1] = i; -} - -var endMSec = Date.now(); -var elapsed = (endMSec - startMSec) / 1000; - -cc.log("It took " + elapsed + " seconds to create " + n + " points in JS using new Float32Array()" ); - - -// -// Testing querying properties -// Valid only when using Typed Arrays for Point -// -var n=50000; -var p = new Float32Array(2); -p[0] = 10; -p[1] = 20; -var startMSec = Date.now(); -for( var i=0; i < n; i++ ) { - var x = p[0]; - var y = p[1]; -} -var endMSec = Date.now(); -var elapsed = (endMSec - startMSec) / 1000; -cc.log("It took " + elapsed + " seconds to parse " + n + " points using p[0], p[1]" ); - -// -// Testing querying properties -// Valid only when using Object for Point -// -var n=50000; -var p = {x:10,y:20}; -var startMSec = Date.now(); -for( var i=0; i < n; i++ ) { - var x = p.x; - var y = p.y; -} -var endMSec = Date.now(); -var elapsed = (endMSec - startMSec) / 1000; -cc.log("It took " + elapsed + " seconds to parse " + n + " points using p.x, p.y" ); - - -// -// Testing native calls -// -var node = cc.Node.create(); -node.setPosition( cc.p(1,1) ); - -var n=50000; -var p = node.getPosition(); -var startMSec = Date.now(); -for( var i=0; i < n; i++ ) { - node.cleanup(); -} -var endMSec = Date.now(); -var elapsed = (endMSec - startMSec) / 1000; -cc.log("It took " + elapsed + " seconds to send " + n + " calls using node.cleanup()" ); - -// -// Testing creating nodes -// -var n=1000; -var startMSec = Date.now(); -for( var i=0; i < n; i++ ) { - var node = cc.Node.create(); -} -var endMSec = Date.now(); -var elapsed = (endMSec - startMSec) / 1000; -cc.log("It took " + elapsed + " seconds to create " + n + " cc.Node objects" ); - - -cc.log('----------------'); diff --git a/samples/TestJavascript/Resources/js/test-rendertexture.js b/samples/TestJavascript/Resources/js/test-rendertexture.js deleted file mode 100644 index c682409812..0000000000 --- a/samples/TestJavascript/Resources/js/test-rendertexture.js +++ /dev/null @@ -1,283 +0,0 @@ -// -// http://www.cocos2d-iphone.org -// http://www.cocos2d-html5.org -// http://www.cocos2d-x.org -// -// Javascript + cocos2d actions tests -// - -require("js/helper.js"); - -director = cc.Director.getInstance(); -winSize = director.getWinSize(); -centerPos = cc.p( winSize.width/2, winSize.height/2 ); -spriteFrameCache = cc.SpriteFrameCache.getInstance(); - -var scenes = []; -var currentScene = 0; - -var nextScene = function () { - currentScene = currentScene + 1; - if( currentScene >= scenes.length ) - currentScene = 0; - - withTransition = true; - loadScene(currentScene); -}; - -var previousScene = function () { - currentScene = currentScene -1; - if( currentScene < 0 ) - currentScene = scenes.length -1; - - withTransition = true; - loadScene(currentScene); -}; - -var restartScene = function () { - loadScene( currentScene ); -}; - -var loadScene = function (sceneIdx) -{ - winSize = director.getWinSize(); - centerPos = cc.p( winSize.width/2, winSize.height/2 ); - - var scene = new cc.Scene(); - scene.init(); - var layer = new scenes[ sceneIdx ](); - - scene.addChild( layer ); - -// scene.walkSceneGraph(0); - - director.replaceScene( scene ); -// __jsc__.garbageCollect(); -} - -var s_pathSister1 = "Images/grossinis_sister1.png"; -var s_pathSister2 = "Images/grossinis_sister2.png"; -var s_pathBlock = "Images/blocks.png"; -var s_grossiniPlist = "animations/grossini.plist"; - -// -// Base Layer -// - -var BaseLayer = cc.LayerGradient.extend({ - - ctor:function () { - - var parent = new cc.LayerGradient(); - __associateObjWithNative(this, parent); - this.init(cc.c4b(0, 0, 0, 255), cc.c4b(0, 128, 255, 255)); - }, - - title:function () { - return "Render Texture"; - }, - - subtitle:function () { - return ""; - }, - - code:function () { - return ""; - }, - - restartCallback:function (sender) { - restartScene(); - }, - - nextCallback:function (sender) { - nextScene(); - }, - - backCallback:function (sender) { - previousScene(); - }, - - onEnter:function () { - // DO NOT CALL this._super() -// this._super(); - - // add title and subtitle - var label = cc.LabelTTF.create(this.title(), "Arial", 28); - this.addChild(label, 10); - label.setPosition( cc.p(winSize.width / 2, winSize.height - 40)); - - var strSubtitle = this.subtitle(); - if (strSubtitle != "") { - var l = cc.LabelTTF.create(strSubtitle, "Thonburi", 16); - this.addChild(l, 10); - l.setPosition( cc.p(winSize.width / 2, winSize.height - 70)); - } - - var strCode = this.code(); - if( strCode !="" ) { - var label = cc.LabelTTF.create(strCode, 'CourierNewPSMT', 16); - label.setPosition( cc.p( winSize.width/2, winSize.height-120) ); - this.addChild( label,10 ); - - var labelbg = cc.LabelTTF.create(strCode, 'CourierNewPSMT', 16); - labelbg.setColor( cc.c3b(10,10,255) ); - labelbg.setPosition( cc.p( winSize.width/2 +1, winSize.height-120 -1) ); - this.addChild( labelbg,9); - } - - // Menu - var item1 = cc.MenuItemImage.create("Images/b1.png", "Images/b2.png", this, this.backCallback); - var item2 = cc.MenuItemImage.create("Images/r1.png", "Images/r2.png", this, this.restartCallback); - var item3 = cc.MenuItemImage.create("Images/f1.png", "Images/f2.png", this, this.nextCallback); - var item4 = cc.MenuItemFont.create("back", this, function() { require("js/main.js"); } ); - item4.setFontSize( 22 ); - - var menu = cc.Menu.create(item1, item2, item3, item4 ); - - menu.setPosition( cc.p(0,0) ); - item1.setPosition( cc.p(winSize.width / 2 - 100, 30)); - item2.setPosition( cc.p(winSize.width / 2, 30)); - item3.setPosition( cc.p(winSize.width / 2 + 100, 30)); - item4.setPosition( cc.p(winSize.width - 60, winSize.height - 30 ) ); - - this.addChild(menu, 10); - } -}); - -//------------------------------------------------------------------ -// -// Tests -// -//------------------------------------------------------------------ -var RenderTextureSave = BaseLayer.extend({ - _brush : null, - _target : null, - _lastLocation : null, - _counter :0, - - onEnter:function () { - this._super(); - - var platform = __getPlatform(); - if( platform.substring(0,7) == 'desktop' ) - this.setMouseEnabled( true ); - else if( platform.substring(0,6) == 'mobile' ) - this.setTouchEnabled( true ); - - this._brush = cc.Sprite.create("Images/fire.png"); - this._brush.retain(); - - this._brush.setColor( cc.RED ); - this._brush.setOpacity( 20 ); - - - var save = cc.MenuItemFont.create("Save", this, this.saveCB ); - var clear = cc.MenuItemFont.create("Clear", this, this.clearCB ); - var menu = cc.Menu.create( save, clear ); - menu.alignItemsVertically(); - menu.setPosition( cc.p( winSize.width-70, winSize.height-80 ) ); - this.addChild( menu, 10 ); - - // create a render texture - var target = cc.RenderTexture.create( winSize.width, winSize.height ); - target.setPosition( cc.p (winSize.width/2, winSize.height/2) ); - this.addChild( target, 1 ); - - this._target = target; - - this._lastLocation = cc.p( winSize.width/2, winSize.height/2); - - }, - - onExit:function() { - this._brush.release(); - }, - - saveCB:function(sender) { - var namePNG = "image-" + this._counter + ".png"; - var nameJPG = "image-" + this._counter + ".jpg"; - - this._target.saveToFile( nameJPG, cc.IMAGE_FORMAT_JPEG ); - this._target.saveToFile( namePNG, cc.IMAGE_FORMAT_PNG ); - - cc.log("images saved!"); - this._counter++; - }, - - clearCB:function(sender) { - this._target.clear( Math.random(), Math.random(), Math.random(), 1 ); - }, - - drawInLocation: function( location ) { - var distance = cc.pDistance( location, this._lastLocation ); - if( distance > 1 ) { - this._target.begin(); - for( var i=0; i < distance; i++ ) { - var diffX = this._lastLocation.x - location.x; - var diffY = this._lastLocation.y - location.y; - - var delta = i / distance; - - this._brush.setPosition( cc._p( location.x + diffX * delta, location.y + diffY * delta ) ); - this._brush.setRotation( Math.random() * 360 ); - this._brush.setScale( Math.random() * 2 ); - this._brush.setColor( cc._c3b( Math.random()*255, 255, 255) ); - this._brush.visit(); - } - this._target.end(); - } - this._lastLocation = location; - }, - - onTouchesBegan:function (touches, event) { - this._lastLocation = touches[0].getLocation(); - return true; - }, - - onTouchesMoved:function (touches, event) { - this.drawInLocation( touches[0].getLocation() ); - return true; - }, - - onMouseDown : function( event ) { - this._lastLocation = event.getLocation(); - return true; - }, - - onMouseDragged : function( event ) { - this.drawInLocation( event.getLocation() ); - return true; - }, - - subtitle:function () { - return "Testing 'save'"; - } -}); - -// -// Order of tests -// - -scenes.push( RenderTextureSave ); - -//------------------------------------------------------------------ -// -// Main entry point -// -//------------------------------------------------------------------ -function run() -{ - var scene = cc.Scene.create(); - var layer = new scenes[currentScene](); - scene.addChild( layer ); - - var runningScene = director.getRunningScene(); - if( runningScene == null ) - director.runWithScene( scene ); - else - director.replaceScene( cc.TransitionFade.create(0.5, scene ) ); -} - -run(); - - diff --git a/samples/TestJavascript/Resources/js/test-sprite.js b/samples/TestJavascript/Resources/js/test-sprite.js deleted file mode 100644 index ab6464d0dc..0000000000 --- a/samples/TestJavascript/Resources/js/test-sprite.js +++ /dev/null @@ -1,781 +0,0 @@ -// -// http://www.cocos2d-iphone.org -// -// Javascript + cocos2d sprite tests -// - -require("js/helper.js"); - -director = cc.Director.getInstance(); -winSize = director.getWinSize(); -centerPos = cc.p( winSize.width/2, winSize.height/2 ); - -var scenes = [] -var currentScene = 0; - -var nextSpriteTestAction = function () { - currentScene = currentScene + 1; - if( currentScene >= scenes.length ) - currentScene = 0; - - loadScene(currentScene); -}; -var backSpriteTestAction = function () { - currentScene = currentScene -1; - if( currentScene < 0 ) - currentScene = scenes.length -1; - - loadScene(currentScene); -}; -var restartSpriteTestAction = function () { - loadScene( currentScene ); -}; - -var loadScene = function (sceneIdx) -{ - winSize = director.getWinSize(); - centerPos = cc.p( winSize.width/2, winSize.height/2 ); - - var scene = new cc.Scene(); - scene.init(); - var layer = new scenes[ sceneIdx ](); - - scene.addChild( layer ); - -// scene.walkSceneGraph(0); - - director.replaceScene( scene ); -// __jsc__.garbageCollect(); -} - -//------------------------------------------------------------------ -// -// BaseLayer -// -//------------------------------------------------------------------ -var BaseLayer = function() { - - // - // VERY IMPORTANT - // - // Only subclasses of a native classes MUST call __associateObjectWithNative - // Failure to do so, it will crash. - // - var parent = goog.base(this); - __associateObjWithNative( this, parent ); - this.init(); - - this.title = function () { - return "No title"; - } - - this.subtitle = function () { - return "No Subtitle"; - } - -} -goog.inherits(BaseLayer, cc.Layer ); - -// -// Instance 'base' methods -// XXX: Should be defined after "goog.inherits" -// -BaseLayer.prototype.onEnter = function() { - var label = cc.LabelTTF.create(this.title(), "Arial", 28); - this.addChild(label, 1); - label.setPosition( cc.p(winSize.width / 2, winSize.height - 50)); - - var strSubtitle = this.subtitle(); - if (strSubtitle != "") { - var l = cc.LabelTTF.create(strSubtitle, "Thonburi", 16); - this.addChild(l, 1); - l.setPosition( cc.p(winSize.width / 2, winSize.height - 80)); - } - - // Menu - var item1 = cc.MenuItemImage.create("Images/b1.png", "Images/b2.png", this, this.backCallback); - var item2 = cc.MenuItemImage.create("Images/r1.png", "Images/r2.png", this, this.restartCallback); - var item3 = cc.MenuItemImage.create("Images/f1.png", "Images/f2.png", this, this.nextCallback); - var item4 = cc.MenuItemFont.create("back", this, function() { require("js/main.js"); } ); - cc.MenuItemFont.setFontSize( 22 ); - - var menu = cc.Menu.create(item1, item2, item3, item4 ); - - menu.setPosition( cc.p(0,0) ); - item1.setPosition( cc.p(winSize.width / 2 - 100, 30)); - item2.setPosition( cc.p(winSize.width / 2, 30)); - item3.setPosition( cc.p(winSize.width / 2 + 100, 30)); - item4.setPosition( cc.p(winSize.width - 60, winSize.height - 30 ) ); - - this.addChild(menu, 1); -} - -BaseLayer.prototype.restartCallback = function (sender) { - cc.log("restart called"); - restartSpriteTestAction(); -} - -BaseLayer.prototype.nextCallback = function (sender) { - cc.log("next called"); - nextSpriteTestAction(); -} - -BaseLayer.prototype.backCallback = function (sender) { - cc.log("back called"); - backSpriteTestAction(); -} - -//------------------------------------------------------------------ -// -// Sprite Touch test -// -//------------------------------------------------------------------ -var SpriteTouchTest = function() { - - goog.base(this); - - this.initialize = function() { - var platform = __getPlatform(); - if( platform.substring(0,7) == 'desktop' ) - this.setMouseEnabled( true ); - else if( platform.substring(0,6) == 'mobile' ) - this.setTouchEnabled( true ); - this.addSprite( centerPos ); - } - - this.addSprite = function(pos) { - var sprite = this.createSprite( pos ); - this.addChild( sprite ); - } - - this.title = function () { - return "Sprite: Simple action test"; - } - - this.subtitle = function () { - return "Tap screen to add more sprites"; - } - - this.initialize(); -} -goog.inherits(SpriteTouchTest, BaseLayer ); - -SpriteTouchTest.prototype.onMouseDown = function( event ) { - this.addSprite( event.getLocation() ); -} - -SpriteTouchTest.prototype.onTouchesEnded = function( touches, event ) { - var l = touches.length; - for( var i=0; i < l; i++) { - this.addSprite( touches[i].getLocation() ); - } -} - - -SpriteTouchTest.prototype.createSprite = function( pos ) { - var idx = Math.random() * 1400 / 100; - idx = Math.floor( idx ); - var x = Math.floor(idx%5) * 85; - var y = Math.floor(idx/5) * 121; - - var sprite = cc.Sprite.create("Images/grossini_dance_atlas.png", cc.rect(x,y,85,121) ); - sprite.setPosition( pos ); - - var rand = Math.random(); - - if( rand < 0.20 ) { - var action = cc.ScaleBy.create(3, 2 ); - } else if(rand < 0.40) { - var action = cc.RotateBy.create(3, 360 ); - } else if( rand < 0.60) { - var action = cc.Blink.create(1, 3 ); - } else if( rand < 0.8 ) { - var action = cc.TintBy.create(2, 0, -255, -255 ); - } else { - var action = cc.FadeOut.create( 2 ); - } - var action_back = action.reverse(); - var seq = cc.Sequence.create(action, action_back); - - sprite.runAction( cc.RepeatForever.create( seq ) ); - - return sprite; -} - - -//------------------------------------------------------------------ -// -// Sprite Batch Touch test -// -//------------------------------------------------------------------ -var SpriteBatchTouchTest = function() { - - goog.base(this); - - this.initialize = function() { - this.batch = cc.SpriteBatchNode.create("Images/grossini_dance_atlas.png", 50 ); - this.addChild( this.batch ); - - var platform = __getPlatform(); - if( platform == 'OSX' ) { - this.setIsMouseEnabled( true ); - } else if( platform == 'iOS' ) { - this.setIsTouchEnabled( true ); - } - } - - this.addSprite = function(pos) { - var sprite = this.createSprite( pos ); - this.batch.addChild( sprite ); - } - - this.title = function () { - return "SpriteBatch: Simple action test"; - } - - this.subtitle = function () { - return "Tap screen to add more sprites"; - } - - this.initialize(); -} -goog.inherits( SpriteBatchTouchTest, SpriteTouchTest ); - -//------------------------------------------------------------------ -// -// Sprite vs. SpriteBatch Animation -// -//------------------------------------------------------------------ -var SpriteFrameTest = function() { - - goog.base(this); - - this.initialize = function() { - var cache = cc.SpriteFrameCache.getInstance(); - cache.addSpriteFrames( "animations/grossini.plist" ); - cache.addSpriteFrames( "animations/grossini_gray.plist", "animations/grossini_gray.png" ); - cache.addSpriteFrames( "animations/grossini_blue.plist", "animations/grossini_blue.png" ); - - // - // Animation using Sprite batch - // - // A CCSpriteBatchNode can reference one and only one texture (one .png file) - // Sprites that are contained in that texture can be instantiatied as CCSprites and then added to the CCSpriteBatchNode - // All CCSprites added to a CCSpriteBatchNode are drawn in one OpenGL ES draw call - // If the CCSprites are not added to a CCSpriteBatchNode then an OpenGL ES draw call will be needed for each one, which is less efficient - // - // When you animate a sprite, CCAnimation changes the frame of the sprite using setDisplayFrame: (this is why the animation must be in the same texture) - // When setDisplayFrame: is used in the CCAnimation it changes the frame to one specified by the CCSpriteFrames that were added to the animation, - // but texture id is still the same and so the sprite is still a child of the CCSpriteBatchNode, - // and therefore all the animation sprites are also drawn as part of the CCSpriteBatchNode - // - - var sprite1 = cc.Sprite.createWithSpriteFrameName("grossini_dance_01.png"); - sprite1.setPosition( cc.p( winSize.width/2-80, winSize.height/2) ); - - var spritebatch = cc.SpriteBatchNode.create("animations/grossini.pvr"); - spritebatch.addChild(sprite1); - this.addChild( spritebatch ); - - var frames = [] - for( var i = 1; i < 15; i++) { - - if( i < 10 ) { - var name = "grossini_dance_0" + i + ".png"; - } else { - var name = "grossini_dance_" + i + ".png"; - } - - var frame = cache.getSpriteFrame( name ); - frames.push( frame ); - } - - var animation = cc.Animation.createWithSpriteFrames( frames, 0.3 ); - // 14 frames * 1sec = 14 seconds - sprite1.runAction( cc.RepeatForever.create( cc.Animate.create( animation ) ) ); - - - // - // Animation using standard Sprite - // - // - var sprite2 = cc.Sprite.createWithSpriteFrameName( "grossini_dance_01.png" ); - sprite2.setPosition( cc.p( winSize.width/2 + 80, winSize.height/2) ); - this.addChild( sprite2 ); - - var moreFrames = [] - for(var i = 1; i < 15; i++) { - if( i < 10 ) { - var name = "grossini_dance_gray_0" + i + ".png"; - } else { - var name = "grossini_dance_gray_" + i + ".png"; - } - var frame = cache.getSpriteFrame( name ); - moreFrames.push( frame ); - } - for( var i = 1; i < 5; i++) { - var name = "grossini_blue_0" + i + ".png"; - var frame = cache.getSpriteFrame( name ); - moreFrames.push( frame ); - } - - - moreFrames.concat( frames ); - var animMixed = cc.Animation.createWithSpriteFrames( moreFrames, 0.3 ); - - // 32 frames * 1 seconds = 32 seconds - sprite2.runAction( cc.RepeatForever.create( cc.Animate.create( animMixed ) ) ); - - // to test issue #732, uncomment the following line - sprite2.setFlipX( false ); - sprite2.setFlipY( false ); - } - - this.title = function () { - return "Sprite vs. SpriteBatchNode animation"; - } - - this.subtitle = function () { - return "Testing issue #792"; - } - - this.initialize(); -} -goog.inherits( SpriteFrameTest, BaseLayer ); - -//------------------------------------------------------------------ -// -// SpriteAnchorPoint -// -//------------------------------------------------------------------ -var SpriteAnchorPoint = function() { - - goog.base(this); - - this.initialize = function() { - for(var i=0;i<3;i++) { - var sprite = cc.Sprite.create("Images/grossini_dance_atlas.png", cc.rect(85*i, 121*1, 85, 121) ); - sprite.setPosition( cc.p( winSize.width/4*(i+1), winSize.height/2) ); - - var point = cc.Sprite.create( "Images/r1.png" ); - point.setScale( 0.25 ); - point.setPosition( sprite.getPosition() ); - this.addChild( point, 10 ); - - if( i == 0 ) { - sprite.setAnchorPoint( cc.p( 0, 0) ); - } else if( i == 1 ) { - sprite.setAnchorPoint( cc.p(0.5, 0.5) ); - } else if( i == 2 ) { - sprite.setAnchorPoint( cc.p(1,1) ); - } - - point.setPosition( sprite.getPosition() ); - - var rotate = cc.RotateBy.create(10, 360); - var action = cc.RepeatForever.create( rotate ); - - sprite.runAction( action ); - this.addChild( sprite, i ); - } - } - - this.title = function () { - return "Sprite: anchor point"; - } - - this.subtitle = function () { - return "Testing 3 different anchor points"; - } - - this.initialize(); -} -goog.inherits( SpriteAnchorPoint, BaseLayer ); - -//------------------------------------------------------------------ -// -// SpriteBatchAnchorPoint -// -//------------------------------------------------------------------ -var SpriteBatchAnchorPoint = function() { - - goog.base(this); - - this.initialize = function() { - var batch = cc.SpriteBatchNode.create( "Images/grossini_dance_atlas.png" ); - for(var i=0;i<3;i++) { - var sprite = cc.Sprite.create("Images/grossini_dance_atlas.png", cc.rect(85*i, 121*1, 85, 121) ); - sprite.setPosition( cc.p( winSize.width/4*(i+1), winSize.height/2) ); - - var point = cc.Sprite.create( "Images/r1.png" ); - point.setScale( 0.25 ); - point.setPosition( sprite.getPosition() ); - this.addChild( point, 10 ); - - if( i == 0 ) { - sprite.setAnchorPoint( cc.p( 0, 0) ); - } else if( i == 1 ) { - sprite.setAnchorPoint( cc.p(0.5, 0.5) ); - } else if( i == 2 ) { - sprite.setAnchorPoint( cc.p(1,1) ); - } - - point.setPosition( sprite.getPosition() ); - - var rotate = cc.RotateBy.create(10, 360); - var action = cc.RepeatForever.create( rotate ); - - sprite.runAction( action ); - batch.addChild( sprite, i ); - } - this.addChild( batch ); - } - - this.title = function () { - return "Sprite Batch: anchor point"; - } - - this.subtitle = function () { - return "Testing 3 different anchor points"; - } - - this.initialize(); -} -goog.inherits( SpriteBatchAnchorPoint, BaseLayer ); - -//------------------------------------------------------------------ -// -// SpriteOffsetAnchorFlip -// -//------------------------------------------------------------------ -var SpriteOffsetAnchorFlip = function() { - - goog.base(this); - - this.initialize = function() { - var cache = cc.SpriteFrameCache.getInstance(); - cache.addSpriteFrames("animations/grossini.plist"); - cache.addSpriteFrames("animations/grossini_gray.plist", "animations/grossini_gray.png"); - - for(var i=0;i<3;i++) { - var sprite = cc.Sprite.create("Images/grossini_dance_atlas.png", cc.rect(85*i, 121*1, 85, 121) ); - sprite.setPosition( cc.p( winSize.width/4*(i+1), winSize.height/2) ); - - var point = cc.Sprite.create( "Images/r1.png" ); - point.setScale( 0.25 ); - point.setPosition( sprite.getPosition() ); - this.addChild( point, 10 ); - - if( i == 0 ) { - sprite.setAnchorPoint( cc.p( 0, 0) ); - } else if( i == 1 ) { - sprite.setAnchorPoint( cc.p(0.5, 0.5) ); - } else if( i == 2 ) { - sprite.setAnchorPoint( cc.p(1,1) ); - } - - point.setPosition( sprite.getPosition() ); - - var frames = [] - for( var j = 1; j < 15; j++) { - - if( j < 10 ) { - var name = "grossini_dance_0" + j + ".png"; - } else { - var name = "grossini_dance_" + j + ".png"; - } - - var frame = cache.getSpriteFrame( name ); - frames.push( frame ); - } - - var animation = cc.Animation.createWithSpriteFrames( frames, 0.3 ); - sprite.runAction( cc.RepeatForever.create( cc.Animate.create( animation ) ) ); - - var flip = cc.FlipY.create( true ); - var flip_back = cc.FlipY.create( false ); - var delay = cc.DelayTime.create( 1 ); - var delay2 = cc.DelayTime.create( 1 ); - var seq = cc.Sequence.create( delay, flip, delay2, flip_back ); - sprite.runAction( cc.RepeatForever.create( seq ) ); - - this.addChild( sprite ); - } - } - - this.title = function () { - return "Sprite offset + anchor + flip"; - } - - this.subtitle = function () { - return "issue #1078"; - } - - this.initialize(); -} -goog.inherits( SpriteOffsetAnchorFlip, BaseLayer ); - -//------------------------------------------------------------------ -// -// SpriteBatchOffsetAnchorFlip -// -//------------------------------------------------------------------ -var SpriteBatchOffsetAnchorFlip = function() { - - goog.base(this); - - this.initialize = function() { - var cache = cc.SpriteFrameCache.getInstance(); - cache.addSpriteFrames("animations/grossini.plist"); - cache.addSpriteFrames("animations/grossini_gray.plist", "animations/grossini_gray.png"); - - var batch = cc.SpriteBatchNode.create("animations/grossini.pvr"); - - for(var i=0;i<3;i++) { - var sprite = cc.Sprite.createWithSpriteFrameName("grossini_dance_01.png"); - sprite.setPosition( cc.p( winSize.width/4*(i+1), winSize.height/2) ); - - var point = cc.Sprite.create( "Images/r1.png" ); - point.setScale( 0.25 ); - point.setPosition( sprite.getPosition() ); - this.addChild( point, 10 ); - - if( i == 0 ) { - sprite.setAnchorPoint( cc.p( 0, 0) ); - } else if( i == 1 ) { - sprite.setAnchorPoint( cc.p(0.5, 0.5) ); - } else if( i == 2 ) { - sprite.setAnchorPoint( cc.p(1,1) ); - } - - point.setPosition( sprite.getPosition() ); - - var frames = [] - for( var j = 1; j < 15; j++) { - - if( j < 10 ) { - var name = "grossini_dance_0" + j + ".png"; - } else { - var name = "grossini_dance_" + j + ".png"; - } - - var frame = cache.getSpriteFrame( name ); - frames.push( frame ); - } - - var animation = cc.Animation.createWithSpriteFrames( frames, 0.3 ); - sprite.runAction( cc.RepeatForever.create( cc.Animate.create( animation ) ) ); - - var flip = cc.FlipY.create( true ); - var flip_back = cc.FlipY.create( false ); - var delay = cc.DelayTime.create( 1 ); - var delay2 = cc.DelayTime.create( 1 ); - var seq = cc.Sequence.create( delay, flip, delay2, flip_back ); - sprite.runAction( cc.RepeatForever.create( seq ) ); - - batch.addChild( sprite ); - } - this.addChild(batch); - } - - this.title = function () { - return "SpriteBatch offset + anchor + flip"; - } - - this.subtitle = function () { - return "issue #1078"; - } - - this.initialize(); -} -goog.inherits( SpriteBatchOffsetAnchorFlip, BaseLayer ); - - -//------------------------------------------------------------------ -// -// SpriteColorOpacity -// -//------------------------------------------------------------------ -var SpriteColorOpacity = function() { - - goog.base(this); - - this.initialize = function() { - var sprite1 = cc.Sprite.create('Images/grossini_dance_atlas.png', cc.rect(85 * 0, 121 * 1, 85, 121)); - var sprite2 = cc.Sprite.create('Images/grossini_dance_atlas.png', cc.rect(85 * 1, 121 * 1, 85, 121)); - var sprite3 = cc.Sprite.create('Images/grossini_dance_atlas.png', cc.rect(85 * 2, 121 * 1, 85, 121)); - var sprite4 = cc.Sprite.create('Images/grossini_dance_atlas.png', cc.rect(85 * 3, 121 * 1, 85, 121)); - var sprite5 = cc.Sprite.create('Images/grossini_dance_atlas.png', cc.rect(85 * 0, 121 * 1, 85, 121)); - var sprite6 = cc.Sprite.create('Images/grossini_dance_atlas.png', cc.rect(85 * 1, 121 * 1, 85, 121)); - var sprite7 = cc.Sprite.create('Images/grossini_dance_atlas.png', cc.rect(85 * 2, 121 * 1, 85, 121)); - var sprite8 = cc.Sprite.create('Images/grossini_dance_atlas.png', cc.rect(85 * 3, 121 * 1, 85, 121)); - - sprite1.setPosition(cc.p((winSize.width / 5) * 1, (winSize.height / 3) * 1)); - sprite2.setPosition(cc.p((winSize.width / 5) * 2, (winSize.height / 3) * 1)); - sprite3.setPosition(cc.p((winSize.width / 5) * 3, (winSize.height / 3) * 1)); - sprite4.setPosition(cc.p((winSize.width / 5) * 4, (winSize.height / 3) * 1)); - sprite5.setPosition(cc.p((winSize.width / 5) * 1, (winSize.height / 3) * 2)); - sprite6.setPosition(cc.p((winSize.width / 5) * 2, (winSize.height / 3) * 2)); - sprite7.setPosition(cc.p((winSize.width / 5) * 3, (winSize.height / 3) * 2)); - sprite8.setPosition(cc.p((winSize.width / 5) * 4, (winSize.height / 3) * 2)); - - var action = cc.FadeIn.create(2); - var action_back = action.reverse(); - var fade = cc.RepeatForever.create( cc.Sequence.create( action, action_back ) ); - - var tintRed = cc.TintBy.create(2, 0, -255, -255); - // var tintRed = cc.RotateBy.create(2, 360 ); - var tintRedBack = tintRed.reverse(); - var red = cc.RepeatForever.create(cc.Sequence.create( tintRed, tintRedBack ) ); - - var tintGreen = cc.TintBy.create(2, -255, 0, -255); - var tintGreenBack = tintGreen.reverse(); - var green = cc.RepeatForever.create(cc.Sequence.create( tintGreen, tintGreenBack ) ); - - var tintBlue = cc.TintBy.create(2, -255, -255, 0); - var tintBlueBack = tintBlue.reverse(); - var blue = cc.RepeatForever.create(cc.Sequence.create( tintBlue, tintBlueBack ) ); - - sprite5.runAction(red); - sprite6.runAction(green); - sprite7.runAction(blue); - sprite8.runAction(fade); - - // late add: test dirtyColor and dirtyPosition - this.addChild(sprite1); - this.addChild(sprite2); - this.addChild(sprite3); - this.addChild(sprite4); - this.addChild(sprite5); - this.addChild(sprite6); - this.addChild(sprite7); - this.addChild(sprite8); - } - - // - // Instance methods - // - this.title = function () { - return "Sprite: Color & Opacity"; - } - - this.subtitle = function () { - return "testing opacity and color"; - } - - this.initialize(); -} -goog.inherits(SpriteColorOpacity, BaseLayer ); - -//------------------------------------------------------------------ -// -// SpriteBatchColorOpacity -// -//------------------------------------------------------------------ -var SpriteBatchColorOpacity = function() { - - goog.base(this); - - this.initialize = function() { - var batch = cc.SpriteBatchNode.create('Images/grossini_dance_atlas.png', 10); - var sprite1 = cc.Sprite.create('Images/grossini_dance_atlas.png', cc.rect(85 * 0, 121 * 1, 85, 121)); - var sprite2 = cc.Sprite.create('Images/grossini_dance_atlas.png', cc.rect(85 * 1, 121 * 1, 85, 121)); - var sprite3 = cc.Sprite.create('Images/grossini_dance_atlas.png', cc.rect(85 * 2, 121 * 1, 85, 121)); - var sprite4 = cc.Sprite.create('Images/grossini_dance_atlas.png', cc.rect(85 * 3, 121 * 1, 85, 121)); - var sprite5 = cc.Sprite.create('Images/grossini_dance_atlas.png', cc.rect(85 * 0, 121 * 1, 85, 121)); - var sprite6 = cc.Sprite.create('Images/grossini_dance_atlas.png', cc.rect(85 * 1, 121 * 1, 85, 121)); - var sprite7 = cc.Sprite.create('Images/grossini_dance_atlas.png', cc.rect(85 * 2, 121 * 1, 85, 121)); - var sprite8 = cc.Sprite.create('Images/grossini_dance_atlas.png', cc.rect(85 * 3, 121 * 1, 85, 121)); - - sprite1.setPosition(cc.p((winSize.width / 5) * 1, (winSize.height / 3) * 1)); - sprite2.setPosition(cc.p((winSize.width / 5) * 2, (winSize.height / 3) * 1)); - sprite3.setPosition(cc.p((winSize.width / 5) * 3, (winSize.height / 3) * 1)); - sprite4.setPosition(cc.p((winSize.width / 5) * 4, (winSize.height / 3) * 1)); - sprite5.setPosition(cc.p((winSize.width / 5) * 1, (winSize.height / 3) * 2)); - sprite6.setPosition(cc.p((winSize.width / 5) * 2, (winSize.height / 3) * 2)); - sprite7.setPosition(cc.p((winSize.width / 5) * 3, (winSize.height / 3) * 2)); - sprite8.setPosition(cc.p((winSize.width / 5) * 4, (winSize.height / 3) * 2)); - - var action = cc.FadeIn.create(2); - var action_back = action.reverse(); - var fade = cc.RepeatForever.create( cc.Sequence.create( action, action_back ) ); - - var tintRed = cc.TintBy.create(2, 0, -255, -255); - // var tintRed = cc.RotateBy.create(2, 360 ); - var tintRedBack = tintRed.reverse(); - var red = cc.RepeatForever.create(cc.Sequence.create( tintRed, tintRedBack ) ); - - var tintGreen = cc.TintBy.create(2, -255, 0, -255); - var tintGreenBack = tintGreen.reverse(); - var green = cc.RepeatForever.create(cc.Sequence.create( tintGreen, tintGreenBack ) ); - - var tintBlue = cc.TintBy.create(2, -255, -255, 0); - var tintBlueBack = tintBlue.reverse(); - var blue = cc.RepeatForever.create(cc.Sequence.create( tintBlue, tintBlueBack ) ); - - sprite5.runAction(red); - sprite6.runAction(green); - sprite7.runAction(blue); - sprite8.runAction(fade); - - // late add: test dirtyColor and dirtyPosition - this.addChild(batch); - batch.addChild(sprite1); - batch.addChild(sprite2); - batch.addChild(sprite3); - batch.addChild(sprite4); - batch.addChild(sprite5); - batch.addChild(sprite6); - batch.addChild(sprite7); - batch.addChild(sprite8); - } - - // - // Instance methods - // - this.title = function () { - return "Sprite Batch: Color & Opacity"; - } - - this.subtitle = function () { - return "testing opacity and color with batches"; - } - - this.initialize(); -} -goog.inherits(SpriteBatchColorOpacity, BaseLayer ); - -// -// Order of tests -// -scenes.push( SpriteTouchTest ); scenes.push( SpriteBatchTouchTest ); - -scenes.push( SpriteFrameTest ); - -scenes.push( SpriteAnchorPoint ); scenes.push( SpriteBatchAnchorPoint ); - -scenes.push( SpriteOffsetAnchorFlip ); scenes.push( SpriteBatchOffsetAnchorFlip ); - -scenes.push( SpriteColorOpacity ); scenes.push( SpriteBatchColorOpacity ); - - -//------------------------------------------------------------------ -// -// Main entry point -// -//------------------------------------------------------------------ -function run() -{ - var scene = cc.Scene.create(); - var layer = new scenes[currentScene](); - scene.addChild( layer ); - - var runningScene = director.getRunningScene(); - if( runningScene == null ) - director.runWithScene( scene ); - else - director.replaceScene( cc.TransitionFade.create(0.5, scene ) ); -} - -run(); - diff --git a/samples/TestJavascript/Resources/js/test-tilemap.js b/samples/TestJavascript/Resources/js/test-tilemap.js deleted file mode 100644 index 1873b4c863..0000000000 --- a/samples/TestJavascript/Resources/js/test-tilemap.js +++ /dev/null @@ -1,1210 +0,0 @@ -// -// http://www.cocos2d-iphone.org -// http://www.cocos2d-html5.org -// http://www.cocos2d-x.org -// -// Javascript + cocos2d actions tests -// - -require("js/helper.js"); - -var TAG_TILE_MAP = 1; - -director = cc.Director.getInstance(); -winSize = director.getWinSize(); -centerPos = cc.p( winSize.width/2, winSize.height/2 ); - -var scenes = [] -var currentScene = 0; - -var nextScene = function () { - currentScene = currentScene + 1; - if( currentScene >= scenes.length ) - currentScene = 0; - - withTransition = true; - loadScene(currentScene); -}; - -var previousScene = function () { - currentScene = currentScene -1; - if( currentScene < 0 ) - currentScene = scenes.length -1; - - withTransition = true; - loadScene(currentScene); -}; - -var restartScene = function () { - loadScene( currentScene ); -}; - -var loadScene = function (sceneIdx) -{ - winSize = director.getWinSize(); - centerPos = cc.p( winSize.width/2, winSize.height/2 ); - - var scene = new cc.Scene(); - scene.init(); - var layer = new scenes[ sceneIdx ](); - - scene.addChild( layer ); - -// scene.walkSceneGraph(0); - - director.replaceScene( scene ); -// __jsc__.garbageCollect(); -} - -// -// Base Layer -// - -var BaseLayer = cc.Layer.extend({ - - prevLocation:null, - - ctor:function () { - - var parent = new cc.Layer(); - __associateObjWithNative(this, parent); - this.init(); - -// var gradient = cc.LayerGradient.create( cc.c4b(0, 0, 0, 255), cc.c4b(0, 128, 255, 255) ); -// this.addChild( gradient, -100 ); - }, - - title:function () { - return "No Title"; - }, - - subtitle:function () { - return ""; - }, - - code:function () { - return ""; - }, - - restartCallback:function (sender) { - restartScene(); - }, - - nextCallback:function (sender) { - nextScene(); - }, - - backCallback:function (sender) { - previousScene(); - }, - - onEnter:function () { - // DO NOT CALL this._super() -// this._super(); - - var platform = __getPlatform(); - if( platform.substring(0,7) == 'desktop' ) - this.setMouseEnabled( true ); - else if( platform.substring(0,6) == 'mobile' ) - this.setTouchEnabled( true ); - - // add title and subtitle - var label = cc.LabelTTF.create(this.title(), "Arial", 28); - this.addChild(label, 1); - label.setPosition( cc.p(winSize.width / 2, winSize.height - 50)); - - var strSubtitle = this.subtitle(); - if (strSubtitle != "") { - var l = cc.LabelTTF.create(strSubtitle, "Thonburi", 16); - this.addChild(l, 1); - l.setPosition( cc.p(winSize.width / 2, winSize.height - 80)); - } - - var strCode = this.code(); - if( strCode !="" ) { - var label = cc.LabelTTF.create(strCode, 'CourierNewPSMT', 16); - label.setPosition( cc.p( winSize.width/2, winSize.height-100) ); - this.addChild( label,10 ); - - var labelbg = cc.LabelTTF.create(strCode, 'CourierNewPSMT', 16); - labelbg.setColor( cc.c3b(10,10,255) ); - labelbg.setPosition( cc.p( winSize.width/2 +1, winSize.height-100 -1) ); - this.addChild( labelbg,9); - } - - // Menu - var item1 = cc.MenuItemImage.create("Images/b1.png", "Images/b2.png", this, this.backCallback); - var item2 = cc.MenuItemImage.create("Images/r1.png", "Images/r2.png", this, this.restartCallback); - var item3 = cc.MenuItemImage.create("Images/f1.png", "Images/f2.png", this, this.nextCallback); - var item4 = cc.MenuItemFont.create("back", this, function() { require("js/main.js"); } ); - cc.MenuItemFont.setFontSize( 22 ); - - var menu = cc.Menu.create(item1, item2, item3, item4 ); - - menu.setPosition( cc.p(0,0) ); - item1.setPosition( cc.p(winSize.width / 2 - 100, 30)); - item2.setPosition( cc.p(winSize.width / 2, 30)); - item3.setPosition( cc.p(winSize.width / 2 + 100, 30)); - item4.setPosition( cc.p(winSize.width - 60, winSize.height - 30 ) ); - - this.addChild(menu, 1); - }, - onExit:function () { - // nothing - }, - - onTouchesMoved:function (touches, event) { - this.moveTile( touches[0].getDelta() ); - }, - - onMouseDragged : function( event ) { - this.moveTile( event.getDelta() ); - }, - - moveTile:function ( delta ) { - - var node = this.getChildByTag(TAG_TILE_MAP); - var currentPos = node.getPosition(); - var newPos = cc.pAdd(currentPos, delta ); - node.setPosition(newPos); - }, -}); - - - -var TileMapTest = BaseLayer.extend({ - ctor:function () { - this._super(); - var map = cc.TileMapAtlas.create("TileMaps/tiles.png", "TileMaps/levelmap.tga", 16, 16); - map.getTexture().setAntiAliasTexParameters(); - - // If you are not going to use the Map, you can free it now - // NEW since v0.7 - map.releaseMap(); - - this.addChild(map, 0, TAG_TILE_MAP); - - map.setAnchorPoint(cc.p(0, 0.5)); - - var scale = cc.ScaleBy.create(4, 0.8); - var scaleBack = scale.reverse(); - - var seq = cc.Sequence.create(scale, scaleBack ); - - map.runAction(cc.RepeatForever.create(seq)); - }, - title:function () { - return "TileMapAtlas"; - } -}); - -var TileMapEditTest = BaseLayer.extend({ - ctor:function () { - this._super(); - var map = cc.TileMapAtlas.create("TileMaps/tiles.png", "TileMaps/levelmap.tga", 16, 16); - // Create an Aliased Atlas - map.getTexture().setAliasTexParameters(); - - // If you are not going to use the Map, you can free it now - // [tilemap releaseMap); - // And if you are going to use, it you can access the data with: - -// this.schedule(this.updateMap, 0.2);//:@selector(updateMap:) interval:0.2f); - - this.addChild(map, 0, TAG_TILE_MAP); - - map.setAnchorPoint(cc.p(0, 0)); - map.setPosition(cc.p(-20, -200)); - - }, - title:function () { - return "Editable TileMapAtlas"; - }, - updateMap:function (dt) { - // IMPORTANT - // The only limitation is that you cannot change an empty, or assign an empty tile to a tile - // The value 0 not rendered so don't assign or change a tile with value 0 - - var tilemap = this.getChildByTag(TAG_TILE_MAP); - - // NEW since v0.7 - var c = tilemap.tileAt(cc.g(13, 21)); - c.r++; - c.r %= 50; - if (c.r == 0) - c.r = 1; - - // NEW since v0.7 - tilemap.setTile(c, cc.g(13, 21)); - } -}); - -//------------------------------------------------------------------ -// -// TMXOrthoTest -// -//------------------------------------------------------------------ -var TMXOrthoTest = BaseLayer.extend({ - ctor:function () { - this._super(); - var map = cc.TMXTiledMap.create("TileMaps/orthogonal-test1.tmx"); - this.addChild(map, 0, TAG_TILE_MAP); - - var childrenArray = map.getChildren(); - for (var i = 0; i < childrenArray.length; i++) { - var child = childrenArray[i]; - child.getTexture().setAntiAliasTexParameters(); - } - map.runAction(cc.ScaleBy.create(2, 0.5)); - }, - title:function () { - return "TMX Orthogonal test"; - }, - - subtitle:function () { - return "Simple TMX test"; - }, - - code : function() { - return 'var map = cc.TMXTiledMap.create("map.tmx");' - }, -}); - -//------------------------------------------------------------------ -// -// TMXOrthoTest2 -// -//------------------------------------------------------------------ -var TMXOrthoTest2 = BaseLayer.extend({ - ctor:function () { - this._super(); - // - // Test orthogonal with 3d camera and anti-alias textures - // - // it should not flicker. No artifacts should appear - // - var map = cc.TMXTiledMap.create("TileMaps/orthogonal-test2.tmx"); - this.addChild(map, 0, TAG_TILE_MAP); - - var childrenArray = map.getChildren(); - var child = null; - for (var i = 0, len = childrenArray.length; i < len; i++) { - child = childrenArray[i]; - child.getTexture().setAntiAliasTexParameters(); - } - -// var x, y, z; -// map.getCamera().getEyeXYZ(x, y, z); -// map.getCamera().setEyeXYZ(x - 200, y, z + 300); - }, - title:function () { - return "TMX Orthogonal test"; - }, - - subtitle:function () { - return "Testing camera... NOT WORKING YET"; - }, - code : function() { - return 'var map = cc.TMXTiledMap.create("map.tmx");' - }, - onEnter:function () { - this._super(); - // 3D == 1 - director.setProjection(1); - }, - onExit:function () { - this._super(); - // 2D == 1 - director.setProjection(0); - } -}); - - -//------------------------------------------------------------------ -// -// TMXOrthoTest3 -// -//------------------------------------------------------------------ -var TMXOrthoTest3 = BaseLayer.extend({ - ctor:function () { - this._super(); - var map = cc.TMXTiledMap.create("TileMaps/orthogonal-test3.tmx"); - this.addChild(map, 0, TAG_TILE_MAP); - - var childrenArray = map.getChildren(); - var child = null; - for (var i = 0, len = childrenArray.length; i < len; i++) { - child = childrenArray[i]; - child.getTexture().setAntiAliasTexParameters(); - } - - map.setScale(0.2); - map.setAnchorPoint(cc.p(0.5, 0.5)); - }, - title:function () { - return "TMX anchorPoint test"; - } -}); - -//------------------------------------------------------------------ -// -// TMXOrthoTest4 -// -//------------------------------------------------------------------ -var TMXOrthoTest4 = BaseLayer.extend({ - elapsedTime:0, - - ctor:function () { - this._super(); - var map = cc.TMXTiledMap.create("TileMaps/orthogonal-test4.tmx"); - this.addChild(map, 0, TAG_TILE_MAP); - - var childrenArray = map.getChildren(); - var child = null; - for (var i = 0, len = childrenArray.length; i < len; i++) { - child = childrenArray[i]; - child.getTexture().setAntiAliasTexParameters(); - } - - map.setAnchorPoint(cc.p(0, 0)); - - var layer = map.layerNamed("Layer 0"); - var s = layer.getLayerSize(); - - var sprite; - sprite = layer.tileAt(cc.p(0, 0)); - sprite.setScale(2); - - sprite = layer.tileAt(cc.p(s.width - 1, 0)); - sprite.setScale(2); - - sprite = layer.tileAt(cc.p(0, s.height - 1)); - sprite.setScale(2); - - sprite = layer.tileAt(cc.p(s.width - 1, s.height - 1)); - sprite.setScale(2); - - this.scheduleUpdate(); - }, - update:function (dt) { - this.elapsedTime += dt; - if( this.elapsedTime > 2 ) { - this.unscheduleUpdate(); - - var map = this.getChildByTag(TAG_TILE_MAP); - - var layer = map.layerNamed("Layer 0"); - var s = layer.getLayerSize(); - - var sprite = layer.tileAt(cc.p(s.width - 1, 0)); - cc.log( layer ); - layer.removeChild(sprite, true); - } - }, - title:function () { - return "TMX width/height test"; - } -}); - -//------------------------------------------------------------------ -// -// TMXReadWriteTest -// -//------------------------------------------------------------------ -var TMXReadWriteTest = BaseLayer.extend({ - gid:0, - ctor:function () { - this._super(); - - var map = cc.TMXTiledMap.create("TileMaps/orthogonal-test2.tmx"); - this.addChild(map, 0, TAG_TILE_MAP); - - - var layer = map.layerNamed("Layer 0"); - layer.getTexture().setAntiAliasTexParameters(); - - map.setScale(1); - - var tile0 = layer.tileAt(cc.p(1, 63)); - var tile1 = layer.tileAt(cc.p(2, 63)); - var tile2 = layer.tileAt(cc.p(3, 62));//cc.p(1,62)); - var tile3 = layer.tileAt(cc.p(2, 62)); - - tile0.setAnchorPoint(cc.p(0.5, 0.5)); - tile1.setAnchorPoint(cc.p(0.5, 0.5)); - tile2.setAnchorPoint(cc.p(0.5, 0.5)); - tile3.setAnchorPoint(cc.p(0.5, 0.5)); - - var move = cc.MoveBy.create(0.5, cc.p(0, 160)); - var rotate = cc.RotateBy.create(2, 360); - var scale = cc.ScaleBy.create(2, 5); - var opacity = cc.FadeOut.create(2); - var fadein = cc.FadeIn.create(2); - var scaleback = cc.ScaleTo.create(1, 1); - var finish = cc.CallFunc.create(this, this.removeSprite); - - var seq0 = cc.Sequence.create(move, rotate, scale, opacity, fadein, scaleback, finish ); - - tile0.runAction(seq0); - tile1.runAction(seq0.copy()); - tile2.runAction(seq0.copy()); - tile3.runAction(seq0.copy()); - - this.gid = layer.tileGIDAt(cc.p(0, 63)); - -// this.schedule(this.updateCol, 2.0); -// this.schedule(this.repaintWithGID, 2.0); -// this.schedule(this.removeTiles, 1.0); - - this.gid2 = 0; - }, - removeSprite:function (sender) { - var p = sender.getParent(); - if (p) { - p.removeChild(sender, true); - } - }, - updateCol:function (dt) { - var map = this.getChildByTag(TAG_TILE_MAP); - var layer = map.getChildByTag(0); - - var s = layer.getLayerSize(); - - for (var y = 0; y < s.height; y++) { - layer.setTileGID(this.gid2, cc.p(3, y)); - } - - this.gid2 = (this.gid2 + 1) % 80; - }, - repaintWithGID:function (dt) { - // [self unschedule:_cmd); - - var map = this.getChildByTag(TAG_TILE_MAP); - var layer = map.getChildByTag(0); - - var s = layer.getLayerSize(); - - for (var x = 0; x < s.width; x++) { - var y = s.height - 1; - var tmpgid = layer.tileGIDAt(cc.p(x, y)); - layer.setTileGID(tmpgid + 1, cc.p(x, y)); - } - }, - removeTiles:function (dt) { - this.unschedule(this.removeTiles); - - var map = this.getChildByTag(TAG_TILE_MAP); - - var layer = map.getChildByTag(0); - - var s = layer.getLayerSize(); - - for (var y = 0; y < s.height; y++) { - layer.removeTileAt(cc.p(5.0, y)); - } - }, - title:function () { - return "TMX Read/Write test"; - } -}); - -//------------------------------------------------------------------ -// -// TMXHexTest -// -//------------------------------------------------------------------ -var TMXHexTest = BaseLayer.extend({ - ctor:function () { - this._super(); - var color = cc.LayerColor.create(cc.c4b(64, 64, 64, 255)); - this.addChild(color, -1); - - var map = cc.TMXTiledMap.create("TileMaps/hexa-test.tmx"); - this.addChild(map, 0, TAG_TILE_MAP); - }, - title:function () { - return "TMX Hex test"; - } -}); - -//------------------------------------------------------------------ -// -// TMXIsoTest -// -//------------------------------------------------------------------ -var TMXIsoTest = BaseLayer.extend({ - ctor:function () { - this._super(); - var color = cc.LayerColor.create(cc.c4b(64, 64, 64, 255)); - this.addChild(color, -1); - - var map = cc.TMXTiledMap.create("TileMaps/iso-test.tmx"); - this.addChild(map, 0, TAG_TILE_MAP); - - // move map to the center of the screen - var ms = map.getMapSize(); - var ts = map.getTileSize(); - - map.runAction(cc.MoveTo.create(1.0, cc.p(-ms.width * ts.width / 2, -ms.height * ts.height / 2))); - }, - title:function () { - return "TMX Isometric test 0"; - } -}); - -//------------------------------------------------------------------ -// -// TMXIsoTest1 -// -//------------------------------------------------------------------ -var TMXIsoTest1 = BaseLayer.extend({ - ctor:function () { - this._super(); - var color = cc.LayerColor.create(cc.c4b(64, 64, 64, 255)); - this.addChild(color, -1); - - var map = cc.TMXTiledMap.create("TileMaps/iso-test1.tmx"); - this.addChild(map, 0, TAG_TILE_MAP); - - map.setAnchorPoint(cc.p(0.5, 0.5)); - }, - title:function () { - return "TMX Isometric test + anchorPoint"; - } -}); - -//------------------------------------------------------------------ -// -// TMXIsoTest2 -// -//------------------------------------------------------------------ -var TMXIsoTest2 = BaseLayer.extend({ - ctor:function () { - this._super(); - var color = cc.LayerColor.create(cc.c4b(64, 64, 64, 255)); - this.addChild(color, -1); - - var map = cc.TMXTiledMap.create("TileMaps/iso-test2.tmx"); - this.addChild(map, 0, TAG_TILE_MAP); - - // move map to the center of the screen - var ms = map.getMapSize(); - var ts = map.getTileSize(); - - map.runAction(cc.MoveTo.create(1.0, cc.p(-ms.width * ts.width / 2, -ms.height * ts.height / 2))); - }, - title:function () { - return "TMX Isometric test 2"; - } -}); - -//------------------------------------------------------------------ -// -// TMXUncompressedTest -// -//------------------------------------------------------------------ -var TMXUncompressedTest = BaseLayer.extend({ - ctor:function () { - this._super(); - var color = cc.LayerColor.create(cc.c4b(64, 64, 64, 255)); - this.addChild(color, -1); - - var map = cc.TMXTiledMap.create("TileMaps/iso-test2-uncompressed.tmx"); - this.addChild(map, 0, TAG_TILE_MAP); - - // move map to the center of the screen - var ms = map.getMapSize(); - var ts = map.getTileSize(); - - map.runAction(cc.MoveTo.create(1.0, cc.p(-ms.width * ts.width / 2, -ms.height * ts.height / 2))); - - // testing release map - var childrenArray = map.getChildren(); - var layer = null; - for (var i = 0, len = childrenArray.length; i < len; i++) { - layer = childrenArray[i]; - if (!layer) - break; - - layer.releaseMap(); - } - }, - title:function () { - return "TMX Uncompressed test"; - } -}); - -//------------------------------------------------------------------ -// -// TMXTilesetTest -// -//------------------------------------------------------------------ -var TMXTilesetTest = BaseLayer.extend({ - ctor:function () { - this._super(); - var map = cc.TMXTiledMap.create("TileMaps/orthogonal-test5.tmx"); - this.addChild(map, 0, TAG_TILE_MAP); - - var layer; - layer = map.layerNamed("Layer 0"); - layer.getTexture().setAntiAliasTexParameters(); - - layer = map.layerNamed("Layer 1"); - layer.getTexture().setAntiAliasTexParameters(); - - layer = map.layerNamed("Layer 2"); - layer.getTexture().setAntiAliasTexParameters(); - }, - title:function () { - return "TMX Tileset test"; - } -}); - -//------------------------------------------------------------------ -// -// TMXOrthoObjectsTest -// -//------------------------------------------------------------------ -var TMXOrthoObjectsTest = BaseLayer.extend({ - ctor:function () { - this._super(); - var map = cc.TMXTiledMap.create("TileMaps/ortho-objects.tmx"); - this.addChild(map, -1, TAG_TILE_MAP); - - var group = map.objectGroupNamed("Object Group 1"); - var objects = group.getObjects(); - - for (var i = 0; i < objects.length; i++) { - var dict = objects[i]; - if (!dict) - break; - } - }, - draw:function () { - var map = this.getChildByTag(TAG_TILE_MAP); - var group = map.objectGroupNamed("Object Group 1"); - var objects = group.getObjects(); - for (var i = 0; i < objects.length; i++) { - var dict = objects[i]; - if (!dict) - break; - - var x = parseInt(dict["x"]); - var y = parseInt(dict["y"]); - var width = parseInt(dict["width"]); - var height = parseInt(dict["height"]); - - cc.renderContext.lineWidth = 3; - cc.renderContext.strokeStyle = "#ffffff"; - - cc.drawingUtil.drawLine(cc.p(x, y), cc.p((x + width), y)); - cc.drawingUtil.drawLine(cc.p((x + width), y), cc.p((x + width), (y + height))); - cc.drawingUtil.drawLine(cc.p((x + width), (y + height)), cc.p(x, (y + height))); - cc.drawingUtil.drawLine(cc.p(x, (y + height)), cc.p(x, y)); - - cc.renderContext.lineWidth = 1; - } - }, - title:function () { - return "TMX Ortho object test"; - }, - subtitle:function () { - return "You should see a white box around the 3 platforms"; - } -}); - -//------------------------------------------------------------------ -// -// TMXIsoObjectsTest -// -//------------------------------------------------------------------ -var TMXIsoObjectsTest = BaseLayer.extend({ - ctor:function () { - this._super(); - var map = cc.TMXTiledMap.create("TileMaps/iso-test-objectgroup.tmx"); - this.addChild(map, -1, TAG_TILE_MAP); - - - var group = map.objectGroupNamed("Object Group 1"); - var objects = group.getObjects(); - - var dict; - for (var i = 0, len = objects.length; i < len; i++) { - dict = objects[i]; - if (!dict) - break; - } - }, - title:function () { - return "TMX Iso object test"; - }, - draw:function () { - var map = this.getChildByTag(TAG_TILE_MAP); - var group = map.objectGroupNamed("Object Group 1"); - var objects = group.getObjects(); - var dict; - for (var i = 0, len = objects.length; i < len; i++) { - dict = objects[i]; - if (!dict) - break; - - var x = parseInt(dict["x"]); - var y = parseInt(dict["y"]); - var width = parseInt(dict["width"]); - var height = parseInt(dict["height"]); - - cc.renderContext.lineWidth = 3; - cc.renderContext.strokeStyle = "#ffffff"; - - cc.drawingUtil.drawLine(cc.p(x, y), cc.p(x + width, y)); - cc.drawingUtil.drawLine(cc.p(x + width, y), cc.p(x + width, y + height)); - cc.drawingUtil.drawLine(cc.p(x + width, y + height), cc.p(x, y + height)); - cc.drawingUtil.drawLine(cc.p(x, y + height), cc.p(x, y)); - - cc.renderContext.lineWidth = 1; - } - }, - subtitle:function () { - return "You need to parse them manually. See bug #810"; - } -}); - -//------------------------------------------------------------------ -// -// TMXResizeTest -// -//------------------------------------------------------------------ -var TMXResizeTest = BaseLayer.extend({ - ctor:function () { - this._super(); - var map = cc.TMXTiledMap.create("TileMaps/orthogonal-test5.tmx"); - this.addChild(map, 0, TAG_TILE_MAP); - - - var layer; - layer = map.layerNamed("Layer 0"); - - var ls = layer.getLayerSize(); - - for (var y = 0; y < ls.height; y++) { - for (var x = 0; x < ls.width; x++) { - layer.setTileGID(1, cc.p(x, y)); - } - } - }, - title:function () { - return "TMX resize test"; - }, - subtitle:function () { - return "Should not crash. Testing issue #740"; - } -}); - -//------------------------------------------------------------------ -// -// TMXIsoZorder -// -//------------------------------------------------------------------ -var TMXIsoZorder = BaseLayer.extend({ - tamara:null, - ctor:function () { - this._super(); - var map = cc.TMXTiledMap.create("TileMaps/iso-test-zorder.tmx"); - this.addChild(map, 0, TAG_TILE_MAP); - - var s = map.getContentSize(); - map.setPosition(cc.p(-s.width / 2, 0)); - - this.tamara = cc.Sprite.create("Images/grossinis_sister1.png"); - map.addChild(this.tamara, map.getChildren().length); - - // move map to the center of the screen - var ms = map.getMapSize(); - var ts = map.getTileSize(); - - var mapWidth = ms.width * ts.width; - this.tamara.setPosition(cc.p(mapWidth / 2, 0)); - this.tamara.setAnchorPoint(cc.p(0.5, 0)); - - - var move = cc.MoveBy.create(10, cc.pMult(cc.p(300, 250), 1 )); - var back = move.reverse(); - var seq = cc.Sequence.create(move, back ); - this.tamara.runAction(cc.RepeatForever.create(seq)); - - this.scheduleUpdate(); - }, - title:function () { - return "TMX Iso Zorder"; - }, - subtitle:function () { - return "Sprite should hide behind the trees"; - }, - onExit:function () { - this.unschedule(this.repositionSprite); - this._super(); - }, - update:function (dt) { - var p = this.tamara.getPosition(); - - var map = this.getChildByTag(TAG_TILE_MAP); - - // there are only 4 layers. (grass and 3 trees layers) - // if tamara < 48, z=4 - // if tamara < 96, z=3 - // if tamara < 144,z=2 - - var newZ = 4 - (p.y / 48); - newZ = Math.max(newZ, 0); - - map.reorderChild(this.tamara, newZ); - } -}); - -//------------------------------------------------------------------ -// -// TMXOrthoZorder -// -//------------------------------------------------------------------ -var TMXOrthoZorder = BaseLayer.extend({ - tamara:null, - ctor:function () { - this._super(); - var map = cc.TMXTiledMap.create("TileMaps/orthogonal-test-zorder.tmx"); - this.addChild(map, 0, TAG_TILE_MAP); - - var s = map.getContentSize(); - - this.tamara = cc.Sprite.create("Images/grossinis_sister1.png"); - map.addChild(this.tamara, map.getChildren().length, TAG_TILE_MAP); - this.tamara.setAnchorPoint(cc.p(0.5, 0)); - - var move = cc.MoveBy.create(10, cc.pMult(cc.p(400, 450), 1 )); - var back = move.reverse(); - var seq = cc.Sequence.create(move, back ); - this.tamara.runAction(cc.RepeatForever.create(seq)); - - this.scheduleUpdate(); - }, - title:function () { - return "TMX Ortho Zorder"; - }, - subtitle:function () { - return "Sprite should hide behind the trees"; - }, - update:function (dt) { - var p = this.tamara.getPosition(); - var map = this.getChildByTag(TAG_TILE_MAP); - - // there are only 4 layers. (grass and 3 trees layers) - // if tamara < 81, z=4 - // if tamara < 162, z=3 - // if tamara < 243,z=2 - - // -10: customization for this particular sample - var newZ = 4 - ((p.y - 10) / 81); - newZ = Math.max(newZ, 0); - - map.reorderChild(this.tamara, newZ); - } -}); - -//------------------------------------------------------------------ -// -// TMXIsoVertexZ -// -//------------------------------------------------------------------ -var TMXIsoVertexZ = BaseLayer.extend({ - tamara:null, - tamara1:null, - ctor:function () { - this._super(); - var map = cc.TMXTiledMap.create("TileMaps/iso-test-vertexz.tmx"); - this.addChild(map, 0, TAG_TILE_MAP); - - var s = map.getContentSize(); - map.setPosition(cc.p(-s.width / 2, 0)); - - // because I'm lazy, I'm reusing a tile as an sprite, but since this method uses vertexZ, you - // can use any cc.Sprite and it will work OK. - var layer = map.layerNamed("Trees"); - this.tamara = layer.tileAt(cc.p(29, 29)); - - var move = cc.MoveBy.create(10, cc.pMult(cc.p(300, 250), 1 )); - var back = move.reverse(); - var seq = cc.Sequence.create(move, back ); - this.tamara.runAction(cc.RepeatForever.create(seq)); - - this.scheduleUpdate(); - }, - title:function () { - return "TMX Iso VertexZ"; - }, - subtitle:function () { - return "Sprite should hide behind the trees (enable DepthBuffer)"; - }, - onEnter:function () { - this._super(); - // TIP: 2d projection should be used - // 0 == 2D - director.setProjection(0); - }, - onExit:function () { -// At exit use any other projection. - // 1 == 3D - // director.setProjection(1); - this._super(); - }, - update:function (dt) { - // tile height is 64x32 - // map size: 30x30 - var p = this.tamara.getPosition(); - this.tamara.setVertexZ(-( (p.y + 32) / 16)); - } -}); - -//------------------------------------------------------------------ -// -// TMXOrthoVertexZ -// -//------------------------------------------------------------------ -var TMXOrthoVertexZ = BaseLayer.extend({ - tamara:null, - ctor:function () { - this._super(); - var map = cc.TMXTiledMap.create("TileMaps/orthogonal-test-vertexz.tmx"); - this.addChild(map, 0, TAG_TILE_MAP); - - - // because I'm lazy, I'm reusing a tile as an sprite, but since this method uses vertexZ, you - // can use any cc.Sprite and it will work OK. - var layer = map.layerNamed("trees"); - this.tamara = layer.tileAt(cc.p(0, 11)); - cc.log("vertexZ: " + this.tamara.getVertexZ()); - - var move = cc.MoveBy.create(10, cc.pMult(cc.p(400, 450), 1 )); - var back = move.reverse(); - var seq = cc.Sequence.create(move, back ); - this.tamara.runAction(cc.RepeatForever.create(seq)); - - this.scheduleUpdate(); - }, - title:function () { - return "TMX Ortho vertexZ"; - }, - subtitle:function () { - return "Sprite should hide behind the trees (enable Depth Buffer!!)"; - }, - onEnter:function () { - this._super(); - - // TIP: 2d projection should be used - // 2d = 0 - director.setProjection(0); - }, - onExit:function () { - // At exit use any other projection. - // 3d = 1 - // director.setProjection(1); - this._super(); - }, - update:function (dt) { - // tile height is 101x81 - // map size: 12x12 - var p = this.tamara.getPosition(); - this.tamara.setVertexZ( -( (p.y + 81) / 81) ); - } -}); - -//------------------------------------------------------------------ -// -// TMXIsoMoveLayer -// -//------------------------------------------------------------------ -var TMXIsoMoveLayer = BaseLayer.extend({ - ctor:function () { - this._super(); - var map = cc.TMXTiledMap.create("TileMaps/iso-test-movelayer.tmx"); - this.addChild(map, 0, TAG_TILE_MAP); - map.setPosition(cc.p(-700, -50)); - - }, - title:function () { - return "TMX Iso Move Layer"; - }, - subtitle:function () { - return "Trees should be horizontally aligned"; - } -}); - -//------------------------------------------------------------------ -// -// TMXOrthoMoveLayer -// -//------------------------------------------------------------------ -var TMXOrthoMoveLayer = BaseLayer.extend({ - ctor:function () { - this._super(); - var map = cc.TMXTiledMap.create("TileMaps/orthogonal-test-movelayer.tmx"); - this.addChild(map, 0, TAG_TILE_MAP); - - }, - title:function () { - return "TMX Ortho Move Layer"; - }, - subtitle:function () { - return "Trees should be horizontally aligned"; - } -}); - -//------------------------------------------------------------------ -// -// TMXBug987 -// -//------------------------------------------------------------------ -var TMXBug987 = BaseLayer.extend({ - ctor:function () { - this._super(); - var map = cc.TMXTiledMap.create("TileMaps/orthogonal-test6.tmx"); - this.addChild(map, 0, TAG_TILE_MAP); - - var s = map.getContentSize(); - cc.log("ContentSize:" + s.width + "," + s.height); - - var childs = map.getChildren(); - var node = null; - for (var i = 0, len = childs.length; i < len; i++) { - node = childs[i]; - node.getTexture().setAntiAliasTexParameters(); - } - - map.setAnchorPoint(cc.p(0, 0)); - var layer = map.layerNamed("Tile Layer 1"); - layer.setTileGID(3, cc.p(2, 2)); - }, - title:function () { - return "TMX Bug 987"; - }, - subtitle:function () { - return "You should see an square"; - } -}); - -//------------------------------------------------------------------ -// -// TMXBug787 -// -//------------------------------------------------------------------ -var TMXBug787 = BaseLayer.extend({ - ctor:function () { - this._super(); - var map = cc.TMXTiledMap.create("TileMaps/iso-test-bug787.tmx"); - this.addChild(map, 0, TAG_TILE_MAP); - - map.setScale(0.25); - }, - title:function () { - return "TMX Bug 787"; - }, - subtitle:function () { - return "You should see a map"; - } -}); - -var TMXGIDObjectsTest = BaseLayer.extend({ - ctor:function () { - this._super(); - var map = cc.TMXTiledMap.create("TileMaps/test-object-layer.tmx"); - this.addChild(map, -1, TAG_TILE_MAP); - - var s = map.getContentSize(); - cc.log("ContentSize:" + s.width + "," + s.height); - cc.log("---. Iterating over all the group objets"); - }, - title:function () { - return "TMX GID objects"; - }, - subtitle:function () { - return "Tiles are created from an object group"; - }, - draw:function () { - var map = this.getChildByTag(TAG_TILE_MAP); - var group = map.objectGroupNamed("Object Layer 1"); - - var array = group.getObjects(); - var dict; - for (var i = 0, len = array.length; i < len; i++) { - dict = array[i]; - if (!dict) - break; - var key = "x"; - var x = parseInt(dict[key]); - key = "y"; - var y = parseInt(dict[key]); - key = "width"; - var width = parseInt(dict[key]); - key = "height"; - var height = parseInt(dict[key]); - - cc.renderContext.lineWidth = 3; - cc.renderContext.strokeStyle = "#ffffff"; - - cc.drawingUtil.drawLine(cc.p(x, y), cc.p((x + width), y)); - cc.drawingUtil.drawLine(cc.p((x + width), y), cc.p((x + width), (y + height))); - cc.drawingUtil.drawLine(cc.p((x + width), (y + height)), cc.p(x, (y + height))); - cc.drawingUtil.drawLine(cc.p(x, (y + height)), cc.p(x, y)); - - cc.renderContext.lineWidth = 1; - } - } -}); - - -// -// Order of tests -// -scenes.push( TMXOrthoTest ); -scenes.push( TMXOrthoTest2 ); -scenes.push( TMXOrthoTest3 ); -scenes.push( TMXOrthoTest4 ); -scenes.push( TMXReadWriteTest ); -scenes.push( TMXHexTest ); -scenes.push( TMXIsoTest ); -scenes.push( TMXIsoTest1 ); -scenes.push( TMXIsoTest2 ); -scenes.push( TMXUncompressedTest ); -scenes.push( TMXTilesetTest ); -scenes.push( TMXOrthoObjectsTest ); -scenes.push( TMXIsoObjectsTest ); -scenes.push( TMXResizeTest ); -scenes.push( TMXIsoZorder ); -scenes.push( TMXOrthoZorder ); -scenes.push( TMXIsoVertexZ ); -scenes.push( TMXOrthoVertexZ ); -scenes.push( TMXIsoMoveLayer ); -scenes.push( TMXOrthoMoveLayer ); -scenes.push( TMXBug987 ); -scenes.push( TMXBug787 ); -scenes.push( TMXGIDObjectsTest ); - - -//------------------------------------------------------------------ -// -// Main entry point -// -//------------------------------------------------------------------ -function run() -{ - var scene = cc.Scene.create(); - var layer = new scenes[currentScene](); - scene.addChild( layer ); - - var runningScene = director.getRunningScene(); - if( runningScene == null ) - director.runWithScene( scene ); - else - director.replaceScene( cc.TransitionFade.create(0.5, scene ) ); -} - -run(); - diff --git a/samples/TestJavascript/Resources/oldjs/1to1/menu.js b/samples/TestJavascript/Resources/oldjs/1to1/menu.js deleted file mode 100644 index 0c8d12657f..0000000000 --- a/samples/TestJavascript/Resources/oldjs/1to1/menu.js +++ /dev/null @@ -1,35 +0,0 @@ -// prepare the menu and other things - -cc.Point.create = function (x, y) { - var pt = new cc.Point(); - pt.x = x; - pt.y = y; - return pt; -}; - -var pointZero = cc.Point.create(0, 0); - -var director = cc.Director.sharedDirector; -var winSize = director.winSize(); - -var hudMenu = new cc.Menu(); - -(function () { - // we add the items as members of menu to avoid GC - // ** otherwise the GC will try to remove the itemN object ** - hudMenu.item1 = new cc.MenuItemImage(); - item1.initWithNormalImage("b1.png", "b2.png"); - hudMenu.item2 = new cc.MenuItemImage(); - item2.initWithNormalImage("r1.png", "r2.png"); - hudMenu.item3 = new cc.MenuItemImage(); - item3.initWithNormalImage("f1.png", "f2.png"); - - hudMenu.addChild(menu.item1); - hudMenu.addChild(menu.item2); - hudMenu.addChild(menu.item3); - hudMenu.position = pointZero; - - hudMenu.item1.position = cc.Point.create(winSize.width / 2 - 100, 30); - hudMenu.item2.position = cc.Point.create(winSize.width / 2 , 30); - hudMenu.item3.position = cc.Point.create(winSize.width / 2 + 100, 30); -})(); diff --git a/samples/TestJavascript/Resources/oldjs/1to1/test_actions.js b/samples/TestJavascript/Resources/oldjs/1to1/test_actions.js deleted file mode 100644 index fd4855f4be..0000000000 --- a/samples/TestJavascript/Resources/oldjs/1to1/test_actions.js +++ /dev/null @@ -1,305 +0,0 @@ -/* - * showcasing actions - */ - -/** - * simple wrappers - */ -cc.Point.create = function (x, y) { - var pt = new cc.Point(); - pt.x = x; - pt.y = y; - return pt; -}; - -cc.Size.create = function (w, h) { - var sz = new cc.Size(); - sz.width = w; - sz.height = h; - return sz; -}; - -cc.Sprite.create = function (file) { - var s = new cc.Sprite(); - s.initWithFile(file); - return s; -}; - -var pointZero = cc.Point.create(0, 0); -var sizeZero = cc.Size.create(0, 0); - -var director = cc.Director.sharedDirector(); -var winSize = director.winSize; - -var scenes = {}; -scenes.currentScene = 1; - -/** - * tests the most basic function: moveTo and moveBy - */ -scenes['test_move'] = function () { - var s1 = cc.Sprite.create("grossini_dance_05.png"); - s1.position = cc.Point.create(winSize.width / 2 + 50, winSize.height / 2); - var s2 = cc.Sprite.create("grossinis_sister1.png"); - s2.position = cc.Point.create(winSize.width / 2 - 50, winSize.height / 2); - - var moveTo = new cc.MoveTo(); - moveTo.initWithDuration(2.0, cc.Point.create(winSize.width, winSize.height / 2)); - var moveBy = new cc.MoveBy(); - moveBy.initWithDuration(2.0, cc.Point.create(100, 100)); - - s1.runAction(moveTo); - s2.runAction(moveBy); - - var scene = new cc.Scene(); scene.init(); - scene.addChild(s1); - scene.addChild(s2); - - // add the menu - var menu = createMenu("Test Move"); - scene.addChild(menu, 1); - - return scene; -}; - -scenes['test_rotate'] = function () { - var s1 = cc.Sprite.create("grossini_dance_05.png"); - s1.position = cc.Point.create(winSize.width / 2 + 50, winSize.height / 2); - var s2 = cc.Sprite.create("grossinis_sister1.png"); - s2.rotation = 90; - s2.position = cc.Point.create(winSize.width / 2 - 100, winSize.height / 2); - - var rotateTo = new cc.RotateTo(); - rotateTo.initWithDuration(1.0, 180.0); - var rotateBy = new cc.RotateBy(); - rotateBy.initWithDuration(2.0, 90); - - s1.runAction(rotateTo); - s2.runAction(rotateBy); - - var scene = new cc.Scene(); scene.init(); - scene.addChild(s1); - scene.addChild(s2); - - // add the menu - var menu = createMenu("Test Rotate"); - scene.addChild(menu, 1); - - return scene; -}; - -scenes['test_animation'] = function () { - var spriteFrameCache = cc.SpriteFrameCache.sharedSpriteFrameCache(); - spriteFrameCache.addSpriteFramesWithFile("tank.plist"); - - // create a new sprite with a sprite frame - var sprite = new cc.Sprite(); - sprite.initWithSpriteFrameName("tank1.png"); - sprite.position = cc.Point.create(winSize.width / 2, winSize.height / 2); - - // create animation - var frames = ["tank1.png", "tank2.png", "tank3.png", "tank4.png", "tank5.png"]; - var animation = new cc.Animation(); - animation.init(); - // set the delay - animation.delayPerUnit = 0.1; - // add the frames - for (var i=0; i < frames.length; i++) { - var frame = spriteFrameCache.spriteFrameByName(frames[i]); - animation.addSpriteFrame(frame); - } - // action stored in the sprite to avoid GC - sprite.anim = new cc.Animate(); - sprite.anim.initWithAnimation(animation); - sprite.runAction(sprite.anim); - - var scene = new cc.Scene(); scene.init(); - scene.addChild(sprite); - - // add the menu - var menu = createMenu("Test Animation"); - scene.addChild(menu, 1); - - return scene; -}; - -scenes['test_repeat'] = function () { - var s1 = cc.Sprite.create("grossinis_sister1.png"); - s1.position = cc.Point.create(winSize.width / 2, winSize.height / 2); - - var rotateBy = new cc.RotateBy(); - rotateBy.initWithDuration(1.0, 90); - - var repeat = new cc.RepeatForever(); - repeat.initWithAction(rotateBy); - - s1.runAction(repeat); - var scene = new cc.Scene(); scene.init(); - scene.addChild(s1); - - // add the menu - var menu = createMenu("Test Repeat"); - scene.addChild(menu, 1); - - return scene; -}; - -scenes['test_sequence'] = function () { - var s1 = cc.Sprite.create("grossini_dance_05.png"); - s1.position = cc.Point.create(winSize.width / 2 + 50, winSize.height / 2); - - var rotate1 = new cc.RotateBy(); - rotate1.initWithDuration(1.0, 90); - var moveBy = new cc.MoveBy(); - moveBy.initWithDuration(2.0, cc.Point.create(100, 100)); - var rotate2 = rotate1.reverse(); - var delay = cc.DelayTime.actionWithDuration(1.5); - - var seq = cc.Sequence.actions(rotate1, moveBy, delay, rotate2); - s1.runAction(seq); - - var scene = new cc.Scene(); scene.init(); - scene.addChild(s1); - - // add the menu - var menu = createMenu("Test Sequence"); - scene.addChild(menu, 1); - - return scene; -}; - -scenes['test_wave3d'] = function () { - var node = new cc.Node(); - var s1 = cc.Sprite.create("grossini_dance_05.png"); - s1.position = cc.Point.create(winSize.width / 2 + 50, winSize.height / 2); - - var rotate1 = new cc.RotateBy(); - rotate1.initWithDuration(1.0, 90); - var moveBy = new cc.MoveBy(); - moveBy.initWithDuration(2.0, cc.Point.create(100, 100)); - var rotate2 = rotate1.reverse(); - var delay = cc.DelayTime.actionWithDuration(1.5); - - var seq = cc.Sequence.actions(rotate1, moveBy, delay, rotate2); - s1.runAction(seq); - - var scene = new cc.Scene(); scene.init(); - node.addChild(s1); - - // simple wave 3d - var gridSize = new cc.GridSize; - gridSize.x = 15; - gridSize.y = 10; - var wave = cc.Waves3D.actionWithWaves(5, 40, gridSize, 3); - scene.runAction(wave); - - // add the menu - var menu = createMenu("Test Sequence"); - scene.addChild(node); - scene.addChild(menu, 1); - - return scene; -}; - - -/** - * from here on there's code that can be shared between different tests - * basically is the hud and the scene handling - */ - -// changes to the next scene -var nextScene = function () { - var l = Object.keys(scenes).length; - scenes.currentScene = (scenes.currentScene + 1) % l; - if (scenes.currentScene === 0) { - scenes.currentScene = 1; - } - playCurrentScene(); -}; - -// changes to the previous scene -var prevScene = function () { - var l = Object.keys(scenes).length; - scenes.currentScene -= 1; - if (scenes.currentScene < 1) { - scenes.currentScene = l - 1; - } - playCurrentScene(); -}; - -var playCurrentScene = function () { - var name = Object.keys(scenes)[scenes.currentScene]; - var scene = scenes[name](); - // cc.log("running scene: " + name + "(" + scene + ")"); - if (director.runningScene === null) { - director.runWithScene(scene); - } else { - director.replaceScene(scene); - } -}; - -// creates the hud -var createMenu = function (labelText) { - var hudMenu = new cc.Menu(); - hudMenu.init(); - - var b1 = new cc.Sprite(); b1.initWithFile("b1.png"); - var b2 = new cc.Sprite(); b2.initWithFile("b2.png"); - item1 = new cc.MenuItemSprite(); - item1.initWithNormalSprite(b1, b2); - item1.action = function () { - prevScene(); - }; - - var r1 = new cc.Sprite(); r1.initWithFile("r1.png"); - var r2 = new cc.Sprite(); r2.initWithFile("r2.png"); - item2 = new cc.MenuItemSprite(); - item2.initWithNormalSprite(r1, r2); - item2.action = function () { - // cc.executeScript("JS/1to1/test_actions.js"); - playCurrentScene(); - }; - - var f1 = new cc.Sprite(); f1.initWithFile("f1.png"); - var f2 = new cc.Sprite(); f2.initWithFile("f2.png"); - item3 = new cc.MenuItemSprite(); - item3.initWithNormalSprite(f1, f2); - item3.action = function () { - nextScene(); - }; - - var c1 = new cc.Sprite(); c1.initWithFile("r1.png"); - var c2 = new cc.Sprite(); c2.initWithFile("r2.png"); - item4 = new cc.MenuItemSprite(); - item4.initWithNormalSprite(c1, c2); - item4.action = function () { - cc.executeScript("JS/1to1/test_actions.js"); - }; - - item1.position = cc.Point.create(winSize.width / 2 - 100, 30); - item2.position = cc.Point.create(winSize.width / 2 , 30); - item3.position = cc.Point.create(winSize.width / 2 + 100, 30); - item4.position = cc.Point.create(30, winSize.height - 30); - - hudMenu.addChild(item1); - hudMenu.addChild(item2); - hudMenu.addChild(item3); - hudMenu.addChild(item4); - hudMenu.position = pointZero; - - if (labelText) { - var label = new cc.LabelTTF(); - // initWithString: text, size, alignment, font, fontSize - label.initWithString(labelText, sizeZero, 0, "Arial", 18.0); - var menuLabel = new cc.MenuItemLabel(); - menuLabel.initWithLabel(label); - menuLabel.position = cc.Point.create(winSize.width / 2, winSize.height - 30); - hudMenu.addChild(menuLabel); - } - - // just to avoid GC - hudMenu.items = [item1, item2, item3]; - return hudMenu; -}; - -playCurrentScene(); diff --git a/samples/TestJavascript/Resources/oldjs/1to1/test_bindings.js b/samples/TestJavascript/Resources/oldjs/1to1/test_bindings.js deleted file mode 100644 index eceefd1555..0000000000 --- a/samples/TestJavascript/Resources/oldjs/1to1/test_bindings.js +++ /dev/null @@ -1,42 +0,0 @@ -// this is to test the test bindings :) - -var simple1 = new SimpleNativeClass(); - -// testing the getters and the constructor (that set some fields) -cc.log("someField: " + simple1.someField); -cc.log("someOtherField: " + simple1.someOtherField); -cc.log("anotherMoreComplexField: " + simple1.anotherMoreComplexField); - -// testing the setters -simple1.someField = 1313; -simple1.someOtherField = 999; -simple1.anotherMoreComplexField = "this is a js string"; - -cc.log("someField: " + simple1.someField); -cc.log("someOtherField: " + simple1.someOtherField); -cc.log("anotherMoreComplexField: " + simple1.anotherMoreComplexField); - -// testing std::string conversion - -cc.log("someProcessing: " + simple1.doSomeProcessing("this is some js string", "this is another javascript string")); - - -var another = new AnotherClass(); -// testing the getters and the constructor (that set some fields) -cc.log("justOneField: " + another.justOneField); -cc.log("aPublicField: " + another.aPublicField); - -// testing setters, the setter for justOneField should not work (since it's not defined correctly in the native class) -another.justOneField = 8888; -another.aPublicField = 6667; -cc.log("justOneField: " + another.justOneField); -cc.log("aPublicField: " + another.aPublicField); - -// should print something in stderr -another.doSomethingSimple(); - -//should print the enum -cc.log("enum: " + someThingEnumerated.kValue1); -cc.log("enum: " + someThingEnumerated.kValue2); -cc.log("enum: " + someThingEnumerated.kValue3); -cc.log("enum: " + someThingEnumerated.kValue4); diff --git a/samples/TestJavascript/Resources/oldjs/1to1/test_ease_actions.js b/samples/TestJavascript/Resources/oldjs/1to1/test_ease_actions.js deleted file mode 100644 index e5a7611376..0000000000 --- a/samples/TestJavascript/Resources/oldjs/1to1/test_ease_actions.js +++ /dev/null @@ -1,572 +0,0 @@ -/* - * showcasing actions - */ - -/** - * simple wrappers - */ -cc.Point.create = function (x, y) { - var pt = new cc.Point(); - pt.x = x; - pt.y = y; - return pt; -}; - -cc.Size.create = function (w, h) { - var sz = new cc.Size(); - sz.width = w; - sz.height = h; - return sz; -}; - -cc.Sprite.create = function (file) { - var s = new cc.Sprite(); - s.initWithFile(file); - return s; -}; - -var pointZero = cc.Point.create(0, 0); -var sizeZero = cc.Size.create(0, 0); - -var director = cc.Director.sharedDirector(); -var winSize = director.winSize; - -var scenes = {}; -scenes.currentScene = 1; - -// -// EaseIn / EaseOut -// -scenes['test_easein'] = function () { - var s1 = new cc.Sprite.create("grossinis_sister1.png"); - s1.position = cc.Point.create(50, winSize.height * 3 / 4 ); - - var s2 = new cc.Sprite.create("grossini_dance_05.png"); - s2.position = cc.Point.create(50, winSize.height * 2 / 4); - - var s3 = new cc.Sprite.create("grossinis_sister2.png"); - s3.position = cc.Point.create(50, winSize.height * 1 / 4); - - var moveBy1 = new cc.MoveBy(); - var moveBy2 = new cc.MoveBy(); - var moveBy3 = new cc.MoveBy(); - - moveBy1.initWithDuration(2.0, cc.Point.create( winSize.width-100, 0)); - moveBy2.initWithDuration(2.0, cc.Point.create( winSize.width-100, 0)); - moveBy3.initWithDuration(2.0, cc.Point.create( winSize.width-100, 0)); - - var easein = cc.EaseIn.actionWithAction(moveBy1, 0.2); - var easein_back = cc.EaseIn.actionWithAction( moveBy1.reverse(), 1/0.2 ); - var seq1 = cc.Sequence.actions(easein, easein_back); - s1.runAction(seq1); - - var seq2 = cc.Sequence.actions(moveBy2, moveBy2.reverse()); - s2.runAction(seq2); - - var easeout = cc.EaseOut.actionWithAction(moveBy3, 0.2); - var seq3 = cc.Sequence.actions(easeout, easeout.reverse()); - s3.runAction(seq3); - - var scene = new cc.Scene(); scene.init(); - scene.addChild(s1); - scene.addChild(s2); - scene.addChild(s3); - - // add the menu - var menu = createMenu("Test EaseIn / EaseOut"); - scene.addChild(menu, 1); - - return scene; -}; - -// -// EaseIn / EaseOut -// -scenes['test_easeinout'] = function () { - - var s1 = new cc.Sprite.create("grossinis_sister1.png"); - s1.position = cc.Point.create(50, winSize.height * 3 / 4 ); - - var s2 = new cc.Sprite.create("grossini_dance_05.png"); - s2.position = cc.Point.create(50, winSize.height * 2 / 4); - - var s3 = new cc.Sprite.create("grossinis_sister2.png"); - s3.position = cc.Point.create(50, winSize.height * 1 / 4); - - - var move1 = cc.MoveBy.actionWithDuration(3, cc.Point.create(winSize.width-130,0) ); - var move2 = cc.MoveBy.actionWithDuration(3, cc.Point.create(winSize.width-130,0) ); - var move3 = cc.MoveBy.actionWithDuration(3, cc.Point.create(winSize.width-130,0) ); - - var move_ease_inout1 = cc.EaseInOut.actionWithAction( move1, 2 ); - var move_ease_inout_back1 = move_ease_inout1.reverse(); - - var move_ease_inout2 = cc.EaseInOut.actionWithAction( move2, 3 ); - var move_ease_inout_back2 = move_ease_inout2.reverse(); - - var move_ease_inout3 = cc.EaseInOut.actionWithAction( move3, 4 ); - var move_ease_inout_back3 = move_ease_inout3.reverse(); - -// var delay = [CCDelayTime actionWithDuration:0.25f]; - - var seq1 = cc.Sequence.actions( move_ease_inout1, move_ease_inout_back1 ); - var seq2 = cc.Sequence.actions( move_ease_inout2, move_ease_inout_back2 ); - var seq3 = cc.Sequence.actions( move_ease_inout3, move_ease_inout_back3 ); - - s1.runAction( cc.RepeatForever.actionWithAction( seq1 ) ); - s2.runAction( cc.RepeatForever.actionWithAction( seq2 ) ); - s3.runAction( cc.RepeatForever.actionWithAction( seq3 ) ); - - var scene = new cc.Scene(); scene.init(); - scene.addChild(s1); - scene.addChild(s2); - scene.addChild(s3); - - // add the menu - var menu = createMenu("Test EaseInOut and reverse"); - scene.addChild(menu, 1); - - return scene; -}; - -// -// Ease BounceIn / Out -// -scenes['test_bouncein'] = function () { - var s1 = new cc.Sprite.create("grossinis_sister1.png"); - s1.position = cc.Point.create(50, winSize.height * 3 / 4 ); - - var s2 = new cc.Sprite.create("grossini_dance_05.png"); - s2.position = cc.Point.create(50, winSize.height * 2 / 4); - - var s3 = new cc.Sprite.create("grossinis_sister2.png"); - s3.position = cc.Point.create(50, winSize.height * 1 / 4); - - var move1 = cc.MoveBy.actionWithDuration(3, cc.Point.create(winSize.width-130,0) ); - var move2 = cc.MoveBy.actionWithDuration(3, cc.Point.create(winSize.width-130,0) ); - var move3 = cc.MoveBy.actionWithDuration(3, cc.Point.create(winSize.width-130,0) ); - - var move1_back = move1.reverse(); - - var move_ease_in = cc.EaseBounceIn.actionWithAction( move2 ); - var move_ease_in_back = move_ease_in.reverse(); - - var move_ease_out = cc.EaseBounceOut.actionWithAction( move3 ); - var move_ease_out_back = move_ease_out.reverse(); - - var seq1 = cc.Sequence.actions( move1, move1_back ); - var seq2 = cc.Sequence.actions( move_ease_in, move_ease_in_back ); - var seq3 = cc.Sequence.actions( move_ease_out, move_ease_out_back ); - - s1.runAction( cc.RepeatForever.actionWithAction( seq1 ) ); - s2.runAction( cc.RepeatForever.actionWithAction( seq2 ) ); - s3.runAction( cc.RepeatForever.actionWithAction( seq3 ) ); - - var scene = new cc.Scene(); scene.init(); - scene.addChild(s1); - scene.addChild(s2); - scene.addChild(s3); - - // add the menu - var menu = createMenu("Test EaseBounceIn / Out and reverse"); - scene.addChild(menu, 1); - - return scene; -}; - -// -// Ease BounceInOut -// -scenes['test_bounceinout'] = function () { - - var s1 = new cc.Sprite.create("grossinis_sister1.png"); - s1.position = cc.Point.create(50, winSize.height * 3 / 4 ); - - var s2 = new cc.Sprite.create("grossinis_sister2.png"); - s2.position = cc.Point.create(50, winSize.height * 1 / 4); - - - var move1 = cc.MoveBy.actionWithDuration(3, cc.Point.create(winSize.width-130,0) ); - var move2 = cc.MoveBy.actionWithDuration(3, cc.Point.create(winSize.width-130,0) ); - - var move1_back = move1.reverse(); - - var move_ease = cc.EaseBounceInOut.actionWithAction( move2 ); - var move_ease_back = move_ease.reverse(); - - var seq1 = cc.Sequence.actions( move1, move1_back ); - var seq2 = cc.Sequence.actions( move_ease, move_ease_back ); - - - s1.runAction( cc.RepeatForever.actionWithAction( seq1 ) ); - s2.runAction( cc.RepeatForever.actionWithAction( seq2 ) ); - - var scene = new cc.Scene(); scene.init(); - scene.addChild(s1); - scene.addChild(s2); - - // add the menu - var menu = createMenu("Test EaseBounceInOut + reverse"); - scene.addChild(menu, 1); - - return scene; -}; - -// -// EaseBackIn / Out -// -scenes['test_backin_out'] = function () { - - var s1 = new cc.Sprite.create("grossinis_sister1.png"); - s1.position = cc.Point.create(50, winSize.height * 3 / 4 ); - - var s2 = new cc.Sprite.create("grossini_dance_05.png"); - s2.position = cc.Point.create(50, winSize.height * 2 / 4); - - var s3 = new cc.Sprite.create("grossinis_sister2.png"); - s3.position = cc.Point.create(50, winSize.height * 1 / 4); - - - var move1 = cc.MoveBy.actionWithDuration(3, cc.Point.create(winSize.width-130,0) ); - var move2 = cc.MoveBy.actionWithDuration(3, cc.Point.create(winSize.width-130,0) ); - var move3 = cc.MoveBy.actionWithDuration(3, cc.Point.create(winSize.width-130,0) ); - - var move1_back = move1.reverse(); - - - var move_ease_in = cc.EaseBackIn.actionWithAction( move2 ); - var move_ease_in_back = move_ease_in.reverse(); - - var move_ease_out = cc.EaseBackOut.actionWithAction( move3 ); - var move_ease_out_back = move_ease_out.reverse(); - - var seq1 = cc.Sequence.actions( move1, move1_back ); - var seq2 = cc.Sequence.actions( move_ease_in, move_ease_in_back ); - var seq3 = cc.Sequence.actions( move_ease_out, move_ease_out_back ); - - s1.runAction( cc.RepeatForever.actionWithAction( seq1 ) ); - s2.runAction( cc.RepeatForever.actionWithAction( seq2 ) ); - s3.runAction( cc.RepeatForever.actionWithAction( seq3 ) ); - - var scene = new cc.Scene(); scene.init(); - scene.addChild(s1); - scene.addChild(s2); - scene.addChild(s3); - - // add the menu - var menu = createMenu("Test EaseBackIn / Out and reverse"); - scene.addChild(menu, 1); - - return scene; -}; - -// -// EaseBackInOut -// -scenes['test_backinout'] = function () { - - var s1 = new cc.Sprite.create("grossinis_sister1.png"); - s1.position = cc.Point.create(50, winSize.height * 3 / 4 ); - - var s2 = new cc.Sprite.create("grossinis_sister2.png"); - s2.position = cc.Point.create(50, winSize.height * 1 / 4); - - - var move1 = cc.MoveBy.actionWithDuration(3, cc.Point.create(winSize.width-130,0) ); - var move2 = cc.MoveBy.actionWithDuration(3, cc.Point.create(winSize.width-130,0) ); - - var move1_back = move1.reverse(); - - var move_ease = cc.EaseBackInOut.actionWithAction( move2 ); - var move_ease_back = move_ease.reverse(); - - var seq1 = cc.Sequence.actions( move1, move1_back ); - var seq2 = cc.Sequence.actions( move_ease, move_ease_back ); - - - s1.runAction( cc.RepeatForever.actionWithAction( seq1 ) ); - s2.runAction( cc.RepeatForever.actionWithAction( seq2 ) ); - - var scene = new cc.Scene(); scene.init(); - scene.addChild(s1); - scene.addChild(s2); - - // add the menu - var menu = createMenu("Test EaseBackInOut + reverse"); - scene.addChild(menu, 1); - - return scene; -}; - -// -// EaseBounceIn / Out -// -scenes['test_sinein_out'] = function () { - - var s1 = new cc.Sprite.create("grossinis_sister1.png"); - s1.position = cc.Point.create(50, winSize.height * 3 / 4 ); - - var s2 = new cc.Sprite.create("grossini_dance_05.png"); - s2.position = cc.Point.create(50, winSize.height * 2 / 4); - - var s3 = new cc.Sprite.create("grossinis_sister2.png"); - s3.position = cc.Point.create(50, winSize.height * 1 / 4); - - - var move1 = cc.MoveBy.actionWithDuration(3, cc.Point.create(winSize.width-130,0) ); - var move2 = cc.MoveBy.actionWithDuration(3, cc.Point.create(winSize.width-130,0) ); - var move3 = cc.MoveBy.actionWithDuration(3, cc.Point.create(winSize.width-130,0) ); - - var move1_back = move1.reverse(); - - - var move_ease_in = cc.EaseSineIn.actionWithAction( move2 ); - var move_ease_in_back = move_ease_in.reverse(); - - var move_ease_out = cc.EaseSineOut.actionWithAction( move3 ); - var move_ease_out_back = move_ease_out.reverse(); - - var seq1 = cc.Sequence.actions( move1, move1_back ); - var seq2 = cc.Sequence.actions( move_ease_in, move_ease_in_back ); - var seq3 = cc.Sequence.actions( move_ease_out, move_ease_out_back ); - - s1.runAction( cc.RepeatForever.actionWithAction( seq1 ) ); - s2.runAction( cc.RepeatForever.actionWithAction( seq2 ) ); - s3.runAction( cc.RepeatForever.actionWithAction( seq3 ) ); - - var scene = new cc.Scene(); scene.init(); - scene.addChild(s1); - scene.addChild(s2); - scene.addChild(s3); - - // add the menu - var menu = createMenu("Test EaseSineIn / Out and reverse"); - scene.addChild(menu, 1); - - return scene; -}; - -// -// EaseSineInOut -// -scenes['test_sineinout'] = function () { - - var s1 = new cc.Sprite.create("grossinis_sister1.png"); - s1.position = cc.Point.create(50, winSize.height * 3 / 4 ); - - var s2 = new cc.Sprite.create("grossinis_sister2.png"); - s2.position = cc.Point.create(50, winSize.height * 1 / 4); - - - var move1 = cc.MoveBy.actionWithDuration(3, cc.Point.create(winSize.width-130,0) ); - var move2 = cc.MoveBy.actionWithDuration(3, cc.Point.create(winSize.width-130,0) ); - - var move1_back = move1.reverse(); - - var move_ease = cc.EaseSineInOut.actionWithAction( move2 ); - var move_ease_back = move_ease.reverse(); - - var seq1 = cc.Sequence.actions( move1, move1_back ); - var seq2 = cc.Sequence.actions( move_ease, move_ease_back ); - - - s1.runAction( cc.RepeatForever.actionWithAction( seq1 ) ); - s2.runAction( cc.RepeatForever.actionWithAction( seq2 ) ); - - var scene = new cc.Scene(); scene.init(); - scene.addChild(s1); - scene.addChild(s2); - - // add the menu - var menu = createMenu("Test EaseSineInOut + reverse"); - scene.addChild(menu, 1); - - return scene; -}; - -// -// EaseElasticIn / Out -// -scenes['test_elasticin_out'] = function () { - - var s1 = new cc.Sprite.create("grossinis_sister1.png"); - s1.position = cc.Point.create(50, winSize.height * 3 / 4 ); - - var s2 = new cc.Sprite.create("grossini_dance_05.png"); - s2.position = cc.Point.create(50, winSize.height * 2 / 4); - - var s3 = new cc.Sprite.create("grossinis_sister2.png"); - s3.position = cc.Point.create(50, winSize.height * 1 / 4); - - - var move1 = cc.MoveBy.actionWithDuration(3, cc.Point.create(winSize.width-130,0) ); - var move2 = cc.MoveBy.actionWithDuration(3, cc.Point.create(winSize.width-130,0) ); - var move3 = cc.MoveBy.actionWithDuration(3, cc.Point.create(winSize.width-130,0) ); - - var move1_back = move1.reverse(); - - var move_ease_in = cc.EaseElasticIn.actionWithAction( move2 ); - var move_ease_in_back = move_ease_in.reverse(); - - var move_ease_out = cc.EaseElasticOut.actionWithAction( move3 ); - var move_ease_out_back = move_ease_out.reverse(); - - var seq1 = cc.Sequence.actions( move1, move1_back ); - var seq2 = cc.Sequence.actions( move_ease_in, move_ease_in_back ); - var seq3 = cc.Sequence.actions( move_ease_out, move_ease_out_back ); - - s1.runAction( cc.RepeatForever.actionWithAction( seq1 ) ); - s2.runAction( cc.RepeatForever.actionWithAction( seq2 ) ); - s3.runAction( cc.RepeatForever.actionWithAction( seq3 ) ); - - var scene = new cc.Scene(); scene.init(); - scene.addChild(s1); - scene.addChild(s2); - scene.addChild(s3); - - // add the menu - var menu = createMenu("Test EaseElasticIn / Out and reverse"); - scene.addChild(menu, 1); - - return scene; -}; - -// -// EaseElasticInOut -// -scenes['test_elasticinout'] = function () { - - var s1 = new cc.Sprite.create("grossinis_sister1.png"); - s1.position = cc.Point.create(50, winSize.height * 3 / 4 ); - - var s2 = new cc.Sprite.create("grossinis_sister2.png"); - s2.position = cc.Point.create(50, winSize.height * 1 / 4); - - - var move1 = cc.MoveBy.actionWithDuration(3, cc.Point.create(winSize.width-130,0) ); - var move2 = cc.MoveBy.actionWithDuration(3, cc.Point.create(winSize.width-130,0) ); - - var move1_back = move1.reverse(); - - var move_ease = cc.EaseElasticInOut.actionWithAction( move2 ); - var move_ease_back = move_ease.reverse(); - - var seq1 = cc.Sequence.actions( move1, move1_back ); - var seq2 = cc.Sequence.actions( move_ease, move_ease_back ); - - - s1.runAction( cc.RepeatForever.actionWithAction( seq1 ) ); - s2.runAction( cc.RepeatForever.actionWithAction( seq2 ) ); - - var scene = new cc.Scene(); scene.init(); - scene.addChild(s1); - scene.addChild(s2); - - // add the menu - var menu = createMenu("Test EaseElasticInOut + reverse"); - scene.addChild(menu, 1); - - return scene; -}; - -/** - * from here on there's code that can be shared between different tests - * basically is the hud and the scene handling - */ - -// changes to the next scene -var nextScene = function () { - var l = Object.keys(scenes).length; - scenes.currentScene = (scenes.currentScene + 1) % l; - if (scenes.currentScene === 0) { - scenes.currentScene = 1; - } - playCurrentScene(); -}; - -// changes to the previous scene -var prevScene = function () { - var l = Object.keys(scenes).length; - scenes.currentScene -= 1; - if (scenes.currentScene < 1) { - scenes.currentScene = l - 1; - } - playCurrentScene(); -}; - -var playCurrentScene = function () { - var name = Object.keys(scenes)[scenes.currentScene]; - var scene = scenes[name](); - // cc.log("running scene: " + name + "(" + scene + ")"); - if (director.runningScene === null) { - director.runWithScene(scene); - } else { - director.replaceScene(scene); - } -}; - -// creates the hud -var createMenu = function (labelText) { - var hudMenu = new cc.Menu(); - hudMenu.init(); - - var b1 = new cc.Sprite(); b1.initWithFile("b1.png"); - var b2 = new cc.Sprite(); b2.initWithFile("b2.png"); - item1 = new cc.MenuItemSprite(); - item1.initWithNormalSprite(b1, b2); - item1.action = function () { - prevScene(); - }; - - var r1 = new cc.Sprite(); r1.initWithFile("r1.png"); - var r2 = new cc.Sprite(); r2.initWithFile("r2.png"); - item2 = new cc.MenuItemSprite(); - item2.initWithNormalSprite(r1, r2); - item2.action = function () { - // cc.executeScript("JS/1to1/test_actions.js"); - playCurrentScene(); - }; - - var f1 = new cc.Sprite(); f1.initWithFile("f1.png"); - var f2 = new cc.Sprite(); f2.initWithFile("f2.png"); - item3 = new cc.MenuItemSprite(); - item3.initWithNormalSprite(f1, f2); - item3.action = function () { - nextScene(); - }; - - var c1 = new cc.Sprite(); c1.initWithFile("r1.png"); - var c2 = new cc.Sprite(); c2.initWithFile("r2.png"); - item4 = new cc.MenuItemSprite(); - item4.initWithNormalSprite(c1, c2); - item4.action = function () { - cc.executeScript("JS/1to1/test_ease_actions.js"); - }; - - item1.position = cc.Point.create(winSize.width / 2 - 100, 30); - item2.position = cc.Point.create(winSize.width / 2 , 30); - item3.position = cc.Point.create(winSize.width / 2 + 100, 30); - item4.position = cc.Point.create(30, winSize.height - 30); - - hudMenu.addChild(item1); - hudMenu.addChild(item2); - hudMenu.addChild(item3); - hudMenu.addChild(item4); - hudMenu.position = pointZero; - - if (labelText) { - var label = new cc.LabelTTF(); - // initWithString: text, size, alignment, font, fontSize - label.initWithString(labelText, sizeZero, 0, "Arial", 18.0); - var menuLabel = new cc.MenuItemLabel(); - menuLabel.initWithLabel(label); - menuLabel.position = cc.Point.create(winSize.width / 2, winSize.height - 30); - hudMenu.addChild(menuLabel); - } - - // just to avoid GC - hudMenu.items = [item1, item2, item3]; - return hudMenu; -}; - -playCurrentScene(); diff --git a/samples/TestJavascript/Resources/oldjs/1to1/test_layer.js b/samples/TestJavascript/Resources/oldjs/1to1/test_layer.js deleted file mode 100644 index 9ce7000c6a..0000000000 --- a/samples/TestJavascript/Resources/oldjs/1to1/test_layer.js +++ /dev/null @@ -1,206 +0,0 @@ -/* - * showcasing layer and touch events - */ - -/** - * simple wrappers - */ -cc.Point.create = function (x, y) { - var pt = new cc.Point(); - pt.x = x; - pt.y = y; - return pt; -}; - -cc.Size.create = function (w, h) { - var sz = new cc.Size(); - sz.width = w; - sz.height = h; - return sz; -}; - -cc.Sprite.create = function (file) { - var s = new cc.Sprite(); - s.initWithFile(file); - return s; -}; - -var pointZero = cc.Point.create(0, 0); -var sizeZero = cc.Size.create(0, 0); - -var director = cc.Director.sharedDirector(); -var winSize = director.winSize; - -var scenes = {}; -scenes.currentScene = 1; - -/** - * tests the most basic function: moveTo and moveBy - */ -scenes['test_layer_1'] = function () { - var layer = new cc.Layer(); layer.init(); - layer.isTouchEnabled = true; - layer.ccTouchesBegan = function (touches) { - for (var i in touches) { - var pt = touches[i].locationInView(); - pt = director.convertToGL(pt); - var s = new cc.Sprite.create("grossinis_sister1.png"); - s.position = pt; - s.rotation = Math.random() * 360; - this.addChild(s); - } - }; - - var scene = new cc.Scene(); scene.init(); - scene.addChild(layer); - - // add the menu - var menu = createMenu("Test Layer 1"); - scene.addChild(menu, 1); - - return scene; -}; - -scenes['test_layer_2'] = function () { - var layer = new cc.Layer(); layer.init(); - layer.isTouchEnabled = true; - layer.currentSprite = null; - - layer.ccTouchesBegan = function (touches) { - for (var i in touches) { - var pt = touches[i].locationInView(); - pt = director.convertToGL(pt); - var s = new cc.Sprite.create("grossinis_sister1.png"); - s.position = pt; - s.rotation = Math.random() * 360; - this.addChild(s); - // only the first - if (this.currentSprite === null) { - this.currentSprite = s; - } - } - }; - - layer.ccTouchesMoved = function (touches) { - pt = touches[0].locationInView(); - pt = director.convertToGL(pt); - if (this.currentSprite) { - this.currentSprite.position = pt; - } - }; - - layer.ccTouchesEnded = function (touches) { - this.currentSprite = null; - }; - - var scene = new cc.Scene(); scene.init(); - scene.addChild(layer); - - // add the menu - var menu = createMenu("Test Layer 2"); - scene.addChild(menu, 1); - - return scene; -}; - -/** - * from here on there's code that can be shared between different tests - * basically is the hud and the scene handling - */ - -// changes to the next scene -var nextScene = function () { - var l = Object.keys(scenes).length; - scenes.currentScene = (scenes.currentScene + 1) % l; - if (scenes.currentScene === 0) { - scenes.currentScene = 1; - } - playCurrentScene(); -}; - -// changes to the previous scene -var prevScene = function () { - var l = Object.keys(scenes).length; - scenes.currentScene -= 1; - if (scenes.currentScene < 1) { - scenes.currentScene = l - 1; - } - playCurrentScene(); -}; - -var playCurrentScene = function () { - var name = Object.keys(scenes)[scenes.currentScene]; - var scene = scenes[name](); - // cc.log("running scene: " + name + "(" + scene + ")"); - if (director.runningScene === null) { - director.runWithScene(scene); - } else { - director.replaceScene(scene); - } -}; - -// creates the hud -var createMenu = function (labelText) { - var hudMenu = new cc.Menu(); - hudMenu.init(); - - var b1 = new cc.Sprite(); b1.initWithFile("b1.png"); - var b2 = new cc.Sprite(); b2.initWithFile("b2.png"); - item1 = new cc.MenuItemSprite(); - item1.initWithNormalSprite(b1, b2); - item1.action = function () { - prevScene(); - }; - - var r1 = new cc.Sprite(); r1.initWithFile("r1.png"); - var r2 = new cc.Sprite(); r2.initWithFile("r2.png"); - item2 = new cc.MenuItemSprite(); - item2.initWithNormalSprite(r1, r2); - item2.action = function () { - // cc.executeScript("JS/1to1/test_actions.js"); - playCurrentScene(); - }; - - var f1 = new cc.Sprite(); f1.initWithFile("f1.png"); - var f2 = new cc.Sprite(); f2.initWithFile("f2.png"); - item3 = new cc.MenuItemSprite(); - item3.initWithNormalSprite(f1, f2); - item3.action = function () { - nextScene(); - }; - - var c1 = new cc.Sprite(); c1.initWithFile("r1.png"); - var c2 = new cc.Sprite(); c2.initWithFile("r2.png"); - item4 = new cc.MenuItemSprite(); - item4.initWithNormalSprite(c1, c2); - item4.action = function () { - cc.executeScript("JS/1to1/test_layer.js"); - }; - - item1.position = cc.Point.create(winSize.width / 2 - 100, 30); - item2.position = cc.Point.create(winSize.width / 2 , 30); - item3.position = cc.Point.create(winSize.width / 2 + 100, 30); - item4.position = cc.Point.create(30, winSize.height - 30); - - hudMenu.addChild(item1); - hudMenu.addChild(item2); - hudMenu.addChild(item3); - hudMenu.addChild(item4); - hudMenu.position = pointZero; - - if (labelText) { - var label = new cc.LabelTTF(); - // initWithString: text, size, alignment, font, fontSize - label.initWithString(labelText, sizeZero, 0, "Arial", 18.0); - var menuLabel = new cc.MenuItemLabel(); - menuLabel.initWithLabel(label); - menuLabel.position = cc.Point.create(winSize.width / 2, winSize.height - 30); - hudMenu.addChild(menuLabel); - } - - // just to avoid GC - hudMenu.items = [item1, item2, item3]; - return hudMenu; -}; - -playCurrentScene(); diff --git a/samples/TestJavascript/Resources/oldjs/1to1/test_particles.js b/samples/TestJavascript/Resources/oldjs/1to1/test_particles.js deleted file mode 100644 index fd5452c6ba..0000000000 --- a/samples/TestJavascript/Resources/oldjs/1to1/test_particles.js +++ /dev/null @@ -1,484 +0,0 @@ -/* - * showcasing actions - */ - -/** - * simple wrappers - */ -cc.Point.create = function (x, y) { - var pt = new cc.Point(); - pt.x = x; - pt.y = y; - return pt; -}; - -cc.Size.create = function (w, h) { - var sz = new cc.Size(); - sz.width = w; - sz.height = h; - return sz; -}; - -cc.Sprite.create = function (file) { - var s = new cc.Sprite(); - s.initWithFile(file); - return s; -}; - -var pointZero = cc.Point.create(0, 0); -var sizeZero = cc.Size.create(0, 0); - -var director = cc.Director.sharedDirector(); -var winSize = director.winSize; - -var scenes = {}; -scenes.currentScene = 1; - -/** - * Manual Particle - */ -scenes['test_manual'] = function () { - - var scene = new cc.Scene(); scene.init(); - - var p1 = new cc.ParticleSystem(); - p1.initWithTotalParticles(250); - p1.position = cc.Point.create(winSize.width / 2, winSize.height / 2 ); - - scene.addChild(p1); - - p1.texture = cc.TextureCache.sharedTextureCache().addImage( "stars2.png" ); - - p1.duration = 3; - - // gravity - p1.gravity = cc.Point.create(0, -5); - - // angle - p1.angle = 90; - p1.angleVar = 360; - - // speed of particles - p1.speed = 160; - p1.speedVar = 20; - - // radial - p1.radialAccel = -120; - p1.radialAccelVar = 0; - - // tagential - p1.tangentialAccel = 30; - p1.tangentialAccelVar = 0; - - // emitter position -// p1.position = cc.Point.create(0, 0); - p1.posVar = cc.Point.create(0, 0); - - // life of particles - p1.life = 4; - p1.lifeVar = 1; - - // spin of particles - p1.startSpin = 0; - p1.startSizeVar = 0; - p1.endSpin = 0; - p1.endSpinVar = 0; - - // color of particles - p1.startColor = [0.5, 0.5, 0.5, 1.0]; - p1.startColorVar = [0.5, 0.5, 0.5, 1.0]; - p1.endColor = [0.1, 0.1, 0.1, 0.2]; - p1.endColorVar = [0.1, 0.1, 0.1, 0.2]; - - // size, in pixels - p1.startSize = 30; - p1.startSizeVar = 0; -// p1.endSize = kParticleStartSizeEqualToEndSize; - - // emits per second - p1.emissionRate = 500; - - // additive - p1.isBlendAdditive = true; - - - // add the menu - var menu = createMenu("Particle: Manual Particle"); - scene.addChild(menu, 1); - - return scene; -}; - -/** - * test particle - */ -scenes['test_lava_flow'] = function () { - - var scene = new cc.Scene(); scene.init(); - - var p1 = cc.ParticleSystem.particleWithFile("LavaFlow.plist"); - p1.position = cc.Point.create(winSize.width / 2, winSize.height / 2 ); - scene.addChild(p1); - - // add the menu - var menu = createMenu("Particle: Lave Flow"); - scene.addChild(menu, 1); - - return scene; -}; - - -/** - * test particle - */ -scenes['test_forest_fire'] = function () { - - var scene = new cc.Scene(); scene.init(); - - var p1 = cc.ParticleSystem.particleWithFile("ForestFire.plist"); - p1.position = cc.Point.create(winSize.width / 2, winSize.height / 2 ); - scene.addChild(p1); - - // add the menu - var menu = createMenu("Particle: Forest Fire"); - scene.addChild(menu, 1); - - return scene; -}; - -/** - * test particle - */ -scenes['test_boiling_foam'] = function () { - - var scene = new cc.Scene(); scene.init(); - - var p1 = cc.ParticleSystem.particleWithFile("BoilingFoam.plist"); - p1.position = cc.Point.create(winSize.width / 2, winSize.height / 2 ); - scene.addChild(p1); - - // add the menu - var menu = createMenu("Particle: Boiling Foam"); - scene.addChild(menu, 1); - - return scene; -}; - - -/** - * test particle - */ -scenes['test_burst_pipe'] = function () { - - var scene = new cc.Scene(); scene.init(); - - var p1 = cc.ParticleSystem.particleWithFile("BurstPipe.plist"); - p1.position = cc.Point.create(winSize.width / 2, winSize.height / 2 ); - scene.addChild(p1); - - // add the menu - var menu = createMenu("Particle: Burst Pipe"); - scene.addChild(menu, 1); - - return scene; -}; - -/** - * test particle - */ -scenes['test_comet'] = function () { - - var scene = new cc.Scene(); scene.init(); - - var p1 = cc.ParticleSystem.particleWithFile("Comet.plist"); - p1.position = cc.Point.create(winSize.width / 2, winSize.height / 2 ); - scene.addChild(p1); - - // add the menu - var menu = createMenu("Particle: Comet"); - scene.addChild(menu, 1); - - return scene; -}; - -/** - * test particle - */ -scenes['test_debian'] = function () { - - var scene = new cc.Scene(); scene.init(); - - var p1 = cc.ParticleSystem.particleWithFile("debian.plist"); - p1.position = cc.Point.create(winSize.width / 2, winSize.height / 2 ); - scene.addChild(p1); - - // add the menu - var menu = createMenu("Particle: Debian"); - scene.addChild(menu, 1); - - return scene; -}; - -/** - * test particle - */ -scenes['test_exploding_ring'] = function () { - - var scene = new cc.Scene(); scene.init(); - - var p1 = cc.ParticleSystem.particleWithFile("ExplodingRing.plist"); - p1.position = cc.Point.create(winSize.width / 2, winSize.height / 2 ); - scene.addChild(p1); - - // add the menu - var menu = createMenu("Particle: Exploding Ring"); - scene.addChild(menu, 1); - - return scene; -}; - -/** - * test particle - */ -scenes['test_flower'] = function () { - - var scene = new cc.Scene(); scene.init(); - - var p1 = cc.ParticleSystem.particleWithFile("Flower.plist"); - p1.position = cc.Point.create(winSize.width / 2, winSize.height / 2 ); - scene.addChild(p1); - - // add the menu - var menu = createMenu("Particle: Flower"); - scene.addChild(menu, 1); - - return scene; -}; - -/** - * test particle - */ -scenes['test_galaxy'] = function () { - - var scene = new cc.Scene(); scene.init(); - - var p1 = cc.ParticleSystem.particleWithFile("Galaxy.plist"); - p1.position = cc.Point.create(winSize.width / 2, winSize.height / 2 ); - scene.addChild(p1); - - // add the menu - var menu = createMenu("Particle: Galaxy"); - scene.addChild(menu, 1); - - return scene; -}; - -/** - * test particle - */ -scenes['test_phoenix'] = function () { - - var scene = new cc.Scene(); scene.init(); - - var p1 = cc.ParticleSystem.particleWithFile("Phoenix.plist"); - p1.position = cc.Point.create(winSize.width / 2, winSize.height / 2 ); - scene.addChild(p1); - - // add the menu - var menu = createMenu("Particle: Phoenix"); - scene.addChild(menu, 1); - - return scene; -}; - -/** - * test particle - */ -scenes['test_small_sun'] = function () { - - var scene = new cc.Scene(); scene.init(); - - var p1 = cc.ParticleSystem.particleWithFile("SmallSun.plist"); - p1.position = cc.Point.create(winSize.width / 2, winSize.height / 2 ); - scene.addChild(p1); - - // add the menu - var menu = createMenu("Particle: Small Sun"); - scene.addChild(menu, 1); - - return scene; -}; - -/** - * test particle - */ -scenes['test_spinningpeas'] = function () { - - var scene = new cc.Scene(); scene.init(); - - var p1 = cc.ParticleSystem.particleWithFile("SpinningPeas.plist"); - p1.position = cc.Point.create(winSize.width / 2, winSize.height / 2 ); - scene.addChild(p1); - - // add the menu - var menu = createMenu("Particle: Spinning Peas"); - scene.addChild(menu, 1); - - return scene; -}; - -/** - * test particle - */ -scenes['test_spiral'] = function () { - - var scene = new cc.Scene(); scene.init(); - - var p1 = cc.ParticleSystem.particleWithFile("Spiral.plist"); - p1.position = cc.Point.create(winSize.width / 2, winSize.height / 2 ); - scene.addChild(p1); - - // add the menu - var menu = createMenu("Particle: Spiral"); - scene.addChild(menu, 1); - - return scene; -}; - -/** - * test particle - */ -scenes['test_sookypeas'] = function () { - - var scene = new cc.Scene(); scene.init(); - - var p1 = cc.ParticleSystem.particleWithFile("SpookyPeas.plist"); - p1.position = cc.Point.create(winSize.width / 2, winSize.height / 2 ); - scene.addChild(p1); - - // add the menu - var menu = createMenu("Particle: Spooky Peas"); - scene.addChild(menu, 1); - - return scene; -}; - -/** - * test particle - */ -scenes['test_upsidedown'] = function () { - - var scene = new cc.Scene(); scene.init(); - - var p1 = cc.ParticleSystem.particleWithFile("Upsidedown.plist"); - p1.position = cc.Point.create(winSize.width / 2, winSize.height / 2 ); - scene.addChild(p1); - - // add the menu - var menu = createMenu("Particle: Upside Down test"); - scene.addChild(menu, 1); - - return scene; -}; - -/** - * from here on there's code that can be shared between different tests - * basically is the hud and the scene handling - */ - -// changes to the next scene -var nextScene = function () { - var l = Object.keys(scenes).length; - scenes.currentScene = (scenes.currentScene + 1) % l; - if (scenes.currentScene === 0) { - scenes.currentScene = 1; - } - playCurrentScene(); -}; - -// changes to the previous scene -var prevScene = function () { - var l = Object.keys(scenes).length; - scenes.currentScene -= 1; - if (scenes.currentScene < 1) { - scenes.currentScene = l - 1; - } - playCurrentScene(); -}; - -var playCurrentScene = function () { - var name = Object.keys(scenes)[scenes.currentScene]; - var scene = scenes[name](); - // cc.log("running scene: " + name + "(" + scene + ")"); - if (director.runningScene === null) { - director.runWithScene(scene); - } else { - director.replaceScene(scene); - } -}; - -// creates the hud -var createMenu = function (labelText) { - var hudMenu = new cc.Menu(); - hudMenu.init(); - - var b1 = new cc.Sprite(); b1.initWithFile("b1.png"); - var b2 = new cc.Sprite(); b2.initWithFile("b2.png"); - item1 = new cc.MenuItemSprite(); - item1.initWithNormalSprite(b1, b2); - item1.action = function () { - prevScene(); - }; - - var r1 = new cc.Sprite(); r1.initWithFile("r1.png"); - var r2 = new cc.Sprite(); r2.initWithFile("r2.png"); - item2 = new cc.MenuItemSprite(); - item2.initWithNormalSprite(r1, r2); - item2.action = function () { - // cc.executeScript("JS/1to1/test_actions.js"); - playCurrentScene(); - }; - - var f1 = new cc.Sprite(); f1.initWithFile("f1.png"); - var f2 = new cc.Sprite(); f2.initWithFile("f2.png"); - item3 = new cc.MenuItemSprite(); - item3.initWithNormalSprite(f1, f2); - item3.action = function () { - nextScene(); - }; - - var c1 = new cc.Sprite(); c1.initWithFile("r1.png"); - var c2 = new cc.Sprite(); c2.initWithFile("r2.png"); - item4 = new cc.MenuItemSprite(); - item4.initWithNormalSprite(c1, c2); - item4.action = function () { - cc.executeScript("JS/1to1/test_particles.js"); - }; - - item1.position = cc.Point.create(winSize.width / 2 - 100, 30); - item2.position = cc.Point.create(winSize.width / 2 , 30); - item3.position = cc.Point.create(winSize.width / 2 + 100, 30); - item4.position = cc.Point.create(30, winSize.height - 30); - - hudMenu.addChild(item1); - hudMenu.addChild(item2); - hudMenu.addChild(item3); - hudMenu.addChild(item4); - hudMenu.position = pointZero; - - if (labelText) { - var label = new cc.LabelTTF(); - // initWithString: text, size, alignment, font, fontSize - label.initWithString(labelText, sizeZero, 0, "Arial", 18.0); - var menuLabel = new cc.MenuItemLabel(); - menuLabel.initWithLabel(label); - menuLabel.position = cc.Point.create(winSize.width / 2, winSize.height - 30); - hudMenu.addChild(menuLabel); - } - - // just to avoid GC - hudMenu.items = [item1, item2, item3]; - return hudMenu; -}; - -playCurrentScene(); diff --git a/samples/TestJavascript/Resources/oldjs/1to1/test_require.js b/samples/TestJavascript/Resources/oldjs/1to1/test_require.js deleted file mode 100644 index 5df5ec7589..0000000000 --- a/samples/TestJavascript/Resources/oldjs/1to1/test_require.js +++ /dev/null @@ -1,3 +0,0 @@ -require("JS/1to1/test_require_second.js"); - -cc.log("value: " + value); diff --git a/samples/TestJavascript/Resources/oldjs/1to1/test_require_second.js b/samples/TestJavascript/Resources/oldjs/1to1/test_require_second.js deleted file mode 100644 index eeb76c56ab..0000000000 --- a/samples/TestJavascript/Resources/oldjs/1to1/test_require_second.js +++ /dev/null @@ -1 +0,0 @@ -value = "this was set in another file"; diff --git a/samples/TestJavascript/Resources/oldjs/1to1/test_sound.js b/samples/TestJavascript/Resources/oldjs/1to1/test_sound.js deleted file mode 100644 index 73442135c8..0000000000 --- a/samples/TestJavascript/Resources/oldjs/1to1/test_sound.js +++ /dev/null @@ -1,166 +0,0 @@ -/* - * showcasing sound - */ - -/** - * simple wrappers - */ -cc.Point.create = function (x, y) { - var pt = new cc.Point(); - pt.x = x; - pt.y = y; - return pt; -}; - -cc.Size.create = function (w, h) { - var sz = new cc.Size(); - sz.width = w; - sz.height = h; - return sz; -}; - -cc.Sprite.create = function (file) { - var s = new cc.Sprite(); - s.initWithFile(file); - return s; -}; - -var pointZero = cc.Point.create(0, 0); -var sizeZero = cc.Size.create(0, 0); - -var director = cc.Director.sharedDirector(); -var winSize = director.winSize; - -var scenes = {}; -scenes.currentScene = 1; - -/** - * tests the most basic function: moveTo and moveBy - */ -scenes['test_move'] = function () { - var audioEngine = cc.SimpleAudioEngine.sharedEngine(); - audioEngine.preloadBackgroundMusic("Silly Fun Theme A.mp3"); - audioEngine.preloadEffect("ballbounce.wav"); - - var layer = new cc.Layer(); layer.init(); - layer.isTouchEnabled = true; - layer.ccTouchesBegan = function (touches) { - for (var i in touches) { - // no loop - audioEngine.playEffect("ballbounce.wav", false); - } - }; - - var scene = new cc.Scene(); scene.init(); - scene.addChild(layer); - - // add the menu - var menu = createMenu("Test Sounds - Touch for SFX"); - scene.addChild(menu, 1); - - // play the bg music - loop - audioEngine.playBackgroundMusic("Silly Fun Theme A.mp3", true); - return scene; -}; - -/** - * from here on there's code that can be shared between different tests - * basically is the hud and the scene handling - */ - -// changes to the next scene -var nextScene = function () { - var l = Object.keys(scenes).length; - scenes.currentScene = (scenes.currentScene + 1) % l; - if (scenes.currentScene === 0) { - scenes.currentScene = 1; - } - playCurrentScene(); -}; - -// changes to the previous scene -var prevScene = function () { - var l = Object.keys(scenes).length; - scenes.currentScene -= 1; - if (scenes.currentScene < 1) { - scenes.currentScene = l - 1; - } - playCurrentScene(); -}; - -var playCurrentScene = function () { - var name = Object.keys(scenes)[scenes.currentScene]; - var scene = scenes[name](); - // cc.log("running scene: " + name + "(" + scene + ")"); - if (director.runningScene === null) { - director.runWithScene(scene); - } else { - director.replaceScene(scene); - } -}; - -// creates the hud -var createMenu = function (labelText) { - var hudMenu = new cc.Menu(); - hudMenu.init(); - - var b1 = new cc.Sprite(); b1.initWithFile("b1.png"); - var b2 = new cc.Sprite(); b2.initWithFile("b2.png"); - item1 = new cc.MenuItemSprite(); - item1.initWithNormalSprite(b1, b2); - item1.action = function () { - prevScene(); - }; - - var r1 = new cc.Sprite(); r1.initWithFile("r1.png"); - var r2 = new cc.Sprite(); r2.initWithFile("r2.png"); - item2 = new cc.MenuItemSprite(); - item2.initWithNormalSprite(r1, r2); - item2.action = function () { - // cc.executeScript("JS/1to1/test_actions.js"); - playCurrentScene(); - }; - - var f1 = new cc.Sprite(); f1.initWithFile("f1.png"); - var f2 = new cc.Sprite(); f2.initWithFile("f2.png"); - item3 = new cc.MenuItemSprite(); - item3.initWithNormalSprite(f1, f2); - item3.action = function () { - nextScene(); - }; - - var c1 = new cc.Sprite(); c1.initWithFile("r1.png"); - var c2 = new cc.Sprite(); c2.initWithFile("r2.png"); - item4 = new cc.MenuItemSprite(); - item4.initWithNormalSprite(c1, c2); - item4.action = function () { - cc.executeScript("JS/1to1/test_actions.js"); - }; - - item1.position = cc.Point.create(winSize.width / 2 - 100, 30); - item2.position = cc.Point.create(winSize.width / 2 , 30); - item3.position = cc.Point.create(winSize.width / 2 + 100, 30); - item4.position = cc.Point.create(30, winSize.height - 30); - - hudMenu.addChild(item1); - hudMenu.addChild(item2); - hudMenu.addChild(item3); - hudMenu.addChild(item4); - hudMenu.position = pointZero; - - if (labelText) { - var label = new cc.LabelTTF(); - // initWithString: text, size, alignment, font, fontSize - label.initWithString(labelText, sizeZero, 0, "Arial", 18.0); - var menuLabel = new cc.MenuItemLabel(); - menuLabel.initWithLabel(label); - menuLabel.position = cc.Point.create(winSize.width / 2, winSize.height - 30); - hudMenu.addChild(menuLabel); - } - - // just to avoid GC - hudMenu.items = [item1, item2, item3]; - return hudMenu; -}; - -playCurrentScene(); diff --git a/samples/TestJavascript/Resources/oldjs/1to1/test_transitions.js b/samples/TestJavascript/Resources/oldjs/1to1/test_transitions.js deleted file mode 100644 index e84c630a96..0000000000 --- a/samples/TestJavascript/Resources/oldjs/1to1/test_transitions.js +++ /dev/null @@ -1,171 +0,0 @@ -/* - * showcasing transitions - */ - -/** - * simple wrappers - */ -cc.Point.create = function (x, y) { - var pt = new cc.Point(); - pt.x = x; - pt.y = y; - return pt; -}; - -cc.Size.create = function (w, h) { - var sz = new cc.Size(); - sz.width = w; - sz.height = h; - return sz; -}; - -cc.Sprite.create = function (file) { - var s = new cc.Sprite(); - s.initWithFile(file); - return s; -}; - -var pointZero = cc.Point.create(0, 0); -var sizeZero = cc.Size.create(0, 0); - -var director = cc.Director.sharedDirector(); -var winSize = director.winSize; - -var scenes = {}; -scenes.currentScene = 1; - -/** - * tests the most basic function: moveTo and moveBy - */ -scenes['test_roto_zoom'] = function () { - var s1 = new cc.Sprite.create("grossini_dance_05.png"); - s1.position = cc.Point.create(winSize.width / 2 + 50, winSize.height / 2); - var s2 = new cc.Sprite.create("grossinis_sister1.png"); - s2.position = cc.Point.create(winSize.width / 2 - 50, winSize.height / 2); - - var moveTo = new cc.MoveTo(); - moveTo.initWithDuration(2.0, cc.Point.create(winSize.width, winSize.height / 2)); - var moveBy = new cc.MoveBy(); - moveBy.initWithDuration(2.0, cc.Point.create(100, 100)); - - s1.runAction(moveTo); - s2.runAction(moveBy); - - var scene = new cc.Scene(); scene.init(); - scene.addChild(s1); - scene.addChild(s2); - - // add the menu - var menu = createMenu("Test Roto Zoom"); - scene.addChild(menu, 1); - - var current = director.runningScene; - if (current) { - var transition = cc.TransitionRotoZoom.transitionWithDuration(1.5, scene); - return transition; - } - - return scene; -}; - -/** - * from here on there's code that can be shared between different tests - * basically is the hud and the scene handling - */ - -// changes to the next scene -var nextScene = function () { - var l = Object.keys(scenes).length; - scenes.currentScene = (scenes.currentScene + 1) % l; - if (scenes.currentScene === 0) { - scenes.currentScene = 1; - } - playCurrentScene(); -}; - -// changes to the previous scene -var prevScene = function () { - var l = Object.keys(scenes).length; - scenes.currentScene -= 1; - if (scenes.currentScene < 1) { - scenes.currentScene = l - 1; - } - playCurrentScene(); -}; - -var playCurrentScene = function () { - var name = Object.keys(scenes)[scenes.currentScene]; - var scene = scenes[name](); - // cc.log("running scene: " + name + "(" + scene + ")"); - if (director.runningScene === null) { - director.runWithScene(scene); - } else { - director.replaceScene(scene); - } -}; - -// creates the hud -var createMenu = function (labelText) { - var hudMenu = new cc.Menu(); - hudMenu.init(); - - var b1 = new cc.Sprite(); b1.initWithFile("b1.png"); - var b2 = new cc.Sprite(); b2.initWithFile("b2.png"); - item1 = new cc.MenuItemSprite(); - item1.initWithNormalSprite(b1, b2); - item1.action = function () { - prevScene(); - }; - - var r1 = new cc.Sprite(); r1.initWithFile("r1.png"); - var r2 = new cc.Sprite(); r2.initWithFile("r2.png"); - item2 = new cc.MenuItemSprite(); - item2.initWithNormalSprite(r1, r2); - item2.action = function () { - // cc.executeScript("JS/1to1/test_actions.js"); - playCurrentScene(); - }; - - var f1 = new cc.Sprite(); f1.initWithFile("f1.png"); - var f2 = new cc.Sprite(); f2.initWithFile("f2.png"); - item3 = new cc.MenuItemSprite(); - item3.initWithNormalSprite(f1, f2); - item3.action = function () { - nextScene(); - }; - - var c1 = new cc.Sprite(); c1.initWithFile("r1.png"); - var c2 = new cc.Sprite(); c2.initWithFile("r2.png"); - item4 = new cc.MenuItemSprite(); - item4.initWithNormalSprite(c1, c2); - item4.action = function () { - cc.executeScript("JS/1to1/test_actions.js"); - }; - - item1.position = cc.Point.create(winSize.width / 2 - 100, 30); - item2.position = cc.Point.create(winSize.width / 2 , 30); - item3.position = cc.Point.create(winSize.width / 2 + 100, 30); - item4.position = cc.Point.create(30, winSize.height - 30); - - hudMenu.addChild(item1); - hudMenu.addChild(item2); - hudMenu.addChild(item3); - hudMenu.addChild(item4); - hudMenu.position = pointZero; - - if (labelText) { - var label = new cc.LabelTTF(); - // initWithString: text, size, alignment, font, fontSize - label.initWithString(labelText, sizeZero, 0, "Arial", 18.0); - var menuLabel = new cc.MenuItemLabel(); - menuLabel.initWithLabel(label); - menuLabel.position = cc.Point.create(winSize.width / 2, winSize.height - 30); - hudMenu.addChild(menuLabel); - } - - // just to avoid GC - hudMenu.items = [item1, item2, item3]; - return hudMenu; -}; - -playCurrentScene(); diff --git a/samples/TestJavascript/Resources/oldjs/jorendb.js b/samples/TestJavascript/Resources/oldjs/jorendb.js deleted file mode 100644 index 813d360980..0000000000 --- a/samples/TestJavascript/Resources/oldjs/jorendb.js +++ /dev/null @@ -1,517 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=8 sw=4 et tw=78: - * - * jorendb - A toy command-line debugger for shell-js programs. - * - * ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is jorendb toy JS debugger. - * - * The Initial Developer of the Original Code is - * Mozilla Foundation. - * Portions created by the Initial Developer are Copyright (C) 2011 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Jason Orendorff - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* - * jorendb is a simple command-line debugger for shell-js programs. It is - * intended as a demo of the Debugger object (as there are no shell js programs - * to speak of). - * - * To run it: $JS -d path/to/this/file/jorendb.js - * To run some JS code under it, try: - * (jorendb) print load("my-script-to-debug.js") - * Execution will stop at debugger statements and you'll get a jorendb prompt. - */ - -// Debugger state. -var focusedFrame = null; -var topFrame = null; -var debuggeeValues = [null]; -var lastExc = null; - -// Cleanup functions to run when we next re-enter the repl. -var replCleanups = []; - -// Convert a debuggee value v to a string. -function dvToString(v) { - return (typeof v !== 'object' || v === null) ? uneval(v) : "[object " + v.class + "]"; -} - -function showDebuggeeValue(dv) { - var dvrepr = dvToString(dv); - var i = debuggeeValues.length; - debuggeeValues[i] = dv; - print("$" + i + " = " + dvrepr); -} - -Object.defineProperty(Debugger.Frame.prototype, "num", { - configurable: true, - enumerable: false, - get: function () { - var i = 0; - for (var f = topFrame; f && f !== this; f = f.older) - i++; - return f === null ? undefined : i; - } - }); - -Debugger.Frame.prototype.frameDescription = function frameDescription() { - if (this.type == "call") - return ((this.callee.name || '') + - "(" + this.arguments.map(dvToString).join(", ") + ")"); - else - return this.type + " code"; -} - -Debugger.Frame.prototype.positionDescription = function positionDescription() { - if (this.script) { - var line = this.script.getOffsetLine(this.offset); - if (this.script.url) - return this.script.url + ":" + line; - return "line " + line; - } - return null; -} - -Debugger.Frame.prototype.fullDescription = function fullDescription() { - var fr = this.frameDescription(); - var pos = this.positionDescription(); - if (pos) - return fr + ", " + pos; - return fr; -} - -Object.defineProperty(Debugger.Frame.prototype, "line", { - configurable: true, - enumerable: false, - get: function() { - if (this.script) - return this.script.getOffsetLine(this.offset); - else - return null; - } - }); - -function callDescription(f) { - return ((f.callee.name || '') + - "(" + f.arguments.map(dvToString).join(", ") + ")"); -} - -function showFrame(f, n) { - if (f === undefined || f === null) { - f = focusedFrame; - if (f === null) { - print("No stack."); - return; - } - } - if (n === undefined) { - n = f.num; - if (n === undefined) - throw new Error("Internal error: frame not on stack"); - } - - print('#' + n + " " + f.fullDescription()); -} - -function saveExcursion(fn) { - var tf = topFrame, ff = focusedFrame; - try { - return fn(); - } finally { - topFrame = tf; - focusedFrame = ff; - } -} - -function quitCommand() { - dbg.enabled = false; - quit(0); -} - -function backtraceCommand() { - if (topFrame === null) - print("No stack."); - for (var i = 0, f = topFrame; f; i++, f = f.older) - showFrame(f, i); -} - -function printCommand(rest) { - if (focusedFrame === null) { - // This is super bogus, need a way to create an env wrapping the debuggeeGlobal - // and eval against that. - var nonwrappedValue; - try { - nonwrappedValue = debuggeeGlobal.eval(rest); - } catch (exc) { - print("Exception caught."); - nonwrappedValue = exc; - } - if (typeof nonwrappedValue !== "object" || nonwrappedValue === null) { - // primitive value, no sweat - print(" " + uneval(nonwrappedValue)); - } else { - // junk for now - print(" " + Object.prototype.toString.call(nonwrappedValue)); - } - } else { - // This is the real deal. - var cv = saveExcursion(function () { - return focusedFrame.eval(rest); - }); - if (cv === null) { - if (!dbg.enabled) - return [cv]; - print("Debuggee died."); - } else if ('return' in cv) { - if (!dbg.enabled) - return [undefined]; - showDebuggeeValue(cv.return); - } else { - if (!dbg.enabled) - return [cv]; - print("Exception caught. (To rethrow it, type 'throw'.)"); - lastExc = cv.throw; - showDebuggeeValue(lastExc); - } - } -} - -function detachCommand() { - dbg.enabled = false; - return [undefined]; -} - -function continueCommand() { - if (focusedFrame === null) { - print("No stack."); - return; - } - return [undefined]; -} - -function throwCommand(rest) { - var v; - if (focusedFrame !== topFrame) { - print("To throw, you must select the newest frame (use 'frame 0')."); - return; - } else if (focusedFrame === null) { - print("No stack."); - return; - } else if (rest === '') { - return [{throw: lastExc}]; - } else { - var cv = saveExcursion(function () { return focusedFrame.eval(rest); }); - if (cv === null) { - if (!dbg.enabled) - return [cv]; - print("Debuggee died while determining what to throw. Stopped."); - } else if ('return' in cv) { - return [{throw: cv.return}]; - } else { - if (!dbg.enabled) - return [cv]; - print("Exception determining what to throw. Stopped."); - showDebuggeeValue(cv.throw); - } - return; - } -} - -function frameCommand(rest) { - var n, f; - if (rest.match(/[0-9]+/)) { - n = +rest; - f = topFrame; - if (f === null) { - print("No stack."); - return; - } - for (var i = 0; i < n && f; i++) { - if (!f.older) { - print("There is no frame " + rest + "."); - return; - } - f.older.younger = f; - f = f.older; - } - focusedFrame = f; - showFrame(f, n); - } else if (rest !== '') { - if (topFrame === null) - print("No stack."); - else - showFrame(); - } else { - print("do what now?"); - } -} - -function upCommand() { - if (focusedFrame === null) - print("No stack."); - else if (focusedFrame.older === null) - print("Initial frame selected; you cannot go up."); - else { - focusedFrame.older.younger = focusedFrame; - focusedFrame = focusedFrame.older; - showFrame(); - } -} - -function downCommand() { - if (focusedFrame === null) - print("No stack."); - else if (!focusedFrame.younger) - print("Youngest frame selected; you cannot go down."); - else { - focusedFrame = focusedFrame.younger; - showFrame(); - } -} - -function forcereturnCommand(rest) { - var v; - var f = focusedFrame; - if (f !== topFrame) { - print("To forcereturn, you must select the newest frame (use 'frame 0')."); - } else if (f === null) { - print("Nothing on the stack."); - } else if (rest === '') { - return [{return: undefined}]; - } else { - var cv = saveExcursion(function () { return f.eval(rest); }); - if (cv === null) { - if (!dbg.enabled) - return [cv]; - print("Debuggee died while determining what to forcereturn. Stopped."); - } else if ('return' in cv) { - return [{return: cv.return}]; - } else { - if (!dbg.enabled) - return [cv]; - print("Error determining what to forcereturn. Stopped."); - showDebuggeeValue(cv.throw); - } - } -} - -function printPop(f, c) { - var fdesc = f.fullDescription(); - if (c.return) { - print("frame returning (still selected): " + fdesc); - showDebuggeeValue(c.return); - } else if (c.throw) { - print("frame threw exception: " + fdesc); - showDebuggeeValue(c.throw); - print("(To rethrow it, type 'throw'.)"); - lastExc = c.throw; - } else { - print("frame was terminated: " + fdesc); - } -} - -// Set |prop| on |obj| to |value|, but then restore its current value -// when we next enter the repl. -function setUntilRepl(obj, prop, value) { - var saved = obj[prop]; - obj[prop] = value; - replCleanups.push(function () { obj[prop] = saved; }); -} - -function doStepOrNext(kind) { - var startFrame = topFrame; - var startLine = startFrame.line; - print("stepping in: " + startFrame.fullDescription()); - print("starting line: " + uneval(startLine)); - - function stepPopped(completion) { - // Note that we're popping this frame; we need to watch for - // subsequent step events on its caller. - this.reportedPop = true; - printPop(this, completion); - topFrame = focusedFrame = this; - return repl(); - } - - function stepEntered(newFrame) { - print("entered frame: " + newFrame.fullDescription()); - topFrame = focusedFrame = newFrame; - return repl(); - } - - function stepStepped() { - print("stepStepped: " + this.fullDescription()); - // If we've changed frame or line, then report that. - if (this !== startFrame || this.line != startLine) { - topFrame = focusedFrame = this; - if (focusedFrame != startFrame) - print(focusedFrame.fullDescription()); - return repl(); - } - - // Otherwise, let execution continue. - return undefined; - } - - if (kind.step) - setUntilRepl(dbg, 'onEnterFrame', stepEntered); - - // If we're stepping after an onPop, watch for steps and pops in the - // next-older frame; this one is done. - var stepFrame = startFrame.reportedPop ? startFrame.older : startFrame; - if (!stepFrame || !stepFrame.script) - stepFrame = null; - if (stepFrame) { - setUntilRepl(stepFrame, 'onStep', stepStepped); - setUntilRepl(stepFrame, 'onPop', stepPopped); - } - - // Let the program continue! - return [undefined]; -} - -function stepCommand() { return doStepOrNext({step:true}); } -function nextCommand() { return doStepOrNext({next:true}); } - -// Build the table of commands. -var commands = {}; -var commandArray = [ - backtraceCommand, "bt", "where", - continueCommand, "c", - detachCommand, - downCommand, "d", - forcereturnCommand, - frameCommand, "f", - nextCommand, "n", - printCommand, "p", - quitCommand, "q", - stepCommand, "s", - throwCommand, "t", - upCommand, "u" - ]; -var last = null; -for (var i = 0; i < commandArray.length; i++) { - var cmd = commandArray[i]; - if (typeof cmd === "string") - commands[cmd] = last; - else - last = commands[cmd.name.replace(/Command$/, '')] = cmd; -} - -// Break cmd into two parts: its first word and everything else. -function breakcmd(cmd) { - cmd = cmd.trimLeft(); - var m = /\s/.exec(cmd); - if (m === null) - return [cmd, '']; - return [cmd.slice(0, m.index), cmd.slice(m.index).trimLeft()]; -} - -function runcmd(cmd) { - var pieces = breakcmd(cmd); - if (pieces[0] === "") - return undefined; - - var first = pieces[0], rest = pieces[1]; - if (!commands.hasOwnProperty(first)) { - print("unrecognized command '" + first + "'"); - return undefined; - } - - var cmd = commands[first]; - if (cmd.length === 0 && rest !== '') { - print("this command cannot take an argument"); - return undefined; - } - - return cmd(rest); -} - -function repl() { - while (replCleanups.length > 0) - replCleanups.pop()(); - - var cmd; - for (;;) { - print("\n" + prompt); - cmd = readline(); - if (cmd === null) - return null; - - try { - var result = runcmd(cmd); - if (result === undefined) - ; // do nothing - else if (Array.isArray(result)) - return result[0]; - else - throw new Error("Internal error: result of runcmd wasn't array or undefined"); - } catch (exc) { - print("*** Internal error: exception in the debugger code."); - print(" " + exc); - print(exc.stack); - } - } -} - -var dbg = new Debugger(); -dbg.onDebuggerStatement = function (frame) { - return saveExcursion(function () { - topFrame = focusedFrame = frame; - print("'debugger' statement hit."); - showFrame(); - return repl(); - }); -}; -dbg.onThrow = function (frame, exc) { - return saveExcursion(function () { - topFrame = focusedFrame = frame; - print("Unwinding due to exception. (Type 'c' to continue unwinding.)"); - showFrame(); - print("Exception value is:"); - showDebuggeeValue(exc); - return repl(); - }); -}; - -// The depth of jorendb nesting. -var jorendbDepth; -if (typeof jorendbDepth == 'undefined') jorendbDepth = 0; - -var debuggeeGlobal = newGlobal("new-compartment"); -debuggeeGlobal.jorendbDepth = jorendbDepth + 1; -dbg.addDebuggee(debuggeeGlobal); - -print("jorendb version -0.0"); -prompt = '(' + Array(jorendbDepth+1).join('meta-') + 'jorendb)'; -print("Prompt is " + prompt); -repl(); diff --git a/samples/TestJavascript/Resources/oldjs/main.js b/samples/TestJavascript/Resources/oldjs/main.js deleted file mode 100644 index 61e6fa516b..0000000000 --- a/samples/TestJavascript/Resources/oldjs/main.js +++ /dev/null @@ -1,125 +0,0 @@ -cc.log("welcome to cocos2d-x-javascript"); - -var Test = function () { -}; -Test.prototype.assertNum = 0; -Test.prototype.assertEqual = function (expr, target, str) { - this.assertNum++; - str = str || ""; - if (expr != target) { - throw "assert failed: " + str + " (" + expr + ")"; - } -}; -Test.prototype.assertFloatEqual = function (num1, target, str) { - this.assertNum++; - str = str || ""; - if (Math.abs(num1 - target) > 0.000001) { - throw "assert failed: " + str + " (" + expr + ")"; - } -}; -Test.prototype.setup = function () {}; -Test.prototype.run = function () { - cc.log("Test started"); - var ok = 0, fail = 0, failed = []; - for (var key in this) { - if (key.match(/^test/)) { - try { - this[key](); - ok++; - } catch (e) { - failed.push(this.assertNum + ": " + e); - fail++; - } - } - } - cc.log("total asserts: " + this.assertNum); - cc.log("tests [ok]: " + ok); - cc.log("tests [fail]: " + fail); - cc.log(failed.join("\n")); -}; - -var GeometryTest = function () { -}; -GeometryTest.prototype = Object.create(Test.prototype); - -GeometryTest.prototype.test_point1 = function () { - var pt = new cc.Point(); - this.assertEqual(pt.x, 0, "pt.x == 0"); - this.assertEqual(pt.y, 0, "pt.y == 0"); - - pt.x = 0.5; - pt.y = 13.37; - this.assertFloatEqual(pt.x, 0.5, "pt.x == 0.5"); - this.assertFloatEqual(pt.y, 13.37, "pt.y == 13.37"); -}; - -GeometryTest.prototype.test_point2 = function () { - var pt1 = new cc.Point(); - var pt2 = new cc.Point(); - pt1.x = 100.50; - pt2.y = 99; - pt1.y = pt1.x + pt2.y; - this.assertFloatEqual(pt1.y, 100.50 + 99, "pt1.y == 100.50 + 99"); -}; - -GeometryTest.prototype.test_size1 = function () { - var sz1 = new cc.Size(); - this.assertEqual(sz1.width, 0, "sz1.width == 0"); - this.assertEqual(sz1.height, 0, "sz1.height == 0"); - - sz1.width = 99.2323; - sz1.height = 13.3700; - this.assertFloatEqual(sz1.width, 99.2323, "sz1.width == 99.2323"); - this.assertFloatEqual(sz1.height, 13.3700, "sz1.height == 13.3700"); -}; - -GeometryTest.prototype.test_rect1 = function () { - var rect = new cc.Rect(); - var orig = rect.origin; - this.assertEqual(orig.x, 0, "orig.x == 0"); - this.assertEqual(orig.y, 0, "orig.y == 0"); - orig.x = 51343.034; - - var orig2 = rect.origin; - this.assertFloatEqual(orig2.x, orig.x, "orig2.x == orig.x"); -}; - -GeometryTest.prototype.test_rect2 = function () { - var rect1 = new cc.Rect(); - var rect2 = new cc.Rect(); - var pt1 = new cc.Point(); - var pt2 = rect1.origin; - - pt2.x = 500; pt2.y = 900; - this.assertEqual(pt2.x, 500, "pt2.x == 500"); - this.assertEqual(pt2.y, 900, "pt2.y == 900"); - - pt1.x = 13.37; pt1.y = 13.13; - rect2.origin = pt1; - pt2 = rect2.origin; - - this.assertFloatEqual(pt2.x, 13.37, "pt2.x == 13.37"); - this.assertFloatEqual(pt2.y, 13.13, "pt2.y == 13.13"); -}; - -test = new GeometryTest(); -test.run(); - -// small performance test - -var totalIter = 10000; -var rect = new cc.Rect(); -var pt = new cc.Point(); -var sum; - -sum = 0; -for (var i=0; i < totalIter; i++) { - pt.x = i; - var startTime = Date.now(); - rect.origin = pt; - var endTime = Date.now(); - sum += (endTime - startTime) / 1000.0; -} -cc.log(totalIter + "\t" + sum); - -cc.log("END OF TEST"); diff --git a/samples/TestJavascript/Resources/oldjs/oa-benchmark.js b/samples/TestJavascript/Resources/oldjs/oa-benchmark.js deleted file mode 100644 index 28438b7591..0000000000 --- a/samples/TestJavascript/Resources/oldjs/oa-benchmark.js +++ /dev/null @@ -1,121 +0,0 @@ -/** - * trying to use the same benchmark that the guys from OA used: - * http://openaphid.github.com/blog/2012/02/20/javascript-and-cocos2d-a-sneak-peek/ - */ - -// taken from goog.inherits -cc.inherits = function(childCtor, parentCtor) { - /** @constructor */ - function tempCtor() {}; - tempCtor.prototype = parentCtor.prototype; - childCtor.superClass_ = parentCtor.prototype; - childCtor.prototype = new tempCtor(); - childCtor.prototype.constructor = childCtor; -}; - -var scene = new cc.Scene(); -scene.init(); -var background = new cc.Sprite(); -background.initWithFile("background.png"); -scene.addChild(background); - -var spriteFrameCache = cc.SpriteFrameCache.sharedSpriteFrameCache(); -spriteFrameCache.addSpriteFramesWithFile("tank.plist"); - -// wrapper around CCSprite -var Tank = function () { - var sprite = new cc.Sprite(); - sprite.initWithSpriteFrameName("tank1.png"); - - var pos = new cc.Point(); - pos.x = Math.random() * 320; - pos.y = Math.random() * 480; - sprite.position = pos; - sprite.vx = Math.random() > 0.5 ? 100 : -100; - sprite.vy = Math.random() > 0.5 ? 100 : -100; - sprite.scheduleUpdate(); - sprite.update = function (delta) { - var p = this.position; - p.x += delta * this.vx; - p.y += delta * this.vy; - //set the new position - this.position = p; - - //make sure tank is inside the screen - if (p.x < 0) { - p.x = 0; - this.vx = -this.vx; - } - - if (p.x > 320) { - p.x = 320; - this.vx = -this.vx; - } - - if (p.y < 0) { - p.y = 0; - this.vy = -this.vy; - } - - if (p.y > 480) { - p.y = 480; - this.vy = -this.vy; - } - }; - - this.sprite = sprite; -}; - -// create animation -var frames = ["tank1.png", "tank2.png", "tank3.png", "tank4.png", "tank5.png"]; -var animation = new cc.Animation(); -animation.init(); -animation.delay = 0.1; -for (var i=0; i < frames.length; i++) { - var frame = spriteFrameCache.spriteFrameByName(frames[i]); - animation.addFrame(frame); -} - -// do the fun -// global array to prevent GC -var tanks = new Array(100); -for (var i=0; i < tanks.length; i++) { - var tank = new Tank(); - tank.tankId = i; - scene.addChild(tank.sprite); - if (i === 0) { - // this is not working correctly (only on ccnodes) - tank.sprite.onEnter = function () { - cc.log("on enter"); - }; - } - - // second argument false by default - tank.action = new cc.Animate(); - tank.action.initWithAnimation(animation); - tank.repeat = new cc.RepeatForever(); - tank.repeat.initWithAction(tank.action); - tank.sprite.runAction(tank.repeat); - - tanks[i] = tank; -} - -var layer = new cc.Layer(); -layer.onEnter = function () { - cc.log("layer enter"); -}; -layer.isTouchEnabled = true; -layer.ccTouchBegan = function (touch) { - var point = touch.locationInView(); - cc.log("cc touch: " + point.x + "," + point.y); -}; -layer.ccTouchesBegan = function (touches) { - for (var i=0; i < touches.length; i++) { - var point = touches[i].locationInView(); - cc.log("cc touches: " + point.x + "," + point.y); - } -}; -scene.addChild(layer); - -var director = cc.Director.sharedDirector(); -director.runWithScene(scene); diff --git a/samples/TestJavascript/Resources/oldjs/test-nodes.js b/samples/TestJavascript/Resources/oldjs/test-nodes.js deleted file mode 100644 index 17fd3395d0..0000000000 --- a/samples/TestJavascript/Resources/oldjs/test-nodes.js +++ /dev/null @@ -1,55 +0,0 @@ -var director = cc.Director.sharedDirector(); -var scene = new cc.Scene(); -scene.init(); - -// our test sprite -var sprite = new cc.Sprite(); -sprite.initWithFile("Icon.png"); -var pt = new cc.Point(); -pt.x = 160; -pt.y = 240; -sprite.position = pt; - -// will call "update" every frame if there's an update property -//sprite.scheduleUpdate(); -sprite.speed = new cc.Point(); -sprite.speed.x = Math.random() * 10 - 5; -sprite.speed.y = Math.random() * 10 - 5; - -// the actual update function -sprite.update = function () { - var curPos = this.position; - curPos.x += this.speed.x; - curPos.y += this.speed.y; - this.position = curPos; - if (curPos.x >= 320 || curPos.x <= 0) this.speed.x *= -1; - if (curPos.y >= 480 || curPos.y <= 0) this.speed.y *= -1; -}; - -// adds the sprite to the scene -scene.addChild(sprite); - -// add a menu -var item = new cc.MenuItemImage();//Sprite(); -//var normal = new cc.Sprite(); normal.initWithFile("CloseNormal.png"); -//var selected = new cc.Sprite(); selected.initWithFile("CloseSelected.png"); -//item.initWithNormalSprite(normal, selected); -item.initFromNormalImage("CloseNormal.png", "CloseSelected.png"); -item.action = function () { - cc.log("action"); -}; -cc.log("normal image: " + item.normalImage); -pt.x = 20; -pt.y = 20; -item.position = pt; -var menu = new cc.Menu(); -menu.init(); -menu.addChild(item); - -pt.x = 0; -pt.y = 0; -menu.position = pt; -scene.addChild(menu, 1); - -// let the games begin -director.runWithScene(scene); From 2e8aad611dd9060a1ab114a8aa5bc7eca4ce8252 Mon Sep 17 00:00:00 2001 From: folecr Date: Thu, 11 Oct 2012 13:49:33 -0700 Subject: [PATCH 03/16] Run tests-boot-jsb.js from the root directory --- samples/TestJavascript/Classes/AppDelegate.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/TestJavascript/Classes/AppDelegate.cpp b/samples/TestJavascript/Classes/AppDelegate.cpp index 21b7b00104..354a9db101 100644 --- a/samples/TestJavascript/Classes/AppDelegate.cpp +++ b/samples/TestJavascript/Classes/AppDelegate.cpp @@ -44,7 +44,7 @@ bool AppDelegate::applicationDidFinishLaunching() CCScriptEngineProtocol *pEngine = ScriptingCore::getInstance(); CCScriptEngineManager::sharedManager()->setScriptEngine(pEngine); - ScriptingCore::getInstance()->runScript("js/main.js"); + ScriptingCore::getInstance()->runScript("tests-boot-jsb.js"); return true; } From c63cf5425648bb8adabd236867b1ce38a7f12539 Mon Sep 17 00:00:00 2001 From: folecr Date: Thu, 11 Oct 2012 16:37:22 -0700 Subject: [PATCH 04/16] Submodule for cocos2d-html5-tests --- .gitmodules | 3 +++ samples/TestJavascript/cocos2d-html5-tests | 1 + 2 files changed, 4 insertions(+) create mode 160000 samples/TestJavascript/cocos2d-html5-tests diff --git a/.gitmodules b/.gitmodules index 165d817134..fdc2613f10 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,3 +4,6 @@ [submodule "scripting/javascript/bindings/generated"] path = scripting/javascript/bindings/generated url = git://github.com/folecr/cocos2dx-autogen-bindings.git +[submodule "samples/TestJavascript/cocos2d-html5-tests"] + path = samples/TestJavascript/cocos2d-html5-tests + url = https://github.com/cocos2d/cocos2d-html5-tests.git diff --git a/samples/TestJavascript/cocos2d-html5-tests b/samples/TestJavascript/cocos2d-html5-tests new file mode 160000 index 0000000000..ba897b31b3 --- /dev/null +++ b/samples/TestJavascript/cocos2d-html5-tests @@ -0,0 +1 @@ +Subproject commit ba897b31b3175afdfb88cd52f24cc7520fb9cf0b From 336af23428bd5a32b0b677fa645ce6e590be9c6c Mon Sep 17 00:00:00 2001 From: folecr Date: Thu, 11 Oct 2012 16:57:13 -0700 Subject: [PATCH 05/16] Helper files copied from cocos2d-iphone --- .../TestJavascript/bindings/jsb_constants.js | 9 + .../bindings/jsb_constants_chipmunk.js | 253 +++++++++++++ .../bindings/jsb_constants_cocos2d.js | 339 ++++++++++++++++++ .../bindings/jsb_constants_cocosbuilder.js | 118 ++++++ .../bindings/jsb_constants_gl.js | 23 ++ 5 files changed, 742 insertions(+) create mode 100644 samples/TestJavascript/bindings/jsb_constants.js create mode 100644 samples/TestJavascript/bindings/jsb_constants_chipmunk.js create mode 100644 samples/TestJavascript/bindings/jsb_constants_cocos2d.js create mode 100644 samples/TestJavascript/bindings/jsb_constants_cocosbuilder.js create mode 100644 samples/TestJavascript/bindings/jsb_constants_gl.js diff --git a/samples/TestJavascript/bindings/jsb_constants.js b/samples/TestJavascript/bindings/jsb_constants.js new file mode 100644 index 0000000000..7aa0419617 --- /dev/null +++ b/samples/TestJavascript/bindings/jsb_constants.js @@ -0,0 +1,9 @@ +// +// Javascript Bindigns helper file +// + +// DO NOT ALTER THE ORDER +require('jsb_constants_cocos2d.js'); +require('jsb_constants_chipmunk.js'); +require('jsb_constants_gl.js'); +require('jsb_constants_cocosbuilder.js'); diff --git a/samples/TestJavascript/bindings/jsb_constants_chipmunk.js b/samples/TestJavascript/bindings/jsb_constants_chipmunk.js new file mode 100644 index 0000000000..724c6afa36 --- /dev/null +++ b/samples/TestJavascript/bindings/jsb_constants_chipmunk.js @@ -0,0 +1,253 @@ +// +// Chipmunk defines +// + +cp.v = cc.p; +cp._v = cc._p; +cp.vzero = cp.v(0,0); + +// Vector: Compatibility with Chipmunk-JS +cp.v.add = cp.vadd; +cp.v.clamp = cp.vclamp; +cp.v.cross = cp.vcross; +cp.v.dist = cp.vdist; +cp.v.distsq = cp.vdistsq; +cp.v.dot = cp.vdot; +cp.v.eql = cp.veql; +cp.v.forangle = cp.vforangle; +cp.v.len = cp.vlength; +cp.v.lengthsq = cp.vlengthsq; +cp.v.lerp = cp.vlerp; +cp.v.lerpconst = cp.vlerpconst; +cp.v.mult = cp.vmult; +cp.v.near = cp.vnear; +cp.v.neg = cp.vneg; +cp.v.normalize = cp.vnormalize; +cp.v.normalize_safe = cp.vnormalize_safe; +cp.v.perp = cp.vperp; +cp.v.project = cp.vproject; +cp.v.rotate = cp.vrotate; +cp.v.rperp = cp.vrperp; +cp.v.slerp = cp.vslerp; +cp.v.slerpconst = cp.vslerpconst; +cp.v.sub = cp.vsub; +cp.v.toangle = cp.vtoangle; +cp.v.unrotate = cp.vunrotate; + + + +/// Initialize an offset box shaped polygon shape. +cp.BoxShape2 = function(body, box) +{ + var verts = [ + box.l, box.b, + box.l, box.t, + box.r, box.t, + box.r, box.b + ]; + + return new cp.PolyShape(body, verts, cp.vzero); +}; + +/// Initialize a box shaped polygon shape. +cp.BoxShape = function(body, width, height) +{ + var hw = width/2; + var hh = height/2; + + return cp.BoxShape2(body, new cp.BB(-hw, -hh, hw, hh)); +}; + + +/// Initialize an static body +cp.BodyStatic = function() +{ + return new cp.Body(Infinity, Infinity); +}; + + +// "Bounding Box" compatibility with Chipmunk-JS +cp.BB = function(l, b, r, t) +{ + return {l:l, b:b, r:r, t:t}; +}; + +// helper function to create a BB +cp.bb = function(l, b, r, t) { + return new cp.BB(l, b, r, t); +}; + + +// +// Some properties +// +// "handle" needed in some cases +Object.defineProperties(cp.Base.prototype, + { + "handle" : { + get : function(){ + return this.getHandle(); + }, + enumerable : true, + configurable : true + } + }); + +// Properties, for Chipmunk-JS compatibility +// Space properties +Object.defineProperties(cp.Space.prototype, + { + "gravity" : { + get : function(){ + return this.getGravity(); + }, + set : function(newValue){ + this.setGravity(newValue); + }, + enumerable : true, + configurable : true + }, + "iterations" : { + get : function(){ + return this.getIterations(); + }, + set : function(newValue){ + this.setIterations(newValue); + }, + enumerable : true, + configurable : true + }, + "damping" : { + get : function(){ + return this.getDamping(); + }, + set : function(newValue){ + this.setDamping(newValue); + }, + enumerable : true, + configurable : true + }, + "staticBody" : { + get : function(){ + return this.getStaticBody(); + }, + enumerable : true, + configurable : true + }, + "idleSpeedThreshold" : { + get : function(){ + return this.getIdleSpeedThreshold(); + }, + set : function(newValue){ + this.setIdleSpeedThreshold(newValue); + }, + enumerable : true, + configurable : true + }, + "sleepTimeThreshold": { + get : function(){ + return this.getSleepTimeThreshold(); + }, + set : function(newValue){ + this.setSleepTimeThreshold(newValue); + }, + enumerable : true, + configurable : true + }, + "collisionSlop": { + get : function(){ + return this.getCollisionSlop(); + }, + set : function(newValue){ + this.setCollisionSlop(newValue); + }, + enumerable : true, + configurable : true + }, + "collisionBias": { + get : function(){ + return this.getCollisionBias(); + }, + set : function(newValue){ + this.setCollisionBias(newValue); + }, + enumerable : true, + configurable : true + }, + "collisionPersistence": { + get : function(){ + return this.getCollisionPersistence(); + }, + set : function(newValue){ + this.setCollisionPersistence(newValue); + }, + enumerable : true, + configurable : true + }, + "enableContactGraph": { + get : function(){ + return this.getEnableContactGraph(); + }, + set : function(newValue){ + this.setEnableContactGraph(newValue); + }, + enumerable : true, + configurable : true + } + }); + +// Body properties +Object.defineProperties(cp.Body.prototype, + { + "a" : { + get : function(){ + return this.getAngle(); + }, + set : function(newValue){ + this.setAngle(newValue); + }, + enumerable : true, + configurable : true + }, + "w" : { + get : function(){ + return this.getAngVel(); + }, + set : function(newValue){ + this.setAngVel(newValue); + }, + enumerable : true, + configurable : true + }, + "p" : { + get : function(){ + return this.getPos(); + }, + set : function(newValue){ + this.setPos(newValue); + }, + enumerable : true, + configurable : true + }, + "v" : { + get : function(){ + return this.getVel(); + }, + set : function(newValue){ + this.setVel(newValue); + }, + enumerable : true, + configurable : true + }, + "i" : { + get : function(){ + return this.getMoment(); + }, + set : function(newValue){ + this.setMoment(newValue); + }, + enumerable : true, + configurable : true + } + + }); diff --git a/samples/TestJavascript/bindings/jsb_constants_cocos2d.js b/samples/TestJavascript/bindings/jsb_constants_cocos2d.js new file mode 100644 index 0000000000..ee39c19d33 --- /dev/null +++ b/samples/TestJavascript/bindings/jsb_constants_cocos2d.js @@ -0,0 +1,339 @@ +// +// cocos2d constants +// +cc.DIRECTOR_PROJECTION_2D = 0; +cc.DIRECTOR_PROJECTION_3D = 1; + +cc.TEXTURE_PIXELFORMAT_RGBA8888 = 0; +cc.TEXTURE_PIXELFORMAT_RGB888 = 1; +cc.TEXTURE_PIXELFORMAT_RGB565 = 2; +cc.TEXTURE_PIXELFORMAT_A8 = 3; +cc.TEXTURE_PIXELFORMAT_I8 = 4; +cc.TEXTURE_PIXELFORMAT_AI88 = 5; +cc.TEXTURE_PIXELFORMAT_RGBA4444 = 6; +cc.TEXTURE_PIXELFORMAT_RGB5A1 = 7; +cc.TEXTURE_PIXELFORMAT_PVRTC4 = 8; +cc.TEXTURE_PIXELFORMAT_PVRTC4 = 9; +cc.TEXTURE_PIXELFORMAT_DEFAULT = cc.TEXTURE_PIXELFORMAT_RGBA8888; + +cc.TEXT_ALIGNMENT_LEFT = 0; +cc.TEXT_ALIGNMENT_CENTER = 1; +cc.TEXT_ALIGNMENT_RIGHT = 2; + +cc.VERTICAL_TEXT_ALIGNMENT_TOP = 0; +cc.VERTICAL_TEXT_ALIGNMENT_CENTER = 1; +cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM = 2; + +cc.IMAGE_FORMAT_JPEG = 0; +cc.IMAGE_FORMAT_PNG = 0; + +cc.PROGRESS_TIMER_TYPE_RADIAL = 0; +cc.PROGRESS_TIMER_TYPE_BAR = 1; + +cc.PARTICLE_TYPE_FREE = 0; +cc.PARTICLE_TYPE_RELATIVE = 1; +cc.PARTICLE_TYPE_GROUPED = 2; +cc.PARTICLE_DURATION_INFINITY = -1; +cc.PARTICLE_MODE_GRAVITY = 0; +cc.PARTICLE_MODE_RADIUS = 1; +cc.PARTICLE_START_SIZE_EQUAL_TO_END_SIZE = -1; +cc.PARTICLE_START_RADIUS_EQUAL_TO_END_RADIUS = -1; + +cc.RED = {r:255, g:0, b:0}; +cc.GREEN = {r:0, g:255, b:0}; +cc.BLUE = {r:0, g:0, b:255}; +cc.BLACK = {r:0, g:0, b:0}; +cc.WHITE = {r:255, g:255, b:255}; + +cc.POINT_ZERO = {x:0, y:0}; + +cc._reuse_p0 = {x:0, y:0}; +cc._reuse_p1 = {x:0, y:0}; +cc._reuse_p_index = 0; +cc._reuse_color3b = {r:255, g:255, b:255 }; +cc._reuse_color4b = {r:255, g:255, b:255, a:255 }; +cc._reuse_grid = cc.g(0,0); + +// +// Color 3B +// +cc.c3b = function( r, g, b ) +{ + return {r:r, g:g, b:b }; +}; +cc._c3b = function( r, g, b ) +{ + cc._reuse_color3b.r = r; + cc._reuse_color3b.g = g; + cc._reuse_color3b.b = b; + return cc._reuse_color3b; +}; +// compatibility +cc.c3 = cc.c3b; +cc._c3 = cc._c3b; + +// +// Color 4B +// +cc.c4b = function( r, g, b, a ) +{ + return {r:r, g:g, b:b, a:a }; +}; +cc._c4b = function( r, g, b, a ) +{ + cc._reuse_color4b.r = r; + cc._reuse_color4b.g = g; + cc._reuse_color4b.b = b; + cc._reuse_color4b.a = a; + return cc._reuse_color4b; +}; +// compatibility +cc.c4 = cc.c4b; +cc._c4 = cc._c4b; + + + +// +// Color 4F +// +cc.c4f = function( r, g, b, a ) +{ + return {r:r, g:g, b:b, a:a }; +}; + +// +// Point +// +cc.p = function( x, y ) +{ + return {x:x, y:y}; +}; +cc._p = function( x, y ) +{ + if( cc._reuse_p_index === 0 ) { + cc._reuse_p0.x = x; + cc._reuse_p0.y = y; + cc._reuse_p_index = 1; + return cc._reuse_p0; + } else { + cc._reuse_p1.x = x; + cc._reuse_p1.y = y; + cc._reuse_p_index = 0; + return cc._reuse_p1; + } +}; + +// +// Grid +// +cc._g = function( x, y ) +{ + cc._reuse_grid.x = x; + cc._reuse_grid.y = y; + return cc._reuse_grid; +}; + +// +// Size +// +cc.size = function(w,h) +{ + return {width:w, height:h}; +}; + +// +// Rect +// +cc.rect = function(x,y,w,h) +{ + return {x:x, y:y, width:w, height:h}; +}; + + +// dump config info, but only in debug mode +cc.dumpConfig = function() +{ + if( cc.config.debug ) { + for( var i in cc.config ) + cc.log( i + " = " + cc.config[i] ); + } +}; + +// +// MenuItemToggle +// +cc.MenuItemToggle.create = function( /* var args */) { + + var n = arguments.length; + + if (typeof arguments[n-1] === 'function') { + var args = Array.prototype.slice.call(arguments); + var func = args.pop(); + var obj = args.pop(); + + // create it with arguments, + var item = cc.MenuItemToggle._create.apply(this, args); + + // then set the callback + item.setCallback(obj, func); + return item; + } else { + return cc.MenuItemToggle._create.apply(this, arguments); + } +}; + +/** + * Associates a base class with a native superclass + * @function + * @param {object} jsobj subclass + * @param {object} klass superclass + */ +cc.associateWithNative = function( jsobj, superclass ) { + var native = new superclass(); + __associateObjWithNative( jsobj, native ); +}; + + +// XXX Should be done in native +cc.rectIntersectsRect = function( rectA, rectB ) +{ + var bool = ! ( rectA.x > rectB.x + rectB.width || + rectA.x + rectA.width < rectB.x || + rectA.y > rectB.y +rectB.height || + rectA.y + rectA.height < rectB.y ); + + return bool; +}; + +// +// Array: for cocos2d-html5 compatibility +// +cc.ArrayRemoveObject = function (arr, delObj) { + for (var i = 0; i < arr.length; i++) { + if (arr[i] == delObj) { + arr.splice(i, 1); + } + } +}; + + +// +// Google "subclasses" +// borrowed from closure library +// +var goog = goog || {}; // Check to see if already defined in current scope +goog.inherits = function (childCtor, parentCtor) { + /** @constructor */ + function tempCtor() {}; + tempCtor.prototype = parentCtor.prototype; + childCtor.superClass_ = parentCtor.prototype; + childCtor.prototype = new tempCtor(); + childCtor.prototype.constructor = childCtor; + + // Copy "static" method, but doesn't generate subclasses. +// for( var i in parentCtor ) { +// childCtor[ i ] = parentCtor[ i ]; +// } +}; +goog.base = function(me, opt_methodName, var_args) { + var caller = arguments.callee.caller; + if (caller.superClass_) { + // This is a constructor. Call the superclass constructor. + ret = caller.superClass_.constructor.apply( me, Array.prototype.slice.call(arguments, 1)); + + // XXX: SpiderMonkey bindings extensions +// __associateObjWithNative( me, ret ); + return ret; + } + + var args = Array.prototype.slice.call(arguments, 2); + var foundCaller = false; + for (var ctor = me.constructor; + ctor; ctor = ctor.superClass_ && ctor.superClass_.constructor) { + if (ctor.prototype[opt_methodName] === caller) { + foundCaller = true; + } else if (foundCaller) { + return ctor.prototype[opt_methodName].apply(me, args); + } + } + + // If we did not find the caller in the prototype chain, + // then one of two things happened: + // 1) The caller is an instance method. + // 2) This method was not called by the right caller. + if (me[opt_methodName] === caller) { + return me.constructor.prototype[opt_methodName].apply(me, args); + } else { + throw Error( + 'goog.base called from a method of one name ' + + 'to a method of a different name'); + } +}; + + +// +// Simple subclass +// + +cc.Class = function(){}; + +cc.Class.extend = function (prop) { + var _super = this.prototype; + + // Instantiate a base class (but only create the instance, + // don't run the init constructor) + initializing = true; + var prototype = new this(); + initializing = false; + fnTest = /xyz/.test(function(){xyz;}) ? /\b_super\b/ : /.*/; + + // Copy the properties over onto the new prototype + for (var name in prop) { + // Check if we're overwriting an existing function + prototype[name] = typeof prop[name] == "function" && + typeof _super[name] == "function" && fnTest.test(prop[name]) ? + (function (name, fn) { + return function () { + var tmp = this._super; + + // Add a new ._super() method that is the same method + // but on the super-class + this._super = _super[name]; + + // The method only need to be bound temporarily, so we + // remove it when we're done executing + var ret = fn.apply(this, arguments); + this._super = tmp; + + return ret; + }; + })(name, prop[name]) : + prop[name]; + } + + // The dummy class constructor + function Class() { + // All construction is actually done in the init method + if (!initializing && this.ctor) + this.ctor.apply(this, arguments); + } + + // Populate our constructed prototype object + Class.prototype = prototype; + + // Enforce the constructor to be what we expect + Class.prototype.constructor = Class; + + // And make this class extendable + Class.extend = arguments.callee; + + return Class; +}; + +cc.Node.extend = cc.Class.extend; +cc.Layer.extend = cc.Class.extend; +cc.LayerGradient.extend = cc.Class.extend; +cc.LayerColor.extend = cc.Class.extend; +cc.Sprite.extend = cc.Class.extend; +cc.MenuItemFont.extend = cc.Class.extend; +cc.Scene.extend = cc.Class.extend; diff --git a/samples/TestJavascript/bindings/jsb_constants_cocosbuilder.js b/samples/TestJavascript/bindings/jsb_constants_cocosbuilder.js new file mode 100644 index 0000000000..a4d33fb89d --- /dev/null +++ b/samples/TestJavascript/bindings/jsb_constants_cocosbuilder.js @@ -0,0 +1,118 @@ +// +// CocosBuilder definitions +// + +cc.Reader = {}; + +var _ccbGlobalContext = this; + +cc.Reader.load = function(file, owner, parentSize) +{ + // Load the node graph using the correct function + var reader = cc._Reader.create(); + var node; + + if (owner && parentSize) + { + node = reader.load(file, owner, parentSize); + } + else if (owner) + { + node = reader.load(file,owner); + } + else + { + node = reader.load(file); + } + + // Assign owner callbacks & member variables + if (owner) + { + // Callbacks + var ownerCallbackNames = reader.getOwnerCallbackNames(); + var ownerCallbackNodes = reader.getOwnerCallbackNodes(); + + for (var i = 0; i < ownerCallbackNames.length; i++) + { + var callbackName = ownerCallbackNames[i]; + var callbackNode = ownerCallbackNodes[i]; + + callbackNode.setCallback(owner, owner[callbackName]); + } + + // Variables + var ownerOutletNames = reader.getOwnerOutletNames(); + var ownerOutletNodes = reader.getOwnerOutletNodes(); + + for (var i = 0; i < ownerOutletNames.length; i++) + { + var outletName = ownerOutletNames[i]; + var outletNode = ownerOutletNodes[i]; + + owner[outletName] = outletNode; + } + } + + var nodesWithAnimationManagers = reader.getNodesWithAnimationManagers(); + var animationManagersForNodes = reader.getAnimationManagersForNodes(); + + // Attach animation managers to nodes and assign root node callbacks and member variables + for (var i = 0; i < nodesWithAnimationManagers.length; i++) + { + var innerNode = nodesWithAnimationManagers[i]; + var animationManager = animationManagersForNodes[i]; + + innerNode.animationManager = animationManager; + + var documentControllerName = animationManager.getDocumentControllerName(); + if (!documentControllerName) continue; + + // Create a document controller + var controller = new _ccbGlobalContext[documentControllerName](); + controller.controllerName = documentControllerName; + + innerNode.controller = controller; + controller.rootNode = innerNode; + + // Callbacks + var documentCallbackNames = animationManager.getDocumentCallbackNames(); + var documentCallbackNodes = animationManager.getDocumentCallbackNodes(); + + for (var j = 0; j < documentCallbackNames.length; j++) + { + var callbackName = documentCallbackNames[j]; + var callbackNode = documentCallbackNodes[j]; + + callbackNode.setCallback(controller, controller[callbackName]); + } + + + // Variables + var documentOutletNames = animationManager.getDocumentOutletNames(); + var documentOutletNodes = animationManager.getDocumentOutletNodes(); + + for (var j = 0; j < documentOutletNames.length; j++) + { + var outletName = documentOutletNames[j]; + var outletNode = documentOutletNodes[j]; + + controller[outletName] = outletNode; + } + + if (typeof(controller.onDidLoadFromCCB) == "function") + { + controller.onDidLoadFromCCB(); + } + } + + return node; +} + +cc.Reader.loadAsScene = function(file, owner, parentSize) +{ + var node = cc.Reader.load(file, owner, parentSize); + var scene = cc.Scene.create(); + scene.addChild( node ); + + return scene; +} diff --git a/samples/TestJavascript/bindings/jsb_constants_gl.js b/samples/TestJavascript/bindings/jsb_constants_gl.js new file mode 100644 index 0000000000..8b9d2f701d --- /dev/null +++ b/samples/TestJavascript/bindings/jsb_constants_gl.js @@ -0,0 +1,23 @@ +// +// OpenGL defines +// + +var gl = gl || {}; +gl.NEAREST = 0x2600; +gl.LINEAR = 0x2601; +gl.REPEAT = 0x2901; +gl.CLAMP_TO_EDGE = 0x812F; +gl.CLAMP_TO_BORDER = 0x812D; +gl.LINEAR_MIPMAP_NEAREST = 0x2701; +gl.NEAREST_MIPMAP_NEAREST = 0x2700; +gl.ZERO = 0; +gl.ONE = 1; +gl.SRC_COLOR = 0x0300; +gl.ONE_MINUS_SRC_COLOR = 0x0301; +gl.SRC_ALPHA = 0x0302; +gl.ONE_MINUS_SRC_ALPHA = 0x0303; +gl.DST_ALPHA = 0x0304; +gl.ONE_MINUS_DST_ALPHA = 0x0305; +gl.DST_COLOR = 0x0306; +gl.ONE_MINUS_DST_COLOR = 0x0307; +gl.SRC_ALPHA_SATURATE = 0x0308; From fc59b2c962340b1b8a3c1031f9b9198f300cb098 Mon Sep 17 00:00:00 2001 From: folecr Date: Thu, 11 Oct 2012 16:49:45 -0700 Subject: [PATCH 06/16] Updated build script * merges js files from the cocos2d-html5-tests submodule into Android's assets folder * copies js helper files into Android's assets folder * copies the res from cocos2d-html5-tests into Android's assets folder --- .../proj.android/build_native.sh | 33 ++++++------------- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/samples/TestJavascript/proj.android/build_native.sh b/samples/TestJavascript/proj.android/build_native.sh index be80429f39..4220642286 100755 --- a/samples/TestJavascript/proj.android/build_native.sh +++ b/samples/TestJavascript/proj.android/build_native.sh @@ -57,38 +57,25 @@ echo " APP_ROOT = $APP_ROOT" echo " APP_ANDROID_ROOT = $APP_ANDROID_ROOT" echo +# Debug +set -x + # make sure assets is exist if [ -d "$APP_ANDROID_ROOT"/assets ]; then rm -rf "$APP_ANDROID_ROOT"/assets fi mkdir "$APP_ANDROID_ROOT"/assets +mkdir "$APP_ANDROID_ROOT"/assets/res +# copy "cocos2d-html5-tests/res" into "assets/res" +cp -rf "$APP_ROOT"/cocos2d-html5-tests/res "$APP_ANDROID_ROOT"/assets -# copy resources -for file in "$APP_ROOT"/Resources/* -do -if [ -d "$file" ]; then - cp -rf "$file" "$APP_ANDROID_ROOT"/assets -fi - - -if [ -f "$file" ]; then - cp "$file" "$APP_ANDROID_ROOT"/assets -fi -done - - -rm -f "$APP_ANDROID_ROOT"/assets/Images/landscape-1024x1024-rgba8888.pvr.gz -rm -f "$APP_ANDROID_ROOT"/assets/Images/test_image_rgba4444.pvr.gz -rm -f "$APP_ANDROID_ROOT"/assets/Images/test_1021x1024_a8.pvr.gz -rm -f "$APP_ANDROID_ROOT"/assets/Images/test_1021x1024_rgb888.pvr.gz -rm -f "$APP_ANDROID_ROOT"/assets/Images/test_1021x1024_rgba4444.pvr.gz -rm -f "$APP_ANDROID_ROOT"/assets/Images/test_1021x1024_rgba8888.pvr.gz -rm -f "$APP_ANDROID_ROOT"/assets/Images/test_image_rgba4444.pvr.gz -rm -f "$APP_ANDROID_ROOT"/assets/Images/texture1024x1024_rgba4444.pvr.gz -rm -f "$APP_ANDROID_ROOT"/assets/Images/PlanetCute-1024x1024-rgba4444.pvr.gz +# copy src/**/*.js from cocos2d-html5-tests into assets' root +find "$APP_ROOT"/cocos2d-html5-tests/src -type f -name '*.js' -exec cp -f {} "$APP_ANDROID_ROOT"/assets \; +# copy bindings/*.js into assets' root +cp -f "$APP_ROOT"/bindings/*.js "$APP_ANDROID_ROOT"/assets echo "Using prebuilt externals" echo From 36f8b31efc4007cc73fdd707a09f336234518aad Mon Sep 17 00:00:00 2001 From: folecr Date: Thu, 11 Oct 2012 17:56:44 -0700 Subject: [PATCH 07/16] Define some helper functions and comment out references to chipmunk --- samples/TestJavascript/bindings/jsb_constants.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/samples/TestJavascript/bindings/jsb_constants.js b/samples/TestJavascript/bindings/jsb_constants.js index 7aa0419617..e6bff28d23 100644 --- a/samples/TestJavascript/bindings/jsb_constants.js +++ b/samples/TestJavascript/bindings/jsb_constants.js @@ -2,8 +2,11 @@ // Javascript Bindigns helper file // +cc.g = cc.g || cc.p; +cc.log = cc.log || log; + // DO NOT ALTER THE ORDER require('jsb_constants_cocos2d.js'); -require('jsb_constants_chipmunk.js'); +// require('jsb_constants_chipmunk.js'); require('jsb_constants_gl.js'); require('jsb_constants_cocosbuilder.js'); From 540b41c09139640fa9c88ddfa842406c19df131d Mon Sep 17 00:00:00 2001 From: Rohan Kuruvilla Date: Thu, 11 Oct 2012 17:54:37 -0700 Subject: [PATCH 08/16] Fixing LabelAtlas to read texture relative to path of plist file --- cocos2dx/label_nodes/CCLabelAtlas.cpp | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/cocos2dx/label_nodes/CCLabelAtlas.cpp b/cocos2dx/label_nodes/CCLabelAtlas.cpp index 8a834918f5..fa3beb358f 100644 --- a/cocos2dx/label_nodes/CCLabelAtlas.cpp +++ b/cocos2dx/label_nodes/CCLabelAtlas.cpp @@ -95,19 +95,22 @@ CCLabelAtlas* CCLabelAtlas::create(const char *string, const char *fntFile) bool CCLabelAtlas::initWithString(const char *theString, const char *fntFile) { - CCDictionary *dict = CCDictionary::createWithContentsOfFile(CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(fntFile)); - - CCAssert(((CCString*)dict->objectForKey("version"))->intValue() == 1, "Unsupported version. Upgrade cocos2d version"); + std::string pathStr = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(fntFile); + std::string relPathStr = pathStr.substr(0, pathStr.find_last_of("/"))+"/"; + CCDictionary *dict = CCDictionary::createWithContentsOfFile(pathStr.c_str()); + + CCAssert(((CCString*)dict->objectForKey("version"))->intValue() == 1, "Unsupported version. Upgrade cocos2d version"); - CCString *textureFilename = (CCString*)dict->objectForKey("textureFilename"); - unsigned int width = ((CCString*)dict->objectForKey("itemWidth"))->intValue() / CC_CONTENT_SCALE_FACTOR(); - unsigned int height = ((CCString*)dict->objectForKey("itemHeight"))->intValue() / CC_CONTENT_SCALE_FACTOR(); - unsigned int startChar = ((CCString*)dict->objectForKey("firstChar"))->intValue(); - + std::string texturePathStr = relPathStr + ((CCString*)dict->objectForKey("textureFilename"))->getCString(); + CCString *textureFilename = CCString::create(texturePathStr); + unsigned int width = ((CCString*)dict->objectForKey("itemWidth"))->intValue() / CC_CONTENT_SCALE_FACTOR(); + unsigned int height = ((CCString*)dict->objectForKey("itemHeight"))->intValue() / CC_CONTENT_SCALE_FACTOR(); + unsigned int startChar = ((CCString*)dict->objectForKey("firstChar"))->intValue(); + - this->initWithString(theString, textureFilename->getCString(), width, height, startChar); + this->initWithString(theString, textureFilename->getCString(), width, height, startChar); - return true; + return true; } //CCLabelAtlas - Atlas generation From 0c1c5a432db9c6f750d8a40b37cfd2b5d8dba4fd Mon Sep 17 00:00:00 2001 From: Rohan Kuruvilla Date: Thu, 11 Oct 2012 17:57:52 -0700 Subject: [PATCH 09/16] Adding support to pass array of CCPoints from JS --- .../javascript/bindings/ScriptingCore.cpp | 29 +++++++++++++++++-- scripting/javascript/bindings/ScriptingCore.h | 3 +- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/scripting/javascript/bindings/ScriptingCore.cpp b/scripting/javascript/bindings/ScriptingCore.cpp index 17433f47c1..ff9e094ccc 100644 --- a/scripting/javascript/bindings/ScriptingCore.cpp +++ b/scripting/javascript/bindings/ScriptingCore.cpp @@ -125,10 +125,10 @@ static void removeJSTouchObject(JSContext *cx, CCTouch *x, jsval &jsret) { } void ScriptingCore::executeJSFunctionWithThisObj(jsval thisObj, jsval callback, - jsval data) { + jsval *data) { jsval retval; if(callback != JSVAL_VOID || thisObj != JSVAL_VOID) { - JS_CallFunctionValue(cx, JSVAL_TO_OBJECT(thisObj), callback, 1, &data, &retval); + JS_CallFunctionValue(cx, JSVAL_TO_OBJECT(thisObj), callback, 1, data, &retval); } } @@ -899,6 +899,31 @@ ccColor3B jsval_to_cccolor3b(JSContext *cx, jsval v) { return cocos2d::ccc3(r, g, b); } +JSBool jsval_to_ccarray_of_CCPoint(JSContext* cx, jsval v, CCPoint **points, int *numPoints) { + // Parsing sequence + JSObject *jsobj; + JSBool ok = JS_ValueToObject( cx, v, &jsobj ); + if(!jsobj || !JS_IsArrayObject( cx, jsobj)) return JS_FALSE; + + uint32_t len; + JS_GetArrayLength(cx, jsobj, &len); + + CCPoint *array = (CCPoint*)malloc( sizeof(CCPoint) * len); + + for( uint32_t i=0; i< len;i++ ) { + jsval valarg; + JS_GetElement(cx, jsobj, i, &valarg); + + array[i] = jsval_to_ccpoint(cx, valarg); + } + + *numPoints = len; + *points = array; + + return JS_TRUE; +} + + CCArray* jsval_to_ccarray(JSContext* cx, jsval v) { JSObject *arr; if (JS_ValueToObject(cx, v, &arr) && JS_IsArrayObject(cx, arr)) { diff --git a/scripting/javascript/bindings/ScriptingCore.h b/scripting/javascript/bindings/ScriptingCore.h index 4cf47360cf..cbd0f9899f 100644 --- a/scripting/javascript/bindings/ScriptingCore.h +++ b/scripting/javascript/bindings/ScriptingCore.h @@ -85,7 +85,7 @@ public: int executeFunctionWithObjectData(CCNode *self, const char *name, JSObject *obj); int executeFunctionWithOwner(jsval owner, const char *name, jsval data); - void executeJSFunctionWithThisObj(jsval thisObj, jsval callback, jsval data); + void executeJSFunctionWithThisObj(jsval thisObj, jsval callback, jsval *data); /** * will eval the specified string @@ -184,6 +184,7 @@ ccGridSize jsval_to_ccgridsize(JSContext *cx, jsval v); ccColor4B jsval_to_cccolor4b(JSContext *cx, jsval v); ccColor4F jsval_to_cccolor4f(JSContext *cx, jsval v); ccColor3B jsval_to_cccolor3b(JSContext *cx, jsval v); +JSBool jsval_to_ccarray_of_CCPoint(JSContext* cx, jsval v, CCPoint **points, int *numPoints); CCArray* jsval_to_ccarray(JSContext* cx, jsval v); jsval ccarray_to_jsval(JSContext* cx, CCArray *arr); // from native From e7ac758b9fa1e6aec8fc0d68e3b79946f91ffb40 Mon Sep 17 00:00:00 2001 From: Rohan Kuruvilla Date: Thu, 11 Oct 2012 18:43:40 -0700 Subject: [PATCH 10/16] Updating bindings to match cocos2d-html5 --- .../javascript/bindings/cocos2d_specifics.cpp | 553 +++++++++++++++++- .../javascript/bindings/cocos2d_specifics.hpp | 46 +- tools/tojs/cocos2dx.ini | 14 +- 3 files changed, 587 insertions(+), 26 deletions(-) diff --git a/scripting/javascript/bindings/cocos2d_specifics.cpp b/scripting/javascript/bindings/cocos2d_specifics.cpp index 51ec52efaf..ab35a6f008 100644 --- a/scripting/javascript/bindings/cocos2d_specifics.cpp +++ b/scripting/javascript/bindings/cocos2d_specifics.cpp @@ -406,7 +406,9 @@ JSBool js_cocos2dx_CCAnimation_create(JSContext *cx, uint32_t argc, jsval *vp) ret = cocos2d::CCAnimation::create(arg0, arg1, loops); } else if (argc == 1) { ret = cocos2d::CCAnimation::createWithSpriteFrames(arg0); - } + } else if (argc == 0) { + ret = cocos2d::CCAnimation::create(); + } jsval jsret; if (ret) { js_proxy_t *proxy; @@ -828,7 +830,509 @@ JSBool js_cocos2dx_CCSet_constructor(JSContext *cx, uint32_t argc, jsval *vp) return JS_FALSE; } +JSBool js_cocos2dx_CCNode_setPosition(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy; JS_GET_NATIVE_PROXY(proxy, obj); + cocos2d::CCNode* cobj = (cocos2d::CCNode *)(proxy ? proxy->ptr : NULL); + TEST_NATIVE_OBJECT(cx, cobj) + + if (argc == 1) { + cocos2d::CCPoint arg0; + arg0 = jsval_to_ccpoint(cx, argv[0]); + cobj->setPosition(arg0); + return JS_TRUE; + } if (argc == 2) { + double x; + if( ! JS_ValueToNumber(cx, argv[0], &x ) ) { + return JS_FALSE; + } + double y; + if( ! JS_ValueToNumber(cx, argv[1], &y ) ) { + return JS_FALSE; + } + cobj->setPosition(CCPoint(x,y)); + return JS_TRUE; + } + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); + return JS_FALSE; +} + + +JSBool js_cocos2dx_CCSprite_setPosition(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy; JS_GET_NATIVE_PROXY(proxy, obj); + cocos2d::CCSprite* cobj = (cocos2d::CCSprite *)(proxy ? proxy->ptr : NULL); + TEST_NATIVE_OBJECT(cx, cobj) + + if (argc == 1) { + cocos2d::CCPoint arg0; + arg0 = jsval_to_ccpoint(cx, argv[0]); + cobj->setPosition(arg0); + return JS_TRUE; + } if (argc == 2) { + double x; + if( ! JS_ValueToNumber(cx, argv[0], &x ) ) { + return JS_FALSE; + } + double y; + if( ! JS_ValueToNumber(cx, argv[1], &y ) ) { + return JS_FALSE; + } + cobj->setPosition(CCPoint(x,y)); + return JS_TRUE; + } + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); + return JS_FALSE; +} + +template +JSBool js_BezierActions_create(JSContext *cx, uint32_t argc, jsval *vp) { + jsval *argv = JS_ARGV(cx, vp); + + if (argc == 2) { + double t; + if( ! JS_ValueToNumber(cx, argv[0], &t) ) { + return JS_FALSE; + } + + int num; + CCPoint *arr; + jsval_to_ccarray_of_CCPoint(cx, argv[1], &arr, &num); + + ccBezierConfig config; + config.controlPoint_1 = arr[0]; + config.controlPoint_2 = arr[1]; + config.endPosition = arr[2]; + + CCBezierBy* ret = CCBezierBy::create(t, config); + + free(arr); + + jsval jsret; + do { + if (ret) { + js_proxy_t *p; + JS_GET_PROXY(p, ret); + if (p) { + jsret = OBJECT_TO_JSVAL(p->obj); + } else { + // create a new js obj of that class + js_proxy_t *proxy = js_get_or_create_proxy(cx, ret); + jsret = OBJECT_TO_JSVAL(proxy->obj); + } + } else { + jsret = JSVAL_NULL; + } + } while (0); + JS_SET_RVAL(cx, vp, jsret); + return JS_TRUE; + + } + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); + return JS_FALSE; +} + +template +JSBool js_CardinalSplineActions_create(JSContext *cx, uint32_t argc, jsval *vp) { + jsval *argv = JS_ARGV(cx, vp); + + if (argc == 3) { + double dur; + if( ! JS_ValueToNumber(cx, argv[0], &dur) ) { + return JS_FALSE; + } + + int num; + CCPoint *arr; + jsval_to_ccarray_of_CCPoint(cx, argv[1], &arr, &num); + + double ten; + if( ! JS_ValueToNumber(cx, argv[2], &ten) ) { + return JS_FALSE; + } + + + CCPointArray *points = CCPointArray::create(num); + + for( int i=0; i < num;i++) { + points->addControlPoint(arr[i]); + } + + T *ret = T::create(dur, points, ten); + + free(arr); + + jsval jsret; + do { + if (ret) { + js_proxy_t *p; + JS_GET_PROXY(p, ret); + if (p) { + jsret = OBJECT_TO_JSVAL(p->obj); + } else { + // create a new js obj of that class + js_proxy_t *proxy = js_get_or_create_proxy(cx, ret); + jsret = OBJECT_TO_JSVAL(proxy->obj); + } + } else { + jsret = JSVAL_NULL; + } + } while (0); + JS_SET_RVAL(cx, vp, jsret); + return JS_TRUE; + + } + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); + return JS_FALSE; +} + +template +JSBool js_CatmullRomActions_create(JSContext *cx, uint32_t argc, jsval *vp) { + jsval *argv = JS_ARGV(cx, vp); + + if (argc == 2) { + double dur; + if( ! JS_ValueToNumber(cx, argv[0], &dur) ) { + return JS_FALSE; + } + + int num; + CCPoint *arr; + jsval_to_ccarray_of_CCPoint(cx, argv[1], &arr, &num); + + + CCPointArray *points = CCPointArray::create(num); + + for( int i=0; i < num;i++) { + points->addControlPoint(arr[i]); + } + + T *ret = T::create(dur, points); + + free(arr); + + jsval jsret; + do { + if (ret) { + js_proxy_t *p; + JS_GET_PROXY(p, ret); + if (p) { + jsret = OBJECT_TO_JSVAL(p->obj); + } else { + // create a new js obj of that class + js_proxy_t *proxy = js_get_or_create_proxy(cx, ret); + jsret = OBJECT_TO_JSVAL(proxy->obj); + } + } else { + jsret = JSVAL_NULL; + } + } while (0); + JS_SET_RVAL(cx, vp, jsret); + return JS_TRUE; + + } + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); + return JS_FALSE; +} + + +JSBool JSB_CCBezierBy_actionWithDuration(JSContext *cx, uint32_t argc, jsval *vp) { + js_BezierActions_create(cx, argc, vp); +} + +JSBool JSB_CCBezierTo_actionWithDuration(JSContext *cx, uint32_t argc, jsval *vp) { + js_BezierActions_create(cx, argc, vp); +} + + +JSBool JSB_CCCardinalSplineBy_actionWithDuration(JSContext *cx, uint32_t argc, jsval *vp) { + return js_CardinalSplineActions_create(cx, argc, vp); +} + +JSBool JSB_CCCardinalSplineTo_actionWithDuration(JSContext *cx, uint32_t argc, jsval *vp) { + return js_CardinalSplineActions_create(cx, argc, vp); +} + +JSBool JSB_CCCatmullRomBy_actionWithDuration(JSContext *cx, uint32_t argc, jsval *vp) { + return js_CatmullRomActions_create(cx, argc, vp); +} + +JSBool JSB_CCCatmullRomTo_actionWithDuration(JSContext *cx, uint32_t argc, jsval *vp) { + return js_CatmullRomActions_create(cx, argc, vp); +} + +JSBool js_cocos2dx_ccpAdd(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + + if (argc == 2) { + cocos2d::CCPoint arg0; + arg0 = jsval_to_ccpoint(cx, argv[0]); + cocos2d::CCPoint arg1; + arg1 = jsval_to_ccpoint(cx, argv[1]); + + CCPoint ret = ccpAdd(arg0, arg1); + + jsval jsret = ccpoint_to_jsval(cx, ret); + JS_SET_RVAL(cx, vp, jsret); + return JS_TRUE; + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); + return JS_FALSE; +} + +JSBool js_cocos2dx_ccpNeg(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + + if (argc == 1) { + cocos2d::CCPoint arg0; + arg0 = jsval_to_ccpoint(cx, argv[0]); + + CCPoint ret = ccpNeg(arg0); + + jsval jsret = ccpoint_to_jsval(cx, ret); + JS_SET_RVAL(cx, vp, jsret); + + return JS_TRUE; + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); + return JS_FALSE; +} + +JSBool js_cocos2dx_ccpSub(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + + if (argc == 2) { + cocos2d::CCPoint arg0; + arg0 = jsval_to_ccpoint(cx, argv[0]); + cocos2d::CCPoint arg1; + arg1 = jsval_to_ccpoint(cx, argv[1]); + + CCPoint ret = ccpSub(arg0, arg1); + + jsval jsret = ccpoint_to_jsval(cx, ret); + JS_SET_RVAL(cx, vp, jsret); + + return JS_TRUE; + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); + return JS_FALSE; +} + +JSBool js_cocos2dx_ccpMult(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + + if (argc == 2) { + cocos2d::CCPoint arg0; + arg0 = jsval_to_ccpoint(cx, argv[0]); + + double arg1; + if( ! JS_ValueToNumber(cx, argv[1], &arg1) ) { + return JS_FALSE; + } + + + CCPoint ret = ccpMult(arg0, arg1); + + jsval jsret = ccpoint_to_jsval(cx, ret); + JS_SET_RVAL(cx, vp, jsret); + + return JS_TRUE; + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); + return JS_FALSE; +} + +JSBool js_cocos2dx_ccpMidpoint(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + + if (argc == 2) { + cocos2d::CCPoint arg0; + arg0 = jsval_to_ccpoint(cx, argv[0]); + cocos2d::CCPoint arg1; + arg1 = jsval_to_ccpoint(cx, argv[1]); + + CCPoint ret = ccpMidpoint(arg0, arg1); + + jsval jsret = ccpoint_to_jsval(cx, ret); + JS_SET_RVAL(cx, vp, jsret); + return JS_TRUE; + + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); + return JS_FALSE; +} + + +JSBool js_cocos2dx_ccpDot(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + + if (argc == 2) { + cocos2d::CCPoint arg0; + arg0 = jsval_to_ccpoint(cx, argv[0]); + cocos2d::CCPoint arg1; + arg1 = jsval_to_ccpoint(cx, argv[1]); + + float ret = ccpDot(arg0, arg1); + + jsval jsret = DOUBLE_TO_JSVAL(ret); + JS_SET_RVAL(cx, vp, jsret); + return JS_TRUE; + + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); + return JS_FALSE; +} + +JSBool js_cocos2dx_ccpCross(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + + if (argc == 2) { + cocos2d::CCPoint arg0; + arg0 = jsval_to_ccpoint(cx, argv[0]); + cocos2d::CCPoint arg1; + arg1 = jsval_to_ccpoint(cx, argv[1]); + + float ret = ccpCross(arg0, arg1); + + jsval jsret = DOUBLE_TO_JSVAL(ret); + JS_SET_RVAL(cx, vp, jsret); + return JS_TRUE; + + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); + return JS_FALSE; +} + +JSBool js_cocos2dx_ccpPerp(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + + if (argc == 1) { + cocos2d::CCPoint arg0; + arg0 = jsval_to_ccpoint(cx, argv[0]); + + + CCPoint ret = ccpPerp(arg0); + + jsval jsret = ccpoint_to_jsval(cx, ret); + JS_SET_RVAL(cx, vp, jsret); + + return JS_TRUE; + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); + return JS_FALSE; +} + + +JSBool js_cocos2dx_ccpRPerp(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + + if (argc == 1) { + cocos2d::CCPoint arg0; + arg0 = jsval_to_ccpoint(cx, argv[0]); + + + CCPoint ret = ccpRPerp(arg0); + + jsval jsret = ccpoint_to_jsval(cx, ret); + JS_SET_RVAL(cx, vp, jsret); + return JS_TRUE; + + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); + return JS_FALSE; +} + + +JSBool js_cocos2dx_ccpProject(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + + if (argc == 2) { + cocos2d::CCPoint arg0; + arg0 = jsval_to_ccpoint(cx, argv[0]); + cocos2d::CCPoint arg1; + arg1 = jsval_to_ccpoint(cx, argv[1]); + + CCPoint ret = ccpProject(arg0, arg1); + + jsval jsret = ccpoint_to_jsval(cx, ret); + JS_SET_RVAL(cx, vp, jsret); + return JS_TRUE; + + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); + return JS_FALSE; +} + +JSBool js_cocos2dx_ccpRotate(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + + if (argc == 2) { + cocos2d::CCPoint arg0; + arg0 = jsval_to_ccpoint(cx, argv[0]); + cocos2d::CCPoint arg1; + arg1 = jsval_to_ccpoint(cx, argv[1]); + + CCPoint ret = ccpRotate(arg0, arg1); + + jsval jsret = ccpoint_to_jsval(cx, ret); + JS_SET_RVAL(cx, vp, jsret); + return JS_TRUE; + + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); + return JS_FALSE; +} + +JSBool js_cocos2dx_ccpNormalize(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + + if (argc == 1) { + cocos2d::CCPoint arg0; + arg0 = jsval_to_ccpoint(cx, argv[0]); + + CCPoint ret = ccpNormalize(arg0); + + jsval jsret = ccpoint_to_jsval(cx, ret); + JS_SET_RVAL(cx, vp, jsret); + + return JS_TRUE; + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); + return JS_FALSE; +} + + extern JSObject* js_cocos2dx_CCNode_prototype; +extern JSObject* js_cocos2dx_CCLayerColor_prototype; +extern JSObject* js_cocos2dx_CCSprite_prototype; extern JSObject* js_cocos2dx_CCAction_prototype; extern JSObject* js_cocos2dx_CCAnimation_prototype; extern JSObject* js_cocos2dx_CCMenuItem_prototype; @@ -839,8 +1343,13 @@ extern JSObject* js_cocos2dx_CCSpriteBatchNode_prototype; //extern JSObject* js_cocos2dx_CCMotionStreak_prototype; extern JSObject* js_cocos2dx_CCAtlasNode_prototype; extern JSObject* js_cocos2dx_CCParticleBatchNode_prototype; -extern JSObject* js_cocos2dx_CCLayerColor_prototype; extern JSObject* js_cocos2dx_CCParticleSystem_prototype; +extern JSObject* js_cocos2dx_CCCatmullRomBy_prototype; +extern JSObject* js_cocos2dx_CCCatmullRomTo_prototype; +extern JSObject* js_cocos2dx_CCCardinalSplineTo_prototype; +extern JSObject* js_cocos2dx_CCCardinalSplineBy_prototype; +extern JSObject* js_cocos2dx_CCBezierTo_prototype; +extern JSObject* js_cocos2dx_CCBezierBy_prototype; // setBlendFunc template @@ -926,6 +1435,29 @@ void register_cocos2dx_js_extensions(JSContext* cx, JSObject* global) JS_DefineFunction(cx, js_cocos2dx_CCNode_prototype, "schedule", js_CCNode_schedule, 1, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, js_cocos2dx_CCNode_prototype, "scheduleOnce", js_CCNode_scheduleOnce, 1, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, js_cocos2dx_CCNode_prototype, "unschedule", js_CCNode_unschedule, 1, JSPROP_READONLY | JSPROP_PERMANENT); + + JS_DefineFunction(cx, js_cocos2dx_CCNode_prototype, "setPosition", js_cocos2dx_CCNode_setPosition, 1, JSPROP_READONLY | JSPROP_PERMANENT); + + JS_DefineFunction(cx, js_cocos2dx_CCSprite_prototype, "setPosition", js_cocos2dx_CCSprite_setPosition, 1, JSPROP_READONLY | JSPROP_PERMANENT); + + tmpObj = JSVAL_TO_OBJECT(anonEvaluate(cx, global, "(function () { return cc.BezierBy; })()")); + JS_DefineFunction(cx, tmpObj, "create", JSB_CCBezierBy_actionWithDuration, 2, JSPROP_READONLY | JSPROP_PERMANENT); + + tmpObj = JSVAL_TO_OBJECT(anonEvaluate(cx, global, "(function () { return cc.BezierTo; })()")); + JS_DefineFunction(cx, tmpObj, "create", JSB_CCBezierTo_actionWithDuration, 2, JSPROP_READONLY | JSPROP_PERMANENT); + + tmpObj = JSVAL_TO_OBJECT(anonEvaluate(cx, global, "(function () { return cc.CardinalSplineBy; })()")); + JS_DefineFunction(cx, tmpObj, "create", JSB_CCCardinalSplineBy_actionWithDuration, 2, JSPROP_READONLY | JSPROP_PERMANENT); + + tmpObj = JSVAL_TO_OBJECT(anonEvaluate(cx, global, "(function () { return cc.CardinalSplineTo; })()")); + JS_DefineFunction(cx, tmpObj, "create", JSB_CCCardinalSplineTo_actionWithDuration, 2, JSPROP_READONLY | JSPROP_PERMANENT); + + tmpObj = JSVAL_TO_OBJECT(anonEvaluate(cx, global, "(function () { return cc.CatmullRomBy; })()")); + JS_DefineFunction(cx, tmpObj, "create", JSB_CCCatmullRomBy_actionWithDuration, 2, JSPROP_READONLY | JSPROP_PERMANENT); + + tmpObj = JSVAL_TO_OBJECT(anonEvaluate(cx, global, "(function () { return cc.CatmullRomTo; })()")); + JS_DefineFunction(cx, tmpObj, "create", JSB_CCCatmullRomTo_actionWithDuration, 2, JSPROP_READONLY | JSPROP_PERMANENT); + JS_DefineFunction(cx, js_cocos2dx_CCNode_prototype, "retain", js_cocos2dx_retain, 0, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, js_cocos2dx_CCNode_prototype, "release", js_cocos2dx_release, 0, JSPROP_READONLY | JSPROP_PERMANENT); @@ -964,7 +1496,7 @@ void register_cocos2dx_js_extensions(JSContext* cx, JSObject* global) tmpObj = JSVAL_TO_OBJECT(anonEvaluate(cx, global, "(function () { return cc.MenuItemFont; })()")); JS_DefineFunction(cx, tmpObj, "create", js_cocos2dx_CCMenuItemFont_create, 1, JSPROP_READONLY | JSPROP_PERMANENT); tmpObj = JSVAL_TO_OBJECT(anonEvaluate(cx, global, "(function () { return cc.MenuItemToggle; })()")); - JS_DefineFunction(cx, tmpObj, "create", js_cocos2dx_CCMenuItemToggle_create, 1, JSPROP_READONLY | JSPROP_PERMANENT); + JS_DefineFunction(cx, tmpObj, "_create", js_cocos2dx_CCMenuItemToggle_create, 1, JSPROP_READONLY | JSPROP_PERMANENT); tmpObj = JSVAL_TO_OBJECT(anonEvaluate(cx, global, "(function () { return cc.Sequence; })()")); JS_DefineFunction(cx, tmpObj, "create", js_cocos2dx_CCSequence_create, 0, JSPROP_READONLY | JSPROP_PERMANENT); tmpObj = JSVAL_TO_OBJECT(anonEvaluate(cx, global, "(function () { return cc.Spawn; })()")); @@ -981,6 +1513,21 @@ void register_cocos2dx_js_extensions(JSContext* cx, JSObject* global) tmpObj = JSVAL_TO_OBJECT(anonEvaluate(cx, global, "(function () { return this; })()")); JS_DefineFunction(cx, tmpObj, "garbageCollect", js_forceGC, 1, JSPROP_READONLY | JSPROP_PERMANENT); + JS_DefineFunction(cx, ns, "pAdd", js_cocos2dx_ccpAdd, 1, JSPROP_READONLY | JSPROP_PERMANENT); + JS_DefineFunction(cx, ns, "pSub", js_cocos2dx_ccpSub, 0, JSPROP_READONLY | JSPROP_PERMANENT); + JS_DefineFunction(cx, ns, "pNeg", js_cocos2dx_ccpNeg, 0, JSPROP_READONLY | JSPROP_PERMANENT); + JS_DefineFunction(cx, ns, "pMult", js_cocos2dx_ccpMult, 0, JSPROP_READONLY | JSPROP_PERMANENT); + JS_DefineFunction(cx, ns, "pMidpoint", js_cocos2dx_ccpMidpoint, 0, JSPROP_READONLY | JSPROP_PERMANENT); + JS_DefineFunction(cx, ns, "pDot", js_cocos2dx_ccpDot, 0, JSPROP_READONLY | JSPROP_PERMANENT); + JS_DefineFunction(cx, ns, "pCross", js_cocos2dx_ccpCross, 0, JSPROP_READONLY | JSPROP_PERMANENT); + JS_DefineFunction(cx, ns, "pPerp", js_cocos2dx_ccpPerp, 0, JSPROP_READONLY | JSPROP_PERMANENT); + JS_DefineFunction(cx, ns, "pRPerp", js_cocos2dx_ccpRPerp, 0, JSPROP_READONLY | JSPROP_PERMANENT); + JS_DefineFunction(cx, ns, "pProject", js_cocos2dx_ccpProject, 0, JSPROP_READONLY | JSPROP_PERMANENT); + JS_DefineFunction(cx, ns, "pRotate", js_cocos2dx_ccpRotate, 0, JSPROP_READONLY | JSPROP_PERMANENT); + JS_DefineFunction(cx, ns, "pNormalize", js_cocos2dx_ccpNormalize, 0, JSPROP_READONLY | JSPROP_PERMANENT); + + + // add constructor for CCSet JSFunction *ccSetConstructor = JS_NewFunction(cx, js_cocos2dx_CCSet_constructor, 0, JSPROP_READONLY | JSPROP_PERMANENT, NULL, "constructor"); JSObject *ctor = JS_GetFunctionObject(ccSetConstructor); diff --git a/scripting/javascript/bindings/cocos2d_specifics.hpp b/scripting/javascript/bindings/cocos2d_specifics.hpp index fcdb5a7838..b77fb840ce 100644 --- a/scripting/javascript/bindings/cocos2d_specifics.hpp +++ b/scripting/javascript/bindings/cocos2d_specifics.hpp @@ -12,7 +12,8 @@ template inline js_type_class_t *js_get_type_from_native(T* native_obj) { js_type_class_t *typeProxy; - long typeId = getHashCodeByString(typeid(*native_obj).name()); + const char *n = typeid(*native_obj).name(); + long typeId = getHashCodeByString(n); HASH_FIND_INT(_js_global_type_ht, &typeId, typeProxy); if (!typeProxy) { TypeInfo *typeInfo = dynamic_cast(native_obj); @@ -66,18 +67,24 @@ public: void callbackFunc(CCNode *node) const { - js_proxy_t *p; - JS_GET_PROXY(p, node); - jsval retObj = OBJECT_TO_JSVAL(p->obj); + jsval valArr[2]; + + JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); + js_proxy_t *proxy = js_get_or_create_proxy(cx, node); + + valArr[0] = OBJECT_TO_JSVAL(proxy->obj); + if(extraData != NULL) { - ScriptingCore::getInstance()->executeJSFunctionWithThisObj(jsThisObj, - jsCallback, - *extraData); + valArr[1] = *extraData; } else { - ScriptingCore::getInstance()->executeJSFunctionWithThisObj(jsThisObj, - jsCallback, - retObj); - } + valArr[1] = JSVAL_NULL; + } + + jsval retval; + if(jsCallback != JSVAL_VOID || jsThisObj != JSVAL_VOID) { + JS_CallFunctionValue(cx, JSVAL_TO_OBJECT(jsThisObj), jsCallback, 1, valArr, &retval); + } + } private: jsval jsCallback; @@ -120,14 +127,17 @@ public: void pause(); - void scheduleFunc(CCNode *node) const { - - jsval retObj = JSVAL_NULL; - ScriptingCore::getInstance()->executeJSFunctionWithThisObj(jsThisObj, - jsSchedule, - retObj); - + void scheduleFunc(float dt) const { + + jsval retval = JSVAL_NULL, data = DOUBLE_TO_JSVAL(dt); + JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); + + if(jsSchedule != JSVAL_VOID || jsThisObj != JSVAL_VOID) { + JS_CallFunctionValue(cx, JSVAL_TO_OBJECT(jsThisObj), jsSchedule, 1, &data, &retval); + } + } + private: jsval jsSchedule; diff --git a/tools/tojs/cocos2dx.ini b/tools/tojs/cocos2dx.ini index c8f0ba2964..7b2f312cc3 100644 --- a/tools/tojs/cocos2dx.ini +++ b/tools/tojs/cocos2dx.ini @@ -26,7 +26,7 @@ headers = %(cocosdir)s/cocos2dx/include/cocos2d.h %(cocosdir)s/CocosDenshion/inc # what classes to produce code for. You can use regular expressions here. When testing the regular # expression, it will be enclosed in "^$", like this: "^CCMenu*$". -classes = CCSprite.* CCScene CCNode CCDirector CCLayer.* CCMenu.* CCTouch CC.*Action.* CCMove.* CCRotate.* CCBlink.* CCTint.* CCSequence CCRepeat.* CCFade.* CCEase.* CCScale.* CCTransition.* CCSpawn CCSequence CCAnimat.* CCFlip.* CCDelay.* CCSkew.* CCJump.* CCPlace.* CCShow.* CCProgress.* CCPointArray CCToggleVisibility.* CCHide CCParticle.* CCLabel.* CCAtlas.* CCTextureCache.* CCTexture2D CCCardinal.* CCCatmullRom.* CCParallaxNode CCTileMap.* CCTMX.* CCCallFunc CCRenderTexture CCGridAction CCGrid3DAction CCShaky3D CCWaves3D CCFlipX3D CCFlipY3D CCSpeed CCActionManager CCSet SimpleAudioEngine CCScheduler CCTimer CCOrbit.* +classes = CCSprite.* CCScene CCNode CCDirector CCLayer.* CCMenu.* CCTouch CC.*Action.* CCMove.* CCRotate.* CCBlink.* CCTint.* CCSequence CCRepeat.* CCFade.* CCEase.* CCScale.* CCTransition.* CCSpawn CCSequence CCAnimat.* CCFlip.* CCDelay.* CCSkew.* CCJump.* CCPlace.* CCShow.* CCProgress.* CCPointArray CCToggleVisibility.* CCHide CCParticle.* CCLabel.* CCAtlas.* CCTextureCache.* CCTexture2D CCCardinal.* CCCatmullRom.* CCParallaxNode CCTileMap.* CCTMX.* CCCallFunc CCRenderTexture CCGridAction CCGrid3DAction CCShaky3D CCWaves3D CCFlipX3D CCFlipY3D CCSpeed CCActionManager CCSet SimpleAudioEngine CCScheduler CCTimer CCOrbit.* CCFollow.* CCBezier.* CCCardinalSpline.* # what should we skip? in the format ClassName::[function function] # ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also @@ -34,8 +34,9 @@ classes = CCSprite.* CCScene CCNode CCDirector CCLayer.* CCMenu.* CCTouch CC.*Ac # add a single "*" as functions. See bellow for several examples. A special class name is "*", which # will apply to all class names. This is a convenience wildcard to be able to skip similar named # functions from all classes. -skip = CCNode::[.*Transform convertToWindowSpace getChildren getGrid setGLServerState description getCamera getShaderProgram getUserObject .*UserData getGLServerState], - CCSprite::[getQuad displayFrame getTexture getBlendFunc setBlendFunc getTextureAtlas setSpriteBatchNode getSpriteBatchNode], + +skip = CCNode::[.*Transform convertToWindowSpace getChildren setPosition getGrid setGLServerState description getCamera getShaderProgram getUserObject .*UserData getGLServerState], + CCSprite::[getQuad displayFrame getTexture getBlendFunc setPosition setBlendFunc getTextureAtlas setSpriteBatchNode getSpriteBatchNode], CCSpriteBatchNode::[getBlendFunc setBlendFunc], CCMotionStreak::[getBlendFunc setBlendFunc], CCAtlasNode::[getBlendFunc setBlendFunc], @@ -44,7 +45,7 @@ skip = CCNode::[.*Transform convertToWindowSpace getChildren getGrid setGLServer CCParticleSystem::[getBlendFunc setBlendFunc], CCDirector::[getAccelerometer getKeypadDispatcher getTouchDispatcher setWatcherCallbackFun getOpenGLView getScheduler getProjection], CCLayer.*::[didAccelerate (g|s)etBlendFunc], - CCMenu.*::[.*Target getSubItems create alignItemsInColumns initWithItems alignItemsInRows], + CCMenu.*::[.*Target getSubItems create initWithItems alignItemsInRows alignItemsInColumns], CCMenuItem.*::[create], CCRGBAProtocol::[*], CCCopying::[*], @@ -88,7 +89,10 @@ skip = CCNode::[.*Transform convertToWindowSpace getChildren getGrid setGLServer CCParticleSystemQuad::[postStep setBatchNode draw setTexture$ setTotalParticles updateQuadWithParticle setupIndices listenBackToForeground initWithTotalParticles particleWithFile node], CCTexture2D::[initWithPVRTCData addPVRTCImage], CCLayerMultiplex::[*], - CCTextureCache::[addPVRTCImage], + CCCatmullRom.*::[create actionWithDuration], + CCBezier.*::[create actionWithDuration], + CCCardinalSpline.*::[create actionWithDuration setPoints], + CCTextureCache::[addPVRTCImage], *::[copyWith.* onEnter.* onExit.* description getObjectType .*RGB.* .*HSV.*] rename_functions = CCDirector::[sharedDirector=getInstance], From eafd6ebf08be2015ad05af7920b9d125a5058510 Mon Sep 17 00:00:00 2001 From: Rohan Kuruvilla Date: Thu, 11 Oct 2012 18:05:25 -0700 Subject: [PATCH 11/16] Fixing restart of context to not leak memory --- scripting/javascript/bindings/ScriptingCore.cpp | 6 ++++++ scripting/javascript/bindings/cocos2d_specifics.hpp | 3 +-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/scripting/javascript/bindings/ScriptingCore.cpp b/scripting/javascript/bindings/ScriptingCore.cpp index ff9e094ccc..4004074eb5 100644 --- a/scripting/javascript/bindings/ScriptingCore.cpp +++ b/scripting/javascript/bindings/ScriptingCore.cpp @@ -372,6 +372,12 @@ void ScriptingCore::removeAllRoots(JSContext *cx) { js_proxy_t *current, *tmp; HASH_ITER(hh, _js_native_global_ht, current, tmp) { JS_RemoveObjectRoot(cx, ¤t->obj); + HASH_DEL(_js_native_global_ht, current); + free(current); + } + HASH_ITER(hh, _native_js_global_ht, current, tmp) { + HASH_DEL(_native_js_global_ht, current); + free(current); } HASH_CLEAR(hh, _js_native_global_ht); HASH_CLEAR(hh, _native_js_global_ht); diff --git a/scripting/javascript/bindings/cocos2d_specifics.hpp b/scripting/javascript/bindings/cocos2d_specifics.hpp index b77fb840ce..03c34ce042 100644 --- a/scripting/javascript/bindings/cocos2d_specifics.hpp +++ b/scripting/javascript/bindings/cocos2d_specifics.hpp @@ -12,8 +12,7 @@ template inline js_type_class_t *js_get_type_from_native(T* native_obj) { js_type_class_t *typeProxy; - const char *n = typeid(*native_obj).name(); - long typeId = getHashCodeByString(n); + long typeId = getHashCodeByString(typeid(*native_obj).name()); HASH_FIND_INT(_js_global_type_ht, &typeId, typeProxy); if (!typeProxy) { TypeInfo *typeInfo = dynamic_cast(native_obj); From 572460e60ab437e5d430398cd8c324001899d27e Mon Sep 17 00:00:00 2001 From: minggo Date: Fri, 12 Oct 2012 12:00:36 +0800 Subject: [PATCH 12/16] make TestJavascript work on iOS --- .../bindings/jsb_constants_cocos2d.js | 6 +- .../TestJavascript.xcodeproj/project.pbxproj | 1254 ----------------- .../project.pbxproj.REMOVED.git-id | 1 + 3 files changed, 6 insertions(+), 1255 deletions(-) delete mode 100644 samples/TestJavascript/proj.ios/TestJavascript.xcodeproj/project.pbxproj create mode 100644 samples/TestJavascript/proj.ios/TestJavascript.xcodeproj/project.pbxproj.REMOVED.git-id diff --git a/samples/TestJavascript/bindings/jsb_constants_cocos2d.js b/samples/TestJavascript/bindings/jsb_constants_cocos2d.js index ee39c19d33..5b73b0c671 100644 --- a/samples/TestJavascript/bindings/jsb_constants_cocos2d.js +++ b/samples/TestJavascript/bindings/jsb_constants_cocos2d.js @@ -52,7 +52,7 @@ cc._reuse_p1 = {x:0, y:0}; cc._reuse_p_index = 0; cc._reuse_color3b = {r:255, g:255, b:255 }; cc._reuse_color4b = {r:255, g:255, b:255, a:255 }; -cc._reuse_grid = cc.g(0,0); +cc._reuse_grid = {x:0, y:0}; // // Color 3B @@ -126,6 +126,10 @@ cc._p = function( x, y ) // // Grid // +cc.g = function(x, y) +{ + return {x:x, y:y}; +}; cc._g = function( x, y ) { cc._reuse_grid.x = x; diff --git a/samples/TestJavascript/proj.ios/TestJavascript.xcodeproj/project.pbxproj b/samples/TestJavascript/proj.ios/TestJavascript.xcodeproj/project.pbxproj deleted file mode 100644 index 83f6b73a4f..0000000000 --- a/samples/TestJavascript/proj.ios/TestJavascript.xcodeproj/project.pbxproj +++ /dev/null @@ -1,1254 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 46; - objects = { - -/* Begin PBXBuildFile section */ - 15384E5716119CC30021DC07 /* CCPhysicsSprite.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384E3E16119CC30021DC07 /* CCPhysicsSprite.cpp */; }; - 15384E5816119CC30021DC07 /* cocos2d_specifics.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384E4016119CC30021DC07 /* cocos2d_specifics.cpp */; }; - 15384E5916119CC30021DC07 /* cocosjs_manual_conversions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384E4216119CC30021DC07 /* cocosjs_manual_conversions.cpp */; }; - 15384E5A16119CC30021DC07 /* cocos2dx.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384E4516119CC30021DC07 /* cocos2dx.cpp */; }; - 15384E5D16119CC30021DC07 /* js_bindings_ccbreader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384E4916119CC30021DC07 /* js_bindings_ccbreader.cpp */; }; - 15384E5E16119CC30021DC07 /* js_bindings_chipmunk_functions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384E4B16119CC30021DC07 /* js_bindings_chipmunk_functions.cpp */; }; - 15384E5F16119CC30021DC07 /* js_bindings_chipmunk_manual.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384E4D16119CC30021DC07 /* js_bindings_chipmunk_manual.cpp */; }; - 15384E6016119CC30021DC07 /* js_manual_conversions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384E5016119CC30021DC07 /* js_manual_conversions.cpp */; }; - 15384E6116119CC30021DC07 /* ScriptingCore.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384E5216119CC30021DC07 /* ScriptingCore.cpp */; }; - 15384ED716119D5E0021DC07 /* CCBAnimationManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384E6516119D5E0021DC07 /* CCBAnimationManager.cpp */; }; - 15384ED816119D5E0021DC07 /* CCBFileLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384E6716119D5E0021DC07 /* CCBFileLoader.cpp */; }; - 15384ED916119D5E0021DC07 /* CCBKeyframe.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384E6916119D5E0021DC07 /* CCBKeyframe.cpp */; }; - 15384EDA16119D5E0021DC07 /* CCBReader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384E6C16119D5E0021DC07 /* CCBReader.cpp */; }; - 15384EDB16119D5E0021DC07 /* CCBSequence.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384E6F16119D5E0021DC07 /* CCBSequence.cpp */; }; - 15384EDC16119D5E0021DC07 /* CCBSequenceProperty.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384E7116119D5E0021DC07 /* CCBSequenceProperty.cpp */; }; - 15384EDD16119D5E0021DC07 /* CCBValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384E7316119D5E0021DC07 /* CCBValue.cpp */; }; - 15384EDE16119D5E0021DC07 /* CCControlButtonLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384E7516119D5E0021DC07 /* CCControlButtonLoader.cpp */; }; - 15384EDF16119D5E0021DC07 /* CCControlLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384E7716119D5E0021DC07 /* CCControlLoader.cpp */; }; - 15384EE016119D5E0021DC07 /* CCData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384E7916119D5E0021DC07 /* CCData.cpp */; }; - 15384EE116119D5E0021DC07 /* CCLabelBMFontLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384E7B16119D5E0021DC07 /* CCLabelBMFontLoader.cpp */; }; - 15384EE216119D5E0021DC07 /* CCLabelTTFLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384E7D16119D5E0021DC07 /* CCLabelTTFLoader.cpp */; }; - 15384EE316119D5E0021DC07 /* CCLayerColorLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384E7F16119D5E0021DC07 /* CCLayerColorLoader.cpp */; }; - 15384EE416119D5E0021DC07 /* CCLayerGradientLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384E8116119D5E0021DC07 /* CCLayerGradientLoader.cpp */; }; - 15384EE516119D5E0021DC07 /* CCLayerLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384E8316119D5E0021DC07 /* CCLayerLoader.cpp */; }; - 15384EE616119D5E0021DC07 /* CCMenuItemImageLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384E8516119D5E0021DC07 /* CCMenuItemImageLoader.cpp */; }; - 15384EE716119D5E0021DC07 /* CCMenuItemLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384E8716119D5E0021DC07 /* CCMenuItemLoader.cpp */; }; - 15384EE816119D5E0021DC07 /* CCNode+CCBRelativePositioning.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384E8A16119D5E0021DC07 /* CCNode+CCBRelativePositioning.cpp */; }; - 15384EE916119D5E0021DC07 /* CCNodeLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384E8C16119D5E0021DC07 /* CCNodeLoader.cpp */; }; - 15384EEA16119D5E0021DC07 /* CCNodeLoaderLibrary.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384E8E16119D5E0021DC07 /* CCNodeLoaderLibrary.cpp */; }; - 15384EEB16119D5E0021DC07 /* CCParticleSystemQuadLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384E9116119D5E0021DC07 /* CCParticleSystemQuadLoader.cpp */; }; - 15384EEC16119D5E0021DC07 /* CCScale9SpriteLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384E9316119D5E0021DC07 /* CCScale9SpriteLoader.cpp */; }; - 15384EED16119D5E0021DC07 /* CCScrollViewLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384E9516119D5E0021DC07 /* CCScrollViewLoader.cpp */; }; - 15384EEE16119D5E0021DC07 /* CCSpriteLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384E9716119D5E0021DC07 /* CCSpriteLoader.cpp */; }; - 15384EFB16119D5E0021DC07 /* CCEditBox.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384EB716119D5E0021DC07 /* CCEditBox.cpp */; }; - 15384EFD16119D5E0021DC07 /* CCEditBoxImplIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 15384EBD16119D5E0021DC07 /* CCEditBoxImplIOS.mm */; }; - 15384EFE16119D5E0021DC07 /* EditBoxImplIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 15384EBF16119D5E0021DC07 /* EditBoxImplIOS.mm */; }; - 15384EFF16119D5E0021DC07 /* CCScrollView.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384EC116119D5E0021DC07 /* CCScrollView.cpp */; }; - 15384F0016119D5E0021DC07 /* CCSorting.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384EC316119D5E0021DC07 /* CCSorting.cpp */; }; - 15384F0116119D5E0021DC07 /* CCTableView.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384EC516119D5E0021DC07 /* CCTableView.cpp */; }; - 15384F0216119D5E0021DC07 /* CCTableViewCell.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15384EC716119D5E0021DC07 /* CCTableViewCell.cpp */; }; - 15426FC315B5742200712A7F /* libcocos2dx.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 15426AF115B5733200712A7F /* libcocos2dx.a */; }; - 15426FE615B5743C00712A7F /* CDAudioManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 15426FD015B5743C00712A7F /* CDAudioManager.m */; }; - 15426FE715B5743C00712A7F /* CDOpenALSupport.m in Sources */ = {isa = PBXBuildFile; fileRef = 15426FD315B5743C00712A7F /* CDOpenALSupport.m */; }; - 15426FE815B5743C00712A7F /* CocosDenshion.m in Sources */ = {isa = PBXBuildFile; fileRef = 15426FD515B5743C00712A7F /* CocosDenshion.m */; }; - 15426FE915B5743C00712A7F /* SimpleAudioEngine.mm in Sources */ = {isa = PBXBuildFile; fileRef = 15426FD615B5743C00712A7F /* SimpleAudioEngine.mm */; }; - 15426FEA15B5743C00712A7F /* SimpleAudioEngine_objc.m in Sources */ = {isa = PBXBuildFile; fileRef = 15426FD815B5743C00712A7F /* SimpleAudioEngine_objc.m */; }; - 15628F6C15F0F5E5000CF24B /* ballbounce.wav in Resources */ = {isa = PBXBuildFile; fileRef = 15628F5D15F0F5E5000CF24B /* ballbounce.wav */; }; - 15628F6D15F0F5E5000CF24B /* cowbell.wav in Resources */ = {isa = PBXBuildFile; fileRef = 15628F5E15F0F5E5000CF24B /* cowbell.wav */; }; - 15628F6E15F0F5E5000CF24B /* Cyber Advance!.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = 15628F5F15F0F5E5000CF24B /* Cyber Advance!.mp3 */; }; - 15628F6F15F0F5E5000CF24B /* Fonts in Resources */ = {isa = PBXBuildFile; fileRef = 15628F6015F0F5E5000CF24B /* Fonts */; }; - 15628F7015F0F5E5000CF24B /* Images in Resources */ = {isa = PBXBuildFile; fileRef = 15628F6115F0F5E5000CF24B /* Images */; }; - 15628F7115F0F5E5000CF24B /* js in Resources */ = {isa = PBXBuildFile; fileRef = 15628F6215F0F5E5000CF24B /* js */; }; - 15628F7215F0F5E5000CF24B /* oldjs in Resources */ = {isa = PBXBuildFile; fileRef = 15628F6315F0F5E5000CF24B /* oldjs */; }; - 15628F7315F0F5E5000CF24B /* Particles in Resources */ = {isa = PBXBuildFile; fileRef = 15628F6415F0F5E5000CF24B /* Particles */; }; - 15628F7415F0F5E5000CF24B /* Silly Fun Theme A.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = 15628F6515F0F5E5000CF24B /* Silly Fun Theme A.mp3 */; }; - 15628F7515F0F5E5000CF24B /* tank.plist in Resources */ = {isa = PBXBuildFile; fileRef = 15628F6615F0F5E5000CF24B /* tank.plist */; }; - 15628F7615F0F5E5000CF24B /* tank.png in Resources */ = {isa = PBXBuildFile; fileRef = 15628F6715F0F5E5000CF24B /* tank.png */; }; - 15628F7715F0F5E5000CF24B /* tank.tps in Resources */ = {isa = PBXBuildFile; fileRef = 15628F6815F0F5E5000CF24B /* tank.tps */; }; - 15628F7815F0F5E5000CF24B /* tank1.png in Resources */ = {isa = PBXBuildFile; fileRef = 15628F6915F0F5E5000CF24B /* tank1.png */; }; - 15628F7915F0F5E5000CF24B /* TileMaps in Resources */ = {isa = PBXBuildFile; fileRef = 15628F6A15F0F5E5000CF24B /* TileMaps */; }; - 15628FA915F1057E000CF24B /* animations in Resources */ = {isa = PBXBuildFile; fileRef = 15628FA815F1057E000CF24B /* animations */; }; - 15CFE1A61612FD0E00BF2188 /* CCControl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15CFE18D1612FD0E00BF2188 /* CCControl.cpp */; }; - 15CFE1A71612FD0E00BF2188 /* CCControlButton.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15CFE18F1612FD0E00BF2188 /* CCControlButton.cpp */; }; - 15CFE1A81612FD0E00BF2188 /* CCControlColourPicker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15CFE1911612FD0E00BF2188 /* CCControlColourPicker.cpp */; }; - 15CFE1A91612FD0E00BF2188 /* CCControlHuePicker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15CFE1941612FD0E00BF2188 /* CCControlHuePicker.cpp */; }; - 15CFE1AA1612FD0E00BF2188 /* CCControlPotentiometer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15CFE1961612FD0E00BF2188 /* CCControlPotentiometer.cpp */; }; - 15CFE1AB1612FD0E00BF2188 /* CCControlSaturationBrightnessPicker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15CFE1981612FD0E00BF2188 /* CCControlSaturationBrightnessPicker.cpp */; }; - 15CFE1AC1612FD0E00BF2188 /* CCControlSlider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15CFE19A1612FD0E00BF2188 /* CCControlSlider.cpp */; }; - 15CFE1AD1612FD0E00BF2188 /* CCControlStepper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15CFE19C1612FD0E00BF2188 /* CCControlStepper.cpp */; }; - 15CFE1AE1612FD0E00BF2188 /* CCControlSwitch.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15CFE19E1612FD0E00BF2188 /* CCControlSwitch.cpp */; }; - 15CFE1AF1612FD0E00BF2188 /* CCControlUtils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15CFE1A01612FD0E00BF2188 /* CCControlUtils.cpp */; }; - 15CFE1B01612FD0E00BF2188 /* CCInvocation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15CFE1A21612FD0E00BF2188 /* CCInvocation.cpp */; }; - 15CFE1B11612FD0E00BF2188 /* CCScale9Sprite.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15CFE1A41612FD0E00BF2188 /* CCScale9Sprite.cpp */; }; - 262829CC15EC7196002C4240 /* .gitignore in Resources */ = {isa = PBXBuildFile; fileRef = 2628297D15EC7196002C4240 /* .gitignore */; }; - 262829CD15EC7196002C4240 /* Android.mk in Resources */ = {isa = PBXBuildFile; fileRef = 2628297E15EC7196002C4240 /* Android.mk */; }; - 262829CE15EC7196002C4240 /* chipmunk-docs.html in Resources */ = {isa = PBXBuildFile; fileRef = 2628297F15EC7196002C4240 /* chipmunk-docs.html */; }; - 262829CF15EC7196002C4240 /* LICENSE.txt in Resources */ = {isa = PBXBuildFile; fileRef = 2628299C15EC7196002C4240 /* LICENSE.txt */; }; - 262829D015EC7196002C4240 /* .cproject in Resources */ = {isa = PBXBuildFile; fileRef = 2628299E15EC7196002C4240 /* .cproject */; }; - 262829D115EC7196002C4240 /* .project in Resources */ = {isa = PBXBuildFile; fileRef = 2628299F15EC7196002C4240 /* .project */; }; - 262829D215EC7196002C4240 /* .cproject in Resources */ = {isa = PBXBuildFile; fileRef = 262829A115EC7196002C4240 /* .cproject */; }; - 262829D315EC7196002C4240 /* .project in Resources */ = {isa = PBXBuildFile; fileRef = 262829A215EC7196002C4240 /* .project */; }; - 262829D415EC7196002C4240 /* Makefile in Sources */ = {isa = PBXBuildFile; fileRef = 262829A315EC7196002C4240 /* Makefile */; }; - 262829D515EC7196002C4240 /* chipmunk.vcproj in Resources */ = {isa = PBXBuildFile; fileRef = 262829A515EC7196002C4240 /* chipmunk.vcproj */; }; - 262829D615EC7196002C4240 /* chipmunk.vcproj.user in Resources */ = {isa = PBXBuildFile; fileRef = 262829A615EC7196002C4240 /* chipmunk.vcproj.user */; }; - 262829D715EC7196002C4240 /* chipmunk.vcxproj in Resources */ = {isa = PBXBuildFile; fileRef = 262829A715EC7196002C4240 /* chipmunk.vcxproj */; }; - 262829D815EC7196002C4240 /* chipmunk.vcxproj.filters in Resources */ = {isa = PBXBuildFile; fileRef = 262829A815EC7196002C4240 /* chipmunk.vcxproj.filters */; }; - 262829D915EC7196002C4240 /* chipmunk.vcxproj.user in Resources */ = {isa = PBXBuildFile; fileRef = 262829A915EC7196002C4240 /* chipmunk.vcxproj.user */; }; - 262829DA15EC7196002C4240 /* README.txt in Resources */ = {isa = PBXBuildFile; fileRef = 262829AA15EC7196002C4240 /* README.txt */; }; - 262829DB15EC7196002C4240 /* chipmunk.c in Sources */ = {isa = PBXBuildFile; fileRef = 262829AC15EC7196002C4240 /* chipmunk.c */; }; - 262829DC15EC7196002C4240 /* CMakeLists.txt in Resources */ = {isa = PBXBuildFile; fileRef = 262829AD15EC7196002C4240 /* CMakeLists.txt */; }; - 262829DD15EC7196002C4240 /* cpConstraint.c in Sources */ = {isa = PBXBuildFile; fileRef = 262829AF15EC7196002C4240 /* cpConstraint.c */; }; - 262829DE15EC7196002C4240 /* cpDampedRotarySpring.c in Sources */ = {isa = PBXBuildFile; fileRef = 262829B015EC7196002C4240 /* cpDampedRotarySpring.c */; }; - 262829DF15EC7196002C4240 /* cpDampedSpring.c in Sources */ = {isa = PBXBuildFile; fileRef = 262829B115EC7196002C4240 /* cpDampedSpring.c */; }; - 262829E015EC7196002C4240 /* cpGearJoint.c in Sources */ = {isa = PBXBuildFile; fileRef = 262829B215EC7196002C4240 /* cpGearJoint.c */; }; - 262829E115EC7196002C4240 /* cpGrooveJoint.c in Sources */ = {isa = PBXBuildFile; fileRef = 262829B315EC7196002C4240 /* cpGrooveJoint.c */; }; - 262829E215EC7196002C4240 /* cpPinJoint.c in Sources */ = {isa = PBXBuildFile; fileRef = 262829B415EC7196002C4240 /* cpPinJoint.c */; }; - 262829E315EC7196002C4240 /* cpPivotJoint.c in Sources */ = {isa = PBXBuildFile; fileRef = 262829B515EC7196002C4240 /* cpPivotJoint.c */; }; - 262829E415EC7196002C4240 /* cpRatchetJoint.c in Sources */ = {isa = PBXBuildFile; fileRef = 262829B615EC7196002C4240 /* cpRatchetJoint.c */; }; - 262829E515EC7196002C4240 /* cpRotaryLimitJoint.c in Sources */ = {isa = PBXBuildFile; fileRef = 262829B715EC7196002C4240 /* cpRotaryLimitJoint.c */; }; - 262829E615EC7196002C4240 /* cpSimpleMotor.c in Sources */ = {isa = PBXBuildFile; fileRef = 262829B815EC7196002C4240 /* cpSimpleMotor.c */; }; - 262829E715EC7196002C4240 /* cpSlideJoint.c in Sources */ = {isa = PBXBuildFile; fileRef = 262829B915EC7196002C4240 /* cpSlideJoint.c */; }; - 262829E815EC7196002C4240 /* cpArbiter.c in Sources */ = {isa = PBXBuildFile; fileRef = 262829BA15EC7196002C4240 /* cpArbiter.c */; }; - 262829E915EC7196002C4240 /* cpArray.c in Sources */ = {isa = PBXBuildFile; fileRef = 262829BB15EC7196002C4240 /* cpArray.c */; }; - 262829EA15EC7196002C4240 /* cpBB.c in Sources */ = {isa = PBXBuildFile; fileRef = 262829BC15EC7196002C4240 /* cpBB.c */; }; - 262829EB15EC7196002C4240 /* cpBBTree.c in Sources */ = {isa = PBXBuildFile; fileRef = 262829BD15EC7196002C4240 /* cpBBTree.c */; }; - 262829EC15EC7196002C4240 /* cpBody.c in Sources */ = {isa = PBXBuildFile; fileRef = 262829BE15EC7196002C4240 /* cpBody.c */; }; - 262829ED15EC7196002C4240 /* cpCollision.c in Sources */ = {isa = PBXBuildFile; fileRef = 262829BF15EC7196002C4240 /* cpCollision.c */; }; - 262829EE15EC7196002C4240 /* cpHashSet.c in Sources */ = {isa = PBXBuildFile; fileRef = 262829C015EC7196002C4240 /* cpHashSet.c */; }; - 262829EF15EC7196002C4240 /* cpPolyShape.c in Sources */ = {isa = PBXBuildFile; fileRef = 262829C115EC7196002C4240 /* cpPolyShape.c */; }; - 262829F015EC7196002C4240 /* cpShape.c in Sources */ = {isa = PBXBuildFile; fileRef = 262829C215EC7196002C4240 /* cpShape.c */; }; - 262829F115EC7196002C4240 /* cpSpace.c in Sources */ = {isa = PBXBuildFile; fileRef = 262829C315EC7196002C4240 /* cpSpace.c */; }; - 262829F215EC7196002C4240 /* cpSpaceComponent.c in Sources */ = {isa = PBXBuildFile; fileRef = 262829C415EC7196002C4240 /* cpSpaceComponent.c */; }; - 262829F315EC7196002C4240 /* cpSpaceHash.c in Sources */ = {isa = PBXBuildFile; fileRef = 262829C515EC7196002C4240 /* cpSpaceHash.c */; }; - 262829F415EC7196002C4240 /* cpSpaceQuery.c in Sources */ = {isa = PBXBuildFile; fileRef = 262829C615EC7196002C4240 /* cpSpaceQuery.c */; }; - 262829F515EC7196002C4240 /* cpSpaceStep.c in Sources */ = {isa = PBXBuildFile; fileRef = 262829C715EC7196002C4240 /* cpSpaceStep.c */; }; - 262829F615EC7196002C4240 /* cpSpatialIndex.c in Sources */ = {isa = PBXBuildFile; fileRef = 262829C815EC7196002C4240 /* cpSpatialIndex.c */; }; - 262829F715EC7196002C4240 /* cpSweep1D.c in Sources */ = {isa = PBXBuildFile; fileRef = 262829C915EC7196002C4240 /* cpSweep1D.c */; }; - 262829F815EC7196002C4240 /* cpVect.c in Sources */ = {isa = PBXBuildFile; fileRef = 262829CA15EC7196002C4240 /* cpVect.c */; }; - A92275421517C094001B78AA /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A92275411517C094001B78AA /* QuartzCore.framework */; }; - A92275441517C094001B78AA /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A92275431517C094001B78AA /* OpenGLES.framework */; }; - A92275461517C094001B78AA /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A92275451517C094001B78AA /* OpenAL.framework */; }; - A92275481517C094001B78AA /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A92275471517C094001B78AA /* AudioToolbox.framework */; }; - A922754A1517C094001B78AA /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A92275491517C094001B78AA /* AVFoundation.framework */; }; - A922754C1517C094001B78AA /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A922754B1517C094001B78AA /* UIKit.framework */; }; - A922754E1517C094001B78AA /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A922754D1517C094001B78AA /* Foundation.framework */; }; - A92275501517C094001B78AA /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A922754F1517C094001B78AA /* CoreGraphics.framework */; }; - D446FDA316102D7D000ADA7B /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = D446FDA216102D7D000ADA7B /* Default.png */; }; - D446FDA516102D82000ADA7B /* Default@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = D446FDA416102D82000ADA7B /* Default@2x.png */; }; - D446FDA716102D86000ADA7B /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = D446FDA616102D86000ADA7B /* Default-568h@2x.png */; }; - D45446D3156DE74F00887EB5 /* AppController.mm in Sources */ = {isa = PBXBuildFile; fileRef = D45446CE156DE74F00887EB5 /* AppController.mm */; }; - D45446D4156DE74F00887EB5 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = D45446CF156DE74F00887EB5 /* main.m */; }; - D45446D5156DE74F00887EB5 /* RootViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = D45446D2156DE74F00887EB5 /* RootViewController.mm */; }; - D454520A156E22B400887EB5 /* libxml2.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = D4545209156E22B400887EB5 /* libxml2.dylib */; }; - D454520C156E22BD00887EB5 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = D454520B156E22BD00887EB5 /* libz.dylib */; }; - D4545227156E28EF00887EB5 /* AppDelegate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D4545215156E28EF00887EB5 /* AppDelegate.cpp */; }; -/* End PBXBuildFile section */ - -/* Begin PBXContainerItemProxy section */ - 15426AF015B5733200712A7F /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 15426AE915B5733200712A7F /* cocos2dx.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 1551A33F158F2AB200E66CFE; - remoteInfo = cocos2dx; - }; - 15426FC115B5741900712A7F /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 15426AE915B5733200712A7F /* cocos2dx.xcodeproj */; - proxyType = 1; - remoteGlobalIDString = 1551A33E158F2AB200E66CFE; - remoteInfo = cocos2dx; - }; -/* End PBXContainerItemProxy section */ - -/* Begin PBXFileReference section */ - 15384E3E16119CC30021DC07 /* CCPhysicsSprite.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCPhysicsSprite.cpp; sourceTree = ""; }; - 15384E3F16119CC30021DC07 /* CCPhysicsSprite.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCPhysicsSprite.h; sourceTree = ""; }; - 15384E4016119CC30021DC07 /* cocos2d_specifics.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cocos2d_specifics.cpp; sourceTree = ""; }; - 15384E4116119CC30021DC07 /* cocos2d_specifics.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = cocos2d_specifics.hpp; sourceTree = ""; }; - 15384E4216119CC30021DC07 /* cocosjs_manual_conversions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cocosjs_manual_conversions.cpp; sourceTree = ""; }; - 15384E4316119CC30021DC07 /* cocosjs_manual_conversions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cocosjs_manual_conversions.h; sourceTree = ""; }; - 15384E4516119CC30021DC07 /* cocos2dx.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cocos2dx.cpp; sourceTree = ""; }; - 15384E4616119CC30021DC07 /* cocos2dx.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = cocos2dx.hpp; sourceTree = ""; }; - 15384E4916119CC30021DC07 /* js_bindings_ccbreader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = js_bindings_ccbreader.cpp; sourceTree = ""; }; - 15384E4A16119CC30021DC07 /* js_bindings_ccbreader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = js_bindings_ccbreader.h; sourceTree = ""; }; - 15384E4B16119CC30021DC07 /* js_bindings_chipmunk_functions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = js_bindings_chipmunk_functions.cpp; sourceTree = ""; }; - 15384E4C16119CC30021DC07 /* js_bindings_chipmunk_functions.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = js_bindings_chipmunk_functions.hpp; sourceTree = ""; }; - 15384E4D16119CC30021DC07 /* js_bindings_chipmunk_manual.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = js_bindings_chipmunk_manual.cpp; sourceTree = ""; }; - 15384E4E16119CC30021DC07 /* js_bindings_chipmunk_manual.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = js_bindings_chipmunk_manual.hpp; sourceTree = ""; }; - 15384E4F16119CC30021DC07 /* js_bindings_config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = js_bindings_config.h; sourceTree = ""; }; - 15384E5016119CC30021DC07 /* js_manual_conversions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = js_manual_conversions.cpp; sourceTree = ""; }; - 15384E5116119CC30021DC07 /* js_manual_conversions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = js_manual_conversions.h; sourceTree = ""; }; - 15384E5216119CC30021DC07 /* ScriptingCore.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptingCore.cpp; sourceTree = ""; }; - 15384E5316119CC30021DC07 /* ScriptingCore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptingCore.h; sourceTree = ""; }; - 15384E5416119CC30021DC07 /* spidermonkey_specifics.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = spidermonkey_specifics.h; sourceTree = ""; }; - 15384E5516119CC30021DC07 /* uthash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = uthash.h; sourceTree = ""; }; - 15384E6516119D5E0021DC07 /* CCBAnimationManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCBAnimationManager.cpp; sourceTree = ""; }; - 15384E6616119D5E0021DC07 /* CCBAnimationManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCBAnimationManager.h; sourceTree = ""; }; - 15384E6716119D5E0021DC07 /* CCBFileLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCBFileLoader.cpp; sourceTree = ""; }; - 15384E6816119D5E0021DC07 /* CCBFileLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCBFileLoader.h; sourceTree = ""; }; - 15384E6916119D5E0021DC07 /* CCBKeyframe.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCBKeyframe.cpp; sourceTree = ""; }; - 15384E6A16119D5E0021DC07 /* CCBKeyframe.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCBKeyframe.h; sourceTree = ""; }; - 15384E6B16119D5E0021DC07 /* CCBMemberVariableAssigner.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCBMemberVariableAssigner.h; sourceTree = ""; }; - 15384E6C16119D5E0021DC07 /* CCBReader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCBReader.cpp; sourceTree = ""; }; - 15384E6D16119D5E0021DC07 /* CCBReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCBReader.h; sourceTree = ""; }; - 15384E6E16119D5E0021DC07 /* CCBSelectorResolver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCBSelectorResolver.h; sourceTree = ""; }; - 15384E6F16119D5E0021DC07 /* CCBSequence.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCBSequence.cpp; sourceTree = ""; }; - 15384E7016119D5E0021DC07 /* CCBSequence.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCBSequence.h; sourceTree = ""; }; - 15384E7116119D5E0021DC07 /* CCBSequenceProperty.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCBSequenceProperty.cpp; sourceTree = ""; }; - 15384E7216119D5E0021DC07 /* CCBSequenceProperty.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCBSequenceProperty.h; sourceTree = ""; }; - 15384E7316119D5E0021DC07 /* CCBValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCBValue.cpp; sourceTree = ""; }; - 15384E7416119D5E0021DC07 /* CCBValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCBValue.h; sourceTree = ""; }; - 15384E7516119D5E0021DC07 /* CCControlButtonLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCControlButtonLoader.cpp; sourceTree = ""; }; - 15384E7616119D5E0021DC07 /* CCControlButtonLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCControlButtonLoader.h; sourceTree = ""; }; - 15384E7716119D5E0021DC07 /* CCControlLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCControlLoader.cpp; sourceTree = ""; }; - 15384E7816119D5E0021DC07 /* CCControlLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCControlLoader.h; sourceTree = ""; }; - 15384E7916119D5E0021DC07 /* CCData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCData.cpp; sourceTree = ""; }; - 15384E7A16119D5E0021DC07 /* CCData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCData.h; sourceTree = ""; }; - 15384E7B16119D5E0021DC07 /* CCLabelBMFontLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCLabelBMFontLoader.cpp; sourceTree = ""; }; - 15384E7C16119D5E0021DC07 /* CCLabelBMFontLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCLabelBMFontLoader.h; sourceTree = ""; }; - 15384E7D16119D5E0021DC07 /* CCLabelTTFLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCLabelTTFLoader.cpp; sourceTree = ""; }; - 15384E7E16119D5E0021DC07 /* CCLabelTTFLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCLabelTTFLoader.h; sourceTree = ""; }; - 15384E7F16119D5E0021DC07 /* CCLayerColorLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCLayerColorLoader.cpp; sourceTree = ""; }; - 15384E8016119D5E0021DC07 /* CCLayerColorLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCLayerColorLoader.h; sourceTree = ""; }; - 15384E8116119D5E0021DC07 /* CCLayerGradientLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCLayerGradientLoader.cpp; sourceTree = ""; }; - 15384E8216119D5E0021DC07 /* CCLayerGradientLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCLayerGradientLoader.h; sourceTree = ""; }; - 15384E8316119D5E0021DC07 /* CCLayerLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCLayerLoader.cpp; sourceTree = ""; }; - 15384E8416119D5E0021DC07 /* CCLayerLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCLayerLoader.h; sourceTree = ""; }; - 15384E8516119D5E0021DC07 /* CCMenuItemImageLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCMenuItemImageLoader.cpp; sourceTree = ""; }; - 15384E8616119D5E0021DC07 /* CCMenuItemImageLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCMenuItemImageLoader.h; sourceTree = ""; }; - 15384E8716119D5E0021DC07 /* CCMenuItemLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCMenuItemLoader.cpp; sourceTree = ""; }; - 15384E8816119D5E0021DC07 /* CCMenuItemLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCMenuItemLoader.h; sourceTree = ""; }; - 15384E8916119D5E0021DC07 /* CCMenuLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCMenuLoader.h; sourceTree = ""; }; - 15384E8A16119D5E0021DC07 /* CCNode+CCBRelativePositioning.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = "CCNode+CCBRelativePositioning.cpp"; sourceTree = ""; }; - 15384E8B16119D5E0021DC07 /* CCNode+CCBRelativePositioning.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "CCNode+CCBRelativePositioning.h"; sourceTree = ""; }; - 15384E8C16119D5E0021DC07 /* CCNodeLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCNodeLoader.cpp; sourceTree = ""; }; - 15384E8D16119D5E0021DC07 /* CCNodeLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCNodeLoader.h; sourceTree = ""; }; - 15384E8E16119D5E0021DC07 /* CCNodeLoaderLibrary.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCNodeLoaderLibrary.cpp; sourceTree = ""; }; - 15384E8F16119D5E0021DC07 /* CCNodeLoaderLibrary.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCNodeLoaderLibrary.h; sourceTree = ""; }; - 15384E9016119D5E0021DC07 /* CCNodeLoaderListener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCNodeLoaderListener.h; sourceTree = ""; }; - 15384E9116119D5E0021DC07 /* CCParticleSystemQuadLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCParticleSystemQuadLoader.cpp; sourceTree = ""; }; - 15384E9216119D5E0021DC07 /* CCParticleSystemQuadLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCParticleSystemQuadLoader.h; sourceTree = ""; }; - 15384E9316119D5E0021DC07 /* CCScale9SpriteLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCScale9SpriteLoader.cpp; sourceTree = ""; }; - 15384E9416119D5E0021DC07 /* CCScale9SpriteLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCScale9SpriteLoader.h; sourceTree = ""; }; - 15384E9516119D5E0021DC07 /* CCScrollViewLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCScrollViewLoader.cpp; sourceTree = ""; }; - 15384E9616119D5E0021DC07 /* CCScrollViewLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCScrollViewLoader.h; sourceTree = ""; }; - 15384E9716119D5E0021DC07 /* CCSpriteLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCSpriteLoader.cpp; sourceTree = ""; }; - 15384E9816119D5E0021DC07 /* CCSpriteLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCSpriteLoader.h; sourceTree = ""; }; - 15384E9916119D5E0021DC07 /* cocos-ext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "cocos-ext.h"; sourceTree = ""; }; - 15384E9A16119D5E0021DC07 /* ExtensionMacros.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ExtensionMacros.h; sourceTree = ""; }; - 15384EB716119D5E0021DC07 /* CCEditBox.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCEditBox.cpp; sourceTree = ""; }; - 15384EB816119D5E0021DC07 /* CCEditBox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCEditBox.h; sourceTree = ""; }; - 15384EB916119D5E0021DC07 /* CCEditBoxImpl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCEditBoxImpl.h; sourceTree = ""; }; - 15384EBC16119D5E0021DC07 /* CCEditBoxImplIOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCEditBoxImplIOS.h; sourceTree = ""; }; - 15384EBD16119D5E0021DC07 /* CCEditBoxImplIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CCEditBoxImplIOS.mm; sourceTree = ""; }; - 15384EBE16119D5E0021DC07 /* EditBoxImplIOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EditBoxImplIOS.h; sourceTree = ""; }; - 15384EBF16119D5E0021DC07 /* EditBoxImplIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = EditBoxImplIOS.mm; sourceTree = ""; }; - 15384EC116119D5E0021DC07 /* CCScrollView.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCScrollView.cpp; sourceTree = ""; }; - 15384EC216119D5E0021DC07 /* CCScrollView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCScrollView.h; sourceTree = ""; }; - 15384EC316119D5E0021DC07 /* CCSorting.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCSorting.cpp; sourceTree = ""; }; - 15384EC416119D5E0021DC07 /* CCSorting.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCSorting.h; sourceTree = ""; }; - 15384EC516119D5E0021DC07 /* CCTableView.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCTableView.cpp; sourceTree = ""; }; - 15384EC616119D5E0021DC07 /* CCTableView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCTableView.h; sourceTree = ""; }; - 15384EC716119D5E0021DC07 /* CCTableViewCell.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCTableViewCell.cpp; sourceTree = ""; }; - 15384EC816119D5E0021DC07 /* CCTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCTableViewCell.h; sourceTree = ""; }; - 15426AE915B5733200712A7F /* cocos2dx.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = cocos2dx.xcodeproj; path = ../../../cocos2dx/proj.ios/cocos2dx.xcodeproj; sourceTree = ""; }; - 15426FCC15B5743C00712A7F /* Export.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Export.h; sourceTree = ""; }; - 15426FCD15B5743C00712A7F /* SimpleAudioEngine.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SimpleAudioEngine.h; sourceTree = ""; }; - 15426FCF15B5743C00712A7F /* CDAudioManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDAudioManager.h; sourceTree = ""; }; - 15426FD015B5743C00712A7F /* CDAudioManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDAudioManager.m; sourceTree = ""; }; - 15426FD115B5743C00712A7F /* CDConfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDConfig.h; sourceTree = ""; }; - 15426FD215B5743C00712A7F /* CDOpenALSupport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDOpenALSupport.h; sourceTree = ""; }; - 15426FD315B5743C00712A7F /* CDOpenALSupport.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDOpenALSupport.m; sourceTree = ""; }; - 15426FD415B5743C00712A7F /* CocosDenshion.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CocosDenshion.h; sourceTree = ""; }; - 15426FD515B5743C00712A7F /* CocosDenshion.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CocosDenshion.m; sourceTree = ""; }; - 15426FD615B5743C00712A7F /* SimpleAudioEngine.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SimpleAudioEngine.mm; sourceTree = ""; }; - 15426FD715B5743C00712A7F /* SimpleAudioEngine_objc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SimpleAudioEngine_objc.h; sourceTree = ""; }; - 15426FD815B5743C00712A7F /* SimpleAudioEngine_objc.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SimpleAudioEngine_objc.m; sourceTree = ""; }; - 15628F5D15F0F5E5000CF24B /* ballbounce.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; name = ballbounce.wav; path = ../Resources/ballbounce.wav; sourceTree = ""; }; - 15628F5E15F0F5E5000CF24B /* cowbell.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; name = cowbell.wav; path = ../Resources/cowbell.wav; sourceTree = ""; }; - 15628F5F15F0F5E5000CF24B /* Cyber Advance!.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; name = "Cyber Advance!.mp3"; path = "../Resources/Cyber Advance!.mp3"; sourceTree = ""; }; - 15628F6015F0F5E5000CF24B /* Fonts */ = {isa = PBXFileReference; lastKnownFileType = folder; name = Fonts; path = ../Resources/Fonts; sourceTree = ""; }; - 15628F6115F0F5E5000CF24B /* Images */ = {isa = PBXFileReference; lastKnownFileType = folder; name = Images; path = ../Resources/Images; sourceTree = ""; }; - 15628F6215F0F5E5000CF24B /* js */ = {isa = PBXFileReference; lastKnownFileType = folder; name = js; path = ../Resources/js; sourceTree = ""; }; - 15628F6315F0F5E5000CF24B /* oldjs */ = {isa = PBXFileReference; lastKnownFileType = folder; name = oldjs; path = ../Resources/oldjs; sourceTree = ""; }; - 15628F6415F0F5E5000CF24B /* Particles */ = {isa = PBXFileReference; lastKnownFileType = folder; name = Particles; path = ../Resources/Particles; sourceTree = ""; }; - 15628F6515F0F5E5000CF24B /* Silly Fun Theme A.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; name = "Silly Fun Theme A.mp3"; path = "../Resources/Silly Fun Theme A.mp3"; sourceTree = ""; }; - 15628F6615F0F5E5000CF24B /* tank.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = tank.plist; path = ../Resources/tank.plist; sourceTree = ""; }; - 15628F6715F0F5E5000CF24B /* tank.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = tank.png; path = ../Resources/tank.png; sourceTree = ""; }; - 15628F6815F0F5E5000CF24B /* tank.tps */ = {isa = PBXFileReference; lastKnownFileType = file; name = tank.tps; path = ../Resources/tank.tps; sourceTree = ""; }; - 15628F6915F0F5E5000CF24B /* tank1.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = tank1.png; path = ../Resources/tank1.png; sourceTree = ""; }; - 15628F6A15F0F5E5000CF24B /* TileMaps */ = {isa = PBXFileReference; lastKnownFileType = folder; name = TileMaps; path = ../Resources/TileMaps; sourceTree = ""; }; - 15628FA815F1057E000CF24B /* animations */ = {isa = PBXFileReference; lastKnownFileType = folder; name = animations; path = ../Resources/animations; sourceTree = ""; }; - 15CFE18D1612FD0E00BF2188 /* CCControl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCControl.cpp; sourceTree = ""; }; - 15CFE18E1612FD0E00BF2188 /* CCControl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCControl.h; sourceTree = ""; }; - 15CFE18F1612FD0E00BF2188 /* CCControlButton.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCControlButton.cpp; sourceTree = ""; }; - 15CFE1901612FD0E00BF2188 /* CCControlButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCControlButton.h; sourceTree = ""; }; - 15CFE1911612FD0E00BF2188 /* CCControlColourPicker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCControlColourPicker.cpp; sourceTree = ""; }; - 15CFE1921612FD0E00BF2188 /* CCControlColourPicker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCControlColourPicker.h; sourceTree = ""; }; - 15CFE1931612FD0E00BF2188 /* CCControlExtensions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCControlExtensions.h; sourceTree = ""; }; - 15CFE1941612FD0E00BF2188 /* CCControlHuePicker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCControlHuePicker.cpp; sourceTree = ""; }; - 15CFE1951612FD0E00BF2188 /* CCControlHuePicker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCControlHuePicker.h; sourceTree = ""; }; - 15CFE1961612FD0E00BF2188 /* CCControlPotentiometer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCControlPotentiometer.cpp; sourceTree = ""; }; - 15CFE1971612FD0E00BF2188 /* CCControlPotentiometer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCControlPotentiometer.h; sourceTree = ""; }; - 15CFE1981612FD0E00BF2188 /* CCControlSaturationBrightnessPicker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCControlSaturationBrightnessPicker.cpp; sourceTree = ""; }; - 15CFE1991612FD0E00BF2188 /* CCControlSaturationBrightnessPicker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCControlSaturationBrightnessPicker.h; sourceTree = ""; }; - 15CFE19A1612FD0E00BF2188 /* CCControlSlider.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCControlSlider.cpp; sourceTree = ""; }; - 15CFE19B1612FD0E00BF2188 /* CCControlSlider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCControlSlider.h; sourceTree = ""; }; - 15CFE19C1612FD0E00BF2188 /* CCControlStepper.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCControlStepper.cpp; sourceTree = ""; }; - 15CFE19D1612FD0E00BF2188 /* CCControlStepper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCControlStepper.h; sourceTree = ""; }; - 15CFE19E1612FD0E00BF2188 /* CCControlSwitch.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCControlSwitch.cpp; sourceTree = ""; }; - 15CFE19F1612FD0E00BF2188 /* CCControlSwitch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCControlSwitch.h; sourceTree = ""; }; - 15CFE1A01612FD0E00BF2188 /* CCControlUtils.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCControlUtils.cpp; sourceTree = ""; }; - 15CFE1A11612FD0E00BF2188 /* CCControlUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCControlUtils.h; sourceTree = ""; }; - 15CFE1A21612FD0E00BF2188 /* CCInvocation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCInvocation.cpp; sourceTree = ""; }; - 15CFE1A31612FD0E00BF2188 /* CCInvocation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCInvocation.h; sourceTree = ""; }; - 15CFE1A41612FD0E00BF2188 /* CCScale9Sprite.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCScale9Sprite.cpp; sourceTree = ""; }; - 15CFE1A51612FD0E00BF2188 /* CCScale9Sprite.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCScale9Sprite.h; sourceTree = ""; }; - 2628297D15EC7196002C4240 /* .gitignore */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = .gitignore; sourceTree = ""; }; - 2628297E15EC7196002C4240 /* Android.mk */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Android.mk; sourceTree = ""; }; - 2628297F15EC7196002C4240 /* chipmunk-docs.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "chipmunk-docs.html"; sourceTree = ""; }; - 2628298215EC7196002C4240 /* chipmunk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = chipmunk.h; sourceTree = ""; }; - 2628298315EC7196002C4240 /* chipmunk_ffi.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = chipmunk_ffi.h; sourceTree = ""; }; - 2628298415EC7196002C4240 /* chipmunk_private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = chipmunk_private.h; sourceTree = ""; }; - 2628298515EC7196002C4240 /* chipmunk_types.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = chipmunk_types.h; sourceTree = ""; }; - 2628298615EC7196002C4240 /* chipmunk_unsafe.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = chipmunk_unsafe.h; sourceTree = ""; }; - 2628298815EC7196002C4240 /* cpConstraint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cpConstraint.h; sourceTree = ""; }; - 2628298915EC7196002C4240 /* cpDampedRotarySpring.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cpDampedRotarySpring.h; sourceTree = ""; }; - 2628298A15EC7196002C4240 /* cpDampedSpring.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cpDampedSpring.h; sourceTree = ""; }; - 2628298B15EC7196002C4240 /* cpGearJoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cpGearJoint.h; sourceTree = ""; }; - 2628298C15EC7196002C4240 /* cpGrooveJoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cpGrooveJoint.h; sourceTree = ""; }; - 2628298D15EC7196002C4240 /* cpPinJoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cpPinJoint.h; sourceTree = ""; }; - 2628298E15EC7196002C4240 /* cpPivotJoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cpPivotJoint.h; sourceTree = ""; }; - 2628298F15EC7196002C4240 /* cpRatchetJoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cpRatchetJoint.h; sourceTree = ""; }; - 2628299015EC7196002C4240 /* cpRotaryLimitJoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cpRotaryLimitJoint.h; sourceTree = ""; }; - 2628299115EC7196002C4240 /* cpSimpleMotor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cpSimpleMotor.h; sourceTree = ""; }; - 2628299215EC7196002C4240 /* cpSlideJoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cpSlideJoint.h; sourceTree = ""; }; - 2628299315EC7196002C4240 /* util.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = util.h; sourceTree = ""; }; - 2628299415EC7196002C4240 /* cpArbiter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cpArbiter.h; sourceTree = ""; }; - 2628299515EC7196002C4240 /* cpBB.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cpBB.h; sourceTree = ""; }; - 2628299615EC7196002C4240 /* cpBody.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cpBody.h; sourceTree = ""; }; - 2628299715EC7196002C4240 /* cpPolyShape.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cpPolyShape.h; sourceTree = ""; }; - 2628299815EC7196002C4240 /* cpShape.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cpShape.h; sourceTree = ""; }; - 2628299915EC7196002C4240 /* cpSpace.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cpSpace.h; sourceTree = ""; }; - 2628299A15EC7196002C4240 /* cpSpatialIndex.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cpSpatialIndex.h; sourceTree = ""; }; - 2628299B15EC7196002C4240 /* cpVect.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cpVect.h; sourceTree = ""; }; - 2628299C15EC7196002C4240 /* LICENSE.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = LICENSE.txt; sourceTree = ""; }; - 2628299E15EC7196002C4240 /* .cproject */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = .cproject; sourceTree = ""; }; - 2628299F15EC7196002C4240 /* .project */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = .project; sourceTree = ""; }; - 262829A115EC7196002C4240 /* .cproject */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = .cproject; sourceTree = ""; }; - 262829A215EC7196002C4240 /* .project */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = .project; sourceTree = ""; }; - 262829A315EC7196002C4240 /* Makefile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.make; path = Makefile; sourceTree = ""; }; - 262829A515EC7196002C4240 /* chipmunk.vcproj */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = chipmunk.vcproj; sourceTree = ""; }; - 262829A615EC7196002C4240 /* chipmunk.vcproj.user */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = chipmunk.vcproj.user; sourceTree = ""; }; - 262829A715EC7196002C4240 /* chipmunk.vcxproj */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = chipmunk.vcxproj; sourceTree = ""; }; - 262829A815EC7196002C4240 /* chipmunk.vcxproj.filters */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = chipmunk.vcxproj.filters; sourceTree = ""; }; - 262829A915EC7196002C4240 /* chipmunk.vcxproj.user */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = chipmunk.vcxproj.user; sourceTree = ""; }; - 262829AA15EC7196002C4240 /* README.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README.txt; sourceTree = ""; }; - 262829AC15EC7196002C4240 /* chipmunk.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = chipmunk.c; sourceTree = ""; }; - 262829AD15EC7196002C4240 /* CMakeLists.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CMakeLists.txt; sourceTree = ""; }; - 262829AF15EC7196002C4240 /* cpConstraint.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = cpConstraint.c; sourceTree = ""; }; - 262829B015EC7196002C4240 /* cpDampedRotarySpring.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = cpDampedRotarySpring.c; sourceTree = ""; }; - 262829B115EC7196002C4240 /* cpDampedSpring.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = cpDampedSpring.c; sourceTree = ""; }; - 262829B215EC7196002C4240 /* cpGearJoint.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = cpGearJoint.c; sourceTree = ""; }; - 262829B315EC7196002C4240 /* cpGrooveJoint.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = cpGrooveJoint.c; sourceTree = ""; }; - 262829B415EC7196002C4240 /* cpPinJoint.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = cpPinJoint.c; sourceTree = ""; }; - 262829B515EC7196002C4240 /* cpPivotJoint.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = cpPivotJoint.c; sourceTree = ""; }; - 262829B615EC7196002C4240 /* cpRatchetJoint.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = cpRatchetJoint.c; sourceTree = ""; }; - 262829B715EC7196002C4240 /* cpRotaryLimitJoint.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = cpRotaryLimitJoint.c; sourceTree = ""; }; - 262829B815EC7196002C4240 /* cpSimpleMotor.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = cpSimpleMotor.c; sourceTree = ""; }; - 262829B915EC7196002C4240 /* cpSlideJoint.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = cpSlideJoint.c; sourceTree = ""; }; - 262829BA15EC7196002C4240 /* cpArbiter.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = cpArbiter.c; sourceTree = ""; }; - 262829BB15EC7196002C4240 /* cpArray.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = cpArray.c; sourceTree = ""; }; - 262829BC15EC7196002C4240 /* cpBB.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = cpBB.c; sourceTree = ""; }; - 262829BD15EC7196002C4240 /* cpBBTree.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = cpBBTree.c; sourceTree = ""; }; - 262829BE15EC7196002C4240 /* cpBody.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = cpBody.c; sourceTree = ""; }; - 262829BF15EC7196002C4240 /* cpCollision.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = cpCollision.c; sourceTree = ""; }; - 262829C015EC7196002C4240 /* cpHashSet.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = cpHashSet.c; sourceTree = ""; }; - 262829C115EC7196002C4240 /* cpPolyShape.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = cpPolyShape.c; sourceTree = ""; }; - 262829C215EC7196002C4240 /* cpShape.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = cpShape.c; sourceTree = ""; }; - 262829C315EC7196002C4240 /* cpSpace.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = cpSpace.c; sourceTree = ""; }; - 262829C415EC7196002C4240 /* cpSpaceComponent.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = cpSpaceComponent.c; sourceTree = ""; }; - 262829C515EC7196002C4240 /* cpSpaceHash.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = cpSpaceHash.c; sourceTree = ""; }; - 262829C615EC7196002C4240 /* cpSpaceQuery.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = cpSpaceQuery.c; sourceTree = ""; }; - 262829C715EC7196002C4240 /* cpSpaceStep.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = cpSpaceStep.c; sourceTree = ""; }; - 262829C815EC7196002C4240 /* cpSpatialIndex.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = cpSpatialIndex.c; sourceTree = ""; }; - 262829C915EC7196002C4240 /* cpSweep1D.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = cpSweep1D.c; sourceTree = ""; }; - 262829CA15EC7196002C4240 /* cpVect.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = cpVect.c; sourceTree = ""; }; - 262829CB15EC7196002C4240 /* prime.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = prime.h; sourceTree = ""; }; - A922753D1517C094001B78AA /* TestJavascript.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = TestJavascript.app; sourceTree = BUILT_PRODUCTS_DIR; }; - A92275411517C094001B78AA /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; }; - A92275431517C094001B78AA /* OpenGLES.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = System/Library/Frameworks/OpenGLES.framework; sourceTree = SDKROOT; }; - A92275451517C094001B78AA /* OpenAL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenAL.framework; path = System/Library/Frameworks/OpenAL.framework; sourceTree = SDKROOT; }; - A92275471517C094001B78AA /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; }; - A92275491517C094001B78AA /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = System/Library/Frameworks/AVFoundation.framework; sourceTree = SDKROOT; }; - A922754B1517C094001B78AA /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; - A922754D1517C094001B78AA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; - A922754F1517C094001B78AA /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; - D446FDA216102D7D000ADA7B /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Default.png; sourceTree = ""; }; - D446FDA416102D82000ADA7B /* Default@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default@2x.png"; sourceTree = ""; }; - D446FDA616102D86000ADA7B /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; - D45446CD156DE74F00887EB5 /* AppController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppController.h; sourceTree = ""; }; - D45446CE156DE74F00887EB5 /* AppController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AppController.mm; sourceTree = ""; }; - D45446CF156DE74F00887EB5 /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; - D45446D0156DE74F00887EB5 /* Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Prefix.pch; sourceTree = ""; }; - D45446D1156DE74F00887EB5 /* RootViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RootViewController.h; sourceTree = ""; }; - D45446D2156DE74F00887EB5 /* RootViewController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RootViewController.mm; sourceTree = ""; }; - D45446D6156DE79D00887EB5 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - D4545209156E22B400887EB5 /* libxml2.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libxml2.dylib; path = usr/lib/libxml2.dylib; sourceTree = SDKROOT; }; - D454520B156E22BD00887EB5 /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = usr/lib/libz.dylib; sourceTree = SDKROOT; }; - D4545215156E28EF00887EB5 /* AppDelegate.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AppDelegate.cpp; sourceTree = ""; }; - D4545216156E28EF00887EB5 /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - A922753A1517C094001B78AA /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 15426FC315B5742200712A7F /* libcocos2dx.a in Frameworks */, - D454520C156E22BD00887EB5 /* libz.dylib in Frameworks */, - D454520A156E22B400887EB5 /* libxml2.dylib in Frameworks */, - A92275421517C094001B78AA /* QuartzCore.framework in Frameworks */, - A92275441517C094001B78AA /* OpenGLES.framework in Frameworks */, - A92275461517C094001B78AA /* OpenAL.framework in Frameworks */, - A92275481517C094001B78AA /* AudioToolbox.framework in Frameworks */, - A922754A1517C094001B78AA /* AVFoundation.framework in Frameworks */, - A922754C1517C094001B78AA /* UIKit.framework in Frameworks */, - A922754E1517C094001B78AA /* Foundation.framework in Frameworks */, - A92275501517C094001B78AA /* CoreGraphics.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - 15384E3C16119CC30021DC07 /* bindings */ = { - isa = PBXGroup; - children = ( - 15384E3E16119CC30021DC07 /* CCPhysicsSprite.cpp */, - 15384E3F16119CC30021DC07 /* CCPhysicsSprite.h */, - 15384E4016119CC30021DC07 /* cocos2d_specifics.cpp */, - 15384E4116119CC30021DC07 /* cocos2d_specifics.hpp */, - 15384E4216119CC30021DC07 /* cocosjs_manual_conversions.cpp */, - 15384E4316119CC30021DC07 /* cocosjs_manual_conversions.h */, - 15384E4416119CC30021DC07 /* generated */, - 15384E4916119CC30021DC07 /* js_bindings_ccbreader.cpp */, - 15384E4A16119CC30021DC07 /* js_bindings_ccbreader.h */, - 15384E4B16119CC30021DC07 /* js_bindings_chipmunk_functions.cpp */, - 15384E4C16119CC30021DC07 /* js_bindings_chipmunk_functions.hpp */, - 15384E4D16119CC30021DC07 /* js_bindings_chipmunk_manual.cpp */, - 15384E4E16119CC30021DC07 /* js_bindings_chipmunk_manual.hpp */, - 15384E4F16119CC30021DC07 /* js_bindings_config.h */, - 15384E5016119CC30021DC07 /* js_manual_conversions.cpp */, - 15384E5116119CC30021DC07 /* js_manual_conversions.h */, - 15384E5216119CC30021DC07 /* ScriptingCore.cpp */, - 15384E5316119CC30021DC07 /* ScriptingCore.h */, - 15384E5416119CC30021DC07 /* spidermonkey_specifics.h */, - 15384E5516119CC30021DC07 /* uthash.h */, - ); - name = bindings; - path = ../../../scripting/javascript/bindings; - sourceTree = ""; - }; - 15384E4416119CC30021DC07 /* generated */ = { - isa = PBXGroup; - children = ( - 15384E4516119CC30021DC07 /* cocos2dx.cpp */, - 15384E4616119CC30021DC07 /* cocos2dx.hpp */, - ); - path = generated; - sourceTree = ""; - }; - 15384E6216119D5E0021DC07 /* extensions */ = { - isa = PBXGroup; - children = ( - 15384E6416119D5E0021DC07 /* CCBReader */, - 15384E9916119D5E0021DC07 /* cocos-ext.h */, - 15384E9A16119D5E0021DC07 /* ExtensionMacros.h */, - 15384E9B16119D5E0021DC07 /* GUI */, - ); - name = extensions; - path = ../../../extensions; - sourceTree = ""; - }; - 15384E6416119D5E0021DC07 /* CCBReader */ = { - isa = PBXGroup; - children = ( - 15384E6516119D5E0021DC07 /* CCBAnimationManager.cpp */, - 15384E6616119D5E0021DC07 /* CCBAnimationManager.h */, - 15384E6716119D5E0021DC07 /* CCBFileLoader.cpp */, - 15384E6816119D5E0021DC07 /* CCBFileLoader.h */, - 15384E6916119D5E0021DC07 /* CCBKeyframe.cpp */, - 15384E6A16119D5E0021DC07 /* CCBKeyframe.h */, - 15384E6B16119D5E0021DC07 /* CCBMemberVariableAssigner.h */, - 15384E6C16119D5E0021DC07 /* CCBReader.cpp */, - 15384E6D16119D5E0021DC07 /* CCBReader.h */, - 15384E6E16119D5E0021DC07 /* CCBSelectorResolver.h */, - 15384E6F16119D5E0021DC07 /* CCBSequence.cpp */, - 15384E7016119D5E0021DC07 /* CCBSequence.h */, - 15384E7116119D5E0021DC07 /* CCBSequenceProperty.cpp */, - 15384E7216119D5E0021DC07 /* CCBSequenceProperty.h */, - 15384E7316119D5E0021DC07 /* CCBValue.cpp */, - 15384E7416119D5E0021DC07 /* CCBValue.h */, - 15384E7516119D5E0021DC07 /* CCControlButtonLoader.cpp */, - 15384E7616119D5E0021DC07 /* CCControlButtonLoader.h */, - 15384E7716119D5E0021DC07 /* CCControlLoader.cpp */, - 15384E7816119D5E0021DC07 /* CCControlLoader.h */, - 15384E7916119D5E0021DC07 /* CCData.cpp */, - 15384E7A16119D5E0021DC07 /* CCData.h */, - 15384E7B16119D5E0021DC07 /* CCLabelBMFontLoader.cpp */, - 15384E7C16119D5E0021DC07 /* CCLabelBMFontLoader.h */, - 15384E7D16119D5E0021DC07 /* CCLabelTTFLoader.cpp */, - 15384E7E16119D5E0021DC07 /* CCLabelTTFLoader.h */, - 15384E7F16119D5E0021DC07 /* CCLayerColorLoader.cpp */, - 15384E8016119D5E0021DC07 /* CCLayerColorLoader.h */, - 15384E8116119D5E0021DC07 /* CCLayerGradientLoader.cpp */, - 15384E8216119D5E0021DC07 /* CCLayerGradientLoader.h */, - 15384E8316119D5E0021DC07 /* CCLayerLoader.cpp */, - 15384E8416119D5E0021DC07 /* CCLayerLoader.h */, - 15384E8516119D5E0021DC07 /* CCMenuItemImageLoader.cpp */, - 15384E8616119D5E0021DC07 /* CCMenuItemImageLoader.h */, - 15384E8716119D5E0021DC07 /* CCMenuItemLoader.cpp */, - 15384E8816119D5E0021DC07 /* CCMenuItemLoader.h */, - 15384E8916119D5E0021DC07 /* CCMenuLoader.h */, - 15384E8A16119D5E0021DC07 /* CCNode+CCBRelativePositioning.cpp */, - 15384E8B16119D5E0021DC07 /* CCNode+CCBRelativePositioning.h */, - 15384E8C16119D5E0021DC07 /* CCNodeLoader.cpp */, - 15384E8D16119D5E0021DC07 /* CCNodeLoader.h */, - 15384E8E16119D5E0021DC07 /* CCNodeLoaderLibrary.cpp */, - 15384E8F16119D5E0021DC07 /* CCNodeLoaderLibrary.h */, - 15384E9016119D5E0021DC07 /* CCNodeLoaderListener.h */, - 15384E9116119D5E0021DC07 /* CCParticleSystemQuadLoader.cpp */, - 15384E9216119D5E0021DC07 /* CCParticleSystemQuadLoader.h */, - 15384E9316119D5E0021DC07 /* CCScale9SpriteLoader.cpp */, - 15384E9416119D5E0021DC07 /* CCScale9SpriteLoader.h */, - 15384E9516119D5E0021DC07 /* CCScrollViewLoader.cpp */, - 15384E9616119D5E0021DC07 /* CCScrollViewLoader.h */, - 15384E9716119D5E0021DC07 /* CCSpriteLoader.cpp */, - 15384E9816119D5E0021DC07 /* CCSpriteLoader.h */, - ); - path = CCBReader; - sourceTree = ""; - }; - 15384E9B16119D5E0021DC07 /* GUI */ = { - isa = PBXGroup; - children = ( - 15CFE18C1612FD0E00BF2188 /* CCControlExtension */, - 15384EB616119D5E0021DC07 /* CCEditBox */, - 15384EC016119D5E0021DC07 /* CCScrollView */, - ); - path = GUI; - sourceTree = ""; - }; - 15384EB616119D5E0021DC07 /* CCEditBox */ = { - isa = PBXGroup; - children = ( - 15384EB716119D5E0021DC07 /* CCEditBox.cpp */, - 15384EB816119D5E0021DC07 /* CCEditBox.h */, - 15384EB916119D5E0021DC07 /* CCEditBoxImpl.h */, - 15384EBC16119D5E0021DC07 /* CCEditBoxImplIOS.h */, - 15384EBD16119D5E0021DC07 /* CCEditBoxImplIOS.mm */, - 15384EBE16119D5E0021DC07 /* EditBoxImplIOS.h */, - 15384EBF16119D5E0021DC07 /* EditBoxImplIOS.mm */, - ); - path = CCEditBox; - sourceTree = ""; - }; - 15384EC016119D5E0021DC07 /* CCScrollView */ = { - isa = PBXGroup; - children = ( - 15384EC116119D5E0021DC07 /* CCScrollView.cpp */, - 15384EC216119D5E0021DC07 /* CCScrollView.h */, - 15384EC316119D5E0021DC07 /* CCSorting.cpp */, - 15384EC416119D5E0021DC07 /* CCSorting.h */, - 15384EC516119D5E0021DC07 /* CCTableView.cpp */, - 15384EC616119D5E0021DC07 /* CCTableView.h */, - 15384EC716119D5E0021DC07 /* CCTableViewCell.cpp */, - 15384EC816119D5E0021DC07 /* CCTableViewCell.h */, - ); - path = CCScrollView; - sourceTree = ""; - }; - 15426AEA15B5733200712A7F /* Products */ = { - isa = PBXGroup; - children = ( - 15426AF115B5733200712A7F /* libcocos2dx.a */, - ); - name = Products; - sourceTree = ""; - }; - 15426FC415B5743C00712A7F /* CocosDenshion */ = { - isa = PBXGroup; - children = ( - 15426FCB15B5743C00712A7F /* include */, - 15426FCE15B5743C00712A7F /* ios */, - ); - name = CocosDenshion; - path = ../../../CocosDenshion; - sourceTree = ""; - }; - 15426FCB15B5743C00712A7F /* include */ = { - isa = PBXGroup; - children = ( - 15426FCC15B5743C00712A7F /* Export.h */, - 15426FCD15B5743C00712A7F /* SimpleAudioEngine.h */, - ); - path = include; - sourceTree = ""; - }; - 15426FCE15B5743C00712A7F /* ios */ = { - isa = PBXGroup; - children = ( - 15426FCF15B5743C00712A7F /* CDAudioManager.h */, - 15426FD015B5743C00712A7F /* CDAudioManager.m */, - 15426FD115B5743C00712A7F /* CDConfig.h */, - 15426FD215B5743C00712A7F /* CDOpenALSupport.h */, - 15426FD315B5743C00712A7F /* CDOpenALSupport.m */, - 15426FD415B5743C00712A7F /* CocosDenshion.h */, - 15426FD515B5743C00712A7F /* CocosDenshion.m */, - 15426FD615B5743C00712A7F /* SimpleAudioEngine.mm */, - 15426FD715B5743C00712A7F /* SimpleAudioEngine_objc.h */, - 15426FD815B5743C00712A7F /* SimpleAudioEngine_objc.m */, - ); - path = ios; - sourceTree = ""; - }; - 15628F5B15F0F5C2000CF24B /* Resources */ = { - isa = PBXGroup; - children = ( - D446FDA616102D86000ADA7B /* Default-568h@2x.png */, - D446FDA416102D82000ADA7B /* Default@2x.png */, - D446FDA216102D7D000ADA7B /* Default.png */, - 15628FA815F1057E000CF24B /* animations */, - 15628F5D15F0F5E5000CF24B /* ballbounce.wav */, - 15628F5E15F0F5E5000CF24B /* cowbell.wav */, - 15628F5F15F0F5E5000CF24B /* Cyber Advance!.mp3 */, - 15628F6015F0F5E5000CF24B /* Fonts */, - 15628F6115F0F5E5000CF24B /* Images */, - 15628F6215F0F5E5000CF24B /* js */, - 15628F6315F0F5E5000CF24B /* oldjs */, - 15628F6415F0F5E5000CF24B /* Particles */, - 15628F6515F0F5E5000CF24B /* Silly Fun Theme A.mp3 */, - 15628F6615F0F5E5000CF24B /* tank.plist */, - 15628F6715F0F5E5000CF24B /* tank.png */, - 15628F6815F0F5E5000CF24B /* tank.tps */, - 15628F6915F0F5E5000CF24B /* tank1.png */, - 15628F6A15F0F5E5000CF24B /* TileMaps */, - ); - name = Resources; - sourceTree = ""; - }; - 15CFE18C1612FD0E00BF2188 /* CCControlExtension */ = { - isa = PBXGroup; - children = ( - 15CFE18D1612FD0E00BF2188 /* CCControl.cpp */, - 15CFE18E1612FD0E00BF2188 /* CCControl.h */, - 15CFE18F1612FD0E00BF2188 /* CCControlButton.cpp */, - 15CFE1901612FD0E00BF2188 /* CCControlButton.h */, - 15CFE1911612FD0E00BF2188 /* CCControlColourPicker.cpp */, - 15CFE1921612FD0E00BF2188 /* CCControlColourPicker.h */, - 15CFE1931612FD0E00BF2188 /* CCControlExtensions.h */, - 15CFE1941612FD0E00BF2188 /* CCControlHuePicker.cpp */, - 15CFE1951612FD0E00BF2188 /* CCControlHuePicker.h */, - 15CFE1961612FD0E00BF2188 /* CCControlPotentiometer.cpp */, - 15CFE1971612FD0E00BF2188 /* CCControlPotentiometer.h */, - 15CFE1981612FD0E00BF2188 /* CCControlSaturationBrightnessPicker.cpp */, - 15CFE1991612FD0E00BF2188 /* CCControlSaturationBrightnessPicker.h */, - 15CFE19A1612FD0E00BF2188 /* CCControlSlider.cpp */, - 15CFE19B1612FD0E00BF2188 /* CCControlSlider.h */, - 15CFE19C1612FD0E00BF2188 /* CCControlStepper.cpp */, - 15CFE19D1612FD0E00BF2188 /* CCControlStepper.h */, - 15CFE19E1612FD0E00BF2188 /* CCControlSwitch.cpp */, - 15CFE19F1612FD0E00BF2188 /* CCControlSwitch.h */, - 15CFE1A01612FD0E00BF2188 /* CCControlUtils.cpp */, - 15CFE1A11612FD0E00BF2188 /* CCControlUtils.h */, - 15CFE1A21612FD0E00BF2188 /* CCInvocation.cpp */, - 15CFE1A31612FD0E00BF2188 /* CCInvocation.h */, - 15CFE1A41612FD0E00BF2188 /* CCScale9Sprite.cpp */, - 15CFE1A51612FD0E00BF2188 /* CCScale9Sprite.h */, - ); - path = CCControlExtension; - sourceTree = ""; - }; - 2628297C15EC7196002C4240 /* chipmunk */ = { - isa = PBXGroup; - children = ( - 2628297D15EC7196002C4240 /* .gitignore */, - 2628297E15EC7196002C4240 /* Android.mk */, - 2628297F15EC7196002C4240 /* chipmunk-docs.html */, - 2628298015EC7196002C4240 /* include */, - 2628299C15EC7196002C4240 /* LICENSE.txt */, - 2628299D15EC7196002C4240 /* proj.blackberry */, - 262829A015EC7196002C4240 /* proj.linux */, - 262829A415EC7196002C4240 /* proj.win32 */, - 262829AA15EC7196002C4240 /* README.txt */, - 262829AB15EC7196002C4240 /* src */, - ); - name = chipmunk; - path = ../../../external/chipmunk; - sourceTree = ""; - }; - 2628298015EC7196002C4240 /* include */ = { - isa = PBXGroup; - children = ( - 2628298115EC7196002C4240 /* chipmunk */, - ); - path = include; - sourceTree = ""; - }; - 2628298115EC7196002C4240 /* chipmunk */ = { - isa = PBXGroup; - children = ( - 2628298215EC7196002C4240 /* chipmunk.h */, - 2628298315EC7196002C4240 /* chipmunk_ffi.h */, - 2628298415EC7196002C4240 /* chipmunk_private.h */, - 2628298515EC7196002C4240 /* chipmunk_types.h */, - 2628298615EC7196002C4240 /* chipmunk_unsafe.h */, - 2628298715EC7196002C4240 /* constraints */, - 2628299415EC7196002C4240 /* cpArbiter.h */, - 2628299515EC7196002C4240 /* cpBB.h */, - 2628299615EC7196002C4240 /* cpBody.h */, - 2628299715EC7196002C4240 /* cpPolyShape.h */, - 2628299815EC7196002C4240 /* cpShape.h */, - 2628299915EC7196002C4240 /* cpSpace.h */, - 2628299A15EC7196002C4240 /* cpSpatialIndex.h */, - 2628299B15EC7196002C4240 /* cpVect.h */, - ); - path = chipmunk; - sourceTree = ""; - }; - 2628298715EC7196002C4240 /* constraints */ = { - isa = PBXGroup; - children = ( - 2628298815EC7196002C4240 /* cpConstraint.h */, - 2628298915EC7196002C4240 /* cpDampedRotarySpring.h */, - 2628298A15EC7196002C4240 /* cpDampedSpring.h */, - 2628298B15EC7196002C4240 /* cpGearJoint.h */, - 2628298C15EC7196002C4240 /* cpGrooveJoint.h */, - 2628298D15EC7196002C4240 /* cpPinJoint.h */, - 2628298E15EC7196002C4240 /* cpPivotJoint.h */, - 2628298F15EC7196002C4240 /* cpRatchetJoint.h */, - 2628299015EC7196002C4240 /* cpRotaryLimitJoint.h */, - 2628299115EC7196002C4240 /* cpSimpleMotor.h */, - 2628299215EC7196002C4240 /* cpSlideJoint.h */, - 2628299315EC7196002C4240 /* util.h */, - ); - path = constraints; - sourceTree = ""; - }; - 2628299D15EC7196002C4240 /* proj.blackberry */ = { - isa = PBXGroup; - children = ( - 2628299E15EC7196002C4240 /* .cproject */, - 2628299F15EC7196002C4240 /* .project */, - ); - path = proj.blackberry; - sourceTree = ""; - }; - 262829A015EC7196002C4240 /* proj.linux */ = { - isa = PBXGroup; - children = ( - 262829A115EC7196002C4240 /* .cproject */, - 262829A215EC7196002C4240 /* .project */, - 262829A315EC7196002C4240 /* Makefile */, - ); - path = proj.linux; - sourceTree = ""; - }; - 262829A415EC7196002C4240 /* proj.win32 */ = { - isa = PBXGroup; - children = ( - 262829A515EC7196002C4240 /* chipmunk.vcproj */, - 262829A615EC7196002C4240 /* chipmunk.vcproj.user */, - 262829A715EC7196002C4240 /* chipmunk.vcxproj */, - 262829A815EC7196002C4240 /* chipmunk.vcxproj.filters */, - 262829A915EC7196002C4240 /* chipmunk.vcxproj.user */, - ); - path = proj.win32; - sourceTree = ""; - }; - 262829AB15EC7196002C4240 /* src */ = { - isa = PBXGroup; - children = ( - 262829AC15EC7196002C4240 /* chipmunk.c */, - 262829AD15EC7196002C4240 /* CMakeLists.txt */, - 262829AE15EC7196002C4240 /* constraints */, - 262829BA15EC7196002C4240 /* cpArbiter.c */, - 262829BB15EC7196002C4240 /* cpArray.c */, - 262829BC15EC7196002C4240 /* cpBB.c */, - 262829BD15EC7196002C4240 /* cpBBTree.c */, - 262829BE15EC7196002C4240 /* cpBody.c */, - 262829BF15EC7196002C4240 /* cpCollision.c */, - 262829C015EC7196002C4240 /* cpHashSet.c */, - 262829C115EC7196002C4240 /* cpPolyShape.c */, - 262829C215EC7196002C4240 /* cpShape.c */, - 262829C315EC7196002C4240 /* cpSpace.c */, - 262829C415EC7196002C4240 /* cpSpaceComponent.c */, - 262829C515EC7196002C4240 /* cpSpaceHash.c */, - 262829C615EC7196002C4240 /* cpSpaceQuery.c */, - 262829C715EC7196002C4240 /* cpSpaceStep.c */, - 262829C815EC7196002C4240 /* cpSpatialIndex.c */, - 262829C915EC7196002C4240 /* cpSweep1D.c */, - 262829CA15EC7196002C4240 /* cpVect.c */, - 262829CB15EC7196002C4240 /* prime.h */, - ); - path = src; - sourceTree = ""; - }; - 262829AE15EC7196002C4240 /* constraints */ = { - isa = PBXGroup; - children = ( - 262829AF15EC7196002C4240 /* cpConstraint.c */, - 262829B015EC7196002C4240 /* cpDampedRotarySpring.c */, - 262829B115EC7196002C4240 /* cpDampedSpring.c */, - 262829B215EC7196002C4240 /* cpGearJoint.c */, - 262829B315EC7196002C4240 /* cpGrooveJoint.c */, - 262829B415EC7196002C4240 /* cpPinJoint.c */, - 262829B515EC7196002C4240 /* cpPivotJoint.c */, - 262829B615EC7196002C4240 /* cpRatchetJoint.c */, - 262829B715EC7196002C4240 /* cpRotaryLimitJoint.c */, - 262829B815EC7196002C4240 /* cpSimpleMotor.c */, - 262829B915EC7196002C4240 /* cpSlideJoint.c */, - ); - path = constraints; - sourceTree = ""; - }; - A92275321517C094001B78AA = { - isa = PBXGroup; - children = ( - 15384E6216119D5E0021DC07 /* extensions */, - 15384E3C16119CC30021DC07 /* bindings */, - 15426AE915B5733200712A7F /* cocos2dx.xcodeproj */, - 15628F5B15F0F5C2000CF24B /* Resources */, - 2628297C15EC7196002C4240 /* chipmunk */, - D4545214156E28EF00887EB5 /* Classes */, - 15426FC415B5743C00712A7F /* CocosDenshion */, - A92275401517C094001B78AA /* Frameworks */, - D45446CC156DE73F00887EB5 /* ios */, - A922753E1517C094001B78AA /* Products */, - ); - sourceTree = ""; - }; - A922753E1517C094001B78AA /* Products */ = { - isa = PBXGroup; - children = ( - A922753D1517C094001B78AA /* TestJavascript.app */, - ); - name = Products; - sourceTree = ""; - }; - A92275401517C094001B78AA /* Frameworks */ = { - isa = PBXGroup; - children = ( - D454520B156E22BD00887EB5 /* libz.dylib */, - D4545209156E22B400887EB5 /* libxml2.dylib */, - A92275411517C094001B78AA /* QuartzCore.framework */, - A92275431517C094001B78AA /* OpenGLES.framework */, - A92275451517C094001B78AA /* OpenAL.framework */, - A92275471517C094001B78AA /* AudioToolbox.framework */, - A92275491517C094001B78AA /* AVFoundation.framework */, - A922754B1517C094001B78AA /* UIKit.framework */, - A922754D1517C094001B78AA /* Foundation.framework */, - A922754F1517C094001B78AA /* CoreGraphics.framework */, - ); - name = Frameworks; - sourceTree = ""; - }; - D45446CC156DE73F00887EB5 /* ios */ = { - isa = PBXGroup; - children = ( - D45446D6156DE79D00887EB5 /* Info.plist */, - D45446CD156DE74F00887EB5 /* AppController.h */, - D45446CE156DE74F00887EB5 /* AppController.mm */, - D45446CF156DE74F00887EB5 /* main.m */, - D45446D0156DE74F00887EB5 /* Prefix.pch */, - D45446D1156DE74F00887EB5 /* RootViewController.h */, - D45446D2156DE74F00887EB5 /* RootViewController.mm */, - ); - name = ios; - sourceTree = ""; - }; - D4545214156E28EF00887EB5 /* Classes */ = { - isa = PBXGroup; - children = ( - D4545215156E28EF00887EB5 /* AppDelegate.cpp */, - D4545216156E28EF00887EB5 /* AppDelegate.h */, - ); - name = Classes; - path = ../Classes; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXNativeTarget section */ - A922753C1517C094001B78AA /* TestJavascript */ = { - isa = PBXNativeTarget; - buildConfigurationList = A92277001517C097001B78AA /* Build configuration list for PBXNativeTarget "TestJavascript" */; - buildPhases = ( - A92275391517C094001B78AA /* Sources */, - A922753A1517C094001B78AA /* Frameworks */, - A922753B1517C094001B78AA /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - 15426FC215B5741900712A7F /* PBXTargetDependency */, - ); - name = TestJavascript; - productName = TestJavascript; - productReference = A922753D1517C094001B78AA /* TestJavascript.app */; - productType = "com.apple.product-type.application"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - A92275341517C094001B78AA /* Project object */ = { - isa = PBXProject; - attributes = { - LastUpgradeCheck = 0430; - }; - buildConfigurationList = A92275371517C094001B78AA /* Build configuration list for PBXProject "TestJavascript" */; - compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; - hasScannedForEncodings = 0; - knownRegions = ( - en, - ); - mainGroup = A92275321517C094001B78AA; - productRefGroup = A922753E1517C094001B78AA /* Products */; - projectDirPath = ""; - projectReferences = ( - { - ProductGroup = 15426AEA15B5733200712A7F /* Products */; - ProjectRef = 15426AE915B5733200712A7F /* cocos2dx.xcodeproj */; - }, - ); - projectRoot = ""; - targets = ( - A922753C1517C094001B78AA /* TestJavascript */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXReferenceProxy section */ - 15426AF115B5733200712A7F /* libcocos2dx.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = libcocos2dx.a; - remoteRef = 15426AF015B5733200712A7F /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; -/* End PBXReferenceProxy section */ - -/* Begin PBXResourcesBuildPhase section */ - A922753B1517C094001B78AA /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 262829CC15EC7196002C4240 /* .gitignore in Resources */, - 262829CD15EC7196002C4240 /* Android.mk in Resources */, - 262829CE15EC7196002C4240 /* chipmunk-docs.html in Resources */, - 262829CF15EC7196002C4240 /* LICENSE.txt in Resources */, - 262829D015EC7196002C4240 /* .cproject in Resources */, - 262829D115EC7196002C4240 /* .project in Resources */, - 262829D215EC7196002C4240 /* .cproject in Resources */, - 262829D315EC7196002C4240 /* .project in Resources */, - 262829D515EC7196002C4240 /* chipmunk.vcproj in Resources */, - 262829D615EC7196002C4240 /* chipmunk.vcproj.user in Resources */, - 262829D715EC7196002C4240 /* chipmunk.vcxproj in Resources */, - 262829D815EC7196002C4240 /* chipmunk.vcxproj.filters in Resources */, - 262829D915EC7196002C4240 /* chipmunk.vcxproj.user in Resources */, - 262829DA15EC7196002C4240 /* README.txt in Resources */, - 262829DC15EC7196002C4240 /* CMakeLists.txt in Resources */, - 15628F6C15F0F5E5000CF24B /* ballbounce.wav in Resources */, - 15628F6D15F0F5E5000CF24B /* cowbell.wav in Resources */, - 15628F6E15F0F5E5000CF24B /* Cyber Advance!.mp3 in Resources */, - 15628F6F15F0F5E5000CF24B /* Fonts in Resources */, - 15628F7015F0F5E5000CF24B /* Images in Resources */, - 15628F7115F0F5E5000CF24B /* js in Resources */, - 15628F7215F0F5E5000CF24B /* oldjs in Resources */, - 15628F7315F0F5E5000CF24B /* Particles in Resources */, - 15628F7415F0F5E5000CF24B /* Silly Fun Theme A.mp3 in Resources */, - 15628F7515F0F5E5000CF24B /* tank.plist in Resources */, - 15628F7615F0F5E5000CF24B /* tank.png in Resources */, - 15628F7715F0F5E5000CF24B /* tank.tps in Resources */, - 15628F7815F0F5E5000CF24B /* tank1.png in Resources */, - 15628F7915F0F5E5000CF24B /* TileMaps in Resources */, - 15628FA915F1057E000CF24B /* animations in Resources */, - D446FDA316102D7D000ADA7B /* Default.png in Resources */, - D446FDA516102D82000ADA7B /* Default@2x.png in Resources */, - D446FDA716102D86000ADA7B /* Default-568h@2x.png in Resources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXResourcesBuildPhase section */ - -/* Begin PBXSourcesBuildPhase section */ - A92275391517C094001B78AA /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - D45446D3156DE74F00887EB5 /* AppController.mm in Sources */, - D45446D4156DE74F00887EB5 /* main.m in Sources */, - D45446D5156DE74F00887EB5 /* RootViewController.mm in Sources */, - D4545227156E28EF00887EB5 /* AppDelegate.cpp in Sources */, - 15426FE615B5743C00712A7F /* CDAudioManager.m in Sources */, - 15426FE715B5743C00712A7F /* CDOpenALSupport.m in Sources */, - 15426FE815B5743C00712A7F /* CocosDenshion.m in Sources */, - 15426FE915B5743C00712A7F /* SimpleAudioEngine.mm in Sources */, - 15426FEA15B5743C00712A7F /* SimpleAudioEngine_objc.m in Sources */, - 262829D415EC7196002C4240 /* Makefile in Sources */, - 262829DB15EC7196002C4240 /* chipmunk.c in Sources */, - 262829DD15EC7196002C4240 /* cpConstraint.c in Sources */, - 262829DE15EC7196002C4240 /* cpDampedRotarySpring.c in Sources */, - 262829DF15EC7196002C4240 /* cpDampedSpring.c in Sources */, - 262829E015EC7196002C4240 /* cpGearJoint.c in Sources */, - 262829E115EC7196002C4240 /* cpGrooveJoint.c in Sources */, - 262829E215EC7196002C4240 /* cpPinJoint.c in Sources */, - 262829E315EC7196002C4240 /* cpPivotJoint.c in Sources */, - 262829E415EC7196002C4240 /* cpRatchetJoint.c in Sources */, - 262829E515EC7196002C4240 /* cpRotaryLimitJoint.c in Sources */, - 262829E615EC7196002C4240 /* cpSimpleMotor.c in Sources */, - 262829E715EC7196002C4240 /* cpSlideJoint.c in Sources */, - 262829E815EC7196002C4240 /* cpArbiter.c in Sources */, - 262829E915EC7196002C4240 /* cpArray.c in Sources */, - 262829EA15EC7196002C4240 /* cpBB.c in Sources */, - 262829EB15EC7196002C4240 /* cpBBTree.c in Sources */, - 262829EC15EC7196002C4240 /* cpBody.c in Sources */, - 262829ED15EC7196002C4240 /* cpCollision.c in Sources */, - 262829EE15EC7196002C4240 /* cpHashSet.c in Sources */, - 262829EF15EC7196002C4240 /* cpPolyShape.c in Sources */, - 262829F015EC7196002C4240 /* cpShape.c in Sources */, - 262829F115EC7196002C4240 /* cpSpace.c in Sources */, - 262829F215EC7196002C4240 /* cpSpaceComponent.c in Sources */, - 262829F315EC7196002C4240 /* cpSpaceHash.c in Sources */, - 262829F415EC7196002C4240 /* cpSpaceQuery.c in Sources */, - 262829F515EC7196002C4240 /* cpSpaceStep.c in Sources */, - 262829F615EC7196002C4240 /* cpSpatialIndex.c in Sources */, - 262829F715EC7196002C4240 /* cpSweep1D.c in Sources */, - 262829F815EC7196002C4240 /* cpVect.c in Sources */, - 15384E5716119CC30021DC07 /* CCPhysicsSprite.cpp in Sources */, - 15384E5816119CC30021DC07 /* cocos2d_specifics.cpp in Sources */, - 15384E5916119CC30021DC07 /* cocosjs_manual_conversions.cpp in Sources */, - 15384E5A16119CC30021DC07 /* cocos2dx.cpp in Sources */, - 15384E5D16119CC30021DC07 /* js_bindings_ccbreader.cpp in Sources */, - 15384E5E16119CC30021DC07 /* js_bindings_chipmunk_functions.cpp in Sources */, - 15384E5F16119CC30021DC07 /* js_bindings_chipmunk_manual.cpp in Sources */, - 15384E6016119CC30021DC07 /* js_manual_conversions.cpp in Sources */, - 15384E6116119CC30021DC07 /* ScriptingCore.cpp in Sources */, - 15384ED716119D5E0021DC07 /* CCBAnimationManager.cpp in Sources */, - 15384ED816119D5E0021DC07 /* CCBFileLoader.cpp in Sources */, - 15384ED916119D5E0021DC07 /* CCBKeyframe.cpp in Sources */, - 15384EDA16119D5E0021DC07 /* CCBReader.cpp in Sources */, - 15384EDB16119D5E0021DC07 /* CCBSequence.cpp in Sources */, - 15384EDC16119D5E0021DC07 /* CCBSequenceProperty.cpp in Sources */, - 15384EDD16119D5E0021DC07 /* CCBValue.cpp in Sources */, - 15384EDE16119D5E0021DC07 /* CCControlButtonLoader.cpp in Sources */, - 15384EDF16119D5E0021DC07 /* CCControlLoader.cpp in Sources */, - 15384EE016119D5E0021DC07 /* CCData.cpp in Sources */, - 15384EE116119D5E0021DC07 /* CCLabelBMFontLoader.cpp in Sources */, - 15384EE216119D5E0021DC07 /* CCLabelTTFLoader.cpp in Sources */, - 15384EE316119D5E0021DC07 /* CCLayerColorLoader.cpp in Sources */, - 15384EE416119D5E0021DC07 /* CCLayerGradientLoader.cpp in Sources */, - 15384EE516119D5E0021DC07 /* CCLayerLoader.cpp in Sources */, - 15384EE616119D5E0021DC07 /* CCMenuItemImageLoader.cpp in Sources */, - 15384EE716119D5E0021DC07 /* CCMenuItemLoader.cpp in Sources */, - 15384EE816119D5E0021DC07 /* CCNode+CCBRelativePositioning.cpp in Sources */, - 15384EE916119D5E0021DC07 /* CCNodeLoader.cpp in Sources */, - 15384EEA16119D5E0021DC07 /* CCNodeLoaderLibrary.cpp in Sources */, - 15384EEB16119D5E0021DC07 /* CCParticleSystemQuadLoader.cpp in Sources */, - 15384EEC16119D5E0021DC07 /* CCScale9SpriteLoader.cpp in Sources */, - 15384EED16119D5E0021DC07 /* CCScrollViewLoader.cpp in Sources */, - 15384EEE16119D5E0021DC07 /* CCSpriteLoader.cpp in Sources */, - 15384EFB16119D5E0021DC07 /* CCEditBox.cpp in Sources */, - 15384EFD16119D5E0021DC07 /* CCEditBoxImplIOS.mm in Sources */, - 15384EFE16119D5E0021DC07 /* EditBoxImplIOS.mm in Sources */, - 15384EFF16119D5E0021DC07 /* CCScrollView.cpp in Sources */, - 15384F0016119D5E0021DC07 /* CCSorting.cpp in Sources */, - 15384F0116119D5E0021DC07 /* CCTableView.cpp in Sources */, - 15384F0216119D5E0021DC07 /* CCTableViewCell.cpp in Sources */, - 15CFE1A61612FD0E00BF2188 /* CCControl.cpp in Sources */, - 15CFE1A71612FD0E00BF2188 /* CCControlButton.cpp in Sources */, - 15CFE1A81612FD0E00BF2188 /* CCControlColourPicker.cpp in Sources */, - 15CFE1A91612FD0E00BF2188 /* CCControlHuePicker.cpp in Sources */, - 15CFE1AA1612FD0E00BF2188 /* CCControlPotentiometer.cpp in Sources */, - 15CFE1AB1612FD0E00BF2188 /* CCControlSaturationBrightnessPicker.cpp in Sources */, - 15CFE1AC1612FD0E00BF2188 /* CCControlSlider.cpp in Sources */, - 15CFE1AD1612FD0E00BF2188 /* CCControlStepper.cpp in Sources */, - 15CFE1AE1612FD0E00BF2188 /* CCControlSwitch.cpp in Sources */, - 15CFE1AF1612FD0E00BF2188 /* CCControlUtils.cpp in Sources */, - 15CFE1B01612FD0E00BF2188 /* CCInvocation.cpp in Sources */, - 15CFE1B11612FD0E00BF2188 /* CCScale9Sprite.cpp in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin PBXTargetDependency section */ - 15426FC215B5741900712A7F /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - name = cocos2dx; - targetProxy = 15426FC115B5741900712A7F /* PBXContainerItemProxy */; - }; -/* End PBXTargetDependency section */ - -/* Begin XCBuildConfiguration section */ - A92276FE1517C097001B78AA /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ARCHS = "$(ARCHS_STANDARD_32_BIT)"; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - DEBUG, - "COCOS2D_DEBUG=1", - USE_FILE32API, - TARGET_OS_IPHONE, - ); - GCC_SYMBOLS_PRIVATE_EXTERN = NO; - GCC_WARN_ABOUT_RETURN_TYPE = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - HEADER_SEARCH_PATHS = ( - "$(SRCROOT)/../../../cocos2dx", - "$(SRCROOT)/../../../cocos2dx/include", - "$(SRCROOT)/../../../cocos2dx/platform/ios", - "$(SRCROOT)/../../../scripting/javascript/spidermonkey-ios/include1", - ); - IPHONEOS_DEPLOYMENT_TARGET = 5.1; - SDKROOT = iphoneos; - }; - name = Debug; - }; - A92276FF1517C097001B78AA /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ARCHS = "$(ARCHS_STANDARD_32_BIT)"; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_PREPROCESSOR_DEFINITIONS = ( - NDEBUG, - USE_FILE32API, - TARGET_OS_IPHONE, - ); - GCC_WARN_ABOUT_RETURN_TYPE = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - HEADER_SEARCH_PATHS = ( - "$(SRCROOT)/../../../cocos2dx", - "$(SRCROOT)/../../../cocos2dx/include", - "$(SRCROOT)/../../../cocos2dx/platform/ios", - "$(SRCROOT)/../../../scripting/javascript/spidermonkey-ios/include1", - ); - IPHONEOS_DEPLOYMENT_TARGET = 5.1; - OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; - SDKROOT = iphoneos; - }; - name = Release; - }; - A92277011517C097001B78AA /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - COPY_PHASE_STRIP = NO; - GCC_DYNAMIC_NO_PIC = NO; - GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = Prefix.pch; - GCC_PREPROCESSOR_DEFINITIONS = ( - COCOS2D_JAVASCRIPT, - DEBUG, - "COCOS2D_DEBUG=1", - USE_FILE32API, - TARGET_OS_IPHONE, - ); - "GCC_THUMB_SUPPORT[arch=armv6]" = ""; - HEADER_SEARCH_PATHS = ( - "\"$(SRCROOT)/../../../cocos2dx\"", - "\"$(SRCROOT)/../../../cocos2dx/kazmath/include\"", - "\"$(SRCROOT)/../../../CocosDenshion/include\"", - "\"$(SDKROOT)/usr/include/libxml2\"", - "$(SRCROOT)/../../../cocos2dx/include", - "$(SRCROOT)/../../../cocos2dx/platform/ios", - "$(SRCROOT)/../../../external/chipmunk/include/chipmunk", - "$(SRCROOT)/../../../scripting/javascript/spidermonkey-ios/include", - "$(SRCROOT)/../../../scripting/javascript/bindings", - ); - INFOPLIST_FILE = Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 5.1; - LIBRARY_SEARCH_PATHS = "\"$(SRCROOT)/../../../scripting/javascript/spidermonkey-ios/lib\""; - OTHER_LDFLAGS = ( - "-lxml2", - "-lz", - "-ljs_static", - ); - PRODUCT_NAME = TestJavascript; - TARGETED_DEVICE_FAMILY = "1,2"; - WRAPPER_EXTENSION = app; - }; - name = Debug; - }; - A92277021517C097001B78AA /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - COPY_PHASE_STRIP = YES; - GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = Prefix.pch; - GCC_PREPROCESSOR_DEFINITIONS = ( - COCOS2D_JAVASCRIPT, - NDEBUG, - USE_FILE32API, - TARGET_OS_IPHONE, - ); - "GCC_THUMB_SUPPORT[arch=armv6]" = ""; - HEADER_SEARCH_PATHS = ( - "\"$(SRCROOT)/../../../cocos2dx\"", - "\"$(SRCROOT)/../../../cocos2dx/kazmath/include\"", - "\"$(SRCROOT)/../../../CocosDenshion/include\"", - "\"$(SDKROOT)/usr/include/libxml2\"", - "$(SRCROOT)/../../../cocos2dx/include", - "$(SRCROOT)/../../../cocos2dx/platform/ios", - "$(SRCROOT)/../../../external/chipmunk/include/chipmunk", - "$(SRCROOT)/../../../scripting/javascript/spidermonkey-ios/include", - "$(SRCROOT)/../../../scripting/javascript/bindings", - ); - INFOPLIST_FILE = Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 5.1; - LIBRARY_SEARCH_PATHS = "\"$(SRCROOT)/../../../scripting/javascript/spidermonkey-ios/lib\""; - OTHER_LDFLAGS = ( - "-lxml2", - "-lz", - "-ljs_static", - ); - PRODUCT_NAME = TestJavascript; - TARGETED_DEVICE_FAMILY = "1,2"; - VALIDATE_PRODUCT = YES; - WRAPPER_EXTENSION = app; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - A92275371517C094001B78AA /* Build configuration list for PBXProject "TestJavascript" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - A92276FE1517C097001B78AA /* Debug */, - A92276FF1517C097001B78AA /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - A92277001517C097001B78AA /* Build configuration list for PBXNativeTarget "TestJavascript" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - A92277011517C097001B78AA /* Debug */, - A92277021517C097001B78AA /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = A92275341517C094001B78AA /* Project object */; -} diff --git a/samples/TestJavascript/proj.ios/TestJavascript.xcodeproj/project.pbxproj.REMOVED.git-id b/samples/TestJavascript/proj.ios/TestJavascript.xcodeproj/project.pbxproj.REMOVED.git-id new file mode 100644 index 0000000000..ecb7e68073 --- /dev/null +++ b/samples/TestJavascript/proj.ios/TestJavascript.xcodeproj/project.pbxproj.REMOVED.git-id @@ -0,0 +1 @@ +e92a199a2b2e5cd26e5d1e1c1b2846f4ba4f978f \ No newline at end of file From 3b0a9892003988f0b81aef57ab5883237c87f10e Mon Sep 17 00:00:00 2001 From: James Chen Date: Fri, 12 Oct 2012 15:14:47 +0800 Subject: [PATCH 13/16] Updated TestJavascript project configuration for VS2008 & VS2010. --- .../proj.win32/TestJavascript.vcproj | 3 ++- .../proj.win32/TestJavascript.vcxproj | 14 ++++++++++++++ .../proj.win32/TestJavascript.vcxproj.user | 2 +- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/samples/TestJavascript/proj.win32/TestJavascript.vcproj b/samples/TestJavascript/proj.win32/TestJavascript.vcproj index 8af9dac184..7713d67f06 100644 --- a/samples/TestJavascript/proj.win32/TestJavascript.vcproj +++ b/samples/TestJavascript/proj.win32/TestJavascript.vcproj @@ -24,6 +24,7 @@ > Windows MachineX86 + + if not exist "$(OutDir)" mkdir "$(OutDir)" +if exist "$(OutDir)\TestJavascriptRes" rd /s /q "$(OutDir)\TestJavascriptRes" +mkdir "$(OutDir)\TestJavascriptRes" +xcopy "$(ProjectDir)..\cocos2d-html5-tests\res" "$(OutDir)\TestJavascriptRes\res\" /e /Y +xcopy "$(ProjectDir)..\bindings\*.js" "$(OutDir)\TestJavascriptRes" /e /Y +dir "$(ProjectDir)..\cocos2d-html5-tests\src\*.js" /a /b /s > filelist.txt +for /f %%I in (filelist.txt) do (copy /Y %%I "$(OutDir)\TestJavascriptRes") +if exist filelist.txt del /f /q filelist.txt + + + + Copy js and resource files. + diff --git a/samples/TestJavascript/proj.win32/TestJavascript.vcxproj.user b/samples/TestJavascript/proj.win32/TestJavascript.vcxproj.user index 314a27ae4d..35e8c9f766 100644 --- a/samples/TestJavascript/proj.win32/TestJavascript.vcxproj.user +++ b/samples/TestJavascript/proj.win32/TestJavascript.vcxproj.user @@ -1,7 +1,7 @@  - $(ProjectDir)..\Resources + $(OutDir)\TestJavascriptRes WindowsLocalDebugger From 21491317c0948e89b40caffb11c45f0d7a2b359f Mon Sep 17 00:00:00 2001 From: James Chen Date: Fri, 12 Oct 2012 15:41:45 +0800 Subject: [PATCH 14/16] Fix compilation errors. --- scripting/javascript/bindings/cocos2d_specifics.cpp | 4 ++-- scripting/javascript/bindings/cocos2d_specifics.hpp | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/scripting/javascript/bindings/cocos2d_specifics.cpp b/scripting/javascript/bindings/cocos2d_specifics.cpp index ab35a6f008..a37ad1aff7 100644 --- a/scripting/javascript/bindings/cocos2d_specifics.cpp +++ b/scripting/javascript/bindings/cocos2d_specifics.cpp @@ -1041,11 +1041,11 @@ JSBool js_CatmullRomActions_create(JSContext *cx, uint32_t argc, jsval *vp) { JSBool JSB_CCBezierBy_actionWithDuration(JSContext *cx, uint32_t argc, jsval *vp) { - js_BezierActions_create(cx, argc, vp); + return js_BezierActions_create(cx, argc, vp); } JSBool JSB_CCBezierTo_actionWithDuration(JSContext *cx, uint32_t argc, jsval *vp) { - js_BezierActions_create(cx, argc, vp); + return js_BezierActions_create(cx, argc, vp); } diff --git a/scripting/javascript/bindings/cocos2d_specifics.hpp b/scripting/javascript/bindings/cocos2d_specifics.hpp index 03c34ce042..bd02d040d8 100644 --- a/scripting/javascript/bindings/cocos2d_specifics.hpp +++ b/scripting/javascript/bindings/cocos2d_specifics.hpp @@ -12,14 +12,14 @@ template inline js_type_class_t *js_get_type_from_native(T* native_obj) { js_type_class_t *typeProxy; - long typeId = getHashCodeByString(typeid(*native_obj).name()); + long typeId = cocos2d::getHashCodeByString(typeid(*native_obj).name()); HASH_FIND_INT(_js_global_type_ht, &typeId, typeProxy); if (!typeProxy) { - TypeInfo *typeInfo = dynamic_cast(native_obj); + cocos2d::TypeInfo *typeInfo = dynamic_cast(native_obj); if (typeInfo) { typeId = typeInfo->getClassTypeInfo(); } else { - typeId = getHashCodeByString(typeid(T).name()); + typeId = cocos2d::getHashCodeByString(typeid(T).name()); } HASH_FIND_INT(_js_global_type_ht, &typeId, typeProxy); } From e876b997e7ae3cdc27a4bdb3562efd19dc1e0be6 Mon Sep 17 00:00:00 2001 From: James Chen Date: Fri, 12 Oct 2012 15:42:00 +0800 Subject: [PATCH 15/16] Updated TestJavascript.vcproj --- samples/TestJavascript/proj.win32/TestJavascript.vcproj | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/samples/TestJavascript/proj.win32/TestJavascript.vcproj b/samples/TestJavascript/proj.win32/TestJavascript.vcproj index 7713d67f06..5f6d01e79a 100644 --- a/samples/TestJavascript/proj.win32/TestJavascript.vcproj +++ b/samples/TestJavascript/proj.win32/TestJavascript.vcproj @@ -24,7 +24,8 @@ > Date: Fri, 12 Oct 2012 15:45:57 +0800 Subject: [PATCH 16/16] Updated *.user for vs2010 & vs2008. --- samples/TestJavascript/proj.win32/TestJavascript.vcproj.user | 4 ++-- samples/TestJavascript/proj.win32/TestJavascript.vcxproj.user | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/samples/TestJavascript/proj.win32/TestJavascript.vcproj.user b/samples/TestJavascript/proj.win32/TestJavascript.vcproj.user index eb4c2b142b..cee9f63107 100644 --- a/samples/TestJavascript/proj.win32/TestJavascript.vcproj.user +++ b/samples/TestJavascript/proj.win32/TestJavascript.vcproj.user @@ -9,14 +9,14 @@ Name="Debug|Win32" > diff --git a/samples/TestJavascript/proj.win32/TestJavascript.vcxproj.user b/samples/TestJavascript/proj.win32/TestJavascript.vcxproj.user index 35e8c9f766..773138191d 100644 --- a/samples/TestJavascript/proj.win32/TestJavascript.vcxproj.user +++ b/samples/TestJavascript/proj.win32/TestJavascript.vcxproj.user @@ -5,7 +5,7 @@ WindowsLocalDebugger - $(ProjectDir)..\Resources + $(OutDir)\TestJavascriptRes WindowsLocalDebugger \ No newline at end of file