Permalink
Browse files

Added sound support (iPhone only)

  • Loading branch information...
Viktor Lidholt
Viktor Lidholt committed Jan 2, 2013
1 parent 8d31fde commit 9cf1cb4644b79b9d7fa9154aac290eb67af5a4af
Showing with 1,004 additions and 172 deletions.
  1. +20 −1 CrystalCraze.ccbproj
  2. +45 −11 Published-HTML5/GameScene.js
  3. +11 −3 Published-HTML5/MainScene.js
  4. BIN Published-HTML5/clickme-down.png
  5. BIN Published-HTML5/clickme.png
  6. +96 −86 Published-HTML5/cocos2d-html5.min.js
  7. +161 −0 Published-HTML5/crystals.plist
  8. BIN Published-HTML5/crystals.png
  9. BIN Published-HTML5/crystals/0.png
  10. BIN Published-HTML5/crystals/1.png
  11. BIN Published-HTML5/crystals/2.png
  12. BIN Published-HTML5/crystals/3.png
  13. BIN Published-HTML5/crystals/4.png
  14. BIN Published-HTML5/crystals/bomb-explo-inner.png
  15. BIN Published-HTML5/crystals/bomb-explo.png
  16. BIN Published-HTML5/crystals/bomb-hi.png
  17. BIN Published-HTML5/crystals/bomb-light.png
  18. BIN Published-HTML5/crystals/bomb.png
  19. BIN Published-HTML5/crystals/hint.png
  20. BIN Published-HTML5/gamescene/background.png
  21. BIN Published-HTML5/gamescene/bg-shimmer-0.png
  22. BIN Published-HTML5/gamescene/bg-shimmer-1-no.png
  23. BIN Published-HTML5/gamescene/bg-shimmer-1-non.png
  24. BIN Published-HTML5/gamescene/bg-shimmer-1.png
  25. BIN Published-HTML5/gamescene/btn-pause-down.png
  26. BIN Published-HTML5/gamescene/btn-pause.png
  27. BIN Published-HTML5/gamescene/go.png
  28. BIN Published-HTML5/gamescene/header.png
  29. BIN Published-HTML5/gamescene/iPhone5-padding.png
  30. +44 −0 Published-HTML5/gamescene/shimmer.plist
  31. BIN Published-HTML5/gamescene/shimmer.png
  32. BIN Published-HTML5/gamescene/sparkle.png
  33. BIN Published-HTML5/gamescene/timer.png
  34. BIN Published-HTML5/mainscene/btn-about-down.png
  35. BIN Published-HTML5/mainscene/btn-about.png
  36. BIN Published-HTML5/mainscene/btn-play-down.png
  37. BIN Published-HTML5/mainscene/btn-play.png
  38. BIN Published-HTML5/mainscene/logo.png
  39. +28 −39 Published-HTML5/resources-html5.js
  40. BIN Published-HTML5/sounds/click.caf
  41. BIN Published-HTML5/sounds/endgame.caf
  42. BIN Published-HTML5/sounds/gem-0.caf
  43. BIN Published-HTML5/sounds/gem-1.caf
  44. BIN Published-HTML5/sounds/gem-2.caf
  45. BIN Published-HTML5/sounds/gem-3.caf
  46. BIN Published-HTML5/sounds/gem-4.caf
  47. BIN Published-HTML5/sounds/loop.m4a
  48. BIN Published-HTML5/sounds/miss.caf
  49. BIN Published-HTML5/sounds/powerup.caf
  50. BIN Published-HTML5/sounds/tap-0.caf
  51. BIN Published-HTML5/sounds/tap-1.caf
  52. BIN Published-HTML5/sounds/tap-2.caf
  53. BIN Published-HTML5/sounds/tap-3.caf
  54. BIN Published-HTML5/sounds/timer.caf
  55. +45 −11 Published-iOS/GameScene.js
  56. +11 −3 Published-iOS/MainScene.js
  57. +61 −0 Published-iOS/ccbResources/resources-iphonehd/ccbDefaultImages.plist
  58. BIN Published-iOS/ccbResources/resources-iphonehd/ccbDefaultImages.png
  59. BIN Published-iOS/clickme-down.png
  60. BIN Published-iOS/clickme.png
  61. BIN Published-iOS/crystals/0.png
  62. BIN Published-iOS/crystals/1.png
  63. BIN Published-iOS/crystals/2.png
  64. BIN Published-iOS/crystals/3.png
  65. BIN Published-iOS/crystals/4.png
  66. BIN Published-iOS/crystals/bomb-explo-inner.png
  67. BIN Published-iOS/crystals/bomb-explo.png
  68. BIN Published-iOS/crystals/bomb-hi.png
  69. BIN Published-iOS/crystals/bomb-light.png
  70. BIN Published-iOS/crystals/bomb.png
  71. BIN Published-iOS/crystals/hint.png
  72. BIN Published-iOS/crystals/resources-ipad/0.png
  73. BIN Published-iOS/crystals/resources-ipad/1.png
  74. BIN Published-iOS/crystals/resources-ipad/2.png
  75. BIN Published-iOS/crystals/resources-ipad/3.png
  76. BIN Published-iOS/crystals/resources-ipad/4.png
  77. BIN Published-iOS/crystals/resources-ipad/bomb-explo-inner.png
  78. BIN Published-iOS/crystals/resources-ipad/bomb-explo.png
  79. BIN Published-iOS/crystals/resources-ipad/bomb-hi.png
  80. BIN Published-iOS/crystals/resources-ipad/bomb-light.png
  81. BIN Published-iOS/crystals/resources-ipad/bomb.png
  82. BIN Published-iOS/crystals/resources-ipad/hint.png
  83. BIN Published-iOS/crystals/resources-iphone/0.png
  84. BIN Published-iOS/crystals/resources-iphone/1.png
  85. BIN Published-iOS/crystals/resources-iphone/2.png
  86. BIN Published-iOS/crystals/resources-iphone/3.png
  87. BIN Published-iOS/crystals/resources-iphone/4.png
  88. BIN Published-iOS/crystals/resources-iphone/bomb-explo-inner.png
  89. BIN Published-iOS/crystals/resources-iphone/bomb-explo.png
  90. BIN Published-iOS/crystals/resources-iphone/bomb-hi.png
  91. BIN Published-iOS/crystals/resources-iphone/bomb-light.png
  92. BIN Published-iOS/crystals/resources-iphone/bomb.png
  93. BIN Published-iOS/crystals/resources-iphone/hint.png
  94. BIN Published-iOS/crystals/resources-iphonehd/0.png
  95. BIN Published-iOS/crystals/resources-iphonehd/1.png
  96. BIN Published-iOS/crystals/resources-iphonehd/2.png
  97. BIN Published-iOS/crystals/resources-iphonehd/3.png
  98. BIN Published-iOS/crystals/resources-iphonehd/4.png
  99. BIN Published-iOS/crystals/resources-iphonehd/bomb-explo-inner.png
  100. BIN Published-iOS/crystals/resources-iphonehd/bomb-explo.png
  101. BIN Published-iOS/crystals/resources-iphonehd/bomb-hi.png
  102. BIN Published-iOS/crystals/resources-iphonehd/bomb-light.png
  103. BIN Published-iOS/crystals/resources-iphonehd/bomb.png
  104. BIN Published-iOS/crystals/resources-iphonehd/hint.png
  105. +15 −0 Published-iOS/fonts/resources-iphonehd/scorefont.fnt
  106. BIN Published-iOS/fonts/resources-iphonehd/scorefont.png
  107. BIN Published-iOS/gamescene/background.png
  108. BIN Published-iOS/gamescene/bg-shimmer-0.png
  109. BIN Published-iOS/gamescene/bg-shimmer-1-no.png
  110. BIN Published-iOS/gamescene/bg-shimmer-1-non.png
  111. BIN Published-iOS/gamescene/bg-shimmer-1.png
  112. BIN Published-iOS/gamescene/btn-pause-down.png
  113. BIN Published-iOS/gamescene/btn-pause.png
  114. BIN Published-iOS/gamescene/go.png
  115. BIN Published-iOS/gamescene/header.png
  116. BIN Published-iOS/gamescene/iPhone5-padding.png
  117. BIN Published-iOS/gamescene/resources-ipad/background.png
  118. BIN Published-iOS/gamescene/resources-ipad/bg-shimmer-0.png
  119. BIN Published-iOS/gamescene/resources-ipad/bg-shimmer-1-no.png
  120. BIN Published-iOS/gamescene/resources-ipad/bg-shimmer-1-non.png
  121. BIN Published-iOS/gamescene/resources-ipad/bg-shimmer-1.png
  122. BIN Published-iOS/gamescene/resources-ipad/btn-pause-down.png
  123. BIN Published-iOS/gamescene/resources-ipad/btn-pause.png
  124. BIN Published-iOS/gamescene/resources-ipad/go.png
  125. BIN Published-iOS/gamescene/resources-ipad/header.png
  126. BIN Published-iOS/gamescene/resources-ipad/iPhone5-padding.png
  127. BIN Published-iOS/gamescene/resources-ipad/sparkle.png
  128. BIN Published-iOS/gamescene/resources-ipad/timer.png
  129. BIN Published-iOS/gamescene/resources-iphone/background.png
  130. BIN Published-iOS/gamescene/resources-iphone/bg-shimmer-0.png
  131. BIN Published-iOS/gamescene/resources-iphone/bg-shimmer-1-no.png
  132. BIN Published-iOS/gamescene/resources-iphone/bg-shimmer-1-non.png
  133. BIN Published-iOS/gamescene/resources-iphone/bg-shimmer-1.png
  134. BIN Published-iOS/gamescene/resources-iphone/btn-pause-down.png
  135. BIN Published-iOS/gamescene/resources-iphone/btn-pause.png
  136. BIN Published-iOS/gamescene/resources-iphone/go.png
  137. BIN Published-iOS/gamescene/resources-iphone/header.png
  138. BIN Published-iOS/gamescene/resources-iphone/iPhone5-padding.png
  139. +44 −0 Published-iOS/gamescene/resources-iphone/shimmer.plist
  140. BIN Published-iOS/gamescene/resources-iphone/shimmer.pvr.gz
  141. BIN Published-iOS/gamescene/resources-iphone/sparkle.png
  142. BIN Published-iOS/gamescene/resources-iphone/timer.png
  143. BIN Published-iOS/gamescene/resources-iphonehd/background.png
  144. BIN Published-iOS/gamescene/resources-iphonehd/bg-shimmer-0.png
  145. BIN Published-iOS/gamescene/resources-iphonehd/bg-shimmer-1-no.png
  146. BIN Published-iOS/gamescene/resources-iphonehd/bg-shimmer-1-non.png
  147. BIN Published-iOS/gamescene/resources-iphonehd/bg-shimmer-1.png
  148. BIN Published-iOS/gamescene/resources-iphonehd/btn-pause-down.png
  149. BIN Published-iOS/gamescene/resources-iphonehd/btn-pause.png
  150. BIN Published-iOS/gamescene/resources-iphonehd/go.png
  151. BIN Published-iOS/gamescene/resources-iphonehd/header.png
  152. BIN Published-iOS/gamescene/resources-iphonehd/iPhone5-padding.png
  153. +44 −0 Published-iOS/gamescene/resources-iphonehd/shimmer.plist
  154. BIN Published-iOS/gamescene/resources-iphonehd/shimmer.pvr.gz
  155. BIN Published-iOS/gamescene/resources-iphonehd/sparkle.png
  156. BIN Published-iOS/gamescene/resources-iphonehd/timer.png
  157. BIN Published-iOS/gamescene/sparkle.png
  158. BIN Published-iOS/gamescene/timer.png
  159. BIN Published-iOS/mainscene/btn-about-down.png
  160. BIN Published-iOS/mainscene/btn-about.png
  161. BIN Published-iOS/mainscene/btn-play-down.png
  162. BIN Published-iOS/mainscene/btn-play.png
  163. BIN Published-iOS/mainscene/logo.png
  164. BIN Published-iOS/mainscene/resources-ipad/btn-about-down.png
  165. BIN Published-iOS/mainscene/resources-ipad/btn-about.png
  166. BIN Published-iOS/mainscene/resources-ipad/btn-play-down.png
  167. BIN Published-iOS/mainscene/resources-ipad/btn-play.png
  168. BIN Published-iOS/mainscene/resources-ipad/logo.png
  169. BIN Published-iOS/mainscene/resources-iphone/btn-about-down.png
  170. BIN Published-iOS/mainscene/resources-iphone/btn-about.png
  171. BIN Published-iOS/mainscene/resources-iphone/btn-play-down.png
  172. BIN Published-iOS/mainscene/resources-iphone/btn-play.png
  173. BIN Published-iOS/mainscene/resources-iphone/logo.png
  174. BIN Published-iOS/mainscene/resources-iphonehd/btn-about-down.png
  175. BIN Published-iOS/mainscene/resources-iphonehd/btn-about.png
  176. BIN Published-iOS/mainscene/resources-iphonehd/btn-play-down.png
  177. BIN Published-iOS/mainscene/resources-iphonehd/btn-play.png
  178. BIN Published-iOS/mainscene/resources-iphonehd/logo.png
  179. BIN Published-iOS/resources-ipad/clickme-down.png
  180. BIN Published-iOS/resources-ipad/clickme.png
  181. BIN Published-iOS/resources-iphone/clickme-down.png
  182. BIN Published-iOS/resources-iphone/clickme.png
  183. +161 −0 Published-iOS/resources-iphone/crystals.plist
  184. BIN Published-iOS/resources-iphone/crystals.pvr.gz
  185. BIN Published-iOS/resources-iphonehd/clickme-down.png
  186. BIN Published-iOS/resources-iphonehd/clickme.png
  187. +161 −0 Published-iOS/resources-iphonehd/crystals.plist
  188. BIN Published-iOS/resources-iphonehd/crystals.pvr.gz
  189. BIN Published-iOS/sounds/click.caf
  190. BIN Published-iOS/sounds/endgame.caf
  191. BIN Published-iOS/sounds/gem-0.caf
  192. BIN Published-iOS/sounds/gem-1.caf
  193. BIN Published-iOS/sounds/gem-2.caf
  194. BIN Published-iOS/sounds/gem-3.caf
  195. BIN Published-iOS/sounds/gem-4.caf
  196. BIN Published-iOS/sounds/loop.m4a
  197. BIN Published-iOS/sounds/miss.caf
  198. BIN Published-iOS/sounds/powerup.caf
  199. BIN Published-iOS/sounds/tap-0.caf
  200. BIN Published-iOS/sounds/tap-1.caf
  201. BIN Published-iOS/sounds/tap-2.caf
  202. BIN Published-iOS/sounds/tap-3.caf
  203. BIN Published-iOS/sounds/timer.caf
  204. +46 −15 Resources/GameScene.js
  205. +11 −3 Resources/MainScene.js
  206. BIN Resources/gamescene/resources-auto/bg-shimmer-0.png
  207. BIN Resources/gamescene/resources-auto/bg-shimmer-1-no.png
  208. BIN Resources/gamescene/resources-auto/bg-shimmer-1-non.png
  209. BIN Resources/gamescene/resources-auto/bg-shimmer-1.png
  210. BIN Resources/gamescene/shimmer/resources-auto/bg-shimmer-0.png
  211. BIN Resources/gamescene/shimmer/resources-auto/bg-shimmer-1.png
  212. BIN Resources/sounds/click.caf
  213. BIN Resources/sounds/endgame.caf
  214. BIN Resources/sounds/gem-0.caf
  215. BIN Resources/sounds/gem-1.caf
  216. BIN Resources/sounds/gem-2.caf
  217. BIN Resources/sounds/gem-3.caf
  218. BIN Resources/sounds/gem-4.caf
  219. BIN Resources/sounds/loop.m4a
  220. BIN Resources/sounds/miss.caf
  221. BIN Resources/sounds/powerup.caf
  222. BIN Resources/sounds/tap-0.caf
  223. BIN Resources/sounds/tap-1.caf
  224. BIN Resources/sounds/tap-2.caf
  225. BIN Resources/sounds/tap-3.caf
  226. BIN Resources/sounds/timer.caf
