Skip to content

Commit 13b281c

Browse files
author
linshun
committed
2 parents ee93e0e + 78ff1a1 commit 13b281c

File tree

11 files changed

+144
-101
lines changed

11 files changed

+144
-101
lines changed

AUTHORS.txt

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,26 @@
1-
cocos2d-html5 authors
2-
3-
1+
Cocos2d-html5 authors
42

53
(ordered by the join in time)
64

7-
8-
9-
Core Developers:
5+
Core Developers:
106

11-
Shun Lin (Sean Lin)
7+
Shun Lin (Sean Lin)
128

13-
Hao Wu (WuHao)
9+
Hao Wu (WuHao)
1410

15-
Dingping Lv (David Lv)
11+
Dingping Lv (David Lv)
1612

1713
Shengxiang Chen (Nero Chan)
1814

15+
Ricardo Quesada
16+
1917

20-
21-
22-
2318
Developers:
24-
25-
19+
2620

2721

28-
Cocos2d-x and cocos2d-html5 can not grow so fast without the active community.
22+
Cocos2d-x and cocos2d-html5 can not grow so fast without the active community.
2923

30-
Thanks to all developers who report & trace bugs, dicuss the engine usage in forum & QQ groups!
24+
Thanks to all developers who report & trace bugs, dicuss the engine usage in forum & QQ groups!
3125

3226
Special thanks to Ricardo Quesada for giving us lots of guidances & suggestions.

CocosDenshion/SimpleAudioEngine.js

