Skip to content

Commit

Permalink
Merge 1.6
Browse files Browse the repository at this point in the history
# Conflicts:
#	cocos2d/core/CCDirector.js
#	cocos2d/core/components/CCSprite.js
  • Loading branch information
jareguo committed Sep 22, 2017
2 parents d4b5071 + f147fcd commit e1601ac
Show file tree
Hide file tree
Showing 20 changed files with 516 additions and 330 deletions.
12 changes: 7 additions & 5 deletions cocos2d/actions/CCActionInterval.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ cc.ActionInterval = cc.FiniteTimeAction.extend({
* !#zh
* 改变一个动作的速度,使它的执行使用更长的时间(speed > 1)<br/>
* 或更少(speed < 1)可以有效得模拟“慢动作”或“快进”的效果。
* @param speed
* @param {Number} speed
* @returns {Action}
*/
speed: function(speed){
Expand Down Expand Up @@ -252,7 +252,7 @@ cc.ActionInterval = cc.FiniteTimeAction.extend({
* To repeat an action forever use the CCRepeatForever action.
* !#zh 重复动作可以按一定次数重复一个动作,使用 RepeatForever 动作来永远重复一个动作。
* @method repeat
* @param times
* @param {Number} times
* @returns {ActionInterval}
*/
repeat: function(times){
Expand Down Expand Up @@ -306,6 +306,7 @@ cc.Sequence = cc.ActionInterval.extend({
_actions:null,
_split:null,
_last:0,
_reversed:false,

ctor:function (tempArray) {
cc.ActionInterval.prototype.ctor.call(this);
Expand Down Expand Up @@ -379,7 +380,7 @@ cc.Sequence = cc.ActionInterval.extend({
// action[0]
new_t = (locSplit !== 0) ? dt / locSplit : 1;

if (found === 0 && locLast === 1) {
if (found === 0 && locLast === 1 && this._reversed) {
// Reverse mode ?
// XXX: Bug. this case doesn't contemplate when _last==-1, found=0 and in "reverse mode"
// since it will require a hack to know if an action is on reverse mode or not.
Expand All @@ -398,7 +399,7 @@ cc.Sequence = cc.ActionInterval.extend({
locActions[0].update(1);
locActions[0].stop();
}
if (!locLast) {
if (locLast === 0) {
// switching to action 1. stop action 0.
locActions[0].update(1);
locActions[0].stop();
Expand All @@ -410,7 +411,7 @@ cc.Sequence = cc.ActionInterval.extend({
if (locLast === found && actionFound.isDone())
return;

// Last action found and it is done
// Last action not found
if (locLast !== found)
actionFound.startWithTarget(this.target);

Expand All @@ -423,6 +424,7 @@ cc.Sequence = cc.ActionInterval.extend({
var action = cc.Sequence._actionOneTwo(this._actions[1].reverse(), this._actions[0].reverse());
this._cloneDecoration(action);
this._reverseEaseList(action);
action._reversed = true;
return action;
}
});
Expand Down
2 changes: 1 addition & 1 deletion cocos2d/audio/CCAudio.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ Audio.State = {
} catch (error) {}
this._element.pause();
// remove touchPlayList
for (var i=0; i<touchPlayList; i++) {
for (var i=0; i<touchPlayList.length; i++) {
if (touchPlayList[i].instance === this) {
touchPlayList.splice(i, 1);
break;
Expand Down
57 changes: 18 additions & 39 deletions cocos2d/audio/CCAudioEngine.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ var audioEngine = {
* @param {Number} volume - Volume size.
* @return {Number} audioId
* @example
* //example
* var audioID = cc.audioEngine.play(path, false, 0.5);
*/
play: function (filePath, loop, volume/*, profile*/) {
Expand Down Expand Up @@ -127,7 +126,6 @@ var audioEngine = {
* @param {Number} audioID - audio id.
* @param {Boolean} loop - Whether cycle.
* @example
* //example
* cc.audioEngine.setLoop(id, true);
*/
setLoop: function (audioID, loop) {
Expand All @@ -144,7 +142,6 @@ var audioEngine = {
* @param {Number} audioID - audio id.
* @return {Boolean} Whether cycle.
* @example
* //example
* cc.audioEngine.isLoop(id);
*/
isLoop: function (audioID) {
Expand All @@ -158,10 +155,9 @@ var audioEngine = {
* !#en Set the volume of audio.
* !#zh 设置音量(0.0 ~ 1.0)。
* @method setVolume
* @param {Number} audioID audio id.
* @param {Number} volume Volume must be in 0.0~1.0 .
* @param {Number} audioID - audio id.
* @param {Number} volume - Volume must be in 0.0~1.0 .
* @example
* //example
* cc.audioEngine.setVolume(id, 0.5);
*/
setVolume: function (audioID, volume) {
Expand All @@ -181,10 +177,9 @@ var audioEngine = {
* !#en The volume of the music max value is 1.0,the min value is 0.0 .
* !#zh 获取音量(0.0 ~ 1.0)。
* @method getVolume
* @param {Number} audioID audio id.
* @param {Number} audioID - audio id.
* @return {Boolean}
* @example
* //example
* var volume = cc.audioEngine.getVolume(id);
*/
getVolume: function (audioID) {
Expand All @@ -198,11 +193,10 @@ var audioEngine = {
* !#en Set current time
* !#zh 设置当前的音频时间。
* @method setCurrentTime
* @param {Number} audioID audio id.
* @param {Number} sec current time.
* @param {Number} audioID - audio id.
* @param {Number} sec - current time.
* @return {Boolean}
* @example
* //example
* cc.audioEngine.setCurrentTime(id, 2);
*/
setCurrentTime: function (audioID, sec) {
Expand All @@ -224,10 +218,9 @@ var audioEngine = {
* !#en Get current time
* !#zh 获取当前的音频播放时间。
* @method getCurrentTime
* @param {Number} audioID audio id.
* @param {Number} audioID - audio id.
* @return {Number} audio current time.
* @example
* //example
* var time = cc.audioEngine.getCurrentTime(id);
*/
getCurrentTime: function (audioID) {
Expand All @@ -241,10 +234,9 @@ var audioEngine = {
* !#en Get audio duration
* !#zh 获取音频总时长。
* @method getDuration
* @param {Number} audioID audio id.
* @param {Number} audioID - audio id.
* @return {Number} audio duration.
* @example
* //example
* var time = cc.audioEngine.getDuration(id);
*/
getDuration: function (audioID) {
Expand All @@ -258,10 +250,9 @@ var audioEngine = {
* !#en Get audio state
* !#zh 获取音频状态。
* @method getState
* @param {Number} audioID audio id.
* @param {Number} audioID - audio id.
* @return {audioEngine.AudioState} audio duration.
* @example
* //example
* var state = cc.audioEngine.getState(id);
*/
getState: function (audioID) {
Expand All @@ -275,10 +266,9 @@ var audioEngine = {
* !#en Set Audio finish callback
* !#zh 设置一个音频结束后的回调
* @method setFinishCallback
* @param {Number} audioID audio id.
* @param {Function} callback loaded callback.
* @param {Number} audioID - audio id.
* @param {Function} callback - loaded callback.
* @example
* //example
* cc.audioEngine.setFinishCallback(id, function () {});
*/
setFinishCallback: function (audioID, callback) {
Expand All @@ -297,7 +287,6 @@ var audioEngine = {
* @method pause
* @param {Number} audioID - The return value of function play.
* @example
* //example
* cc.audioEngine.pause(audioID);
*/
pause: function (audioID) {
Expand All @@ -314,7 +303,6 @@ var audioEngine = {
* !#zh 暂停现在正在播放的所有音频。
* @method pauseAll
* @example
* //example
* cc.audioEngine.pauseAll();
*/
pauseAll: function () {
Expand Down Expand Up @@ -352,7 +340,6 @@ var audioEngine = {
* !#zh 恢复播放所有之前暂停的所有音频。
* @method resumeAll
* @example
* //example
* cc.audioEngine.resumeAll();
*/
resumeAll: function () {
Expand All @@ -370,7 +357,6 @@ var audioEngine = {
* @method stop
* @param {Number} audioID - The return value of function play.
* @example
* //example
* cc.audioEngine.stop(audioID);
*/
stop: function (audioID) {
Expand All @@ -387,7 +373,6 @@ var audioEngine = {
* !#zh 停止正在播放的所有音频。
* @method stopAll
* @example
* //example
* cc.audioEngine.stopAll();
*/
stopAll: function () {
Expand All @@ -404,9 +389,8 @@ var audioEngine = {
* !#en Set up an audio can generate a few examples.
* !#zh 设置一个音频可以设置几个实例
* @method setMaxAudioInstance
* @param {Number} num a number of instances to be created from within an audio
* @param {Number} num - a number of instances to be created from within an audio
* @example
* //example
* cc.audioEngine.setMaxAudioInstance(20);
*/
setMaxAudioInstance: function (num) {
Expand All @@ -417,9 +401,8 @@ var audioEngine = {
* !#en Getting audio can produce several examples.
* !#zh 获取一个音频可以设置几个实例
* @method getMaxAudioInstance
* @return {Number} a number of instances to be created from within an audio
* @return {Number} a - number of instances to be created from within an audio
* @example
* //example
* cc.audioEngine.getMaxAudioInstance();
*/
getMaxAudioInstance: function () {
Expand All @@ -432,7 +415,6 @@ var audioEngine = {
* @method uncache
* @param {String} filePath
* @example
* //example
* cc.audioEngine.uncache(filePath);
*/
uncache: function (filePath) {
Expand All @@ -453,7 +435,6 @@ var audioEngine = {
* !#zh 卸载所有音频。
* @method uncacheAll
* @example
* //example
* cc.audioEngine.uncacheAll();
*/
uncacheAll: function () {
Expand All @@ -473,28 +454,26 @@ var audioEngine = {
/**
* !#en Preload audio file.
* !#zh 预加载一个音频
* @param filePath The file path of an audio.
* @param callback The callback of an audio.
* @method preload
* @param {String} filePath - The file path of an audio.
* @param {Function} [callback] - The callback of an audio.
* @example
* //example
* cc.audioEngine.preload(path);
*/
preload: function (filePath, callback) {
cc.loader.load(filePath, function (error) {
cc.loader.load(filePath, callback && function (error) {
if (!error) {
callback();
}
});
},

/**
* !#en Set a size, the unit is KB,Over this size is directly resolved into DOM nodes
* !#zh 设置一个以kb为单位的尺寸,大于这个尺寸的音频在加载的时候会强制使用 dom 方式加载
* @param kb The file path of an audio.
* !#en Set a size, the unit is KB. Over this size is directly resolved into DOM nodes.
* !#zh 设置一个以 KB 为单位的尺寸,大于这个尺寸的音频在加载的时候会强制使用 dom 方式加载
* @method setMaxWebAudioSize
* @param {Number} kb - The file path of an audio.
* @example
* //example
* cc.audioEngine.setMaxWebAudioSize(300);
*/
// Because webAudio takes up too much memory,So allow users to manually choose
Expand Down
Loading

0 comments on commit e1601ac

Please sign in to comment.