mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-01 15:52:40 +08:00
Merge pull request #1757 from pandamicro/v1.5
Strict assert for sequence construction
This commit is contained in:
@@ -20,6 +20,8 @@ if (CC_DEV) {
|
||||
"1016": "cc.RotateTo.reverse(): it should be overridden in subclass.", //RotateTo.reverse
|
||||
"1017": "cc.GridAction.getGrid(): it should be overridden in subclass.", //ActionGrid.getGrid
|
||||
"1018": "Grid size must be (1,1)", //ActionGrid3D.initWithSize
|
||||
"1019": "Failed to construct, Sequence construction needs two or more actions", //ActionInterval.sequence
|
||||
"1020": "Failed to construct, Spawn construction needs two or more actions", //ActionInterval.spawn
|
||||
//configuration: 1100
|
||||
"1100": "Expected 'data' dict, but not found. Config file: %s", //loadConfigFile
|
||||
"1101": "Please load the resource first : %s", //loadConfigFile_2
|
||||
|
||||
@@ -313,6 +313,10 @@ cc.Sequence = cc.ActionInterval.extend({
|
||||
this._actions = [];
|
||||
|
||||
var paramArray = (tempArray instanceof Array) ? tempArray : arguments;
|
||||
if (paramArray.length === 1) {
|
||||
cc.errorID(1019);
|
||||
return;
|
||||
}
|
||||
var last = paramArray.length - 1;
|
||||
if ((last >= 0) && (paramArray[last] == null))
|
||||
cc.logID(1015);
|
||||
@@ -444,6 +448,10 @@ cc.Sequence = cc.ActionInterval.extend({
|
||||
// todo: It should be use new
|
||||
cc.sequence = function (/*Multiple Arguments*/tempArray) {
|
||||
var paramArray = (tempArray instanceof Array) ? tempArray : arguments;
|
||||
if (paramArray.length === 1) {
|
||||
cc.errorID(1019);
|
||||
return null;
|
||||
}
|
||||
var last = paramArray.length - 1;
|
||||
if ((last >= 0) && (paramArray[last] == null))
|
||||
cc.logID(1015);
|
||||
@@ -731,6 +739,10 @@ cc.Spawn = cc.ActionInterval.extend({
|
||||
this._two = null;
|
||||
|
||||
var paramArray = (tempArray instanceof Array) ? tempArray : arguments;
|
||||
if (paramArray.length === 1) {
|
||||
cc.errorID(1020);
|
||||
return;
|
||||
}
|
||||
var last = paramArray.length - 1;
|
||||
if ((last >= 0) && (paramArray[last] == null))
|
||||
cc.logID(1015);
|
||||
@@ -825,6 +837,10 @@ cc.Spawn = cc.ActionInterval.extend({
|
||||
*/
|
||||
cc.spawn = function (/*Multiple Arguments*/tempArray) {
|
||||
var paramArray = (tempArray instanceof Array) ? tempArray : arguments;
|
||||
if (paramArray.length === 1) {
|
||||
cc.errorID(1020);
|
||||
return null;
|
||||
}
|
||||
if ((paramArray.length > 0) && (paramArray[paramArray.length - 1] == null))
|
||||
cc.logID(1015);
|
||||
|
||||
|
||||
+48
-2
@@ -53,8 +53,6 @@ var actionArr = [
|
||||
'Place',
|
||||
'CallFunc',
|
||||
'DelayTime',
|
||||
'Sequence',
|
||||
'Spawn',
|
||||
'Speed',
|
||||
'Repeat',
|
||||
'RepeatForever',
|
||||
@@ -117,6 +115,54 @@ if (!ENABLE_GC_FOR_NATIVE_OBJECTS) {
|
||||
}
|
||||
}
|
||||
|
||||
cc.Sequence.prototype._ctor = function (...args) {
|
||||
var paramArray = (args[0] instanceof Array) ? args[0] : args;
|
||||
if (paramArray.length === 1) {
|
||||
cc.errorID(1019);
|
||||
return;
|
||||
}
|
||||
var last = paramArray.length - 1;
|
||||
if ((last >= 0) && (paramArray[last] == null))
|
||||
cc.logID(1015);
|
||||
|
||||
if (last >= 0) {
|
||||
this.init(paramArray);
|
||||
}
|
||||
|
||||
if (!ENABLE_GC_FOR_NATIVE_OBJECTS) {
|
||||
this.retain();
|
||||
this._retained = true;
|
||||
}
|
||||
};
|
||||
|
||||
cc.sequence = function (...args) {
|
||||
var paramArray = (args[0] instanceof Array) ? args[0] : args;
|
||||
return new cc.Sequence(paramArray);
|
||||
}
|
||||
|
||||
cc.Spawn.prototype._ctor = function (...args) {
|
||||
var paramArray = (args[0] instanceof Array) ? args[0] : args;
|
||||
if (paramArray.length === 1)
|
||||
cc.errorID(1020);
|
||||
var last = paramArray.length - 1;
|
||||
if ((last >= 0) && (paramArray[last] == null))
|
||||
cc.logID(1015);
|
||||
|
||||
if (last >= 0) {
|
||||
this.init(paramArray);
|
||||
}
|
||||
|
||||
if (!ENABLE_GC_FOR_NATIVE_OBJECTS) {
|
||||
this.retain();
|
||||
this._retained = true;
|
||||
}
|
||||
};
|
||||
|
||||
cc.spawn = function (...args) {
|
||||
var paramArray = (args[0] instanceof Array) ? args[0] : args;
|
||||
return new cc.Spawn(paramArray);
|
||||
}
|
||||
|
||||
cc.targetedAction = function (target, action) {
|
||||
return new cc.TargetedAction(target, action);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user