diff --git a/samples/js-moonwarriors-runtime/.cocos-project.json b/samples/js-moonwarriors-runtime/.cocos-project.json new file mode 100755 index 0000000000..fd8f99a44d --- /dev/null +++ b/samples/js-moonwarriors-runtime/.cocos-project.json @@ -0,0 +1,4 @@ +{ + "has_native": true, + "project_type": "js" +} \ No newline at end of file diff --git a/samples/js-moonwarriors-runtime/config.json b/samples/js-moonwarriors-runtime/config.json new file mode 100644 index 0000000000..41bd31db09 --- /dev/null +++ b/samples/js-moonwarriors-runtime/config.json @@ -0,0 +1,19 @@ +{ + "game_name": "月亮战士v3", + "package_name": "org.cocos2dx.moonwarriors.v3", + "version_name": "3.0.0", + "version_code": 3, + "runtime_version": "3.3.0.4", + "description": "这是灰常好玩的打飞机游戏!", + "orientation": "portrait", + "entry_file": "main.js", + "game_type":"offline", + "design_resolution": { + "width": 480, + "height": 720, + "policy": "SHOW_ALL" + }, + "security": { + "password":"moonwarriors" + } +} diff --git a/samples/js-moonwarriors-runtime/group.json b/samples/js-moonwarriors-runtime/group.json new file mode 100644 index 0000000000..5f2f718919 --- /dev/null +++ b/samples/js-moonwarriors-runtime/group.json @@ -0,0 +1,96 @@ +{ + "boot": { + "priority": 0, + "files": [ + "res_engine/dialog_bg.png", + "res_engine/dialog_cancel_normal.png", + "res_engine/dialog_cancel_press.png", + "res_engine/dialog_confirm_normal.png", + "res_engine/dialog_confirm_press.png", + "res_engine/preload_bg.jpg", + "res_engine/preload_logo.png", + "res_engine/preload_title.png", + "res_engine/progress_bar.png", + "res_engine/progress_bg.png", + "res_engine/progress_light.png", + "res_engine/progress_shadow.png", + "res/dialog_bg.png", + "res/dialog_cancel_normal.png", + "res/dialog_cancel_press.png", + "res/dialog_confirm_normal.png", + "res/dialog_confirm_press.png", + "res/flare.jpg", + "res/loading.png", + "res/logoBack.png", + "res/logo.png", + "res/menu.png", + "res/Music/buttonEffet.mp3", + "res/Music/buttonEffet.ogg", + "res/Music/mainMainMusic.mp3", + "res/Music/mainMainMusic.ogg", + "res/textureTransparentPack.plist", + "res/textureTransparentPack.png", + "src/AboutLayer.js", + "src/Background.js", + "src/Bullet.js", + "src/config/EnemyType.js", + "src/config/GameConfig.js", + "src/config/Level.js", + "src/Effect.js", + "src/Enemy.js", + "src/Explosion.js", + "src/GameController.js", + "src/GameControlMenu.js", + "src/GameLayer.js", + "src/GameOver.js", + "src/HitEffect.js", + "src/LevelManager.js", + "src/Resource.js", + "src/SettingsLayer.js", + "src/Ship.js", + "src/SparkEffect.js", + "src/SysMenu.js" + ] + }, + + "common": { + "priority": 1, + "files": [ + "res/menuTitle.png" + ] + }, + + "gamelayer": { + "priority": 2, + "files": [ + "res/arial-14.fnt", + "res/arial-14.GlyphProject", + "res/arial-14.png", + "res/b01.plist", + "res/b01.png", + "res/explode.plist", + "res/explosion.plist", + "res/explosion.png", + "res/level01.tmx", + "res/Music/bgMusic.mp3", + "res/Music/bgMusic.ogg", + "res/Music/explodeEffect.mp3", + "res/Music/explodeEffect.ogg", + "res/Music/fireEffect.mp3", + "res/Music/fireEffect.ogg", + "res/Music/shipDestroyEffect.mp3", + "res/Music/shipDestroyEffect.ogg", + "res/textureOpaquePack.plist", + "res/textureOpaquePack.png" + ] + }, + + "gameover": { + "priority": 3, + "files": [ + "res/cocos2d-html5.png", + "res/gameOver.png", + "res/gameoverBack.png" + ] + } +} diff --git a/samples/js-moonwarriors-runtime/index.html b/samples/js-moonwarriors-runtime/index.html new file mode 100755 index 0000000000..7682455190 --- /dev/null +++ b/samples/js-moonwarriors-runtime/index.html @@ -0,0 +1,36 @@ + + + + Cocos2d-html5 Show Case - MoonWarriors + + + + + + + + + diff --git a/samples/js-moonwarriors-runtime/main.js b/samples/js-moonwarriors-runtime/main.js new file mode 100755 index 0000000000..7f4ea229c9 --- /dev/null +++ b/samples/js-moonwarriors-runtime/main.js @@ -0,0 +1,143 @@ +/**************************************************************************** + Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2008-2010 Ricardo Quesada + Copyright (c) 2011 Zynga Inc. + + http://www.cocos2d-x.org + + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +/** + * A brief explanation for "project.json": + * Here is the content of project.json file, this is the global configuration for your game, you can modify it to customize some behavior. + * The detail of each field is under it. + { + "debugMode" : 1, + // "debugMode" possible values : + // 0 - No message will be printed. + // 1 - cc.error, cc.assert, cc.warn, cc.log will print in console. + // 2 - cc.error, cc.assert, cc.warn will print in console. + // 3 - cc.error, cc.assert will print in console. + // 4 - cc.error, cc.assert, cc.warn, cc.log will print on canvas, available only on web. + // 5 - cc.error, cc.assert, cc.warn will print on canvas, available only on web. + // 6 - cc.error, cc.assert will print on canvas, available only on web. + + "showFPS" : true, + // Left bottom corner fps information will show when "showFPS" equals true, otherwise it will be hide. + + "frameRate" : 60, + // "frameRate" set the wanted frame rate for your game, but the real fps depends on your game implementation and the running environment. + + "id" : "gameCanvas", + // "gameCanvas" sets the id of your canvas element on the web page, it's useful only on web. + + "renderMode" : 0, + // "renderMode" sets the renderer type, only useful on web : + // 0 - Automatically chosen by engine + // 1 - Forced to use canvas renderer + // 2 - Forced to use WebGL renderer, but this will be ignored on mobile browsers + + "engineDir" : "../../frameworks/cocos2d-html5/", + // In debug mode, if you use the whole engine to develop your game, you should specify its relative path with "engineDir", + // but if you are using a single engine file, you can ignore it. + + "modules" : ["cocos2d"], + // "modules" defines which modules you will need in your game, it's useful only on web, + // using this can greatly reduce your game's resource size, and the cocos console tool can package your game with only the modules you set. + // For details about modules definitions, you can refer to "../../frameworks/cocos2d-html5/modulesConfig.json". + + "jsList" : [ + ] + // "jsList" sets the list of js files in your game. + } + * + */ + +cc.log("==> main.js loaded!"); + +cc.game.onStart = function () { + cc.log("==> cc.game.onStart ..."); + cc.view.adjustViewPort(true); + cc.view.setDesignResolutionSize(480, 720, cc.ResolutionPolicy.SHOW_ALL); + cc.view.resizeWithBrowserSize(true); + cc.director.setProjection(cc.Director.PROJECTION_2D); + cc.LoaderLayer.setConfig({ + background: { + res: "res/loading.png" + }, + logo: { + res: "res/logo.png", + action: null + }, + title: { + res: "res/logoBack.png" + }, + onEnter: function (layer) { + cc.log("moonwarriors onEnter"); + var label = new cc.LabelTTF("this is moonwarriors","Arial",22); + label.setColor(cc.color(255,0,0)); + label.setPosition(cc.p(cc.winSize.width/2,200)); + layer.addChild(label); + }, + onExit: function (layer) { + cc.log("moonwarriors onExit"); + }, + tips: { + color: cc.color(255, 0, 0), + tipsProgress: function (status, loaderlayer) { + var statusStr = "runtime正在"; + if (status.stage == cc.network.preloadstatus.DOWNLOAD) { + statusStr += "下载"; + } else if (status.stage == cc.network.preloadstatus.UNZIP) { + statusStr += "解压"; + } + if (status.groupName) { + statusStr += status.groupName; + } + statusStr += " 进度:" + status.percent.toFixed(2) + "%"; + loaderlayer.getTipsLabel().setString(statusStr); + } + } + }); + if (cc.sys.isNative) { + //get netowrk status + var networkStatus = cc.network.getNetworkType(); + if (networkStatus == cc.network.type.WIFI) { + cc.log("current network is WIFI"); + } else if (networkStatus == cc.network.type.MOBILE) { + cc.log("current network is MOBILE"); + } else if (networkStatus == cc.network.type.NO_NETWORK) { + cc.log("current network is UNKNOWN"); + } + cc.director.runScene(SysMenu.scene()); + } else { + cc.LoaderScene.preload(window["boot"], function () { + cc.LoaderLayer.preload(["gamelayer"], function () { + cc.director.runScene(SysMenu.scene()); + }); + }); + } + + var self = this; + //load resources +}; + +cc.game.run(); \ No newline at end of file diff --git a/samples/js-moonwarriors-runtime/project.json b/samples/js-moonwarriors-runtime/project.json new file mode 100644 index 0000000000..611f349303 --- /dev/null +++ b/samples/js-moonwarriors-runtime/project.json @@ -0,0 +1,32 @@ +{ + "debugMode" : 1, + "showFPS" : false, + "frameRate" : 60, + "id" : "gameCanvas", + "renderMode" : 0, + "engineDir":"../../frameworks/cocos2d-html5", + + "modules" : ["cocos2d","extensions","runtime"], + "jsList" : [ + "src/Resource.js", + "src/config/GameConfig.js", + "src/config/EnemyType.js", + "src/config/Level.js", + "src/Effect.js", + "src/Bullet.js", + "src/Enemy.js", + "src/Explosion.js", + "src/Ship.js", + "src/LevelManager.js", + "src/GameController.js", + "src/GameControlMenu.js", + "src/GameLayer.js", + "src/GameOver.js", + "src/AboutLayer.js", + "src/SettingsLayer.js", + "src/SysMenu.js", + "src/HitEffect.js", + "src/SparkEffect.js", + "src/Background.js" + ] +} \ No newline at end of file diff --git a/samples/js-moonwarriors-runtime/res/Music/bgMusic.mp3 b/samples/js-moonwarriors-runtime/res/Music/bgMusic.mp3 new file mode 100755 index 0000000000..69923507fe Binary files /dev/null and b/samples/js-moonwarriors-runtime/res/Music/bgMusic.mp3 differ diff --git a/samples/js-moonwarriors-runtime/res/Music/bgMusic.ogg b/samples/js-moonwarriors-runtime/res/Music/bgMusic.ogg new file mode 100644 index 0000000000..71ea9a1629 Binary files /dev/null and b/samples/js-moonwarriors-runtime/res/Music/bgMusic.ogg differ diff --git a/samples/js-moonwarriors-runtime/res/Music/buttonEffet.mp3 b/samples/js-moonwarriors-runtime/res/Music/buttonEffet.mp3 new file mode 100755 index 0000000000..1bf32984e8 Binary files /dev/null and b/samples/js-moonwarriors-runtime/res/Music/buttonEffet.mp3 differ diff --git a/samples/js-moonwarriors-runtime/res/Music/buttonEffet.ogg b/samples/js-moonwarriors-runtime/res/Music/buttonEffet.ogg new file mode 100644 index 0000000000..e27b7abbaf Binary files /dev/null and b/samples/js-moonwarriors-runtime/res/Music/buttonEffet.ogg differ diff --git a/samples/js-moonwarriors-runtime/res/Music/explodeEffect.mp3 b/samples/js-moonwarriors-runtime/res/Music/explodeEffect.mp3 new file mode 100755 index 0000000000..6c48679e4a Binary files /dev/null and b/samples/js-moonwarriors-runtime/res/Music/explodeEffect.mp3 differ diff --git a/samples/js-moonwarriors-runtime/res/Music/explodeEffect.ogg b/samples/js-moonwarriors-runtime/res/Music/explodeEffect.ogg new file mode 100644 index 0000000000..53251d42f0 Binary files /dev/null and b/samples/js-moonwarriors-runtime/res/Music/explodeEffect.ogg differ diff --git a/samples/js-moonwarriors-runtime/res/Music/fireEffect.mp3 b/samples/js-moonwarriors-runtime/res/Music/fireEffect.mp3 new file mode 100755 index 0000000000..31d140c8ac Binary files /dev/null and b/samples/js-moonwarriors-runtime/res/Music/fireEffect.mp3 differ diff --git a/samples/js-moonwarriors-runtime/res/Music/fireEffect.ogg b/samples/js-moonwarriors-runtime/res/Music/fireEffect.ogg new file mode 100644 index 0000000000..b8a7978891 Binary files /dev/null and b/samples/js-moonwarriors-runtime/res/Music/fireEffect.ogg differ diff --git a/samples/js-moonwarriors-runtime/res/Music/mainMainMusic.mp3 b/samples/js-moonwarriors-runtime/res/Music/mainMainMusic.mp3 new file mode 100755 index 0000000000..118e5daf5e Binary files /dev/null and b/samples/js-moonwarriors-runtime/res/Music/mainMainMusic.mp3 differ diff --git a/samples/js-moonwarriors-runtime/res/Music/mainMainMusic.ogg b/samples/js-moonwarriors-runtime/res/Music/mainMainMusic.ogg new file mode 100644 index 0000000000..c2f047dc84 Binary files /dev/null and b/samples/js-moonwarriors-runtime/res/Music/mainMainMusic.ogg differ diff --git a/samples/js-moonwarriors-runtime/res/Music/shipDestroyEffect.mp3 b/samples/js-moonwarriors-runtime/res/Music/shipDestroyEffect.mp3 new file mode 100755 index 0000000000..d1886c77e8 Binary files /dev/null and b/samples/js-moonwarriors-runtime/res/Music/shipDestroyEffect.mp3 differ diff --git a/samples/js-moonwarriors-runtime/res/Music/shipDestroyEffect.ogg b/samples/js-moonwarriors-runtime/res/Music/shipDestroyEffect.ogg new file mode 100644 index 0000000000..4e60a8b06e Binary files /dev/null and b/samples/js-moonwarriors-runtime/res/Music/shipDestroyEffect.ogg differ diff --git a/samples/js-moonwarriors-runtime/res/arial-14.GlyphProject b/samples/js-moonwarriors-runtime/res/arial-14.GlyphProject new file mode 100755 index 0000000000..cbac22bf53 Binary files /dev/null and b/samples/js-moonwarriors-runtime/res/arial-14.GlyphProject differ diff --git a/samples/js-moonwarriors-runtime/res/arial-14.fnt b/samples/js-moonwarriors-runtime/res/arial-14.fnt new file mode 100755 index 0000000000..1d16cb10bb --- /dev/null +++ b/samples/js-moonwarriors-runtime/res/arial-14.fnt @@ -0,0 +1,182 @@ +info face="ArialMT" size=14 bold=0 italic=0 charset="" unicode=0 stretchH=100 smooth=1 aa=1 padding=0,0,0,0 spacing=2,2 +common lineHeight=15 base=13 scaleW=256 scaleH=128 pages=1 packed=0 +page id=0 file="arial-14.png" +chars count=95 +char id=64 x=2 y=2 width=18 height=18 xoffset=-1 yoffset=1 xadvance=14 page=0 chnl=0 letter="@" +char id=123 x=22 y=2 width=9 height=18 xoffset=-1 yoffset=1 xadvance=5 page=0 chnl=0 letter="{" +char id=125 x=33 y=2 width=9 height=18 xoffset=-1 yoffset=1 xadvance=5 page=0 chnl=0 letter="}" +char id=40 x=44 y=2 width=8 height=18 xoffset=-1 yoffset=1 xadvance=5 page=0 chnl=0 letter="(" +char id=41 x=54 y=2 width=8 height=18 xoffset=0 yoffset=1 xadvance=5 page=0 chnl=0 letter=")" +char id=124 x=64 y=2 width=6 height=18 xoffset=0 yoffset=1 xadvance=4 page=0 chnl=0 letter="|" +char id=36 x=72 y=2 width=12 height=17 xoffset=-1 yoffset=1 xadvance=8 page=0 chnl=0 letter="$" +char id=106 x=86 y=2 width=8 height=17 xoffset=-2 yoffset=2 xadvance=3 page=0 chnl=0 letter="j" +char id=91 x=96 y=2 width=8 height=17 xoffset=-1 yoffset=2 xadvance=4 page=0 chnl=0 letter="[" +char id=93 x=106 y=2 width=7 height=17 xoffset=-1 yoffset=2 xadvance=4 page=0 chnl=0 letter="]" +char id=37 x=115 y=2 width=16 height=16 xoffset=-1 yoffset=1 xadvance=12 page=0 chnl=0 letter="%" +char id=81 x=133 y=2 width=15 height=16 xoffset=-1 yoffset=1 xadvance=11 page=0 chnl=0 letter="Q" +char id=79 x=150 y=2 width=15 height=16 xoffset=-1 yoffset=1 xadvance=11 page=0 chnl=0 letter="O" +char id=71 x=167 y=2 width=14 height=16 xoffset=-1 yoffset=1 xadvance=11 page=0 chnl=0 letter="G" +char id=67 x=183 y=2 width=14 height=16 xoffset=-1 yoffset=1 xadvance=10 page=0 chnl=0 letter="C" +char id=38 x=199 y=2 width=13 height=16 xoffset=-1 yoffset=1 xadvance=9 page=0 chnl=0 letter="&" +char id=83 x=214 y=2 width=13 height=16 xoffset=-1 yoffset=1 xadvance=9 page=0 chnl=0 letter="S" +char id=35 x=229 y=2 width=12 height=16 xoffset=-1 yoffset=1 xadvance=8 page=0 chnl=0 letter="#" +char id=47 x=243 y=2 width=8 height=16 xoffset=-1 yoffset=1 xadvance=4 page=0 chnl=0 letter="/" +char id=92 x=2 y=22 width=8 height=16 xoffset=-1 yoffset=1 xadvance=4 page=0 chnl=0 letter="\" +char id=85 x=12 y=22 width=12 height=15 xoffset=0 yoffset=2 xadvance=10 page=0 chnl=0 letter="U" +char id=51 x=26 y=22 width=12 height=15 xoffset=-1 yoffset=2 xadvance=8 page=0 chnl=0 letter="3" +char id=53 x=40 y=22 width=12 height=15 xoffset=-1 yoffset=2 xadvance=8 page=0 chnl=0 letter="5" +char id=54 x=54 y=22 width=12 height=15 xoffset=-1 yoffset=2 xadvance=8 page=0 chnl=0 letter="6" +char id=56 x=68 y=22 width=12 height=15 xoffset=-1 yoffset=2 xadvance=8 page=0 chnl=0 letter="8" +char id=57 x=82 y=22 width=12 height=15 xoffset=-1 yoffset=2 xadvance=8 page=0 chnl=0 letter="9" +char id=48 x=96 y=22 width=12 height=15 xoffset=-1 yoffset=2 xadvance=8 page=0 chnl=0 letter="0" +char id=63 x=110 y=22 width=12 height=15 xoffset=-1 yoffset=1 xadvance=8 page=0 chnl=0 letter="?" +char id=98 x=124 y=22 width=12 height=15 xoffset=-1 yoffset=2 xadvance=8 page=0 chnl=0 letter="b" +char id=112 x=138 y=22 width=12 height=15 xoffset=-1 yoffset=4 xadvance=8 page=0 chnl=0 letter="p" +char id=121 x=152 y=22 width=11 height=15 xoffset=-1 yoffset=4 xadvance=7 page=0 chnl=0 letter="y" +char id=103 x=165 y=22 width=11 height=15 xoffset=-1 yoffset=4 xadvance=8 page=0 chnl=0 letter="g" +char id=100 x=178 y=22 width=11 height=15 xoffset=-1 yoffset=2 xadvance=8 page=0 chnl=0 letter="d" +char id=113 x=191 y=22 width=11 height=15 xoffset=-1 yoffset=4 xadvance=8 page=0 chnl=0 letter="q" +char id=74 x=204 y=22 width=10 height=15 xoffset=-1 yoffset=2 xadvance=7 page=0 chnl=0 letter="J" +char id=102 x=216 y=22 width=9 height=15 xoffset=-1 yoffset=1 xadvance=4 page=0 chnl=0 letter="f" +char id=116 x=227 y=22 width=8 height=15 xoffset=-1 yoffset=2 xadvance=4 page=0 chnl=0 letter="t" +char id=87 x=237 y=22 width=17 height=14 xoffset=-1 yoffset=2 xadvance=13 page=0 chnl=0 letter="W" +char id=77 x=2 y=40 width=14 height=14 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=0 letter="M" +char id=65 x=18 y=40 width=14 height=14 xoffset=-1 yoffset=2 xadvance=9 page=0 chnl=0 letter="A" +char id=86 x=34 y=40 width=14 height=14 xoffset=-1 yoffset=2 xadvance=9 page=0 chnl=0 letter="V" +char id=88 x=50 y=40 width=14 height=14 xoffset=-1 yoffset=2 xadvance=9 page=0 chnl=0 letter="X" +char id=89 x=66 y=40 width=14 height=14 xoffset=-1 yoffset=2 xadvance=9 page=0 chnl=0 letter="Y" +char id=82 x=82 y=40 width=13 height=14 xoffset=0 yoffset=2 xadvance=10 page=0 chnl=0 letter="R" +char id=68 x=97 y=40 width=13 height=14 xoffset=0 yoffset=2 xadvance=10 page=0 chnl=0 letter="D" +char id=75 x=112 y=40 width=13 height=14 xoffset=0 yoffset=2 xadvance=9 page=0 chnl=0 letter="K" +char id=84 x=127 y=40 width=13 height=14 xoffset=-1 yoffset=2 xadvance=9 page=0 chnl=0 letter="T" +char id=90 x=142 y=40 width=13 height=14 xoffset=-1 yoffset=2 xadvance=9 page=0 chnl=0 letter="Z" +char id=72 x=157 y=40 width=12 height=14 xoffset=0 yoffset=2 xadvance=10 page=0 chnl=0 letter="H" +char id=78 x=171 y=40 width=12 height=14 xoffset=0 yoffset=2 xadvance=10 page=0 chnl=0 letter="N" +char id=66 x=185 y=40 width=12 height=14 xoffset=0 yoffset=2 xadvance=9 page=0 chnl=0 letter="B" +char id=80 x=199 y=40 width=12 height=14 xoffset=0 yoffset=2 xadvance=9 page=0 chnl=0 letter="P" +char id=69 x=213 y=40 width=12 height=14 xoffset=0 yoffset=2 xadvance=9 page=0 chnl=0 letter="E" +char id=52 x=227 y=40 width=12 height=14 xoffset=-1 yoffset=2 xadvance=8 page=0 chnl=0 letter="4" +char id=50 x=241 y=40 width=12 height=14 xoffset=-1 yoffset=2 xadvance=8 page=0 chnl=0 letter="2" +char id=55 x=2 y=56 width=12 height=14 xoffset=-1 yoffset=2 xadvance=8 page=0 chnl=0 letter="7" +char id=70 x=16 y=56 width=11 height=14 xoffset=0 yoffset=2 xadvance=9 page=0 chnl=0 letter="F" +char id=76 x=29 y=56 width=11 height=14 xoffset=0 yoffset=2 xadvance=8 page=0 chnl=0 letter="L" +char id=104 x=42 y=56 width=11 height=14 xoffset=-1 yoffset=2 xadvance=8 page=0 chnl=0 letter="h" +char id=107 x=55 y=56 width=11 height=14 xoffset=-1 yoffset=2 xadvance=7 page=0 chnl=0 letter="k" +char id=49 x=68 y=56 width=9 height=14 xoffset=0 yoffset=2 xadvance=8 page=0 chnl=0 letter="1" +char id=105 x=79 y=56 width=7 height=14 xoffset=-1 yoffset=2 xadvance=3 page=0 chnl=0 letter="i" +char id=108 x=88 y=56 width=7 height=14 xoffset=-1 yoffset=2 xadvance=3 page=0 chnl=0 letter="l" +char id=73 x=97 y=56 width=6 height=14 xoffset=0 yoffset=2 xadvance=4 page=0 chnl=0 letter="I" +char id=33 x=105 y=56 width=6 height=14 xoffset=0 yoffset=2 xadvance=4 page=0 chnl=0 letter="!" +char id=59 x=113 y=56 width=6 height=14 xoffset=0 yoffset=4 xadvance=4 page=0 chnl=0 letter=";" +char id=111 x=121 y=56 width=12 height=13 xoffset=-1 yoffset=4 xadvance=8 page=0 chnl=0 letter="o" +char id=97 x=135 y=56 width=12 height=13 xoffset=-1 yoffset=4 xadvance=8 page=0 chnl=0 letter="a" +char id=101 x=149 y=56 width=12 height=13 xoffset=-1 yoffset=4 xadvance=8 page=0 chnl=0 letter="e" +char id=99 x=163 y=56 width=11 height=13 xoffset=-1 yoffset=4 xadvance=7 page=0 chnl=0 letter="c" +char id=115 x=176 y=56 width=11 height=13 xoffset=-1 yoffset=4 xadvance=7 page=0 chnl=0 letter="s" +char id=117 x=189 y=56 width=11 height=13 xoffset=-1 yoffset=4 xadvance=8 page=0 chnl=0 letter="u" +char id=109 x=202 y=56 width=15 height=12 xoffset=-1 yoffset=4 xadvance=12 page=0 chnl=0 letter="m" +char id=119 x=219 y=56 width=14 height=12 xoffset=-1 yoffset=4 xadvance=10 page=0 chnl=0 letter="w" +char id=60 x=235 y=56 width=12 height=12 xoffset=-1 yoffset=3 xadvance=8 page=0 chnl=0 letter="<" +char id=62 x=2 y=72 width=12 height=12 xoffset=-1 yoffset=3 xadvance=8 page=0 chnl=0 letter=">" +char id=43 x=16 y=72 width=12 height=12 xoffset=-1 yoffset=3 xadvance=8 page=0 chnl=0 letter="+" +char id=118 x=30 y=72 width=11 height=12 xoffset=-1 yoffset=4 xadvance=7 page=0 chnl=0 letter="v" +char id=120 x=43 y=72 width=11 height=12 xoffset=-1 yoffset=4 xadvance=7 page=0 chnl=0 letter="x" +char id=122 x=56 y=72 width=11 height=12 xoffset=-1 yoffset=4 xadvance=7 page=0 chnl=0 letter="z" +char id=110 x=69 y=72 width=11 height=12 xoffset=-1 yoffset=4 xadvance=8 page=0 chnl=0 letter="n" +char id=114 x=82 y=72 width=9 height=12 xoffset=-1 yoffset=4 xadvance=5 page=0 chnl=0 letter="r" +char id=58 x=93 y=72 width=6 height=12 xoffset=0 yoffset=4 xadvance=4 page=0 chnl=0 letter=":" +char id=94 x=101 y=72 width=11 height=11 xoffset=-1 yoffset=1 xadvance=7 page=0 chnl=0 letter="^" +char id=61 x=114 y=72 width=12 height=10 xoffset=-1 yoffset=4 xadvance=8 page=0 chnl=0 letter="=" +char id=42 x=128 y=72 width=9 height=9 xoffset=-1 yoffset=1 xadvance=5 page=0 chnl=0 letter="*" +char id=34 x=139 y=72 width=9 height=8 xoffset=-1 yoffset=2 xadvance=5 page=0 chnl=0 letter=""" +char id=39 x=150 y=72 width=6 height=8 xoffset=-1 yoffset=2 xadvance=3 page=0 chnl=0 letter="'" +char id=44 x=158 y=72 width=6 height=8 xoffset=0 yoffset=10 xadvance=4 page=0 chnl=0 letter="," +char id=126 x=166 y=72 width=12 height=7 xoffset=-1 yoffset=6 xadvance=8 page=0 chnl=0 letter="~" +char id=96 x=180 y=72 width=8 height=7 xoffset=-1 yoffset=1 xadvance=5 page=0 chnl=0 letter="`" +char id=95 x=190 y=72 width=13 height=6 xoffset=-2 yoffset=13 xadvance=8 page=0 chnl=0 letter="_" +char id=45 x=205 y=72 width=9 height=6 xoffset=-1 yoffset=7 xadvance=5 page=0 chnl=0 letter="-" +char id=46 x=216 y=72 width=6 height=6 xoffset=0 yoffset=10 xadvance=4 page=0 chnl=0 letter="." +char id=32 x=224 y=72 width=0 height=0 xoffset=0 yoffset=133 xadvance=4 page=0 chnl=0 letter="space" +kernings count=82 +kerning first=64 second=42 amount=-1 +kerning first=79 second=102 amount=-1 +kerning first=79 second=82 amount=-1 +kerning first=47 second=52 amount=-1 +kerning first=63 second=126 amount=-1 +kerning first=121 second=44 amount=-1 +kerning first=121 second=46 amount=-1 +kerning first=87 second=65 amount=-1 +kerning first=87 second=97 amount=-1 +kerning first=87 second=44 amount=-1 +kerning first=87 second=46 amount=-1 +kerning first=65 second=87 amount=-1 +kerning first=65 second=86 amount=-1 +kerning first=65 second=89 amount=-1 +kerning first=65 second=84 amount=-1 +kerning first=65 second=32 amount=-1 +kerning first=86 second=121 amount=-1 +kerning first=86 second=65 amount=-1 +kerning first=86 second=59 amount=-1 +kerning first=86 second=111 amount=-1 +kerning first=86 second=97 amount=-1 +kerning first=86 second=101 amount=-1 +kerning first=86 second=117 amount=-1 +kerning first=86 second=114 amount=-1 +kerning first=86 second=58 amount=-1 +kerning first=86 second=44 amount=-1 +kerning first=86 second=45 amount=-1 +kerning first=86 second=46 amount=-1 +kerning first=89 second=112 amount=-1 +kerning first=89 second=113 amount=-1 +kerning first=89 second=65 amount=-1 +kerning first=89 second=105 amount=-1 +kerning first=89 second=59 amount=-1 +kerning first=89 second=111 amount=-1 +kerning first=89 second=97 amount=-1 +kerning first=89 second=101 amount=-1 +kerning first=89 second=117 amount=-1 +kerning first=89 second=118 amount=-1 +kerning first=89 second=58 amount=-1 +kerning first=89 second=44 amount=-2 +kerning first=89 second=45 amount=-1 +kerning first=89 second=46 amount=-2 +kerning first=84 second=121 amount=-1 +kerning first=84 second=65 amount=-1 +kerning first=84 second=105 amount=-1 +kerning first=84 second=59 amount=-2 +kerning first=84 second=111 amount=-2 +kerning first=84 second=97 amount=-2 +kerning first=84 second=101 amount=-2 +kerning first=84 second=99 amount=-2 +kerning first=84 second=115 amount=-2 +kerning first=84 second=117 amount=-1 +kerning first=84 second=119 amount=-1 +kerning first=84 second=114 amount=-1 +kerning first=84 second=58 amount=-2 +kerning first=84 second=44 amount=-2 +kerning first=84 second=45 amount=-1 +kerning first=84 second=46 amount=-2 +kerning first=80 second=65 amount=-1 +kerning first=80 second=62 amount=-1 +kerning first=80 second=44 amount=-2 +kerning first=80 second=46 amount=-2 +kerning first=70 second=65 amount=-1 +kerning first=70 second=44 amount=-2 +kerning first=70 second=46 amount=-2 +kerning first=76 second=121 amount=-1 +kerning first=76 second=87 amount=-1 +kerning first=76 second=86 amount=-1 +kerning first=76 second=89 amount=-1 +kerning first=76 second=84 amount=-1 +kerning first=76 second=32 amount=-1 +kerning first=49 second=49 amount=-1 +kerning first=33 second=102 amount=-1 +kerning first=119 second=44 amount=-1 +kerning first=119 second=46 amount=-1 +kerning first=62 second=35 amount=-1 +kerning first=118 second=44 amount=-1 +kerning first=118 second=46 amount=-1 +kerning first=114 second=44 amount=-1 +kerning first=114 second=46 amount=-1 +kerning first=32 second=92 amount=-1 +kerning first=32 second=65 amount=-1 diff --git a/samples/js-moonwarriors-runtime/res/arial-14.png b/samples/js-moonwarriors-runtime/res/arial-14.png new file mode 100755 index 0000000000..b9ef57eb74 Binary files /dev/null and b/samples/js-moonwarriors-runtime/res/arial-14.png differ diff --git a/samples/js-moonwarriors-runtime/res/b01.plist b/samples/js-moonwarriors-runtime/res/b01.plist new file mode 100644 index 0000000000..400d027b79 --- /dev/null +++ b/samples/js-moonwarriors-runtime/res/b01.plist @@ -0,0 +1,74 @@ + + + + + frames + + lvl1_map1.png + + frame + {{404,360},{298,100}} + offset + {-4,0} + rotated + + sourceColorRect + {{3,0},{298,100}} + sourceSize + {312,100} + + lvl1_map2.png + + frame + {{2,689},{174,249}} + offset + {-1,1} + rotated + + sourceColorRect + {{0,4},{174,249}} + sourceSize + {176,259} + + lvl1_map3.png + + frame + {{2,360},{327,400}} + offset + {0,0} + rotated + + sourceColorRect + {{0,0},{327,400}} + sourceSize + {327,400} + + lvl1_map4.png + + frame + {{2,2},{356,411}} + offset + {0,0} + rotated + + sourceColorRect + {{2,0},{356,411}} + sourceSize + {360,411} + + + metadata + + format + 2 + realTextureFileName + b01.png + size + {512,1024} + smartupdate + $TexturePacker:SmartUpdate:75fa3b17bb1f485ae38e2638ec6da711:1/1$ + textureFileName + b01.png + + + diff --git a/samples/js-moonwarriors-runtime/res/b01.png b/samples/js-moonwarriors-runtime/res/b01.png new file mode 100644 index 0000000000..c0e6b132b7 Binary files /dev/null and b/samples/js-moonwarriors-runtime/res/b01.png differ diff --git a/samples/js-moonwarriors-runtime/res/cocos2d-html5.png b/samples/js-moonwarriors-runtime/res/cocos2d-html5.png new file mode 100755 index 0000000000..bbf877b836 Binary files /dev/null and b/samples/js-moonwarriors-runtime/res/cocos2d-html5.png differ diff --git a/samples/js-moonwarriors-runtime/res/dialog_bg.png b/samples/js-moonwarriors-runtime/res/dialog_bg.png new file mode 100755 index 0000000000..a6718db97b Binary files /dev/null and b/samples/js-moonwarriors-runtime/res/dialog_bg.png differ diff --git a/samples/js-moonwarriors-runtime/res/dialog_cancel_normal.png b/samples/js-moonwarriors-runtime/res/dialog_cancel_normal.png new file mode 100755 index 0000000000..3359e9b82a Binary files /dev/null and b/samples/js-moonwarriors-runtime/res/dialog_cancel_normal.png differ diff --git a/samples/js-moonwarriors-runtime/res/dialog_cancel_press.png b/samples/js-moonwarriors-runtime/res/dialog_cancel_press.png new file mode 100755 index 0000000000..69ff93b999 Binary files /dev/null and b/samples/js-moonwarriors-runtime/res/dialog_cancel_press.png differ diff --git a/samples/js-moonwarriors-runtime/res/dialog_confirm_normal.png b/samples/js-moonwarriors-runtime/res/dialog_confirm_normal.png new file mode 100755 index 0000000000..4515c5db0f Binary files /dev/null and b/samples/js-moonwarriors-runtime/res/dialog_confirm_normal.png differ diff --git a/samples/js-moonwarriors-runtime/res/dialog_confirm_press.png b/samples/js-moonwarriors-runtime/res/dialog_confirm_press.png new file mode 100755 index 0000000000..058aa0716b Binary files /dev/null and b/samples/js-moonwarriors-runtime/res/dialog_confirm_press.png differ diff --git a/samples/js-moonwarriors-runtime/res/explode.plist b/samples/js-moonwarriors-runtime/res/explode.plist new file mode 100644 index 0000000000..e69de29bb2 diff --git a/samples/js-moonwarriors-runtime/res/explosion.plist b/samples/js-moonwarriors-runtime/res/explosion.plist new file mode 100755 index 0000000000..0e34916a48 --- /dev/null +++ b/samples/js-moonwarriors-runtime/res/explosion.plist @@ -0,0 +1,477 @@ + + + + + frames + + explosion_01.png + + frame + {{158,348},{18,24}} + offset + {2,4} + rotated + + sourceColorRect + {{57,48},{18,24}} + sourceSize + {128,128} + + explosion_02.png + + frame + {{296,258},{40,42}} + offset + {2,7} + rotated + + sourceColorRect + {{46,36},{40,42}} + sourceSize + {128,128} + + explosion_03.png + + frame + {{220,210},{42,48}} + offset + {3,8} + rotated + + sourceColorRect + {{46,32},{42,48}} + sourceSize + {128,128} + + explosion_04.png + + frame + {{264,210},{46,60}} + offset + {2,0} + rotated + + sourceColorRect + {{43,34},{46,60}} + sourceSize + {128,128} + + explosion_05.png + + frame + {{2,458},{50,56}} + offset + {1,-4} + rotated + + sourceColorRect + {{40,40},{50,56}} + sourceSize + {128,128} + + explosion_06.png + + frame + {{60,458},{48,56}} + offset + {-1,-3} + rotated + + sourceColorRect + {{39,39},{48,56}} + sourceSize + {128,128} + + explosion_07.png + + frame + {{160,210},{56,58}} + offset + {0,-2} + rotated + + sourceColorRect + {{36,37},{56,58}} + sourceSize + {128,128} + + explosion_08.png + + frame + {{292,72},{60,64}} + offset + {-3,-5} + rotated + + sourceColorRect + {{31,37},{60,64}} + sourceSize + {128,128} + + explosion_09.png + + frame + {{160,70},{70,68}} + offset + {-4,-7} + rotated + + sourceColorRect + {{25,37},{70,68}} + sourceSize + {128,128} + + explosion_10.png + + frame + {{252,428},{76,76}} + offset + {-4,-6} + rotated + + sourceColorRect + {{22,32},{76,76}} + sourceSize + {128,128} + + explosion_11.png + + frame + {{76,284},{80,84}} + offset + {-2,-2} + rotated + + sourceColorRect + {{22,24},{80,84}} + sourceSize + {128,128} + + explosion_12.png + + frame + {{2,372},{80,84}} + offset + {-1,4} + rotated + + sourceColorRect + {{23,18},{80,84}} + sourceSize + {128,128} + + explosion_13.png + + frame + {{84,370},{74,84}} + offset + {4,3} + rotated + + sourceColorRect + {{31,19},{74,84}} + sourceSize + {128,128} + + explosion_14.png + + frame + {{84,186},{74,80}} + offset + {6,-4} + rotated + + sourceColorRect + {{33,28},{74,80}} + sourceSize + {128,128} + + explosion_15.png + + frame + {{2,194},{80,88}} + offset + {6,-4} + rotated + + sourceColorRect + {{30,24},{80,88}} + sourceSize + {128,128} + + explosion_16.png + + frame + {{2,2},{82,98}} + offset + {6,-4} + rotated + + sourceColorRect + {{29,19},{82,98}} + sourceSize + {128,128} + + explosion_17.png + + frame + {{2,102},{80,90}} + offset + {10,-3} + rotated + + sourceColorRect + {{34,22},{80,90}} + sourceSize + {128,128} + + explosion_18.png + + frame + {{158,268},{78,74}} + offset + {14,-1} + rotated + + sourceColorRect + {{39,28},{78,74}} + sourceSize + {128,128} + + explosion_19.png + + frame + {{2,284},{86,72}} + offset + {14,1} + rotated + + sourceColorRect + {{35,27},{86,72}} + sourceSize + {128,128} + + explosion_20.png + + frame + {{160,368},{78,70}} + offset + {7,0} + rotated + + sourceColorRect + {{32,29},{78,70}} + sourceSize + {128,128} + + explosion_21.png + + frame + {{330,2},{76,66}} + offset + {4,-1} + rotated + + sourceColorRect + {{30,32},{76,66}} + sourceSize + {128,128} + + explosion_22.png + + frame + {{354,70},{58,58}} + offset + {-2,1} + rotated + + sourceColorRect + {{33,34},{58,58}} + sourceSize + {128,128} + + explosion_23.png + + frame + {{234,260},{64,60}} + offset + {1,1} + rotated + + sourceColorRect + {{33,33},{64,60}} + sourceSize + {128,128} + + explosion_24.png + + frame + {{408,2},{70,66}} + offset + {4,-2} + rotated + + sourceColorRect + {{33,33},{70,66}} + sourceSize + {128,128} + + explosion_25.png + + frame + {{86,2},{72,80}} + offset + {10,-2} + rotated + + sourceColorRect + {{38,26},{72,80}} + sourceSize + {128,128} + + explosion_26.png + + frame + {{84,102},{74,82}} + offset + {10,-3} + rotated + + sourceColorRect + {{37,26},{74,82}} + sourceSize + {128,128} + + explosion_27.png + + frame + {{118,456},{54,64}} + offset + {6,2} + rotated + + sourceColorRect + {{43,30},{54,64}} + sourceSize + {128,128} + + explosion_28.png + + frame + {{296,138},{58,62}} + offset + {5,4} + rotated + + sourceColorRect + {{40,29},{58,62}} + sourceSize + {128,128} + + explosion_29.png + + frame + {{184,448},{62,66}} + offset + {5,5} + rotated + + sourceColorRect + {{38,26},{62,66}} + sourceSize + {128,128} + + explosion_30.png + + frame + {{160,140},{66,68}} + offset + {4,6} + rotated + + sourceColorRect + {{35,24},{66,68}} + sourceSize + {128,128} + + explosion_31.png + + frame + {{234,2},{72,68}} + offset + {4,5} + rotated + + sourceColorRect + {{32,25},{72,68}} + sourceSize + {128,128} + + explosion_32.png + + frame + {{232,348},{78,68}} + offset + {4,6} + rotated + + sourceColorRect + {{29,24},{78,68}} + sourceSize + {128,128} + + explosion_33.png + + frame + {{160,2},{72,66}} + offset + {9,9} + rotated + + sourceColorRect + {{37,22},{72,66}} + sourceSize + {128,128} + + explosion_34.png + + frame + {{228,140},{68,66}} + offset + {9,17} + rotated + + sourceColorRect + {{39,14},{68,66}} + sourceSize + {128,128} + + explosion_35.png + + frame + {{232,72},{66,58}} + offset + {12,14} + rotated + + sourceColorRect + {{43,21},{66,58}} + sourceSize + {128,128} + + + metadata + + format + 2 + realTextureFileName + explosion.png + size + {512,512} + smartupdate + $TexturePacker:SmartUpdate:32444a4ee5ed4b15bbb0544a15090343$ + textureFileName + explosion.png + + + diff --git a/samples/js-moonwarriors-runtime/res/explosion.png b/samples/js-moonwarriors-runtime/res/explosion.png new file mode 100755 index 0000000000..97bca7d49f Binary files /dev/null and b/samples/js-moonwarriors-runtime/res/explosion.png differ diff --git a/samples/js-moonwarriors-runtime/res/flare.jpg b/samples/js-moonwarriors-runtime/res/flare.jpg new file mode 100755 index 0000000000..1434edfadd Binary files /dev/null and b/samples/js-moonwarriors-runtime/res/flare.jpg differ diff --git a/samples/js-moonwarriors-runtime/res/gameOver.png b/samples/js-moonwarriors-runtime/res/gameOver.png new file mode 100755 index 0000000000..432659e041 Binary files /dev/null and b/samples/js-moonwarriors-runtime/res/gameOver.png differ diff --git a/samples/js-moonwarriors-runtime/res/gameoverBack.png b/samples/js-moonwarriors-runtime/res/gameoverBack.png new file mode 100644 index 0000000000..9975853ce3 Binary files /dev/null and b/samples/js-moonwarriors-runtime/res/gameoverBack.png differ diff --git a/samples/js-moonwarriors-runtime/res/level01.tmx b/samples/js-moonwarriors-runtime/res/level01.tmx new file mode 100755 index 0000000000..7c04ddcad9 --- /dev/null +++ b/samples/js-moonwarriors-runtime/res/level01.tmx @@ -0,0 +1,12 @@ + + + + + + + + + H4sIAAAAAAAAC2NgGAWkAsaBdgAJgHmgHTAEAdNAO2AAActAO4AAAABYXSHTsAQAAA== + + + diff --git a/samples/js-moonwarriors-runtime/res/loading.png b/samples/js-moonwarriors-runtime/res/loading.png new file mode 100755 index 0000000000..27115ac957 Binary files /dev/null and b/samples/js-moonwarriors-runtime/res/loading.png differ diff --git a/samples/js-moonwarriors-runtime/res/logo.png b/samples/js-moonwarriors-runtime/res/logo.png new file mode 100755 index 0000000000..18c643708c Binary files /dev/null and b/samples/js-moonwarriors-runtime/res/logo.png differ diff --git a/samples/js-moonwarriors-runtime/res/logoBack.png b/samples/js-moonwarriors-runtime/res/logoBack.png new file mode 100644 index 0000000000..6fc952b2a4 Binary files /dev/null and b/samples/js-moonwarriors-runtime/res/logoBack.png differ diff --git a/samples/js-moonwarriors-runtime/res/menu.png b/samples/js-moonwarriors-runtime/res/menu.png new file mode 100755 index 0000000000..364ab06500 Binary files /dev/null and b/samples/js-moonwarriors-runtime/res/menu.png differ diff --git a/samples/js-moonwarriors-runtime/res/menuTitle.png b/samples/js-moonwarriors-runtime/res/menuTitle.png new file mode 100755 index 0000000000..7383b319d9 Binary files /dev/null and b/samples/js-moonwarriors-runtime/res/menuTitle.png differ diff --git a/samples/js-moonwarriors-runtime/res/sg.zip b/samples/js-moonwarriors-runtime/res/sg.zip new file mode 100644 index 0000000000..03ff7f5fcb Binary files /dev/null and b/samples/js-moonwarriors-runtime/res/sg.zip differ diff --git a/samples/js-moonwarriors-runtime/res/textureOpaquePack.plist b/samples/js-moonwarriors-runtime/res/textureOpaquePack.plist new file mode 100644 index 0000000000..ae4f712cb9 --- /dev/null +++ b/samples/js-moonwarriors-runtime/res/textureOpaquePack.plist @@ -0,0 +1,100 @@ + + + + + frames + + W1.png + + frame + {{23,232},{12,30}} + offset + {1,-16} + rotated + + sourceColorRect + {{2,32},{12,30}} + sourceSize + {14,62} + + W2.png + + frame + {{2,232},{19,19}} + offset + {2,1} + rotated + + sourceColorRect + {{5,2},{19,19}} + sourceSize + {25,25} + + explode1.png + + frame + {{2,100},{96,90}} + offset + {0,3} + rotated + + sourceColorRect + {{0,0},{96,90}} + sourceSize + {96,96} + + explode2.png + + frame + {{2,2},{96,96}} + offset + {0,0} + rotated + + sourceColorRect + {{0,0},{96,96}} + sourceSize + {96,96} + + explode3.png + + frame + {{94,100},{96,68}} + offset + {0,0} + rotated + + sourceColorRect + {{0,14},{96,68}} + sourceSize + {96,96} + + hit.png + + frame + {{2,198},{32,32}} + offset + {0,0} + rotated + + sourceColorRect + {{0,0},{32,32}} + sourceSize + {32,32} + + + metadata + + format + 2 + realTextureFileName + textureOpaquePack.png + size + {256,256} + smartupdate + $TexturePacker:SmartUpdate:264133b3f8692a94e25ec8a621b59e3d:1/1$ + textureFileName + textureOpaquePack.png + + + diff --git a/samples/js-moonwarriors-runtime/res/textureOpaquePack.png b/samples/js-moonwarriors-runtime/res/textureOpaquePack.png new file mode 100644 index 0000000000..9b958cca30 Binary files /dev/null and b/samples/js-moonwarriors-runtime/res/textureOpaquePack.png differ diff --git a/samples/js-moonwarriors-runtime/res/textureTransparentPack.plist b/samples/js-moonwarriors-runtime/res/textureTransparentPack.plist new file mode 100644 index 0000000000..e8849b5ae8 --- /dev/null +++ b/samples/js-moonwarriors-runtime/res/textureTransparentPack.plist @@ -0,0 +1,152 @@ + + + + + frames + + E0.png + + frame + {{104,1275},{74,39}} + offset + {0,0} + rotated + + sourceColorRect + {{0,0},{74,39}} + sourceSize + {74,39} + + E1.png + + frame + {{414,1173},{96,68}} + offset + {0,0} + rotated + + sourceColorRect + {{0,0},{96,68}} + sourceSize + {96,68} + + E2.png + + frame + {{414,1243},{74,93}} + offset + {0,0} + rotated + + sourceColorRect + {{0,0},{74,93}} + sourceSize + {74,93} + + E3.png + + frame + {{213,1247},{76,57}} + offset + {0,0} + rotated + + sourceColorRect + {{0,0},{76,57}} + sourceSize + {76,57} + + E4.png + + frame + {{315,1173},{89,97}} + offset + {0,0} + rotated + + sourceColorRect + {{0,0},{89,97}} + sourceSize + {89,97} + + E5.png + + frame + {{2,1173},{95,107}} + offset + {0,0} + rotated + + sourceColorRect + {{0,0},{95,107}} + sourceSize + {95,107} + + bg01.png + + frame + {{2,2},{480,1169}} + offset + {0,0} + rotated + + sourceColorRect + {{0,0},{480,1169}} + sourceSize + {480,1169} + + ship01.png + + frame + {{111,1173},{100,100}} + offset + {0,0} + rotated + + sourceColorRect + {{0,0},{100,100}} + sourceSize + {100,100} + + ship02.png + + frame + {{213,1173},{100,72}} + offset + {0,-14} + rotated + + sourceColorRect + {{0,28},{100,72}} + sourceSize + {100,100} + + ship03.png + + frame + {{2,1270},{100,72}} + offset + {0,-14} + rotated + + sourceColorRect + {{0,28},{100,72}} + sourceSize + {100,100} + + + metadata + + format + 2 + realTextureFileName + textureTransparentPack.png + size + {512,2048} + smartupdate + $TexturePacker:SmartUpdate:c30a7cd03f24331e71eddccb0ee83ea5:1/1$ + textureFileName + textureTransparentPack.png + + + diff --git a/samples/js-moonwarriors-runtime/res/textureTransparentPack.png b/samples/js-moonwarriors-runtime/res/textureTransparentPack.png new file mode 100644 index 0000000000..4782890295 Binary files /dev/null and b/samples/js-moonwarriors-runtime/res/textureTransparentPack.png differ diff --git a/samples/js-moonwarriors-runtime/res_engine/dialog_bg.png b/samples/js-moonwarriors-runtime/res_engine/dialog_bg.png new file mode 100644 index 0000000000..ffaa453b82 Binary files /dev/null and b/samples/js-moonwarriors-runtime/res_engine/dialog_bg.png differ diff --git a/samples/js-moonwarriors-runtime/res_engine/dialog_cancel_normal.png b/samples/js-moonwarriors-runtime/res_engine/dialog_cancel_normal.png new file mode 100644 index 0000000000..3386c01867 Binary files /dev/null and b/samples/js-moonwarriors-runtime/res_engine/dialog_cancel_normal.png differ diff --git a/samples/js-moonwarriors-runtime/res_engine/dialog_cancel_press.png b/samples/js-moonwarriors-runtime/res_engine/dialog_cancel_press.png new file mode 100644 index 0000000000..6d9d565c90 Binary files /dev/null and b/samples/js-moonwarriors-runtime/res_engine/dialog_cancel_press.png differ diff --git a/samples/js-moonwarriors-runtime/res_engine/dialog_confirm_normal.png b/samples/js-moonwarriors-runtime/res_engine/dialog_confirm_normal.png new file mode 100644 index 0000000000..3a7e34ccba Binary files /dev/null and b/samples/js-moonwarriors-runtime/res_engine/dialog_confirm_normal.png differ diff --git a/samples/js-moonwarriors-runtime/res_engine/dialog_confirm_press.png b/samples/js-moonwarriors-runtime/res_engine/dialog_confirm_press.png new file mode 100644 index 0000000000..21a22ea043 Binary files /dev/null and b/samples/js-moonwarriors-runtime/res_engine/dialog_confirm_press.png differ diff --git a/samples/js-moonwarriors-runtime/res_engine/preload_bg.jpg b/samples/js-moonwarriors-runtime/res_engine/preload_bg.jpg new file mode 100644 index 0000000000..47f75d78a1 Binary files /dev/null and b/samples/js-moonwarriors-runtime/res_engine/preload_bg.jpg differ diff --git a/samples/js-moonwarriors-runtime/res_engine/preload_logo.png b/samples/js-moonwarriors-runtime/res_engine/preload_logo.png new file mode 100644 index 0000000000..d856c50065 Binary files /dev/null and b/samples/js-moonwarriors-runtime/res_engine/preload_logo.png differ diff --git a/samples/js-moonwarriors-runtime/res_engine/preload_title.png b/samples/js-moonwarriors-runtime/res_engine/preload_title.png new file mode 100644 index 0000000000..73d4119b6d Binary files /dev/null and b/samples/js-moonwarriors-runtime/res_engine/preload_title.png differ diff --git a/samples/js-moonwarriors-runtime/res_engine/progress_bar.png b/samples/js-moonwarriors-runtime/res_engine/progress_bar.png new file mode 100644 index 0000000000..0f55b6ddb8 Binary files /dev/null and b/samples/js-moonwarriors-runtime/res_engine/progress_bar.png differ diff --git a/samples/js-moonwarriors-runtime/res_engine/progress_bg.png b/samples/js-moonwarriors-runtime/res_engine/progress_bg.png new file mode 100644 index 0000000000..4626934eda Binary files /dev/null and b/samples/js-moonwarriors-runtime/res_engine/progress_bg.png differ diff --git a/samples/js-moonwarriors-runtime/res_engine/progress_light.png b/samples/js-moonwarriors-runtime/res_engine/progress_light.png new file mode 100644 index 0000000000..2ca6555140 Binary files /dev/null and b/samples/js-moonwarriors-runtime/res_engine/progress_light.png differ diff --git a/samples/js-moonwarriors-runtime/res_engine/progress_shadow.png b/samples/js-moonwarriors-runtime/res_engine/progress_shadow.png new file mode 100644 index 0000000000..4abfffee8d Binary files /dev/null and b/samples/js-moonwarriors-runtime/res_engine/progress_shadow.png differ diff --git a/samples/js-moonwarriors-runtime/src/AboutLayer.js b/samples/js-moonwarriors-runtime/src/AboutLayer.js new file mode 100755 index 0000000000..931fc081e8 --- /dev/null +++ b/samples/js-moonwarriors-runtime/src/AboutLayer.js @@ -0,0 +1,77 @@ +/**************************************************************************** + Cocos2d-html5 show case : Moon Warriors + + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. 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. + + @Authors: + Programmer: Shengxiang Chen (陈升想), Dingping Lv (吕定平), Ricardo Quesada + Effects animation: Hao Wu (吴昊) + Quality Assurance: Sean Lin (林顺) + ****************************************************************************/ + +var AboutLayer = cc.Layer.extend({ + ctor:function(){ + this._super(); + this.init(); + }, + init:function () { + var sp = new cc.Sprite(res.loading_png); + sp.anchorX = 0; + sp.anchorY = 0; + sp.scale = MW.SCALE; + this.addChild(sp, 0, 1); + + var cacheImage = cc.textureCache.addImage(res.menuTitle_png); + var title = new cc.Sprite(cacheImage, cc.rect(0, 40, 120, 38)); + title.x = winSize.width / 2; + title.y = winSize.height - 60; + this.addChild(title); + + // There is a bug in LabelTTF native. Apparently it fails with some unicode chars. + var about = new cc.LabelTTF(" This showcase utilizes many features from Cocos2d-html5 engine, including: Parallax background, tilemap, actions, ease, frame animation, schedule, Labels, keyboard Dispatcher, Scene Transition. \n Art and audio is copyrighted by Enigmata Genus Revenge, you may not use any copyrigted material without permission. This showcase is licensed under MIT. \n \n Programmer: \n Shengxiang Chen (陈升想) \n Dingping Lv (吕定平) \n Effects animation: Hao Wu(吴昊)\n Quality Assurance: Sean Lin(林顺)", "Arial", 21, cc.size(MW.WIDTH * 0.85, 0), cc.TEXT_ALIGNMENT_LEFT ); + about.attr({ + x: winSize.width / 2, + y: MW.HEIGHT / 2 + 30, + anchorX: 0.5, + anchorY: 0.5 + }); + about.setColor(cc.color(MW.FONTCOLOR)); + this.addChild(about); + + var label = new cc.LabelTTF("Go back", "Arial", 21); + label.setColor(cc.color(MW.FONTCOLOR)); + var back = new cc.MenuItemLabel(label, this.onBackCallback); + var menu = new cc.Menu(back); + menu.x = winSize.width / 2; + menu.y = 60; + this.addChild(menu); + + return true; + }, + onBackCallback:function (pSender) { + var scene = new cc.Scene(); + scene.addChild(new SysMenu()); + cc.director.runScene(new cc.TransitionFade(1.2, scene)); + } +}); diff --git a/samples/js-moonwarriors-runtime/src/Background.js b/samples/js-moonwarriors-runtime/src/Background.js new file mode 100644 index 0000000000..ef9dc8bed0 --- /dev/null +++ b/samples/js-moonwarriors-runtime/src/Background.js @@ -0,0 +1,128 @@ +/**************************************************************************** + Cocos2d-html5 show case : Moon Warriors + + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. 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. + + @Authors: + Programmer: Shengxiang Chen (陈升想), Dingping Lv (吕定平), Ricardo Quesada + Effects animation: Hao Wu (吴昊) + Quality Assurance: Sean Lin (林顺) + ****************************************************************************/ + +var BackSky = cc.Sprite.extend({ + active:true, + ctor:function () { + this._super("#bg01.png"); + var rect = cc.rect(0, 1, this.width, this.height-2); + this.setTextureRect(rect); + this.anchorX = 0; + this.anchorY = 0; + }, + destroy:function () { + this.visible = false; + this.active = false; + } +}); + +BackSky.create = function () { + var background = new BackSky(); + g_sharedGameLayer.addChild(background, -10); + MW.CONTAINER.BACKSKYS.push(background); + return background; +}; + +BackSky.getOrCreate = function () { + var selChild = null; + for (var j = 0; j < MW.CONTAINER.BACKSKYS.length; j++) { + selChild = MW.CONTAINER.BACKSKYS[j]; + if (selChild.active == false) { + selChild.visible = true; + selChild.active = true; + return selChild; + } + } + selChild = BackSky.create(); + return selChild; +}; + + +BackSky.preSet = function () { + var background = null; + for (var i = 0; i < 2; i++) { + background = BackSky.create(); + background.visible = false; + background.active = false; + } +}; + +var BackTileMapLvl1 = [ + "lvl1_map1.png", + "lvl1_map2.png", + "lvl1_map3.png", + "lvl1_map4.png" +]; + +var BackTileMap = cc.Sprite.extend({ + active:true, + ctor:function (frameName) { + this._super("#"+frameName); + this.anchorX = 0.5; + this.anchorY = 0; + }, + destroy:function () { + this.visible = false; + this.active = false; + } +}); + +BackTileMap.create = function (frameName) { + var backTileMap = new BackTileMap(frameName); + g_sharedGameLayer.addChild(backTileMap, -9); + MW.CONTAINER.BACKTILEMAPS.push(backTileMap); + return backTileMap; +}; + +BackTileMap.getOrCreate = function () { + var selChild = null; + for (var j = 0; j < MW.CONTAINER.BACKTILEMAPS.length; j++) { + selChild = MW.CONTAINER.BACKTILEMAPS[j]; + if (selChild.active == false) { + selChild.visible = true; + selChild.active = true; + return selChild; + } + } + selChild = BackTileMap.create(BackTileMapLvl1[0|Math.random()*4]); + return selChild; +}; + + +BackTileMap.preSet = function () { + var backTileMap = null; + for (var i = 0; i < BackTileMapLvl1.length; i++) { + backTileMap = BackTileMap.create(BackTileMapLvl1[i]); + backTileMap.visible = false; + backTileMap.active = false; + } +}; diff --git a/samples/js-moonwarriors-runtime/src/Bullet.js b/samples/js-moonwarriors-runtime/src/Bullet.js new file mode 100755 index 0000000000..8f6ac127a5 --- /dev/null +++ b/samples/js-moonwarriors-runtime/src/Bullet.js @@ -0,0 +1,124 @@ +/**************************************************************************** + Cocos2d-html5 show case : Moon Warriors + + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. 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. + + @Authors: + Programmer: Shengxiang Chen (陈升想), Dingping Lv (吕定平), Ricardo Quesada + Effects animation: Hao Wu (吴昊) + Quality Assurance: Sean Lin (林顺) + ****************************************************************************/ + +//bullet +var Bullet = cc.Sprite.extend({ + active:true, + xVelocity:0, + yVelocity:200, + power:1, + HP:1, + moveType:null, + zOrder:3000, + attackMode:MW.ENEMY_MOVE_TYPE.NORMAL, + parentType:MW.BULLET_TYPE.PLAYER, + ctor:function (bulletSpeed, weaponType, attackMode) { + this._super("#"+weaponType); + + this.yVelocity = -bulletSpeed; + this.attackMode = attackMode; + //this.setBlendFunc(cc.SRC_ALPHA, cc.ONE); + }, + update:function (dt) { + var x = this.x, y = this.y; + this.x = x - this.xVelocity * dt; + this.y = y - this.yVelocity * dt; + if (x < 0 || x > g_sharedGameLayer.screenRect.width || y < 0 || y > g_sharedGameLayer.screenRect.height || this.HP <= 0) { + this.destroy(); + } + }, + destroy:function () { + var explode = HitEffect.getOrCreateHitEffect(this.x, this.y, Math.random() * 360, 0.75); + this.active = false; + this.visible = false; + }, + hurt:function () { + this.HP--; + }, + collideRect:function (x, y) { + return cc.rect(x - 3, y - 3, 6, 6); + } +}); + +Bullet.getOrCreateBullet = function (bulletSpeed, weaponType, attackMode, zOrder, mode) { + /**/ + var selChild = null; + if (mode == MW.UNIT_TAG.PLAYER_BULLET) { + for (var j = 0; j < MW.CONTAINER.PLAYER_BULLETS.length; j++) { + selChild = MW.CONTAINER.PLAYER_BULLETS[j]; + if (selChild.active == false) { + selChild.visible = true; + selChild.HP = 1; + selChild.active = true; + return selChild; + } + } + } + else { + for (var j = 0; j < MW.CONTAINER.ENEMY_BULLETS.length; j++) { + selChild = MW.CONTAINER.ENEMY_BULLETS[j]; + if (selChild.active == false) { + selChild.visible = true; + selChild.HP = 1; + selChild.active = true; + return selChild; + } + } + } + selChild = Bullet.create(bulletSpeed, weaponType, attackMode, zOrder, mode); + return selChild; +}; + +Bullet.create = function (bulletSpeed, weaponType, attackMode, zOrder, mode) { + var bullet = new Bullet(bulletSpeed, weaponType, attackMode); + g_sharedGameLayer.addBullet(bullet, zOrder, mode); + if (mode == MW.UNIT_TAG.PLAYER_BULLET) { + MW.CONTAINER.PLAYER_BULLETS.push(bullet); + } else { + MW.CONTAINER.ENEMY_BULLETS.push(bullet); + } + return bullet; +}; + +Bullet.preSet = function () { + var bullet = null; + for (var i = 0; i < 10; i++) { + var bullet = Bullet.create(MW.BULLET_SPEED.SHIP, "W1.png", MW.ENEMY_ATTACK_MODE.NORMAL, 3000, MW.UNIT_TAG.PLAYER_BULLET); + bullet.visible = false; + bullet.active = false; + } + for (var i = 0; i < 10; i++) { + bullet = Bullet.create(MW.BULLET_SPEED.ENEMY, "W2.png", MW.ENEMY_ATTACK_MODE.NORMAL, 3000, MW.UNIT_TAG.ENMEY_BULLET); + bullet.visible = false; + bullet.active = false; + } +}; diff --git a/samples/js-moonwarriors-runtime/src/Effect.js b/samples/js-moonwarriors-runtime/src/Effect.js new file mode 100755 index 0000000000..a10c367281 --- /dev/null +++ b/samples/js-moonwarriors-runtime/src/Effect.js @@ -0,0 +1,114 @@ +/**************************************************************************** + Cocos2d-html5 show case : Moon Warriors + + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. 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. + + @Authors: + Programmer: Shengxiang Chen (陈升想), Dingping Lv (吕定平), Ricardo Quesada + Effects animation: Hao Wu (吴昊) + Quality Assurance: Sean Lin (林顺) + ****************************************************************************/ + +var flareEffect = function (flare,target, callback) { + flare.stopAllActions(); + flare.setBlendFunc(cc.SRC_ALPHA, cc.ONE); + flare.attr({ + x: -45, + y: MW.FLAREY, + visible: true, + opacity: 0, + rotation: -120, + scale: 0.3 + }); + + var opacityAnim = cc.fadeTo(0.5, 255); + var opacDim = cc.fadeTo(1, 0); + var biggerEase = cc.scaleBy(0.7, 1.2, 1.2).easing(cc.easeSineOut()); + var easeMove = cc.moveBy(0.5, cc.p(490, 0)).easing(cc.easeSineOut()); + var rotateEase = cc.rotateBy(2.5, 90).easing(cc.easeExponentialOut()); + var bigger = cc.scaleTo(0.5, 1); + + var onComplete = cc.callFunc(callback, target); + var killflare = cc.callFunc(function () { + this.parent.removeChild(this,true); + }, flare); + flare.runAction(cc.sequence(opacityAnim, biggerEase, opacDim, killflare, onComplete)); + flare.runAction(easeMove); + flare.runAction(rotateEase); + flare.runAction(bigger); +}; + +var removeFromParent = function( sprite ) +{ + sprite.removeFromParent(); +}; + +var spark = function (x, y, parent, scale, duration) { + scale = scale || 0.3; + duration = duration || 0.5; + + var one = new cc.Sprite("#explode1.png"); + var two = new cc.Sprite("#explode2.png"); + var three = new cc.Sprite("#explode3.png"); + + one.attr({ + x: x, + y: y, + scale: scale + }); + two.attr({ + x: x, + y: y, + scale: scale + }); + three.attr({ + x: x, + y: y, + scale: scale, + rotation: Math.random() * 360 + }); + + //parent.addChild(one); + parent.addSpark(two); + parent.addSpark(three); + + var left = cc.rotateBy(duration, -45); + var right = cc.rotateBy(duration, 45); + var scaleBy = cc.scaleBy(duration, 3, 3); + var fadeOut = cc.fadeOut(duration); + var remove = cc.callFunc(removeFromParent, this); + var seq = cc.sequence( fadeOut, remove ); + + one.runAction(left); + two.runAction(right); + + one.runAction(scaleBy); + two.runAction(scaleBy.clone()); + three.runAction(scaleBy.clone()); + + one.runAction(seq); + two.runAction(seq.clone() ); + three.runAction(seq.clone()); +}; + diff --git a/samples/js-moonwarriors-runtime/src/Enemy.js b/samples/js-moonwarriors-runtime/src/Enemy.js new file mode 100755 index 0000000000..71a22d84a6 --- /dev/null +++ b/samples/js-moonwarriors-runtime/src/Enemy.js @@ -0,0 +1,155 @@ +/**************************************************************************** + Cocos2d-html5 show case : Moon Warriors + + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. 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. + + @Authors: + Programmer: Shengxiang Chen (陈升想), Dingping Lv (吕定平), Ricardo Quesada + Effects animation: Hao Wu (吴昊) + Quality Assurance: Sean Lin (林顺) + ****************************************************************************/ + +var Enemy = cc.Sprite.extend({ + eID:0, + enemyType:1, + active:true, + speed:200, + bulletSpeed:MW.BULLET_SPEED.ENEMY, + HP:15, + bulletPowerValue:1, + moveType:null, + scoreValue:200, + zOrder:1000, + delayTime:1 + 1.2 * Math.random(), + attackMode:MW.ENEMY_MOVE_TYPE.NORMAL, + _hurtColorLife:0, + ctor:function (arg) { + this._super("#"+arg.textureName); + if (arg.textureName != "E4.png") + this.flippedY = true; + + this.HP = arg.HP; + this.moveType = arg.moveType; + this.scoreValue = arg.scoreValue; + this.attackMode = arg.attackMode; + this.enemyType = arg.type; + this.schedule(this.shoot, this.delayTime); + }, + _timeTick:0, + update:function (dt) { + var x = this.x; + var y = this.y; + if ((x < 0 || x > MW.WIDTH) && (y < 0 || y > MW.HEIGHT)) { + this.active = false; + } + this._timeTick += dt; + if (this._timeTick > 0.1) { + this._timeTick = 0; + if (this._hurtColorLife > 0) { + this._hurtColorLife--; + } + } + + if (x < 0 || x > g_sharedGameLayer.screenRect.width || y < 0 || y > g_sharedGameLayer.screenRect.height || this.HP <= 0) { + this.active = false; + this.destroy(); + } + + }, + destroy:function () { + MW.SCORE += this.scoreValue; + var a = Explosion.getOrCreateExplosion(); + a.attr({ + x: this.x, + y: this.y + }); + SparkEffect.getOrCreateSparkEffect(this.x, this.y); + if (MW.SOUND) { + cc.audioEngine.playEffect(res.explodeEffect_mp3); + } + this.visible = false; + this.active = false; + this.stopAllActions(); + this.unschedule(this.shoot); + MW.ACTIVE_ENEMIES--; + }, + shoot:function () { + var x = this.x, y = this.y; + var b = Bullet.getOrCreateBullet(this.bulletSpeed, "W2.png", this.attackMode, 3000, MW.UNIT_TAG.ENMEY_BULLET); + b.x = x; + b.y = y - this.height * 0.2; + }, + hurt:function () { + this._hurtColorLife = 2; + this.HP--; + }, + collideRect:function (x, y) { + var w = this.width, h = this.height; + return cc.rect(x - w / 2, y - h / 4, w, h / 2+20); + } +}); + +Enemy.getOrCreateEnemy = function (arg) { + var selChild = null; + for (var j = 0; j < MW.CONTAINER.ENEMIES.length; j++) { + selChild = MW.CONTAINER.ENEMIES[j]; + + if (selChild.active == false && selChild.enemyType == arg.type) { + selChild.HP = arg.HP; + selChild.active = true; + selChild.moveType = arg.moveType; + selChild.scoreValue = arg.scoreValue; + selChild.attackMode = arg.attackMode; + selChild._hurtColorLife = 0; + + selChild.schedule(selChild.shoot, selChild.delayTime); + selChild.visible = true; + MW.ACTIVE_ENEMIES++; + return selChild; + } + } + selChild = Enemy.create(arg); + MW.ACTIVE_ENEMIES++; + return selChild; +}; + +Enemy.create = function (arg) { + var enemy = new Enemy(arg); + g_sharedGameLayer.addEnemy(enemy, enemy.zOrder, MW.UNIT_TAG.ENEMY); + MW.CONTAINER.ENEMIES.push(enemy); + return enemy; +}; + +Enemy.preSet = function () { + var enemy = null; + for (var i = 0; i < 3; i++) { + for (var j = 0; j < EnemyType.length; j++) { + enemy = Enemy.create(EnemyType[j]); + enemy.visible = false; + enemy.active = false; + enemy.stopAllActions(); + enemy.unscheduleAllCallbacks(); + } + } +}; diff --git a/samples/js-moonwarriors-runtime/src/Explosion.js b/samples/js-moonwarriors-runtime/src/Explosion.js new file mode 100755 index 0000000000..9816a1af65 --- /dev/null +++ b/samples/js-moonwarriors-runtime/src/Explosion.js @@ -0,0 +1,101 @@ +/**************************************************************************** + Cocos2d-html5 show case : Moon Warriors + + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. 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. + + @Authors: + Programmer: Shengxiang Chen (陈升想), Dingping Lv (吕定平), Ricardo Quesada + Effects animation: Hao Wu (吴昊) + Quality Assurance: Sean Lin (林顺) + ****************************************************************************/ + +var Explosion = cc.Sprite.extend({ + tmpWidth:0, + tmpHeight:0, + active:true, + animation:null, + ctor:function () { + var pFrame = cc.spriteFrameCache.getSpriteFrame("explosion_01.png"); + this._super(pFrame); + this.setBlendFunc(cc.SRC_ALPHA, cc.ONE); + + this.tmpWidth = this.width; + this.tmpHeight = this.height; + this.animation = cc.animationCache.getAnimation("Explosion"); + }, + play:function(){ + //return; + this.runAction(cc.sequence( + cc.animate(this.animation), + cc.callFunc(this.destroy, this) + )); + }, + destroy:function () { + this.visible = false; + this.active = false; + } +}); + +Explosion.sharedExplosion = function () { + var animFrames = []; + var str = ""; + for (var i = 1; i < 35; i++) { + str = "explosion_" + (i < 10 ? ("0" + i) : i) + ".png"; + var frame = cc.spriteFrameCache.getSpriteFrame(str); + animFrames.push(frame); + } + var animation = new cc.Animation(animFrames, 0.04); + cc.animationCache.addAnimation(animation, "Explosion"); +}; + +Explosion.getOrCreateExplosion = function () { + var selChild =null; + for (var j = 0; j < MW.CONTAINER.EXPLOSIONS.length; j++) { + var selChild = MW.CONTAINER.EXPLOSIONS[j]; + if (selChild.active == false) { + selChild.visible = true; + selChild.active = true; + selChild.play(); + return selChild; + } + } + selChild = Explosion.create(); + selChild.play(); + return selChild; +}; +Explosion.create = function () { + var explosion = new Explosion(); + g_sharedGameLayer.addExplosions(explosion); + MW.CONTAINER.EXPLOSIONS.push(explosion); + return explosion; +}; + +Explosion.preSet = function () { + var explosion = null; + for (var i = 0; i < 6; i++) { + explosion = Explosion.create(); + explosion.visible = false; + explosion.active = false; + } +}; diff --git a/samples/js-moonwarriors-runtime/src/GameControlMenu.js b/samples/js-moonwarriors-runtime/src/GameControlMenu.js new file mode 100755 index 0000000000..d350e24803 --- /dev/null +++ b/samples/js-moonwarriors-runtime/src/GameControlMenu.js @@ -0,0 +1,63 @@ +/**************************************************************************** + Cocos2d-html5 show case : Moon Warriors + + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. 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. + + @Authors: + Programmer: Shengxiang Chen (陈升想), Dingping Lv (吕定平), Ricardo Quesada + Effects animation: Hao Wu (吴昊) + Quality Assurance: Sean Lin (林顺) + ****************************************************************************/ + +var GameControlMenu = cc.Layer.extend({ + ctor:function(){ + this._super(); + this.init(); + }, + init:function () { + cc.MenuItemFont.setFontSize(24); + cc.MenuItemFont.setFontName("Arial"); + var systemMenu = new cc.MenuItemFont("Main Menu", this.onSysMenu); + systemMenu.setColor(cc.color(MW.FONTCOLOR)); + var menu = new cc.Menu(systemMenu); + menu.x = 0; + menu.y = 0; + systemMenu.attr({ + x: winSize.width-125, + y: 5, + anchorX: 0, + anchorY: 0 + }); + this.addChild(menu, 1, 2); + + return true; + }, + onSysMenu:function (pSender) { + cc.audioEngine.stopMusic(); + cc.audioEngine.stopAllEffects(); + var scene = new cc.Scene(); + scene.addChild(new SysMenu()); + cc.director.runScene(new cc.TransitionFade(1.2,scene)); + } +}); diff --git a/samples/js-moonwarriors-runtime/src/GameController.js b/samples/js-moonwarriors-runtime/src/GameController.js new file mode 100755 index 0000000000..4d134bc77f --- /dev/null +++ b/samples/js-moonwarriors-runtime/src/GameController.js @@ -0,0 +1,84 @@ +/**************************************************************************** + Cocos2d-html5 show case : Moon Warriors + + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. 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. + + @Authors: + Programmer: Shengxiang Chen (陈升想), Dingping Lv (吕定平), Ricardo Quesada + Effects animation: Hao Wu (吴昊) + Quality Assurance: Sean Lin (林顺) + ****************************************************************************/ + +MW.GameController = cc.Class.extend({ + _curScene:null, + _gameState:MW.GAME_STATE.HOME, + _isNewGame:true, + _curLevel:MW.LEVEL.STAGE1, + _selectLevel:MW.LEVEL.STAGE1, + init:function () { + return true; + }, + setCurScene:function (s) { + if (this._curScene != s) { + if (this._curScene !== null) { + this._curScene.onExit(); + } + this._curScene = s; + if (this._curScene) { + this._curScene.onEnter(); + cc.director.runScene(s); + } + } + }, + getCurScene:function () { + return this._curScene; + }, + runGame:function () { + + }, + newGame:function () { + + }, + option:function () { + + }, + about:function () { + + } +}); + +MW.GameController.getInstance = function () { + cc.assert(this._sharedGame, "Havn't call setSharedGame"); + if (!this._sharedGame) { + this._sharedGame = new MW.GameController(); + if (this._sharedGame.init()) { + return this._sharedGame; + } + } else { + return this._sharedGame; + } + return null; +}; + +MW.GameController._sharedGame = null; diff --git a/samples/js-moonwarriors-runtime/src/GameLayer.js b/samples/js-moonwarriors-runtime/src/GameLayer.js new file mode 100755 index 0000000000..b8067b31a0 --- /dev/null +++ b/samples/js-moonwarriors-runtime/src/GameLayer.js @@ -0,0 +1,402 @@ +/**************************************************************************** + Cocos2d-html5 show case : Moon Warriors + + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. 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. + + @Authors: + Programmer: Shengxiang Chen (陈升想), Dingping Lv (吕定平), Ricardo Quesada + Effects animation: Hao Wu (吴昊) + Quality Assurance: Sean Lin (林顺) + ****************************************************************************/ + +STATE_PLAYING = 0; +STATE_GAMEOVER = 1; +MAX_CONTAINT_WIDTH = 40; +MAX_CONTAINT_HEIGHT = 40; + +var g_sharedGameLayer; + +var GameLayer = cc.Layer.extend({ + _time:null, + _ship:null, + _backSky:null, + _backSkyHeight:0, + _backSkyRe:null, + _levelManager:null, + _tmpScore:0, + _isBackSkyReload:false, + _isBackTileReload:false, + lbScore:null, + screenRect:null, + explosionAnimation:[], + _beginPos:cc.p(0, 0), + _state:STATE_PLAYING, + _explosions:null, + _texOpaqueBatch:null, + _texTransparentBatch:null, + + ctor:function(){ + this._super(); + this.init(); + }, + init:function () { + cc.spriteFrameCache.addSpriteFrames(res.textureOpaquePack_plist); + cc.spriteFrameCache.addSpriteFrames(res.b01_plist); + + // reset global values + MW.CONTAINER.ENEMIES = []; + MW.CONTAINER.ENEMY_BULLETS = []; + MW.CONTAINER.PLAYER_BULLETS = []; + MW.CONTAINER.EXPLOSIONS = []; + MW.CONTAINER.SPARKS = []; + MW.CONTAINER.HITS = []; + MW.CONTAINER.BACKSKYS = []; + MW.CONTAINER.BACKTILEMAPS = []; + MW.ACTIVE_ENEMIES = 0; + + MW.SCORE = 0; + MW.LIFE = 4; + this._state = STATE_PLAYING; + + // OpaqueBatch + var texOpaque = cc.textureCache.addImage(res.textureOpaquePack_png); + this._texOpaqueBatch = new cc.SpriteBatchNode(texOpaque); + this._sparkBatch = new cc.SpriteBatchNode(texOpaque); + if(cc.sys.isNative) this._sparkBatch.setBlendFunc(cc.SRC_ALPHA, cc.ONE); + this.addChild(this._texOpaqueBatch); + this.addChild(this._sparkBatch); + + // TransparentBatch + var texTransparent = cc.textureCache.addImage(res.textureTransparentPack_png); + this._texTransparentBatch = new cc.SpriteBatchNode(texTransparent); + this.addChild(this._texTransparentBatch); + + winSize = cc.director.getWinSize(); + this._levelManager = new LevelManager(this); + + this.screenRect = cc.rect(0, 0, winSize.width, winSize.height + 10); + + // score + this.lbScore = new cc.LabelBMFont("Score: 0", res.arial_14_fnt); + this.lbScore.attr({ + anchorX: 1, + anchorY: 0, + x: winSize.width - 5, + y: winSize.height - 30, + scale: MW.SCALE + }); + this.lbScore.textAlign = cc.TEXT_ALIGNMENT_RIGHT; + this.addChild(this.lbScore, 1000); + + // ship life + var life = new cc.Sprite("#ship03.png"); + life.attr({ + scale: 0.6, + x: 30, + y: MW.HEIGHT - 30 + }); + this._texTransparentBatch.addChild(life, 1, 5); + + // ship Life count + this._lbLife = new cc.LabelTTF("0", "Arial", 20); + this._lbLife.x = 60; + this._lbLife.y = MW.HEIGHT - 25; + this._lbLife.color = cc.color(255, 0, 0); + this.addChild(this._lbLife, 1000); + + // ship + this._ship = new Ship(); + this._texTransparentBatch.addChild(this._ship, this._ship.zOrder, MW.UNIT_TAG.PLAYER); + + // explosion batch node + cc.spriteFrameCache.addSpriteFrames(res.explosion_plist); + var explosionTexture = cc.textureCache.addImage(res.explosion_png); + this._explosions = new cc.SpriteBatchNode(explosionTexture); + this._explosions.setBlendFunc(cc.SRC_ALPHA, cc.ONE); + this.addChild(this._explosions); + Explosion.sharedExplosion(); + + if (cc.sys.capabilities.hasOwnProperty('keyboard')) + cc.eventManager.addListener({ + event: cc.EventListener.KEYBOARD, + onKeyPressed:function (key, event) { + MW.KEYS[key] = true; + }, + onKeyReleased:function (key, event) { + MW.KEYS[key] = false; + } + }, this); + + if ('mouse' in cc.sys.capabilities) + cc.eventManager.addListener({ + event: cc.EventListener.MOUSE, + onMouseMove: function(event){ + if(event.getButton() == cc.EventMouse.BUTTON_LEFT) + event.getCurrentTarget().processEvent(event); + } + }, this); + + if (cc.sys.capabilities.hasOwnProperty('touches')){ + cc.eventManager.addListener({ + prevTouchId: -1, + event: cc.EventListener.TOUCH_ALL_AT_ONCE, + onTouchesMoved:function (touches, event) { + var touch = touches[0]; + if (this.prevTouchId != touch.getID()) + this.prevTouchId = touch.getID(); + else event.getCurrentTarget().processEvent(touches[0]); + } + }, this); + } + + // schedule + this.scheduleUpdate(); + this.schedule(this.scoreCounter, 1); + + if (MW.SOUND) + cc.audioEngine.playMusic(res.bgMusic_mp3, true); + + g_sharedGameLayer = this; + + //pre set + Bullet.preSet(); + Enemy.preSet(); + HitEffect.preSet(); + SparkEffect.preSet(); + Explosion.preSet(); + BackSky.preSet(); + BackTileMap.preSet(); + + this.initBackground(); + + return true; + }, + + scoreCounter:function () { + if (this._state == STATE_PLAYING) { + this._time++; + this._levelManager.loadLevelResource(this._time); + } + }, + + processEvent:function (event) { + if (this._state == STATE_PLAYING) { + var delta = event.getDelta(); + var curPos = cc.p(this._ship.x, this._ship.y); + curPos = cc.pAdd(curPos, delta); + curPos = cc.pClamp(curPos, cc.p(0, 0), cc.p(winSize.width, winSize.height)); + this._ship.x = curPos.x; + this._ship.y = curPos.y; + curPos = null; + } + }, + + update:function (dt) { + if (this._state == STATE_PLAYING) { + this.checkIsCollide(); + this.removeInactiveUnit(dt); + this.checkIsReborn(); + this.updateUI(); + this._movingBackground(dt); + } + }, + checkIsCollide:function () { + var selChild, bulletChild; + // check collide + var i, locShip =this._ship; + for (i = 0; i < MW.CONTAINER.ENEMIES.length; i++) { + selChild = MW.CONTAINER.ENEMIES[i]; + if (!selChild.active) + continue; + + for (var j = 0; j < MW.CONTAINER.PLAYER_BULLETS.length; j++) { + bulletChild = MW.CONTAINER.PLAYER_BULLETS[j]; + if (bulletChild.active && this.collide(selChild, bulletChild)) { + bulletChild.hurt(); + selChild.hurt(); + } + } + if (this.collide(selChild, locShip)) { + if (locShip.active) { + selChild.hurt(); + locShip.hurt(); + } + } + } + + for (i = 0; i < MW.CONTAINER.ENEMY_BULLETS.length; i++) { + selChild = MW.CONTAINER.ENEMY_BULLETS[i]; + if (selChild.active && this.collide(selChild, locShip)) { + if (locShip.active) { + selChild.hurt(); + locShip.hurt(); + } + } + } + }, + removeInactiveUnit:function (dt) { + var i, selChild, children = this._texOpaqueBatch.children; + for (i in children) { + selChild = children[i]; + if (selChild && selChild.active) + selChild.update(dt); + } + + children = this._sparkBatch.children; + for (i in children) { + selChild = children[i]; + if (selChild && selChild.active) + selChild.update(dt); + } + + children = this._texTransparentBatch.children; + for (i in children) { + selChild = children[i]; + if (selChild && selChild.active) + selChild.update(dt); + } + }, + checkIsReborn:function () { + var locShip = this._ship; + if (MW.LIFE > 0 && !locShip.active) { + locShip.born(); + } else if (MW.LIFE <= 0 && !locShip.active) { + this._state = STATE_GAMEOVER; + // XXX: needed for JS bindings. + this._ship = null; + this.runAction(cc.sequence( + cc.delayTime(0.2), + cc.callFunc(this.onGameOver, this) + )); + } + }, + updateUI:function () { + if (this._tmpScore < MW.SCORE) { + this._tmpScore += 1; + } + this._lbLife.setString(MW.LIFE + ''); + this.lbScore.setString("Score: " + this._tmpScore); + }, + collide:function (a, b) { + var ax = a.x, ay = a.y, bx = b.x, by = b.y; + if (Math.abs(ax - bx) > MAX_CONTAINT_WIDTH || Math.abs(ay - by) > MAX_CONTAINT_HEIGHT) + return false; + + var aRect = a.collideRect(ax, ay); + var bRect = b.collideRect(bx, by); + return cc.rectIntersectsRect(aRect, bRect); + }, + initBackground:function () { + this._backSky = BackSky.getOrCreate(); + this._backSkyHeight = this._backSky.height; + + this.moveTileMap(); + this.schedule(this.moveTileMap, 5); + }, + moveTileMap:function () { + var backTileMap = BackTileMap.getOrCreate(); + var ran = Math.random(); + backTileMap.x = ran * 320; + backTileMap.y = winSize.height; + var move = cc.moveBy(ran * 2 + 10, cc.p(0, -winSize.height-backTileMap.height)); + var fun = cc.callFunc(function(){ + backTileMap.destroy(); + },this); + backTileMap.runAction(cc.sequence(move,fun)); + }, + + _movingBackground:function(dt){ + var movingDist = 16 * dt; // background's moving rate is 16 pixel per second + + var locSkyHeight = this._backSkyHeight, locBackSky = this._backSky; + var currPosY = locBackSky.y - movingDist; + var locBackSkyRe = this._backSkyRe; + + if(locSkyHeight + currPosY <= winSize.height){ + if(locBackSkyRe != null) + throw "The memory is leaking at moving background"; + locBackSkyRe = this._backSky; + this._backSkyRe = this._backSky; + + //create a new background + this._backSky = BackSky.getOrCreate(); + locBackSky = this._backSky; + locBackSky.y = currPosY + locSkyHeight - 5; + } else + locBackSky.y = currPosY; + + if(locBackSkyRe){ + //locBackSkyRe + currPosY = locBackSkyRe.y - movingDist; + if(currPosY + locSkyHeight < 0){ + locBackSkyRe.destroy(); + this._backSkyRe = null; + } else + locBackSkyRe.y = currPosY; + } + }, + + onGameOver:function () { + cc.audioEngine.stopMusic(); + cc.audioEngine.stopAllEffects(); + + var self = this; + var cb = function(isSucceed) { + if (isSucceed) { + var scene = new cc.Scene(); + scene.addChild(new GameOver()); + cc.director.runScene(new cc.TransitionFade(1.2, scene)); + } + }; + + cc.LoaderLayer.preload("gameover", cb, self); + } +}); + +GameLayer.scene = function () { + var scene = new cc.Scene(); + var layer = new GameLayer(); + scene.addChild(layer, 1); + return scene; +}; + +GameLayer.prototype.addEnemy = function (enemy, z, tag) { + this._texTransparentBatch.addChild(enemy, z, tag); +}; + +GameLayer.prototype.addExplosions = function (explosion) { + this._explosions.addChild(explosion); +}; + +GameLayer.prototype.addBulletHits = function (hit, zOrder) { + this._texOpaqueBatch.addChild(hit, zOrder); +}; + +GameLayer.prototype.addSpark = function (spark) { + this._sparkBatch.addChild(spark); +}; + +GameLayer.prototype.addBullet = function (bullet, zOrder, mode) { + this._texOpaqueBatch.addChild(bullet, zOrder, mode); +}; diff --git a/samples/js-moonwarriors-runtime/src/GameOver.js b/samples/js-moonwarriors-runtime/src/GameOver.js new file mode 100755 index 0000000000..f4c8a19f8c --- /dev/null +++ b/samples/js-moonwarriors-runtime/src/GameOver.js @@ -0,0 +1,136 @@ +/**************************************************************************** + Cocos2d-html5 show case : Moon Warriors + + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. 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. + + @Authors: + Programmer: Shengxiang Chen (陈升想), Dingping Lv (吕定平), Ricardo Quesada + Effects animation: Hao Wu (吴昊) + Quality Assurance: Sean Lin (林顺) + ****************************************************************************/ + +var GameOver = cc.Layer.extend({ + _ship:null, + _lbScore:0, + + ctor:function(){ + this._super(); + this.init(); + }, + init:function () { + var sp = new cc.Sprite(res.loading_png); + sp.anchorX = 0; + sp.anchorY = 0; + sp.scale = MW.SCALE; + this.addChild(sp, 0, 1); + + var logo = new cc.Sprite(res.gameOver_png); + logo.attr({ + anchorX: 0, + anchorY: 0, + x: 40, + y: 450, + scale: MW.SCALE + }); + this.addChild(logo,10,1); + + var logoBack = new cc.Sprite(res.gameOverBack_png); + logoBack.attr({ + anchorX: 0, + anchorY: 0, + x: 50, + y: logo.y - 30, + scale: MW.SCALE + }); + this.addChild(logoBack, 9); + + var singalHeight = MW.menuHeight; + var singalWidth = MW.menuWidth; + + var playAgainNormal = new cc.Sprite(res.menu_png, cc.rect(singalWidth * 3, 0, singalWidth, singalHeight)); + var playAgainSelected = new cc.Sprite(res.menu_png, cc.rect(singalWidth * 3, singalHeight, singalWidth, singalHeight)); + var playAgainDisabled = new cc.Sprite(res.menu_png, cc.rect(singalWidth * 3, singalHeight * 2, singalWidth, singalHeight)); + + var cocos2dhtml5 = new cc.Sprite(res.cocos2d_html5_png); + cocos2dhtml5.x = 240; + cocos2dhtml5.y = 225; + this.addChild(cocos2dhtml5, 10); + var flare = new cc.Sprite(res.flare_jpg); + this.addChild(flare); + flare.visible = false; + var playAgain = new cc.MenuItemSprite(playAgainNormal, playAgainSelected, playAgainDisabled, function(){ + flareEffect(flare,this,this.onPlayAgain); + }.bind(this) ); + playAgain.scale = MW.SCALE; + + var menu = new cc.Menu(playAgain); + this.addChild(menu, 1, 2); + menu.x = winSize.width / 2; + menu.y = 300; + + var lbScore = new cc.LabelTTF("Your Score:"+MW.SCORE,"Arial Bold",24); + lbScore.x = 240; + lbScore.y = 370; + lbScore.color = cc.color(255,0,0); + this.addChild(lbScore,10); + + var b1 = new cc.LabelTTF("Download Cocos2d-JS","Arial",21); + b1.setColor(cc.color(MW.FONTCOLOR)); + var b2 = new cc.LabelTTF("Github Repository","Arial",21); + b2.setColor(cc.color(MW.FONTCOLOR)); + var menu1 = new cc.MenuItemLabel(b1,function(){ + window.location.href = "http://www.cocos2d-x.org/download"; + }); + var menu2 = new cc.MenuItemLabel(b2,function(){ + window.location.href = "https://github.com/cocos2d/cocos2d-js"; + }); + var cocos2dMenu = new cc.Menu(menu1,menu2); + cocos2dMenu.alignItemsVerticallyWithPadding(10); + cocos2dMenu.x = 240; + cocos2dMenu.y = 120; + this.addChild(cocos2dMenu); + + + if(MW.SOUND){ + cc.audioEngine.playMusic(res.mainMainMusic_mp3, true); + } + + return true; + }, + onPlayAgain:function (pSender) { + cc.audioEngine.stopMusic(); + cc.audioEngine.stopAllEffects(); + var scene = new cc.Scene(); + scene.addChild(new GameLayer()); + scene.addChild(new GameControlMenu()); + cc.director.runScene(new cc.TransitionFade(1.2,scene)); + } +}); + +GameOver.scene = function () { + var scene = new cc.Scene(); + var layer = new GameOver(); + scene.addChild(layer); + return scene; +}; diff --git a/samples/js-moonwarriors-runtime/src/HitEffect.js b/samples/js-moonwarriors-runtime/src/HitEffect.js new file mode 100755 index 0000000000..3e5741cda2 --- /dev/null +++ b/samples/js-moonwarriors-runtime/src/HitEffect.js @@ -0,0 +1,85 @@ +/**************************************************************************** + Cocos2d-html5 show case : Moon Warriors + + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. 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. + + @Authors: + Programmer: Shengxiang Chen (陈升想), Dingping Lv (吕定平), Ricardo Quesada + Effects animation: Hao Wu (吴昊) + Quality Assurance: Sean Lin (林顺) + ****************************************************************************/ + +var HitEffect = cc.Sprite.extend({ + active:true, + ctor:function () { + this._super("#hit.png"); + this.setBlendFunc(cc.SRC_ALPHA, cc.ONE); + }, + reset:function (x, y, rotation, scale) { + this.attr({ + x: x, + y: y, + rotation: rotation, + scale: scale + }); + this.runAction(cc.scaleBy(0.3, 2, 2)); + this.runAction(cc.sequence(cc.fadeOut(0.3), cc.callFunc(this.destroy, this))); + }, + destroy:function () { + this.visible = false; + this.active = false; + } +}); + +HitEffect.getOrCreateHitEffect = function (x, y, rotation, scale) { + var selChild = null; + for (var j = 0; j < MW.CONTAINER.HITS.length; j++) { + selChild = MW.CONTAINER.HITS[j]; + if (selChild.active == false) { + selChild.visible = true; + selChild.active = true; + selChild.reset(x, y, rotation, scale); + return selChild; + } + } + selChild = HitEffect.create(); + selChild.reset(x, y, rotation, scale); + return selChild; +}; + +HitEffect.create = function () { + var hitEffect = new HitEffect(); + g_sharedGameLayer.addBulletHits(hitEffect, 9999); + MW.CONTAINER.HITS.push(hitEffect); + return hitEffect; +}; + +HitEffect.preSet = function () { + var hitEffect = null; + for (var i = 0; i < 10; i++) { + hitEffect = HitEffect.create(); + hitEffect.setVisible(false); + hitEffect.active = false; + } +}; diff --git a/samples/js-moonwarriors-runtime/src/LevelManager.js b/samples/js-moonwarriors-runtime/src/LevelManager.js new file mode 100755 index 0000000000..930d852dcf --- /dev/null +++ b/samples/js-moonwarriors-runtime/src/LevelManager.js @@ -0,0 +1,128 @@ +/**************************************************************************** + Cocos2d-html5 show case : Moon Warriors + + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. 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. + + @Authors: + Programmer: Shengxiang Chen (陈升想), Dingping Lv (吕定平), Ricardo Quesada + Effects animation: Hao Wu (吴昊) + Quality Assurance: Sean Lin (林顺) + ****************************************************************************/ + +var LevelManager = cc.Class.extend({ + _currentLevel:null, + _gameLayer:null, + ctor:function(gameLayer){ + if(!gameLayer){ + throw "gameLayer must be non-nil"; + } + this._currentLevel = Level1; + this._gameLayer = gameLayer; + this.setLevel(this._currentLevel); + }, + + setLevel:function(level){ + var locCurrentLevelEnemies = this._currentLevel.enemies; + for(var i = 0; i< level.enemies.length; i++) + locCurrentLevelEnemies[i].ShowTime = this._minuteToSecond(locCurrentLevelEnemies[i].ShowTime); + }, + _minuteToSecond:function(minuteStr){ + if(!minuteStr) + return 0; + if(typeof(minuteStr) != "number"){ + var mins = minuteStr.split(':'); + if(mins.length == 1){ + return parseInt(mins[0],10); + }else { + return parseInt(mins[0],10 )* 60 + parseInt(mins[1],10); + } + } + return minuteStr; + }, + + loadLevelResource:function(deltaTime){ + if(MW.ACTIVE_ENEMIES>= this._currentLevel.enemyMax){ + return; + } + //load enemy + var locCurrentLevel = this._currentLevel; + for(var i = 0; i< locCurrentLevel.enemies.length; i++){ + var selEnemy = locCurrentLevel.enemies[i]; + if(selEnemy){ + if(selEnemy.ShowType === "Once"){ + if(selEnemy.ShowTime == deltaTime){ + for(var tIndex = 0; tIndex < selEnemy.Types.length;tIndex++ ){ + this.addEnemyToGameLayer(selEnemy.Types[tIndex]); + } + } + }else if(selEnemy.ShowType === "Repeate"){ + if(deltaTime % selEnemy.ShowTime === 0){ + for(var rIndex = 0; rIndex < selEnemy.Types.length;rIndex++ ){ + this.addEnemyToGameLayer(selEnemy.Types[rIndex]); + } + } + } + } + } + }, + + addEnemyToGameLayer:function(enemyType){ + var addEnemy = Enemy.getOrCreateEnemy(EnemyType[enemyType]); + addEnemy.x = 80 + (winSize.width - 160) * Math.random(); + addEnemy.y = winSize.height; + + var offset, tmpAction; + var a0=0; + var a1=0; + switch (addEnemy.moveType) { + case MW.ENEMY_MOVE_TYPE.ATTACK: + offset = cc.p(this._gameLayer._ship.x, this._gameLayer._ship.y); + tmpAction = cc.moveTo(1, offset); + break; + case MW.ENEMY_MOVE_TYPE.VERTICAL: + offset = cc.p(0, -winSize.height - addEnemy.height); + tmpAction = cc.moveBy(4, offset); + break; + case MW.ENEMY_MOVE_TYPE.HORIZONTAL: + offset = cc.p(0, -100 - 200 * Math.random()); + a0 = cc.moveBy(0.5, offset); + a1 = cc.moveBy(1, cc.p(-50 - 100 * Math.random(), 0)); + var onComplete = cc.callFunc(function (pSender) { + var a2 = cc.delayTime(1); + var a3 = cc.moveBy(1, cc.p(100 + 100 * Math.random(), 0)); + pSender.runAction(cc.sequence(a2, a3, a2.clone(), a3.reverse()).repeatForever()); + }.bind(addEnemy) ); + tmpAction = cc.sequence(a0, a1, onComplete); + break; + case MW.ENEMY_MOVE_TYPE.OVERLAP: + var newX = (addEnemy.x <= winSize.width / 2) ? MW.WIDTH : -MW.WIDTH; + a0 = cc.moveBy(4, cc.p(newX, -MW.WIDTH*0.75)); + a1 = cc.moveBy(4, cc.p(-newX,-MW.WIDTH)); + tmpAction = cc.sequence(a0,a1); + break; + } + + addEnemy.runAction(tmpAction); + } +}); diff --git a/samples/js-moonwarriors-runtime/src/Resource.js b/samples/js-moonwarriors-runtime/src/Resource.js new file mode 100755 index 0000000000..2f0fa2631c --- /dev/null +++ b/samples/js-moonwarriors-runtime/src/Resource.js @@ -0,0 +1,159 @@ +/**************************************************************************** + Cocos2d-html5 show case : Moon Warriors + + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. 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. + + @Authors: + Programmer: Shengxiang Chen (陈升想), Dingping Lv (吕定平), Ricardo Quesada + Effects animation: Hao Wu (吴昊) + Quality Assurance: Sean Lin (林顺) + ****************************************************************************/ + +var res = { + bgMusic_mp3 : 'res/Music/bgMusic.mp3', + bgMusic_ogg : 'res/Music/bgMusic.ogg', + buttonEffet_mp3 : 'res/Music/buttonEffet.mp3', + buttonEffet_ogg : 'res/Music/buttonEffet.ogg', + explodeEffect_mp3 : 'res/Music/explodeEffect.mp3', + explodeEffect_ogg : 'res/Music/explodeEffect.ogg', + fireEffect_mp3 : 'res/Music/fireEffect.mp3', //unused + fireEffect_ogg : 'res/Music/fireEffect.ogg', //unused + mainMainMusic_mp3 : 'res/Music/mainMainMusic.mp3', + mainMainMusic_ogg : 'res/Music/mainMainMusic.ogg', + shipDestroyEffect_mp3 : 'res/Music/shipDestroyEffect.mp3', + shipDestroyEffect_ogg : 'res/Music/shipDestroyEffect.ogg', + arial_14_fnt : 'res/arial-14.fnt', + arial_14_png : 'res/arial-14.png', + b01_plist : 'res/b01.plist', + b01_png : 'res/b01.png', + cocos2d_html5_png : 'res/cocos2d-html5.png', + explode_plist : 'res/explode.plist', //unused + explosion_plist : 'res/explosion.plist', + explosion_png : 'res/explosion.png', + flare_jpg : 'res/flare.jpg', + gameOver_png : 'res/gameOver.png', + gameOverBack_png : 'res/gameoverBack.png', + level01_tmx : 'res/level01.tmx', + loading_png : 'res/loading.png', + logo_png : 'res/logo.png', + logoBack_png : 'res/logoBack.png', + menu_png : 'res/menu.png', + menuTitle_png : 'res/menuTitle.png', + textureOpaquePack_plist : 'res/textureOpaquePack.plist', + textureOpaquePack_png : 'res/textureOpaquePack.png', + textureTransparentPack_plist : 'res/textureTransparentPack.plist', + textureTransparentPack_png : 'res/textureTransparentPack.png', + + //loading + glow_png:'res_engine/progress_light.png', + preload_logo_png:'res_engine/preload_logo.png', + preload_title_png:'res_engine/preload_title.png', + preload_bg_jpg:'res_engine/preload_bg.jpg', + progress_bar_png:'res_engine/progress_bar.png', + progress_bg_png:'res_engine/progress_bg.png', + progress_shadow_png:'res_engine/progress_shadow.png', + dialog_bg_png:"res_engine/dialog_bg.png", + dialog_cancel_normal_png:"res_engine/dialog_cancel_normal.png", + dialog_cancel_press_png:"res_engine/dialog_cancel_press.png", + dialog_confirm_normal_png:"res_engine/dialog_confirm_normal.png", + dialog_confirm_press_png:"res_engine/dialog_confirm_press.png", + + //for test + network_dialog_bg_png:"res/dialog_bg.png", + network_dialog_cancel_normal_png:"res/dialog_cancel_normal.png", + network_dialog_cancel_press_png:"res/dialog_cancel_press.png", + network_dialog_confirm_normal_png:"res/dialog_confirm_normal.png", + network_dialog_confirm_press_png:"res/dialog_confirm_press.png" +}; + +window["boot"] = [ + res.loading_png, + res.flare_jpg, + res.menu_png, + res.logo_png, + res.logoBack_png, + res.mainMainMusic_mp3, + res.mainMainMusic_ogg, + res.textureTransparentPack_plist, + res.textureTransparentPack_png, + res.glow_png, + res.preload_logo_png, + res.preload_bg_jpg, + res.progress_bar_png, + res.progress_bg_png, + res.progress_shadow_png, + res.dialog_bg_png, + res.dialog_cancel_normal_png, + res.dialog_cancel_press_png, + res.dialog_confirm_normal_png, + res.dialog_confirm_press_png, + res.network_dialog_bg_png, + res.network_dialog_cancel_normal_png, + res.network_dialog_cancel_press_png, + res.network_dialog_confirm_normal_png, + res.network_dialog_confirm_press_png +]; + +window["gamelayer"] = [ + //image + res.b01_png, + res.b01_plist, + res.arial_14_png, + res.explosion_png, + res.textureOpaquePack_png, + + //tmx + //res.level01_tmx, + + //plist + res.explosion_plist, + res.textureOpaquePack_plist, + + //music + res.bgMusic_mp3, + res.bgMusic_ogg, + + //effect + res.buttonEffet_mp3, + res.explodeEffect_mp3, + res.fireEffect_mp3, + res.shipDestroyEffect_mp3, + res.buttonEffet_ogg, + res.explodeEffect_ogg, + res.fireEffect_ogg, + res.shipDestroyEffect_ogg, + + // FNT + res.arial_14_fnt +]; + +window["common"] = [ + res.menuTitle_png +]; + +window["gameover"] = [ + res.cocos2d_html5_png, + res.gameOverBack_png, + res.gameOver_png +]; diff --git a/samples/js-moonwarriors-runtime/src/SettingsLayer.js b/samples/js-moonwarriors-runtime/src/SettingsLayer.js new file mode 100755 index 0000000000..2a1bafe90c --- /dev/null +++ b/samples/js-moonwarriors-runtime/src/SettingsLayer.js @@ -0,0 +1,116 @@ +/**************************************************************************** + Cocos2d-html5 show case : Moon Warriors + + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. 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. + + @Authors: + Programmer: Shengxiang Chen (陈升想), Dingping Lv (吕定平), Ricardo Quesada + Effects animation: Hao Wu (吴昊) + Quality Assurance: Sean Lin (林顺) + ****************************************************************************/ + +var SettingsLayer = cc.Layer.extend({ + ctor:function(){ + this._super(); + this.init(); + }, + init:function () { + var sp = new cc.Sprite(res.loading_png); + sp.anchorX = 0; + sp.anchorY = 0; + sp.scale = MW.SCALE; + this.addChild(sp, 0, 1); + + var cacheImage = cc.textureCache.addImage(res.menuTitle_png); + var title = new cc.Sprite(cacheImage, cc.rect(0, 0, 134, 39)); + title.x = winSize.width / 2; + title.y = winSize.height - 120; + this.addChild(title); + + + cc.MenuItemFont.setFontName("Arial"); + cc.MenuItemFont.setFontSize(18); + var title1 = new cc.MenuItemFont("Sound"); + title1.setEnabled(false); + title1.setColor(cc.color(MW.FONTCOLOR)); + + cc.MenuItemFont.setFontName("Arial"); + cc.MenuItemFont.setFontSize(26); + var item1 = new cc.MenuItemToggle( + new cc.MenuItemFont("On"),new cc.MenuItemFont("Off")); + item1.setCallback(this.onSoundControl ); + item1.setColor(cc.color(MW.FONTCOLOR)); + var state = MW.SOUND ? 0 : 1; + item1.setSelectedIndex(state); + + cc.MenuItemFont.setFontName("Arial"); + cc.MenuItemFont.setFontSize(18); + var title2 = new cc.MenuItemFont("Mode"); + title2.setEnabled(false); + title2.setColor(cc.color(MW.FONTCOLOR)); + + cc.MenuItemFont.setFontName("Arial"); + cc.MenuItemFont.setFontSize(26); + var item2 = new cc.MenuItemToggle( + new cc.MenuItemFont("Easy"), + new cc.MenuItemFont("Normal"), + new cc.MenuItemFont("Hard")); + item2.setColor(cc.color(MW.FONTCOLOR)); + item2.setCallback( this.onModeControl ); + + + cc.MenuItemFont.setFontName("Arial"); + cc.MenuItemFont.setFontSize(26); + var label = new cc.LabelTTF("Go back", "Arial", 20); + label.setColor(cc.color(MW.FONTCOLOR)); + var back = new cc.MenuItemLabel(label, this.onBackCallback); + back.scale = 0.8; + + var menu = new cc.Menu(title1, title2, item1, item2, back); + menu.alignItemsInColumns(2, 2, 1); + this.addChild(menu); + + back.y -= 50; + + return true; + }, + onBackCallback:function (pSender) { + var scene = new cc.Scene(); + scene.addChild(new SysMenu()); + cc.director.runScene(new cc.TransitionFade(1.2, scene)); + }, + onSoundControl:function(){ + MW.SOUND = !MW.SOUND; + var audioEngine = cc.audioEngine; + if(MW.SOUND){ + audioEngine.playMusic(res.mainMainMusic_mp3); + } + else{ + audioEngine.stopMusic(); + audioEngine.stopAllEffects(); + } + }, + onModeControl:function(){ + } +}); diff --git a/samples/js-moonwarriors-runtime/src/Ship.js b/samples/js-moonwarriors-runtime/src/Ship.js new file mode 100755 index 0000000000..76a7bbf078 --- /dev/null +++ b/samples/js-moonwarriors-runtime/src/Ship.js @@ -0,0 +1,157 @@ +/**************************************************************************** + Cocos2d-html5 show case : Moon Warriors + + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. 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. + + @Authors: + Programmer: Shengxiang Chen (陈升想), Dingping Lv (吕定平), Ricardo Quesada + Effects animation: Hao Wu (吴昊) + Quality Assurance: Sean Lin (林顺) + ****************************************************************************/ + +var Ship = cc.Sprite.extend({ + speed:220, + bulletSpeed:MW.BULLET_SPEED.SHIP, + HP:5, + bulletTypeValue:1, + bulletPowerValue:1, + throwBombing:false, + canBeAttack:true, + isThrowingBomb:false, + zOrder:3000, + maxBulletPowerValue:4, + appearPosition:cc.p(160, 60), + _hurtColorLife:0, + active:true, + bornSprite:null, + ctor:function () { + this._super("#ship01.png"); + this.tag = this.zOrder; + this.x = this.appearPosition.x; + this.y = this.appearPosition.y; + + // set frame + //var frame2 = cc.spriteFrameCache.getSpriteFrame("ship03.png"); + var frame0 = cc.spriteFrameCache.getSpriteFrame("ship01.png"); + var frame1 = cc.spriteFrameCache.getSpriteFrame("ship02.png"); + + var animFrames = []; + //animFrames.push(frame2); + animFrames.push(frame0); + animFrames.push(frame1); + + // ship animate + var animation = new cc.Animation(animFrames, 0.1); + var animate = cc.animate(animation); + this.runAction(animate.repeatForever()); + this.schedule(this.shoot, 1 / 6); + + this.initBornSprite(); + this.born(); + }, + update:function (dt) { + if ((MW.KEYS[cc.KEY.w] || MW.KEYS[cc.KEY.up]) && this.y <= winSize.height) { + this.y += dt * this.speed; + } + if ((MW.KEYS[cc.KEY.s] || MW.KEYS[cc.KEY.down]) && this.y >= 0) { + this.y -= dt * this.speed; + } + if ((MW.KEYS[cc.KEY.a] || MW.KEYS[cc.KEY.left]) && this.x >= 0) { + this.x -= dt * this.speed; + } + if ((MW.KEYS[cc.KEY.d] || MW.KEYS[cc.KEY.right]) && this.x <= winSize.width) { + this.x += dt * this.speed; + } + + if (this.HP <= 0) { + this.active = false; + this.destroy(); + } + this._timeTick += dt; + if (this._timeTick > 0.1) { + this._timeTick = 0; + if (this._hurtColorLife > 0) { + this._hurtColorLife--; + } + } + }, + shoot:function (dt) { + //this.shootEffect(); + var offset = 27; + var a = Bullet.getOrCreateBullet(this.bulletSpeed, "W1.png", MW.ENEMY_ATTACK_MODE.NORMAL, 3000, MW.UNIT_TAG.PLAYER_BULLET); + a.x = this.x + offset; + a.y = this.y + 3 + this.height * 0.3; + + var b = Bullet.getOrCreateBullet(this.bulletSpeed, "W1.png", MW.ENEMY_ATTACK_MODE.NORMAL, 3000, MW.UNIT_TAG.PLAYER_BULLET); + b.x = this.x - offset; + b.y = this.y + 3 + this.height * 0.3; + }, + destroy:function () { + MW.LIFE--; + + var explosion = Explosion.getOrCreateExplosion(); + explosion.x = this.x; + explosion.y = this.y; + + if (MW.SOUND) { + cc.audioEngine.playEffect(res.shipDestroyEffect_mp3); + } + }, + hurt:function () { + if (this.canBeAttack) { + this._hurtColorLife = 2; + this.HP--; + } + }, + collideRect:function (x, y) { + var w = this.width, h = this.height; + return cc.rect(x - w / 2, y - h / 2, w, h / 2); + }, + initBornSprite:function () { + this.bornSprite = new cc.Sprite("#ship03.png"); + this.bornSprite.setBlendFunc(cc.SRC_ALPHA, cc.ONE); + this.bornSprite.x = this.width / 2; + this.bornSprite.y = this.height / 2; + this.bornSprite.visible = false; + this.addChild(this.bornSprite, 3000, 99999); + }, + born:function () { + //revive effect + this.canBeAttack = false; + this.bornSprite.scale = 8; + this.bornSprite.runAction(cc.scaleTo(0.5, 1, 1)); + this.bornSprite.visible = true; + var blinks = cc.blink(3, 9); + var makeBeAttack = cc.callFunc(function (t) { + t.canBeAttack = true; + t.visible = true; + t.bornSprite.visible = false; + }.bind(this)); + this.runAction(cc.sequence(cc.delayTime(0.5), blinks, makeBeAttack)); + + this.HP = 5; + this._hurtColorLife = 0; + this.active = true; + } +}); diff --git a/samples/js-moonwarriors-runtime/src/SparkEffect.js b/samples/js-moonwarriors-runtime/src/SparkEffect.js new file mode 100755 index 0000000000..1bae9b77fe --- /dev/null +++ b/samples/js-moonwarriors-runtime/src/SparkEffect.js @@ -0,0 +1,111 @@ +/**************************************************************************** + Cocos2d-html5 show case : Moon Warriors + + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. 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. + + @Authors: + Programmer: Shengxiang Chen (陈升想), Dingping Lv (吕定平), Ricardo Quesada + Effects animation: Hao Wu (吴昊) + Quality Assurance: Sean Lin (林顺) + ****************************************************************************/ + +var SparkEffect = cc.Class.extend({ + active:true, + spark1:null, + spark2:null, + scale:1.2, + duration:0.7, + ctor:function () { + this.spark1 = new cc.Sprite("#explode2.png"); + //this.spark1.setBlendFunc(cc.SRC_ALPHA, cc.ONE); + this.spark2 = new cc.Sprite("#explode3.png"); + //this.spark2.setBlendFunc(cc.SRC_ALPHA, cc.ONE); + }, + reset:function (x, y) { + this.spark1.attr({ + x: x, + y: y, + scale: this.scale, + opacity: 255 + }); + this.spark2.attr({ + x: x, + y: y, + scale: this.scale, + rotation: Math.random() * 360, + opacity: 255 + }); + + var right = cc.rotateBy(this.duration, 45); + var scaleBy = cc.scaleBy(this.duration, 3, 3); + var seq = cc.sequence(cc.fadeOut(this.duration), cc.callFunc(this.destroy, this)); + + this.spark1.runAction(right); + this.spark1.runAction(scaleBy); + this.spark1.runAction(seq); + + this.spark2.runAction(scaleBy.clone()); + this.spark2.runAction(seq.clone()); + }, + destroy:function () { + this.active = false; + this.spark1.visible = false; + this.spark2.visible = false; + } +}); + +SparkEffect.getOrCreateSparkEffect = function (x, y) { + var selChild = null; + for (var j = 0; j < MW.CONTAINER.SPARKS.length; j++) { + selChild = MW.CONTAINER.SPARKS[j]; + if (selChild.active == false) { + selChild.active = true; + selChild.spark1.setVisible(true); + selChild.spark2.setVisible(true); + selChild.reset(x, y); + return selChild; + } + } + var spark = SparkEffect.create(); + spark.reset(x, y); + return spark; +}; + +SparkEffect.create = function () { + var sparkEffect = new SparkEffect(); + g_sharedGameLayer.addSpark(sparkEffect.spark1); + g_sharedGameLayer.addSpark(sparkEffect.spark2); + MW.CONTAINER.SPARKS.push(sparkEffect); + return sparkEffect; +}; + +SparkEffect.preSet = function () { + var sparkEffect = null; + for (var i = 0; i < 6; i++) { + sparkEffect = SparkEffect.create(); + sparkEffect.active = false; + sparkEffect.spark1.visible = false; + sparkEffect.spark2.visible = false; + } +}; diff --git a/samples/js-moonwarriors-runtime/src/SysMenu.js b/samples/js-moonwarriors-runtime/src/SysMenu.js new file mode 100755 index 0000000000..96fb487edc --- /dev/null +++ b/samples/js-moonwarriors-runtime/src/SysMenu.js @@ -0,0 +1,306 @@ +/**************************************************************************** + Cocos2d-html5 show case : Moon Warriors + + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. 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. + + @Authors: + Programmer: Shengxiang Chen (陈升想), Dingping Lv (吕定平), Ricardo Quesada + Effects animation: Hao Wu (吴昊) + Quality Assurance: Sean Lin (林顺) + ****************************************************************************/ + +var SysMenu = cc.Layer.extend({ + _ship:null, + + ctor:function () { + this._super(); + this.init(); + }, + init:function () { + if (cc.sys.isNative) { + var writablePath = jsb.fileUtils.getWritablePath(); + cc.log("writablePath: " + writablePath); + var obj = { + server_url: "http://192.168.0.1", + version_code: 100 + }; + jsb.fileUtils.writeToFile(obj, writablePath + "/hello_writable.json"); + } + + cc.spriteFrameCache.addSpriteFrames(res.textureTransparentPack_plist); + + winSize = cc.director.getWinSize(); + var sp = new cc.Sprite(res.loading_png); + sp.anchorX = 0; + sp.anchorY = 0; + sp.scale = MW.SCALE; + this.addChild(sp, 0, 1); + + var logo = new cc.Sprite(res.logo_png); + logo.attr({ + anchorX: 0, + anchorY: 0, + x: 0, + y: MW.LOGOY, + scale: MW.SCALE + }); + this.addChild(logo, 10, 1); + + var logoBack = new cc.Sprite(res.logoBack_png); + logoBack.attr({ + anchorX: 0, + anchorY: 0, + x: 60, + y: MW.LOGOY + logo.height, + scale: MW.SCALE + }); + this.addChild(logoBack, 9); + + var singalHeight = MW.menuHeight; + var singalWidth = MW.menuWidth; + var newGameNormal = new cc.Sprite(res.menu_png, cc.rect(0, 0, singalWidth, singalHeight)); + var newGameSelected = new cc.Sprite(res.menu_png, cc.rect(0, singalHeight, singalWidth, singalHeight)); + var newGameDisabled = new cc.Sprite(res.menu_png, cc.rect(0, singalHeight * 2, singalWidth, singalHeight)); + + var gameSettingsNormal = new cc.Sprite(res.menu_png, cc.rect(singalWidth, 0, singalWidth, singalHeight)); + var gameSettingsSelected = new cc.Sprite(res.menu_png, cc.rect(singalWidth, singalHeight, singalWidth, singalHeight)); + var gameSettingsDisabled = new cc.Sprite(res.menu_png, cc.rect(singalWidth, singalHeight * 2, singalWidth, singalHeight)); + + var aboutNormal = new cc.Sprite(res.menu_png, cc.rect(singalWidth * 2, 0, singalWidth, singalHeight)); + var aboutSelected = new cc.Sprite(res.menu_png, cc.rect(singalWidth * 2, singalHeight, singalWidth, singalHeight)); + var aboutDisabled = new cc.Sprite(res.menu_png, cc.rect(singalWidth * 2, singalHeight * 2, singalWidth, singalHeight)); + var flare = new cc.Sprite(res.flare_jpg); + this.addChild(flare, 15, 10); + flare.visible = false; + var newGame = new cc.MenuItemSprite(newGameNormal, newGameSelected, newGameDisabled, function () { + this.onButtonEffect(); + //this.onNewGame(); + flareEffect(flare, this, this.onNewGame); + }.bind(this)); + var gameSettings = new cc.MenuItemSprite(gameSettingsNormal, gameSettingsSelected, gameSettingsDisabled, this.onSettings, this); + var about = new cc.MenuItemSprite(aboutNormal, aboutSelected, aboutDisabled, this.onAbout, this); + newGame.scale = MW.SCALE; + gameSettings.scale = MW.SCALE; + about.scale = MW.SCALE; + + // make crash Item + var makeCrash = new cc.MenuItemFont("Make a crash", function(sender) { + var sprite = new cc.Sprite("fileNotExist.png"); + sprite.release(); + this.addChild(sprite); + }, this); + + makeCrash.fontSize = 21; + makeCrash.fontName = "Arial"; + makeCrash.color = cc.color(MW.FONTCOLOR) + + var menu = new cc.Menu(newGame, gameSettings, about, makeCrash); + menu.alignItemsVerticallyWithPadding(15); + this.addChild(menu, 1, 2); + menu.x = winSize.width / 2; + menu.y = winSize.height / 2 - 140; + + var label = new cc.LabelTTF("Power by Cocos2d-JS", "Arial", 21); + label.setColor(cc.color(MW.FONTCOLOR)); + this.addChild(label, 1); + label.x = winSize.width / 2; + label.y = 80; + + this.schedule(this.update, 0.1); + + this._ship = new cc.Sprite("#ship03.png"); + this.addChild(this._ship, 0, 4); + this._ship.x = Math.random() * winSize.width; + this._ship.y = 0; + this._ship.runAction(cc.moveBy(2, cc.p(Math.random() * winSize.width, this._ship.y + winSize.height + 100))); + + // game version + var versionLabel = new cc.LabelTTF("version:3.0.0", "Marker Felt", 20); + this.addChild(versionLabel, 1, 2); + versionLabel.x = winSize.width - 80; + versionLabel.y = winSize.height - 20; + + if (MW.SOUND) { + cc.audioEngine.setMusicVolume(0.7); + cc.audioEngine.playMusic(res.mainMainMusic_mp3, true); + } + cc.runtime.setOption("network_error_dialog", { + background: { + res: "res/dialog_bg.png" + }, + confirmBtn:{ + normalRes:"res/dialog_confirm_normal.png", + pressRes:"res/dialog_confirm_press.png", + text:"", + position:cc.p(225,25) + }, + cancelBtn:{ + normalRes:"res/dialog_cancel_normal.png", + pressRes:"res/dialog_cancel_press.png", + text:"", + position:cc.p(75,25) + }, + messageLabel:{ + text:"网络连接错误哈~~~", + position:cc.p(175,30), + dimisions:cc.size(200,15), + fontSize:20 + } + }); + + cc.runtime.setOption("no_space_error_dialog", { + background: { + res: "res/dialog_bg.png" + }, + confirmBtn:{ + normalRes:"res/dialog_confirm_normal.png", + pressRes:"res/dialog_confirm_press.png", + text:"", + position:cc.p(225,25) + }, + cancelBtn:{ + normalRes:"res/dialog_cancel_normal.png", + pressRes:"res/dialog_cancel_press.png", + text:"", + position:cc.p(75,25) + }, + messageLabel:{ + text:"没有空间了额~~~", + position:cc.p(175,30), + dimisions:cc.size(200,15), + fontSize:20 + } + }); + cc.runtime.setOption("verify_error_dialog", { + messageLabel:{ + text:"验证失败了额~~~", + position:cc.p(175,30), + dimisions:cc.size(200,15), + fontSize:20 + } + }); + return true; + }, + onNewGame:function (pSender) { + //load resources + var self = this; + var cb = function(isSucceed) { + cc.log("onNewGame callback: " + isSucceed); + cc.audioEngine.stopMusic(); + cc.audioEngine.stopAllEffects(); + var scene = new cc.Scene(); + scene.addChild(new GameLayer()); + scene.addChild(new GameControlMenu()); + cc.director.runScene(new cc.TransitionFade(1.2, scene)); + }; + cc.LoaderLayer.preload(["gamelayer"], cb, self); + }, + onSettings:function (pSender) { + this.onButtonEffect(); + var self = this; + var cb = function(isSucceed) { + var scene = new cc.Scene(); + scene.addChild(new SettingsLayer()); + cc.director.runScene(new cc.TransitionFade(1.2, scene)); + }; + cc.LoaderLayer.preload("common", cb, self); + }, + onAbout:function (pSender) { + this.onButtonEffect(); + var self = this; + var cb = function(isSucceed) { + var scene = new cc.Scene(); + scene.addChild(new AboutLayer()); + cc.director.runScene(new cc.TransitionFade(1.2, scene)); + }; + cc.LoaderLayer.preload("common", cb, self); + }, + update:function () { + if (this._ship.y > 750) { + this._ship.x = Math.random() * winSize.width; + this._ship.y = 10; + this._ship.runAction(cc.moveBy( + parseInt(5 * Math.random(), 10), + cc.p(Math.random() * winSize.width, this._ship.y + 750) + )); + } + }, + onButtonEffect:function(){ + if (MW.SOUND) { + var s = cc.audioEngine.playEffect(res.buttonEffet_mp3); + } + } +}); + +SysMenu.scene = function () { + var scene = new cc.Scene(); + var layer = new SysMenu(); + scene.addChild(layer); + return scene; +}; + +var getNativeKeyName = function(keyCode) { + var allCode = Object.getOwnPropertyNames(cc.KEY); + var keyName = ""; + for(var x in allCode){ + if(cc.KEY[allCode[x]] == keyCode){ + keyName = allCode[x]; + break; + } + } + return keyName; +}; + +var registerKeyEvent = function() { + cc.eventManager.addListener(cc.EventListener.create({ + event: cc.EventListener.KEYBOARD, + onKeyReleased: function(keyCode, event){ + cc.log("Key " + (cc.sys.isNative ? getNativeKeyName(keyCode) : String.fromCharCode(keyCode) ) + "(" + keyCode.toString() + ") was released!"); + if (keyCode == cc.KEY.back) { + if (cc.sys.isNative) { + var conf = { + messageLabel: { + text: "确定退出游戏吗?" + }, + confirmBtn:{ + callback: function () { + cc.director.end(); + } + }, + cancelBtn:{ + callback: function () { + cc.log("取消退出游戏"); + } + } + } + cc.Dialog.show(conf); + } + } + } + }), -1); +}; +registerKeyEvent(); + + + diff --git a/samples/js-moonwarriors-runtime/src/config/EnemyType.js b/samples/js-moonwarriors-runtime/src/config/EnemyType.js new file mode 100755 index 0000000000..914616ce99 --- /dev/null +++ b/samples/js-moonwarriors-runtime/src/config/EnemyType.js @@ -0,0 +1,88 @@ +/**************************************************************************** + Cocos2d-html5 show case : Moon Warriors + + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. 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. + + @Authors: + Programmer: Shengxiang Chen (陈升想), Dingping Lv (吕定平), Ricardo Quesada + Effects animation: Hao Wu (吴昊) + Quality Assurance: Sean Lin (林顺) + ****************************************************************************/ + +var EnemyType = [ + { + type:0, + textureName:"E0.png", + bulletType:"W2.png", + HP:1, + moveType:MW.ENEMY_MOVE_TYPE.ATTACK, + attackMode:MW.ENEMY_MOVE_TYPE.NORMAL, + scoreValue:15 + }, + { + type:1, + textureName:"E1.png", + bulletType:"W2.png", + HP:2, + moveType:MW.ENEMY_MOVE_TYPE.ATTACK, + attackMode:MW.ENEMY_MOVE_TYPE.NORMAL, + scoreValue:40 + }, + { + type:2, + textureName:"E2.png", + bulletType:"W2.png", + HP:4, + moveType:MW.ENEMY_MOVE_TYPE.HORIZONTAL, + attackMode:MW.ENEMY_ATTACK_MODE.TSUIHIKIDAN, + scoreValue:60 + }, + { + type:3, + textureName:"E3.png", + bulletType:"W2.png", + HP:6, + moveType:MW.ENEMY_MOVE_TYPE.OVERLAP, + attackMode:MW.ENEMY_MOVE_TYPE.NORMAL, + scoreValue:80 + }, + { + type:4, + textureName:"E4.png", + bulletType:"W2.png", + HP:10, + moveType:MW.ENEMY_MOVE_TYPE.HORIZONTAL, + attackMode:MW.ENEMY_ATTACK_MODE.TSUIHIKIDAN, + scoreValue:150 + }, + { + type:5, + textureName:"E5.png", + bulletType:"W2.png", + HP:15, + moveType:MW.ENEMY_MOVE_TYPE.HORIZONTAL, + attackMode:MW.ENEMY_MOVE_TYPE.NORMAL, + scoreValue:200 + } +]; diff --git a/samples/js-moonwarriors-runtime/src/config/GameConfig.js b/samples/js-moonwarriors-runtime/src/config/GameConfig.js new file mode 100755 index 0000000000..0a0e29ae62 --- /dev/null +++ b/samples/js-moonwarriors-runtime/src/config/GameConfig.js @@ -0,0 +1,133 @@ +/**************************************************************************** + Cocos2d-html5 show case : Moon Warriors + + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. 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. + + @Authors: + Programmer: Shengxiang Chen (陈升想), Dingping Lv (吕定平), Ricardo Quesada + Effects animation: Hao Wu (吴昊) + Quality Assurance: Sean Lin (林顺) + ****************************************************************************/ + +var MW = MW || {}; + +//game state +MW.GAME_STATE = { + HOME:0, + PLAY:1, + OVER:2 +}; + +//keys +MW.KEYS = []; + +//level +MW.LEVEL = { + STAGE1:1, + STAGE2:2, + STAGE3:3 +}; + +//life +MW.LIFE = 4; + +//score +MW.SCORE = 0; + +//sound +MW.SOUND = true; + +//enemy move type +MW.ENEMY_MOVE_TYPE = { + ATTACK:0, + VERTICAL:1, + HORIZONTAL:2, + OVERLAP:3 +}; + +//delta x +MW.DELTA_X = -100; + +//offset x +MW.OFFSET_X = -24; + +//rot +MW.ROT = -5.625; + +//bullet type +MW.BULLET_TYPE = { + PLAYER:1, + ENEMY:2 +}; + +//weapon type +MW.WEAPON_TYPE = { + ONE:1 +}; + +//unit tag +MW.UNIT_TAG = { + ENMEY_BULLET:900, + PLAYER_BULLET:901, + ENEMY:1000, + PLAYER:1000 +}; + +//attack mode +MW.ENEMY_ATTACK_MODE = { + NORMAL:1, + TSUIHIKIDAN:2 +}; + +//life up sorce +MW.LIFEUP_SORCE = [50000, 100000, 150000, 200000, 250000, 300000]; + +//container +MW.CONTAINER = { + ENEMIES:[], + ENEMY_BULLETS:[], + PLAYER_BULLETS:[], + EXPLOSIONS:[], + SPARKS:[], + HITS:[], + BACKSKYS:[], + BACKTILEMAPS:[] +}; + +//bullet speed +MW.BULLET_SPEED = { + ENEMY:-200, + SHIP:900 +}; +// the counter of active enemies +MW.ACTIVE_ENEMIES = 0; + +MW.LOGOY = 350; +MW.FLAREY = 445; +MW.SCALE = 1.5; +MW.WIDTH = 480; +MW.HEIGHT = 720; +MW.FONTCOLOR = "#1f2d96"; +MW.menuHeight = 36; +MW.menuWidth = 123; \ No newline at end of file diff --git a/samples/js-moonwarriors-runtime/src/config/Level.js b/samples/js-moonwarriors-runtime/src/config/Level.js new file mode 100755 index 0000000000..d036113deb --- /dev/null +++ b/samples/js-moonwarriors-runtime/src/config/Level.js @@ -0,0 +1,82 @@ +/**************************************************************************** + Cocos2d-html5 show case : Moon Warriors + + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. 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. + + @Authors: + Programmer: Shengxiang Chen (陈升想), Dingping Lv (吕定平), Ricardo Quesada + Effects animation: Hao Wu (吴昊) + Quality Assurance: Sean Lin (林顺) + ****************************************************************************/ + +var Level1 = { + enemyMax:6, + enemies:[ + { + ShowType:"Repeate", + ShowTime:"00:02", + Types:[0,1,2] + }, + { + ShowType:"Repeate", + ShowTime:"00:05", + Types:[3,4,5] + } + /*{ + ShowType:"Repeate", + ShowTime:"00:08", + Types:[0,4,3,5] + }, + { + ShowType:"Once", + ShowTime:"00:6", + Types:[0,2,4,3] + }, + { + ShowType:"Once", + ShowTime:"00:16", + Types:[0,2,5,4,3] + }, + { + ShowType:"Once", + ShowTime:"00:25", + Types:[0,3,5,4,3] + }, + { + ShowType:"Once", + ShowTime:"00:35", + Types:[4,5,3,1,3] + }, + { + ShowType:"Once", + ShowTime:"00:50", + Types:[0,3,2,1,0,3] + }, + { + ShowType:"Once", + ShowTime:"01:15", + Types:[4,5,2,1,0] + }*/ + ] +};