Skip to content

Commit 8d1c206

Browse files
committed
Merge branch 'master' of cocos2d-js-test into Iss2294_MigrateActionClasses
Conflicts: games/MoonWarriors/src/SparkEffect.js tests/SpriteTest/SpriteTest.js
2 parents 6f7413c + ec0a790 commit 8d1c206

File tree

528 files changed

+20081
-521
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

528 files changed

+20081
-521
lines changed

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
.DS_Store
22
.idea/
3-
Published*/

games/CocosDragonJS/CocosDragonJS.ccbproj

+7-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
<true/>
2525
<key>javascriptMainCCB</key>
2626
<string>MainMenuScene</string>
27+
<key>needRepublish</key>
28+
<false/>
2729
<key>onlyPublishCCBs</key>
2830
<false/>
2931
<key>publishDirectory</key>
@@ -55,7 +57,7 @@
5557
<key>publishResolution_large</key>
5658
<true/>
5759
<key>publishResolution_medium</key>
58-
<false/>
60+
<true/>
5961
<key>publishResolution_small</key>
6062
<true/>
6163
<key>publishResolution_xlarge</key>
@@ -85,5 +87,9 @@
8587
<string>Source/sounds</string>
8688
</dict>
8789
</array>
90+
<key>versionStr</key>
91+
<string>Version: 3.0-alpha5
92+
GitHub: 76499877e8
93+
</string>
8894
</dict>
8995
</plist>
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/* http://www.cocosbuilder.com
2+
* http://www.cocos2d-iphone.org
3+
*
4+
* Copyright (c) 2012 Zynga, Inc.
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
* SOFTWARE.
23+
*/
24+
25+
//
26+
// Controller for the Bomb Object
27+
// When the Dragon (hero) touches this object, the Dragon moves downwards.
28+
//
29+
var Bomb = function () {
30+
this.radius = 15;
31+
};
32+
33+
Bomb.prototype.onUpdate = function () {
34+
};
35+
36+
Bomb.prototype.handleCollisionWith = function (gameObjectController) {
37+
if (gameObjectController.controllerName == "Dragon") {
38+
// Collided with the dragon, remove object and add an exposion instead
39+
this.isScheduledForRemove = true;
40+
41+
cc.AudioEngine.getInstance().playEffect("Explo.mp3");
42+
43+
var explosion = cc.BuilderReader.load("Explosion.ccbi");
44+
explosion.setPosition(this.rootNode.getPosition());
45+
46+
this.rootNode.getParent().addChild(explosion);
47+
}
48+
};
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/* http://www.cocosbuilder.com
2+
* http://www.cocos2d-iphone.org
3+
*
4+
* Copyright (c) 2012 Zynga, Inc.
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
* SOFTWARE.
23+
*/
24+
25+
26+
//
27+
// Controller for the Coin Object
28+
// When the Dragon (hero) touches this object, the Dragon moves upwards
29+
//
30+
31+
var Coin = function()
32+
{
33+
this.radius = 15;
34+
};
35+
36+
Coin.prototype.onUpdate = function()
37+
{};
38+
39+
Coin.prototype.handleCollisionWith = function(gameObjectController)
40+
{
41+
if (gameObjectController.controllerName == "Dragon")
42+
{
43+
cc.AudioEngine.getInstance().playEffect("Coin.mp3");
44+
this.isScheduledForRemove = true;
45+
}
46+
};
Binary file not shown.
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
/* http://www.cocosbuilder.com
2+
* http://www.cocos2d-iphone.org
3+
*
4+
* Copyright (c) 2012 Zynga, Inc.
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
* SOFTWARE.
23+
*/
24+
25+
//
26+
// controller for the Dragon Object (the Hero)
27+
//
28+
29+
// Constants
30+
var CD_START_SPEED = 8;
31+
var CD_COIN_SPEED = 8;
32+
var CD_START_TARGET = 160;
33+
34+
var CD_TARGET_FILTER_FACTOR = 0.05;
35+
var CD_SLOW_DOWN_FACTOR = 0.995;
36+
var CD_GRAVITY_SPEED = 0.1;
37+
var CD_GAMEOVER_SPEED = -10;
38+
var CD_DELTA_TO_ROTATION_FACTOR = 5;
39+
40+
var Dragon = function () {
41+
this.xTarget = CD_START_TARGET * gScaleFactor;
42+
this.ySpeed = CD_START_SPEED;
43+
this.radius = 25;
44+
};
45+
46+
Dragon.prototype.onUpdate = function () {
47+
// Calculate the new position
48+
var oldPosition = cc.pMult(this.rootNode.getPosition(), 1.0 / gScaleFactor);
49+
50+
var xNew = (this.xTarget / gScaleFactor) * CD_TARGET_FILTER_FACTOR + oldPosition.x * (1 - CD_TARGET_FILTER_FACTOR);
51+
var yNew = oldPosition.y + this.ySpeed;
52+
this.rootNode.setPosition(xNew * gScaleFactor, yNew * gScaleFactor);
53+
54+
// Update the vertical speed
55+
this.ySpeed = (this.ySpeed - CD_GRAVITY_SPEED) * CD_SLOW_DOWN_FACTOR;
56+
57+
// Tilt the dragon
58+
var xDelta = xNew - oldPosition.x;
59+
this.rootNode.setRotation(xDelta * CD_DELTA_TO_ROTATION_FACTOR);
60+
61+
// Check for game over
62+
if (this.ySpeed < CD_GAMEOVER_SPEED) {
63+
sharedGameScene.handleGameOver();
64+
}
65+
};
66+
67+
Dragon.prototype.handleCollisionWith = function (gameObjectController) {
68+
if (gameObjectController.controllerName == "Coin") {
69+
// Took a coin
70+
this.ySpeed = CD_COIN_SPEED;
71+
sharedGameScene.setScore(sharedGameScene.score + 1);
72+
}
73+
else if (gameObjectController.controllerName == "Bomb") {
74+
// Hit a bomb
75+
if (this.ySpeed > 0) this.ySpeed = 0;
76+
77+
this.rootNode.animationManager.runAnimationsForSequenceNamed("Hit");
78+
}
79+
};
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/* http://www.cocosbuilder.com
2+
* http://www.cocos2d-iphone.org
3+
*
4+
* Copyright (c) 2012 Zynga, Inc.
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
* SOFTWARE.
23+
*/
24+
25+
//
26+
// Controller for the EndCoin object
27+
// When the Dragon (hero) touches this object, the game is won.
28+
//
29+
var EndCoin = function()
30+
{
31+
this.radius = 15;
32+
};
33+
34+
EndCoin.prototype.onUpdate = function()
35+
{};
36+
37+
EndCoin.prototype.handleCollisionWith = function(gameObjectController)
38+
{
39+
if (gameObjectController.controllerName == "Dragon")
40+
{
41+
cc.AudioEngine.getInstance().playEffect("Coin.mp3");
42+
this.isScheduledForRemove = true;
43+
sharedGameScene.handleLevelComplete();
44+
}
45+
};
Binary file not shown.
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/* http://www.cocosbuilder.com
2+
* http://www.cocos2d-iphone.org
3+
*
4+
* Copyright (c) 2012 Zynga, Inc.
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
* SOFTWARE.
23+
*/
24+
25+
//
26+
// Controller for the Bomb Object
27+
// This object is run when the Dragon (hero) touches a bomb
28+
//
29+
30+
var Explosion = function () {
31+
this.radius = 15;
32+
};
33+
34+
Explosion.prototype.onDidLoadFromCCB = function () {
35+
this.rootNode.animationManager.setCompletedAnimationCallback(this, this.onAnimationComplete);
36+
};
37+
38+
Explosion.prototype.onUpdate = function () {
39+
};
40+
41+
Explosion.prototype.handleCollisionWith = function (gameObjectController) {
42+
};
43+
44+
Explosion.prototype.onAnimationComplete = function (animationManager) {
45+
this.isScheduledForRemove = true;
46+
};
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/* http://www.cocosbuilder.com
2+
* http://www.cocos2d-iphone.org
3+
*
4+
* Copyright (c) 2012 Zynga, Inc.
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
* SOFTWARE.
23+
*/
24+
25+
//
26+
// Controller for the GameScene Object
27+
// This object loads the main Scene
28+
//
29+
30+
var GameScene = function(){};
31+
var sharedGameScene;
32+
var gLevelOffsetX = 0;
33+
34+
GameScene.prototype.onDidLoadFromCCB = function()
35+
{
36+
sharedGameScene = this;
37+
38+
this.score = 0;
39+
40+
var level = cc.BuilderReader.load("Level.ccbi");
41+
42+
// Center the level on Screen
43+
gLevelOffsetX = (gWinSize.width-CD_LEVEL_WIDTH*gScaleFactor)/2;
44+
45+
level.setPosition(cc.p(gLevelOffsetX,0));
46+
47+
this.rootNode.addChild(level);
48+
};
49+
50+
GameScene.prototype.setScore = function(score)
51+
{
52+
this.score = score;
53+
this.scoreLabel.setString(""+score);
54+
};
55+
56+
GameScene.prototype.getScore = function()
57+
{
58+
return this.score;
59+
};
60+
61+
GameScene.prototype.handleGameOver = function()
62+
{
63+
var scene = cc.BuilderReader.loadAsScene("MainMenuScene.ccbi");
64+
cc.Director.getInstance().replaceScene(scene);
65+
};
66+
67+
GameScene.prototype.handleLevelComplete = function()
68+
{
69+
var scene = cc.BuilderReader.loadAsScene("MainMenuScene.ccbi");
70+
cc.Director.getInstance().replaceScene(scene);
71+
};
Binary file not shown.

0 commit comments

Comments
 (0)