View
@@ -19,7 +19,26 @@
<key>flattenPaths</key>
<false/>
<key>generatedSpriteSheets</key>
- <dict/>
+ <dict>
+ <key>crystals</key>
+ <dict>
+ <key>compress</key>
+ <true/>
+ <key>dither</key>
+ <true/>
+ <key>textureFileFormat</key>
+ <integer>2</integer>
+ </dict>
+ <key>gamescene/shimmer</key>
+ <dict>
+ <key>compress</key>
+ <true/>
+ <key>dither</key>
+ <true/>
+ <key>textureFileFormat</key>
+ <integer>5</integer>
+ </dict>
+ </dict>
<key>javascriptBased</key>
<true/>
<key>javascriptMainCCB</key>
@@ -49,6 +49,7 @@ var gPossibleMove;
var gIsGameOver;
var gGameOverGems;
var gScoreLabel;
+var gEndTimerStarted;
//require("GameBoard.js");
function setupBoard()
@@ -165,13 +166,13 @@ function removeConnectedGems(x, y)
{
gBoard[idx] = kBoardTypePup0;
- var sprt = cc.Sprite.create("crystals/bomb.png");
+ var sprt = cc.Sprite.createWithSpriteFrameName("crystals/bomb.png");
sprt.setPosition(cc.p(gemX*kGemSize, gemY*kGemSize));
sprt.setAnchorPoint(cc.p(0,0));
sprt.setOpacity(0);
sprt.runAction(cc.FadeIn.create(0.4));
- var sprtGlow = cc.Sprite.create("crystals/bomb-hi.png");
+ var sprtGlow = cc.Sprite.createWithSpriteFrameName("crystals/bomb-hi.png");
sprtGlow.setAnchorPoint(cc.p(0,0));
sprtGlow.setOpacity(0);
sprtGlow.runAction(cc.RepeatForever.create(cc.Sequence.create(cc.FadeIn.create(0.4),cc.FadeOut.create(0.4))));
@@ -183,7 +184,7 @@ function removeConnectedGems(x, y)
else if (idxPup != -1)
{
// Animate effect for power-up
- var sprtLight = cc.Sprite.create("crystals/bomb-light.png");
+ var sprtLight = cc.Sprite.createWithSpriteFrameName("crystals/bomb-light.png");
sprtLight.setPosition(cc.p(gemX*kGemSize+kGemSize/2, gemY*kGemSize+kGemSize/2));
sprtLight.setBlendFunc(gl.SRC_ALPHA, gl.ONE);
gEffectsLayer.addChild(sprtLight);
@@ -195,6 +196,10 @@ function removeConnectedGems(x, y)
}
}
}
+ else
+ {
+ gAudioEngine.playEffect("sounds/miss.caf");
+ }
var d = new Date();
gLastMoveTime = d.getTime();
@@ -214,6 +219,8 @@ function activatePowerUp(x, y)
if (gBoard[idx] == kBoardTypePup0)
{
// Activate bomb
+ gAudioEngine.playEffect("sounds/powerup.caf");
+
removedGems = true;
addScore(2000);
@@ -261,7 +268,7 @@ function activatePowerUp(x, y)
var center = cc.p(x*kGemSize+kGemSize/2, y*kGemSize+kGemSize/2);
// Horizontal
- var sprtH0 = cc.Sprite.create("crystals/bomb-explo.png");
+ var sprtH0 = cc.Sprite.createWithSpriteFrameName("crystals/bomb-explo.png");
sprtH0.setBlendFunc(gl.SRC_ALPHA, gl.ONE);
sprtH0.setPosition(center);
sprtH0.setScaleX(5);
@@ -270,7 +277,7 @@ function activatePowerUp(x, y)
gEffectsLayer.addChild(sprtH0);
// Vertical
- var sprtV0 = cc.Sprite.create("crystals/bomb-explo.png");
+ var sprtV0 = cc.Sprite.createWithSpriteFrameName("crystals/bomb-explo.png");
sprtV0.setBlendFunc(gl.SRC_ALPHA, gl.ONE);
sprtV0.setPosition(center);
sprtV0.setScaleY(5);
@@ -279,7 +286,7 @@ function activatePowerUp(x, y)
gEffectsLayer.addChild(sprtV0);
// Horizontal
- var sprtH1 = cc.Sprite.create("crystals/bomb-explo-inner.png");
+ var sprtH1 = cc.Sprite.createWithSpriteFrameName("crystals/bomb-explo-inner.png");
sprtH1.setBlendFunc(gl.SRC_ALPHA, gl.ONE);
sprtH1.setPosition(center);
sprtH1.setScaleX(0.5);
@@ -288,7 +295,7 @@ function activatePowerUp(x, y)
gEffectsLayer.addChild(sprtH1);
// Vertical
- var sprtV1 = cc.Sprite.create("crystals/bomb-explo-inner.png");
+ var sprtV1 = cc.Sprite.createWithSpriteFrameName("crystals/bomb-explo-inner.png");
sprtV1.setRotation(90);
sprtV1.setBlendFunc(gl.SRC_ALPHA, gl.ONE);
sprtV1.setPosition(center);
@@ -377,7 +384,7 @@ function setGemType(x, y, newType)
// Remove old gem and insert a new one
gGameLayer.removeChild(gBoardSprites[idx], true);
- var gemSprite = cc.Sprite.create("crystals/"+newType+".png");
+ var gemSprite = cc.Sprite.createWithSpriteFrameName("crystals/"+newType+".png");
gemSprite.setPosition(cc.p(x * kGemSize, y * kGemSize));
gemSprite.setAnchorPoint(cc.p(0,0));
@@ -514,7 +521,7 @@ function displayHint()
var actionSeq = cc.Sequence.create(actionFadeIn, actionFadeOut);
var action = cc.RepeatForever.create(actionSeq);
- var hintSprite = cc.Sprite.create("crystals/hint.png");
+ var hintSprite = cc.Sprite.createWithSpriteFrameName("crystals/hint.png");
hintSprite.setOpacity(0);
hintSprite.setPosition(cc.p(x*kGemSize, y*kGemSize));
hintSprite.setAnchorPoint(cc.p(0, 0));
@@ -537,9 +544,11 @@ function debugPrintBoard()
function setupShimmer()
{
+ cc.SpriteFrameCache.getInstance().addSpriteFrames("gamescene/shimmer.plist");
+
for (var i = 0; i < 2; i++)
{
- var sprt = cc.Sprite.create("gamescene/bg-shimmer-"+i+".png");
+ var sprt = cc.Sprite.createWithSpriteFrameName("gamescene/shimmer/bg-shimmer-"+i+".png");
var seqRot = null;
var seqMov = null;
@@ -707,6 +716,7 @@ GameScene.prototype.onDidLoadFromCCB = function()
gLastMoveTime = d.getTime();
gNumConsecutiveGems = 0;
gIsPowerPlay = false;
+ gEndTimerStarted = false;
gScore = 0;
@@ -761,6 +771,10 @@ GameScene.prototype.onTouchesBegan = function(touches, event)
removeConnectedGems(x,y))
{
// Player did a valid move
+ var sound = gNumConsecutiveGems;
+ if (sound > 4) sound = 4;
+ gAudioEngine.playEffect("sounds/gem-"+sound+".caf");
+
gNumConsecutiveGems++;
}
else
@@ -791,7 +805,7 @@ GameScene.prototype.onUpdate = function(dt)
{
// A gem should be added to this column!
var gemType = Math.floor(Math.random()*5);
- var gemSprite = cc.Sprite.create("crystals/"+gemType+".png");
+ var gemSprite = cc.Sprite.createWithSpriteFrameName("crystals/"+gemType+".png");
gemSprite.setPosition(cc.p(x * kGemSize, kBoardHeight * kGemSize));
gemSprite.setAnchorPoint(cc.p(0,0));
@@ -807,6 +821,7 @@ GameScene.prototype.onUpdate = function(dt)
}
// Move falling gems
+ var gemLanded = false;
for (var x = 0; x < kBoardWidth; x++)
{
var column = gFallingGems[x];
@@ -822,6 +837,12 @@ GameScene.prototype.onUpdate = function(dt)
if (gem.yPos <= gNumGemsInColumn[x])
{
// The gem hit the ground or a fixed gem
+ if (!gemLanded)
+ {
+ gAudioEngine.playEffect("sounds/tap-"+Math.floor(Math.random()*4)+".caf");
+ gemLanded = true;
+ }
+
column.splice(i, 1);
// Insert into board
@@ -890,12 +911,22 @@ GameScene.prototype.onUpdate = function(dt)
// Update sparkles
updateSparkle();
+ // Check if timer sound should be played
+ if (timeLeft < 6.6 && !gEndTimerStarted)
+ {
+ gAudioEngine.playEffect("sounds/timer.caf");
+ gEndTimerStarted = true;
+ }
+
// Check for game over
if (timeLeft == 0)
{
createGameOver();
this.rootNode.animationManager.runAnimationsForSequenceNamed("Outro");
gIsGameOver = true;
+ //gAudioEngine.stopAllEffects();
+ cc.log("stopAllEffects not working!");
+ gAudioEngine.playEffect("sounds/endgame.caf");
gLastScore = gScore;
}
else if (currentTime - gLastMoveTime > kDelayBeforeHint && !gIsDisplayingHint)
@@ -924,4 +955,7 @@ GameScene.prototype.onPauseClicked = function(dt)
createGameOver();
this.rootNode.animationManager.runAnimationsForSequenceNamed("Outro");
gIsGameOver = true;
+ //gAudioEngine.stopAllEffects();
+ cc.log("stopAllEffects not working!");
+ gAudioEngine.playEffect("sounds/endgame.caf");
};
@@ -3,6 +3,7 @@ var kMenuSelectionPlay = 1;
var kMenuSelectionAbout = 2;
var gLastScore = 0;
+var gAudioEngine;
//
// MainScene class
@@ -32,7 +33,11 @@ MainScene.prototype.onDidLoadFromCCB = function()
this.rootNode.schedule(this.rootNode.onUpdate);
// Load sprite sheets
- //cc.SpriteFrameCache.getInstance().addSpriteFrames("crystals.plist");
+ cc.SpriteFrameCache.getInstance().addSpriteFrames("crystals.plist");
+
+ // Setup sound
+ gAudioEngine = cc.AudioEngine.getInstance();
+ gAudioEngine.playMusic("sounds/loop.m4a");
};
// Create callback for button
@@ -41,6 +46,8 @@ MainScene.prototype.onPressPlay = function()
this.menuSelection = kMenuSelectionPlay;
this.rootNode.animationManager.runAnimationsForSequenceNamed("Outro");
+ gAudioEngine.playEffect("sounds/click.caf");
+
// Fade out gems
for (var i = 0; i < this.fallingGems.length; i++)
{
@@ -56,6 +63,7 @@ MainScene.prototype.onAnimationComplete = function()
{
var scene = cc.BuilderReader.loadAsScene("GameScene.ccbi");
cc.Director.getInstance().replaceScene(scene);
+ gAudioEngine.stopMusic();
}
};
@@ -64,8 +72,8 @@ MainScene.prototype.onUpdate = function()
if (Math.random() < 0.02)
{
var type = Math.floor(Math.random()*5);
- //var sprt = cc.Sprite.createWithSpriteFrameName("crystals/"+type+".png");
- var sprt = cc.Sprite.create("crystals/"+type+".png");
+ var sprt = cc.Sprite.createWithSpriteFrameName("crystals/"+type+".png");
+ //var sprt = cc.Sprite.create("crystals/"+type+".png");
//var p = cc.ParticleSystem.create("particles/falling-gem.plist");
var x = Math.random()*this.fallingGemsLayer.getContentSize().width;
Binary file not shown.
View
Binary file not shown.
Oops, something went wrong.

0 comments on commit 9cf1cb4

Please sign in to comment.