Lines changed: 38 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ cc.AudioEngine = cc.Class.extend(/** @lends cc.AudioEngine# */{
3636
_soundEnable:false,
3737
_effectList:{},
3838
_muiscList:{},
39+
_soundList:{},
3940
_isMusicPlaying:false,
4041
_playingMusic:null,
4142
_effectsVolume:1,
@@ -81,13 +82,13 @@ cc.AudioEngine = cc.Class.extend(/** @lends cc.AudioEngine# */{
8182
/**
8283
* Preload music resource.<br />
8384
* This method is called when cc.Loader preload resources.
84-
* @param {String} path The path of the music file without filename extension.
85+
* @param {String} path The path of the music file with filename extension.
8586
*/
86-
preloadMusic:function (path) {
87+
preloadSound:function (path) {
8788
if (this._soundEnable) {
8889
var extName = this._getExtFromFullPath(path);
8990
var keyname = this._getPathWithoutExt(path);
90-
if (this._checkAudioFormatSupported(extName) && !this._muiscList.hasOwnProperty(keyname)) {
91+
if (this._checkAudioFormatSupported(extName) && !this._soundList.hasOwnProperty(keyname)) {
9192
var soundCache = new Audio(path);
9293
soundCache.preload = 'auto';
9394

@@ -96,21 +97,13 @@ cc.AudioEngine = cc.Class.extend(/** @lends cc.AudioEngine# */{
9697
}, false);
9798

9899
soundCache.addEventListener("error", function (e) {
100+
this.removeEventListener('error', arguments.callee, false);
99101
cc.Loader.getInstance().onResLoadingErr();
100102
}, false);
101103

102-
soundCache.addEventListener("playing", function (e) {
103-
cc.AudioEngine._instance._isMusicPlaying = true;
104-
}, false);
105-
106-
soundCache.addEventListener("pause", function (e) {
107-
cc.AudioEngine._instance._isMusicPlaying = false;
108-
}, false);
109-
104+
this._soundList[keyname] = true;
110105
// load it
111106
soundCache.load();
112-
113-
this._muiscList[keyname] = soundCache
114107
}
115108
}
116109
cc.Loader.getInstance().onResLoaded();
@@ -126,14 +119,31 @@ cc.AudioEngine = cc.Class.extend(/** @lends cc.AudioEngine# */{
126119
*/
127120
playMusic:function (path, loop) {
128121
var keyname = this._getPathWithoutExt(path);
122+
var actExt = this._supportedFormat[0];
123+
var au;
129124
if (this._muiscList.hasOwnProperty(this._playingMusic)) {
130125
this._muiscList[this._playingMusic].pause();
131126
}
132127
this._playingMusic = keyname;
133128
if (this._muiscList.hasOwnProperty(this._playingMusic)) {
134-
this._muiscList[this._playingMusic].loop = loop || false;
135-
this._muiscList[this._playingMusic].play();
129+
au = this._muiscList[this._playingMusic];
136130
}
131+
else {
132+
au = new Audio(keyname + "." + actExt);
133+
au.preload = 'auto';
134+
this._muiscList[this._playingMusic] = au;
135+
136+
au.addEventListener("playing", function (e) {
137+
cc.AudioEngine._instance._isMusicPlaying = true;
138+
}, false);
139+
140+
au.addEventListener("pause", function (e) {
141+
cc.AudioEngine._instance._isMusicPlaying = false;
142+
}, false);
143+
}
144+
145+
au.loop = loop || false;
146+
au.play();
137147
},
138148

139149
/**
@@ -145,9 +155,10 @@ cc.AudioEngine = cc.Class.extend(/** @lends cc.AudioEngine# */{
145155
*/
146156
stopMusic:function (releaseData) {
147157
if (this._muiscList.hasOwnProperty(this._playingMusic)) {
148-
this._muiscList[this._playingMusic].pause();
149-
this._muiscList[this._playingMusic].currentTime = 0;
150-
if (releaseData && this._muiscList.hasOwnProperty(this._playingMusic)) {
158+
var au = this._muiscList[this._playingMusic];
159+
au.pause();
160+
au.currentTime = au.duration;
161+
if (releaseData) {
151162
delete this._muiscList[this._playingMusic];
152163
}
153164
}
@@ -189,6 +200,7 @@ cc.AudioEngine = cc.Class.extend(/** @lends cc.AudioEngine# */{
189200
this._muiscList[this._playingMusic].play();
190201
}
191202
},
203+
192204
willPlayMusic:function () {
193205
return false;
194206
},
@@ -245,26 +257,9 @@ cc.AudioEngine = cc.Class.extend(/** @lends cc.AudioEngine# */{
245257
}
246258
},
247259

248-
/**
249-
* Preload sound effect resource.
250-
* This method is called when cc.Loader preload resources.
251-
* @param {String} path The path of the sound effect file without filename extension.
252-
*/
253-
preloadEffect:function (path) {
254-
if (this._soundEnable) {
255-
var extName = this._getExtFromFullPath(path);
256-
var keyname = this._getPathWithoutExt(path);
257-
if (this._checkAudioFormatSupported(extName) && !this._effectList.hasOwnProperty(keyname)) {
258-
this._effectList[keyname] = [];
259-
this._effectList[keyname].push(new Audio(path));
260-
}
261-
}
262-
cc.Loader.getInstance().onResLoaded();
263-
},
264-
265260
/**
266261
* Play sound effect.
267-
* @param {String} path The path of the sound effect without filename extension.
262+
* @param {String} path The path of the sound effect with filename extension.
268263
* @param {Boolean} loop Whether to loop the effect playing, default value is false
269264
* @example
270265
* //example
@@ -274,7 +269,7 @@ cc.AudioEngine = cc.Class.extend(/** @lends cc.AudioEngine# */{
274269
var keyname = this._getPathWithoutExt(path);
275270
var actExt = this._supportedFormat[0];
276271
var reclaim = this._getEffectList(keyname), au;
277-
if(reclaim.length > 0){
272+
if (reclaim.length > 0) {
278273
for (var i = 0; i < reclaim.length; i++) {
279274
//if one of the effect ended, play it
280275
if (reclaim[i].ended) {
@@ -284,12 +279,13 @@ cc.AudioEngine = cc.Class.extend(/** @lends cc.AudioEngine# */{
284279
}
285280
}
286281
}
287-
if (!au){
282+
283+
if (!au) {
288284
if (reclaim.length >= this._maxAudioInstance) {
289285
cc.log("Error: " + path + " greater than " + this._maxAudioInstance);
290286
return keyname;
291287
}
292-
au = new Audio(keyname+"."+actExt);
288+
au = new Audio(keyname + "." + actExt);
293289
reclaim.push(au);
294290
}
295291

@@ -478,6 +474,7 @@ cc.AudioEngine = cc.Class.extend(/** @lends cc.AudioEngine# */{
478474
unloadEffect:function (path) {
479475
var keyname = this._getPathWithoutExt(path);
480476
if (this._effectList.hasOwnProperty(keyname)) {
477+
this.stopEffect(path);
481478
delete this._effectList[keyname];
482479
}
483480
},
@@ -498,7 +495,8 @@ cc.AudioEngine = cc.Class.extend(/** @lends cc.AudioEngine# */{
498495
return this._effectList[elt];
499496
}
500497
else {
501-
return [];
498+
this._effectList[elt] = [];
499+
return this._effectList[elt];
502500
}
503501
},
504502

cocos2d/CCLoader.js

Lines changed: 2 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cocos2d/Draw_Nodes/CCDrawNode.js

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -275,10 +275,10 @@ cc.DrawNode = cc.Node.extend({
275275
},
276276

277277
/** draw a polygon with a fill color and line color */
278-
drawPolyWithVerts:function (verts, count, fillColor, width, borderColor) {
278+
drawPoly:function (verts, fillColor, width, borderColor) {
279279
var element = new cc._DrawNodeElement(cc.DRAWNODE_TYPE_POLY);
280-
element.verts = cc.DrawNode.convertVerts(verts);
281-
element.count = count;
280+
element.verts = verts;
281+
element.count = verts.length;
282282
element.fillColor = fillColor;
283283
element.borderWidth = width;
284284
element.borderColor = borderColor;
@@ -395,10 +395,3 @@ cc._DrawNodeElement = function (type) {
395395
cc.DRAWNODE_TYPE_DOT = 0;
396396
cc.DRAWNODE_TYPE_SEGMENT = 1;
397397
cc.DRAWNODE_TYPE_POLY = 2;
398-
cc.DrawNode.convertVerts = function (verts) {
399-
var ret = [];
400-
for (var i = 0; i < verts.length / 2; i++) {
401-
ret[i] = {x:verts[i * 2], y:verts[i * 2 + 1]};
402-
}
403-
return ret;
404-
};

cocos2d/build.xml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<target name="compile_Canvas">
88
<jscomp compilationLevel="simple" warning="quiet"
9-
debug="false" output="../lib/Cocos2d-html5-v2.0.min.js">
9+
debug="false" output="../lib/Cocos2d-html5-v2.1.min.js">
1010
<externs dir="${basedir}">
1111
<file name="cocos2d_externs.js"/>
1212
</externs>
@@ -98,15 +98,15 @@
9898
</sources>
9999
<!-- extensions -->
100100
<sources dir="${basedir}/../extensions">
101-
<file name="CCBReader/CCNodeLoaderLibrary.js"/>
102101
<file name="CCBReader/CCBReaderUtil.js"/>
102+
<file name="CCBReader/CCBValue.js"/>
103+
<file name="CCBReader/CCBKeyframe.js"/>
104+
<file name="CCBReader/CCBSequence.js"/>
103105
<file name="CCBReader/CCNodeLoader.js"/>
104106
<file name="CCBReader/CCBReader.js"/>
105107
<file name="CCBReader/CCControlLoader.js"/>
106108
<file name="CCBReader/CCSpriteLoader.js"/>
107-
<file name="CCBReader/CCBValue.js"/>
108-
<file name="CCBReader/CCBKeyframe.js"/>
109-
<file name="CCBReader/CCBSequence.js"/>
109+
<file name="CCBReader/CCNodeLoaderLibrary.js"/>
110110
<file name="CCBReader/CCBRelativePositioning.js"/>
111111
<file name="CCBReader/CCBAnimationManager.js"/>
112112
<file name="GUI/CCControlExtension/CCControl.js"/>
@@ -121,8 +121,9 @@
121121
<file name="GUI/CCControlExtension/CCControlSaturationBrightnessPicker.js"/>
122122
<file name="GUI/CCControlExtension/CCMenuPassive.js"/>
123123
<file name="GUI/CCScrollView/CCSorting.js"/>
124-
<file name="GUI/CCScrollView/CCTableView.js"/>
125124
<file name="GUI/CCScrollView/CCScrollView.js"/>
125+
<file name="GUI/CCScrollView/CCTableView.js"/>
126+
<file name="CCControlEditBox.js"/>
126127
</sources>
127128
</jscomp>
128129
</target>

cocos2d/particle_nodes/CCParticleBatchNode.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ cc.ParticleBatchNode = cc.Node.extend(/** @lends cc.ParticleBatchNode# */{
8787
* @param {Number} capacity
8888
* @return {Boolean}
8989
*/
90-
initWithFile:function (fileImage, capacity) {
90+
init:function (fileImage, capacity) {
9191
var tex = cc.TextureCache.getInstance().addImage(fileImage);
9292
return this.initWithTexture(tex, capacity);
9393
},
@@ -277,7 +277,8 @@ cc.ParticleBatchNode = cc.Node.extend(/** @lends cc.ParticleBatchNode# */{
277277
* @override
278278
* @param {CanvasContext} ctx
279279
*/
280-
draw:function (ctx) {
280+
// XXX: Remove the "XXX_" prefix once WebGL is supported
281+
XXX_draw:function (ctx) {
281282
cc.PROFILER_STOP("CCParticleBatchNode - draw");
282283
if (this._textureAtlas.getTotalQuads() == 0) {
283284
return;
@@ -336,7 +337,8 @@ cc.ParticleBatchNode = cc.Node.extend(/** @lends cc.ParticleBatchNode# */{
336337

337338
// override visit.
338339
// Don't call visit on it's children
339-
visit:function (ctx) {
340+
// XXX: Remove the "XXX_" prefix once WebGL is supported
341+
XXX_visit:function (ctx) {
340342
// CAREFUL:
341343
// This visit is almost identical to cc.Node#visit
342344
// with the exception that it doesn't call visit on it's children
@@ -499,7 +501,7 @@ cc.ParticleBatchNode.createWithTexture = function (texture, capacity) {
499501
*/
500502
cc.ParticleBatchNode.create = function (fileImage, capacity) {
501503
var ret = new cc.ParticleBatchNode();
502-
if (ret && ret.initWithFile(fileImage, capacity)) {
504+
if (ret && ret.init(fileImage, capacity)) {
503505
return ret;
504506
}
505507
return null;

cocos2d/physics_nodes/CCPhysicsDebugNode.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@
3434
as the private API may change with little or no warning.
3535
*/
3636

37+
// Helper. Converts an array of numbers into an array of vectors(x,y)
38+
cc.__convertVerts = function (verts) {
39+
var ret = [];
40+
for (var i = 0; i < verts.length / 2; i++) {
41+
ret[i] = {x:verts[i * 2], y:verts[i * 2 + 1]};
42+
}
43+
return ret;
44+
};
45+
3746
cc.ColorForBody = function (body) {
3847
if (body.isRogue() || body.isSleeping()) {
3948
return cc.c4f(0.5, 0.5, 0.5, 0.5);
@@ -57,7 +66,7 @@ cc.DrawShape = function (shape, renderer) {
5766
break;
5867
case cp.PolyShape.prototype.collisionCode:
5968
var line = cc.c4f(color.r, color.g, color.b, cc.lerp(color.a, 1.0, 0.5));
60-
this.drawPolyWithVerts(shape.tVerts, shape.getNumVerts(), color, 1.0, line);
69+
this.drawPoly(cc.__convertVerts(shape.tVerts), color, 1.0, line);
6170
break;
6271
default:
6372
cc.Assert(false, "Bad assertion in DrawShape()");
@@ -153,4 +162,5 @@ cc.PhysicsDebugNode.debugNodeForCPSpace = function (space) {
153162
return null;
154163
};
155164

156-
cc.PhysicsDebugNode.create = cc.PhysicsDebugNode.debugNodeForCPSpace;
165+
cc.PhysicsDebugNode.create = cc.PhysicsDebugNode.debugNodeForCPSpace;
166+

0 commit comments

Comments
 (0)