Merge branch 'master' of github.com:cocos-creator/engine

This commit is contained in:
Nan Wang
2016-02-06 23:00:21 +08:00
14 changed files with 134 additions and 57 deletions
+9 -3
View File
@@ -439,9 +439,15 @@ cc._initDebugSetting = function (mode) {
* @param {any} obj - A JavaScript string containing zero or more substitution strings.
* @param {any} ...subst - JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output.
*/
cc.warn = function(){
return console.warn.apply(console, arguments);
};
if (console.warn.bind) {
// use bind to avoid pollute call stacks
cc.warn = console.warn.bind(console);
}
else {
cc.warn = function() {
return console.warn.apply(console, arguments);
};
}
if(mode === cc.DebugMode.INFO) {
/**
* Outputs a message to the Cocos Creator Console (editor) or Web Console (runtime).
+22 -1
View File
@@ -626,7 +626,8 @@ cc.Audio = cc._Class.extend({
/**
* cc.audioEngine is the singleton object, it provide simple audio APIs.
* @namespace
* @class audioEngine
* @static
*/
cc.audioEngine = {
_currMusic: null,
@@ -636,12 +637,14 @@ cc.Audio = cc._Class.extend({
/**
* Indicates whether any background music can be played or not.
* @method willPlayMusic
* @returns {boolean} <i>true</i> if the background music is playing, otherwise <i>false</i>
*/
willPlayMusic: function(){return false;},
/**
* Play music.
* @method playMusic
* @param {String} url The path of the music file without filename extension.
* @param {Boolean} loop Whether the music loop or not.
* @example
@@ -666,6 +669,7 @@ cc.Audio = cc._Class.extend({
/**
* Stop playing music.
* @method stopMusic
* @param {Boolean} [releaseData] If release the music data or not.As default value is false.
* @example
* //example
@@ -682,6 +686,7 @@ cc.Audio = cc._Class.extend({
/**
* Pause playing music.
* @method pauseMusic
* @example
* //example
* cc.audioEngine.pauseMusic();
@@ -694,6 +699,7 @@ cc.Audio = cc._Class.extend({
/**
* Resume playing music.
* @method resumeMusic
* @example
* //example
* cc.audioEngine.resumeMusic();
@@ -706,6 +712,7 @@ cc.Audio = cc._Class.extend({
/**
* Rewind playing music.
* @method rewindMusic
* @example
* //example
* cc.audioEngine.rewindMusic();
@@ -720,6 +727,7 @@ cc.Audio = cc._Class.extend({
/**
* The volume of the music max value is 1.0,the min value is 0.0 .
* @method getMusicVolume
* @return {Number}
* @example
* //example
@@ -731,6 +739,7 @@ cc.Audio = cc._Class.extend({
/**
* Set the volume of music.
* @method setMusicVolume
* @param {Number} volume Volume must be in 0.0~1.0 .
* @example
* //example
@@ -751,6 +760,7 @@ cc.Audio = cc._Class.extend({
/**
* Whether the music is playing.
* @method isMusicPlaying
* @return {Boolean} If is playing return true,or return false.
* @example
* //example
@@ -775,6 +785,7 @@ cc.Audio = cc._Class.extend({
_effectVolume: 1,
/**
* Play sound effect.
* @method playEffect
* @param {String} url The path of the sound effect with filename extension.
* @param {Boolean} loop Whether to loop the effect playing, default value is false
* @return {Number|null} the audio id
@@ -827,6 +838,7 @@ cc.Audio = cc._Class.extend({
/**
* Set the volume of sound effects.
* @method setEffectsVolume
* @param {Number} volume Volume must be in 0.0~1.0 .
* @example
* //example
@@ -851,6 +863,7 @@ cc.Audio = cc._Class.extend({
/**
* The volume of the effects max value is 1.0,the min value is 0.0 .
* @method getEffectsVolume
* @return {Number}
* @example
* //example
@@ -862,6 +875,7 @@ cc.Audio = cc._Class.extend({
/**
* Pause playing sound effect.
* @method pauseEffect
* @param {Number} cc.Audio The return value of function playEffect.
* @example
* //example
@@ -875,6 +889,7 @@ cc.Audio = cc._Class.extend({
/**
* Pause all playing sound effect.
* @method pauseAllEffects
* @example
* //example
* cc.audioEngine.pauseAllEffects();
@@ -893,6 +908,7 @@ cc.Audio = cc._Class.extend({
/**
* Resume playing sound effect.
* @method resumeEffect
* @param {Number} cc.Audio The return value of function playEffect.
* @audioID
* //example
@@ -905,6 +921,7 @@ cc.Audio = cc._Class.extend({
/**
* Resume all playing sound effect
* @method resumeAllEffects
* @example
* //example
* cc.audioEngine.resumeAllEffects();
@@ -921,6 +938,7 @@ cc.Audio = cc._Class.extend({
/**
* Stop playing sound effect.
* @method stopEffect
* @param {Number} cc.Audio The return value of function playEffect.
* @example
* //example
@@ -933,6 +951,7 @@ cc.Audio = cc._Class.extend({
/**
* Stop all playing sound effects.
* @method stopAllEffects
* @example
* //example
* cc.audioEngine.stopAllEffects();
@@ -949,6 +968,7 @@ cc.Audio = cc._Class.extend({
/**
* Unload the preloaded effect from internal buffer
* @method unloadEffect
* @param {String} url
* @example
* //example
@@ -968,6 +988,7 @@ cc.Audio = cc._Class.extend({
/**
* End music and effects.
* @method end
*/
end: function(){
this.stopMusic();
+1 -1
View File
@@ -24,7 +24,7 @@
THE SOFTWARE.
****************************************************************************/
EventTarget = require("../cocos2d/core/event/event-target");
var EventTarget = cc.EventTarget;
/**
* <p>cc.AtlasNode is a subclass of ccsg.Node, it knows how to render a TextureAtlas object. </p>
+1 -1
View File
@@ -241,7 +241,7 @@ var Animation = cc.Class({
/**
* Resumes an animation named name. If no name is supplied then resumes all paused animations that were started with this Animation.
* @method pause
* @method resume
* @param {String} [name] - The animation to resumes, if not supplied then resumes all paused animations.
*/
resume: function (name) {
+1 -1
View File
@@ -26,7 +26,7 @@
/**
* Audio Source.
* @class AudioScource
* @class AudioSource
* @extends Component
*/
+1 -1
View File
@@ -31,7 +31,7 @@
* @type {String}
* @name cc.ENGINE_VERSION
*/
window['CocosEngine'] = cc.ENGINE_VERSION = 'Cocos Creator v0.7';
window['CocosEngine'] = cc.ENGINE_VERSION = 'Cocos Creator v0.8.0';
/**
* <p>
+1 -1
View File
@@ -46,7 +46,7 @@ function _copyprop(name, source, target) {
/**
* This module provides some JavaScript utilities.
*
* @module js
* @module cc.js
*/
var js = {
+15 -6
View File
@@ -32,13 +32,22 @@ module.exports = {
);
},
callInNextTick: function (callback, p1, p2) {
if (callback) {
setTimeout(function () {
callback(p1, p2);
}, 1);
callInNextTick: CC_EDITOR ?
function (callback, p1, p2) {
if (callback) {
process.nextTick(function () {
callback(p1, p2);
});
}
}
:
function (callback, p1, p2) {
if (callback) {
setTimeout(function () {
callback(p1, p2);
}, 0);
}
}
}
};
if (CC_DEV) {
+14 -3
View File
@@ -203,6 +203,19 @@ if (CC_DEV) {
return cc.js.array.copy;
});
Object.defineProperty(cc._ComponentInSG.prototype, 'visible', {
get: function () {
cc.warn('The "visible" property of %s is deprecated, use "enabled" instead please.', cc.js.getClassName(this));
return this.enabled;
},
set: function (value) {
var printWarning = this.visible;
this.enabled = value;
}
});
function deprecateEnum (obj, oldPath, newPath, hasTypePrefixBefore) {
hasTypePrefixBefore = hasTypePrefixBefore !== false;
var enumDef = eval(newPath);
@@ -233,14 +246,12 @@ if (CC_DEV) {
deprecateEnum(cc.ParticleSystem, 'cc.ParticleSystem.MODE', 'cc.ParticleSystem.EmitterMode');
deprecateEnum(cc.ProgressTimer, 'cc.ProgressTimer.TYPE', 'cc.ProgressTimer.Type');
deprecateEnum(cc.game, 'cc.game.DEBUG_MODE', 'cc.DebugMode');
deprecateEnum(cc, 'cc', 'cc.Texture2D.WrapMode', false);
if (_ccsg.EditBox) {
deprecateEnum(cc, 'cc.KEYBOARD_RETURNTYPE', '_ccsg.EditBox.KeyboardReturnType');
deprecateEnum(cc, 'cc.EDITBOX_INPUT_MODE', '_ccsg.EditBox.InputMode');
deprecateEnum(cc, 'cc.EDITBOX_INPUT_FLAG', '_ccsg.EditBox.InputFlag');
}
cc.game.once(cc.game.EVENT_RENDERER_INITED, function () {
deprecateEnum(cc, 'cc', 'cc.Texture2D.WrapMode', false);
});
function markAsRemoved (ownerCtor, removedProps, ownerName) {
ownerName = ownerName || js.getClassName(ownerCtor);
-2
View File
@@ -1,2 +0,0 @@
require('./bind');
require('./string');
+4 -2
View File
@@ -43,9 +43,11 @@ if (CC_DEV) {
cc._Test = {};
}
// predefine some modules for cocos
// polyfills
/* require('./polyfill/bind'); */
require('./polyfill/string');
require('./polyfill');
// predefine some modules for cocos
require('./cocos2d/core/platform/js');
require('./cocos2d/core/value-types');
require('./cocos2d/core/utils');
+64
View File
@@ -0,0 +1,64 @@
if (typeof CustomEvent === 'undefined') {
CustomEvent = function () {
}
}
if (typeof Set == 'undefined') {
// very simple polyfill
Set = function () {
this.values = [];
};
Set.prototype.has = function (value) {
return this.values.indexOf(value) !== -1;
};
Set.prototype.add = function (value) {
this.values.push(value);
};
}
// http://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind.html
if (!Function.prototype.bind) {
Function.prototype.bind = function (oThis) {
//return function () {};
if (typeof this !== 'function') {
// closest thing possible to the ECMAScript 5
// internal IsCallable function
throw new TypeError('Function.prototype.bind - what is trying to be bound is not callable');
}
var aArgs = Array.prototype.slice.call(arguments, 1),
fToBind = this,
fNOP = function () {},
fBound = function () {
return fToBind.apply(this instanceof fNOP && oThis
? this
: oThis,
aArgs.concat(Array.prototype.slice.call(arguments)));
};
// test this.prototype in case of native functions binding:
// - https://gist.github.com/jacomyal/4b7ae101a1cf6b985c60
if (this.prototype)
fNOP.prototype = this.prototype;
fBound.prototype = new fNOP();
return fBound;
};
}
var isPhantomJS = window.navigator.userAgent.indexOf('PhantomJS') !== -1;
if (isPhantomJS) {
QUnit.config.notrycatch = true;
window.onerror = function (msg, url, line, column, error) {
if (error) {
console.error(error.stack);
}
else {
console.error(msg + '.\n' + url + ':' + line);
}
};
// polyfill
var video = document.createElement("video");
video.constructor.prototype.canPlayType = function () { return ''; };
}
+1 -17
View File
@@ -18,23 +18,7 @@ qunit references:
<script src="../test/qunit/lib/assert-deep-close.js"></script>
<script src="../test/qunit/lib/qunit-assert-callback.js"></script>
<script src="../test/qunit/lib/qunit-large-module.js"></script>
<script>
var isPhantomJS = window.navigator.userAgent.indexOf('PhantomJS') !== -1;
if (isPhantomJS) {
QUnit.config.notrycatch = true;
window.onerror = function (msg, url, line, column, error) {
if (error) {
console.error(error.stack);
}
else {
console.error(msg + '.\n' + url + ':' + line);
}
};
// polyfill
var video = document.createElement("video");
video.constructor.prototype.canPlayType = function () { return ''; };
}
</script>
<script src="../test/qunit/lib/polyfill-for-phantom.js"></script>
</head>
<body>
<div id="qunit"></div>
-18
View File
@@ -1,18 +0,0 @@
if (typeof CustomEvent === 'undefined') {
CustomEvent = function () {
}
}
if (typeof Set == 'undefined') {
// very simple polyfill
Set = function () {
this.values = [];
};
Set.prototype.has = function (value) {
return this.values.indexOf(value) !== -1;
};
Set.prototype.add = function (value) {
this.values.push(value);
};
}