Merge branch 'master' into add_Label_OverFlow

This commit is contained in:
Huabing.Xu
2015-12-29 14:25:15 +08:00
12 changed files with 125 additions and 23 deletions
+1
View File
@@ -3,6 +3,7 @@ var JS = cc.js;
var AnimationManager = cc.Class({
ctor: function () {
this.animators = [];
this.__instanceId = cc.ClassManager.getNewInstanceId();
},
// for manager
+3 -1
View File
@@ -224,7 +224,9 @@ var game = /** @lends cc.game# */{
*/
cc.winSize = cc.director.getWinSize();
this._initEvents();
if (!CC_EDITOR) {
this._initEvents();
}
this._setAnimFrame();
this._runMainLoop();
+4
View File
@@ -376,6 +376,10 @@ var Node = cc.Class({
this._parent = null;
}
}
else {
this._sgNode.release();
this._sgNode = null;
}
},
// COMPONENT
+10
View File
@@ -24,6 +24,16 @@ cc.RawAsset = cc.Class({
* @param {Object} callback.node - the created node or null
*/
createNodeByInfo: null,
/**
* @method isRawAssetType
* @param {Function} ctor
* @returns {Boolean}
* @private
*/
isRawAssetType: function (ctor) {
return cc.isChildClassOf(ctor, cc.RawAsset) && !cc.isChildClassOf(ctor, cc.Asset);
}
}
});
+3
View File
@@ -132,6 +132,9 @@ var Canvas = cc.Class({
},
onLoad: function () {
var Flags = cc.Object.Flags;
this._objFlags |= (Flags.IsPositionLocked | Flags.IsAnchorLocked | Flags.IsSizeLocked);
if (Canvas.instance) {
return cc.error("Can't init canvas '%s' because it conflicts with the existing '%s', the scene should only have one active canvas at the same time",
this.node.name, Canvas.instance.node.name);
+4 -4
View File
@@ -47,8 +47,8 @@ function callOnEnable (self, enable) {
self.onEnable();
}
}
cc.director.getScheduler().resumeTarget(this);
cc.director.getScheduler().resumeTarget(self);
_registerEvent(self, true);
@@ -66,7 +66,7 @@ function callOnEnable (self, enable) {
}
}
cc.director.getScheduler().pauseTarget(this);
cc.director.getScheduler().pauseTarget(self);
_registerEvent(self, false);
@@ -577,7 +577,7 @@ var Component = cc.Class({
isRunning: function () {
return this.enabledInHierarchy;
},
/**
* <p>Schedules a custom selector. <br/>
* If the selector is already scheduled, then the interval parameter will be updated without scheduling it again.</p>
+3 -6
View File
@@ -775,10 +775,10 @@ function FireClass (options) {
else if (CC_DEV) {
var correct = TYPO_TO_CORRECT[funcName];
if (correct) {
cc.warn('Unknown parameter of %s.%s, maybe you want is "%s".', name, funcName, correct);
cc.warn('Unknown type of %s.%s, maybe you want is "%s".', name, funcName, correct);
}
else if (func) {
cc.error('Unknown parameter of %s.%s, property should be defined in "properties" or "ctor"', name, funcName);
cc.error('Unknown type of %s.%s, property should be defined in "properties" or "ctor"', name, funcName);
}
}
}
@@ -819,15 +819,12 @@ FireClass._isCCClass = function (constructor) {
// constructor.prop = _metaClass.prop;
//};
// Optimized define function only for internal base classes
//
// Specially optimized define function only for internal base classes
//
// @method _fastDefine
// @param {String} className
// @param {Function} constructor
// @param {string[]} serializableFields
// @private
//
function fastDefine (className, constructor, serializableFields) {
JS.setClassName(className, constructor);
constructor.__props__ = serializableFields;
+13 -1
View File
@@ -17,6 +17,12 @@ var IsOnEnableCalled = 1 << 12;
var IsOnLoadCalled = 1 << 13;
var IsOnStartCalled = 1 << 14;
var IsPositionLocked = 1 << 15;
var IsRotationLocked = 1 << 16;
var IsScaleLocked = 1 << 17;
var IsAnchorLocked = 1 << 18;
var IsSizeLocked = 1 << 19;
var Hide = HideInGame | HideInEditor;
// should not clone or serialize these flags
var PersistentMask = ~(ToDestroy | Dirty | Destroying | DontDestroy |
@@ -120,7 +126,13 @@ CCObject.Flags = {
IsOnLoadCalled: IsOnLoadCalled,
IsOnEnableCalled: IsOnEnableCalled,
IsOnStartCalled: IsOnStartCalled
IsOnStartCalled: IsOnStartCalled,
IsPositionLocked: IsPositionLocked,
IsRotationLocked: IsRotationLocked,
IsScaleLocked: IsScaleLocked,
IsAnchorLocked: IsAnchorLocked,
IsSizeLocked: IsSizeLocked,
};
require('./CCClass').fastDefine('cc.Object', CCObject, ['_name', '_objFlags']);
+29 -8
View File
@@ -122,8 +122,7 @@ function parseType (val, type, className, propName) {
}
if (CC_EDITOR) {
if (typeof type === 'function') {
var isRaw = cc.isChildClassOf(type, cc.RawAsset) && !cc.isChildClassOf(type, cc.Asset);
if (isRaw) {
if (cc.RawAsset.isRawAssetType(type)) {
cc.warn('The "type" attribute of "%s.%s" must be child class of cc.Asset, ' +
'otherwise you should use "url: %s" instead', className, propName,
cc.js.getClassName(type));
@@ -149,13 +148,35 @@ function postCheckType (val, type, className, propName) {
module.exports = function (properties, className) {
for (var propName in properties) {
var val = properties[propName];
var isObj = val && typeof val === 'object' && !Array.isArray(val);
var isLiteral = isObj && val.constructor === Object;
var isLiteral = val && val.constructor === Object;
if ( !isLiteral ) {
properties[propName] = val = {
default: val
};
if (Array.isArray(val) && val.length > 0) {
val = {
default: [],
type: val
};
}
else if (typeof val === 'function') {
if (cc.isChildClassOf(val, cc.ValueType)) {
//noinspection JSUnresolvedFunction
val = {
default: new val(),
type: val
};
}
else {
val = {
default: cc.RawAsset.isRawAssetType(val) ? '' : null,
type: val
};
}
}
else {
val = {
default: val
};
}
properties[propName] = val;
}
if (val) {
var notify = val.notify;
+1
View File
@@ -541,6 +541,7 @@ test('CCAnimation._updateClip', function () {
};
animation._updateClip(newClip);
animation.sample();
var clips = animation.getClips();
+32 -3
View File
@@ -12,9 +12,11 @@ test('test', function () {
tooltip: 'Float',
displayName: 'displayName'
},
eat: function () {
return function () {
return 'eating';
eat: {
default: function () {
return function () {
return 'eating';
}
}
},
weight: {
@@ -110,6 +112,33 @@ test('test', function () {
cc.js.unregisterClass(Animal, Labrador);
});
test('define property in quick way', function () {
var Class = cc.Class({
properties: {
undefinedVal: undefined,
nullVal: null,
string: '...',
array: [],
node: cc.Node,
rawAsset: cc.Texture2D,
asset: cc.SpriteFrame,
vec2: cc.Vec2,
vec2_one: cc.Vec2.ONE,
}
});
var obj = new Class();
strictEqual(obj.undefinedVal, undefined, 'could define default value of undefined');
strictEqual(obj.nullVal, null, 'could define default value of null');
strictEqual(obj.string, '...', 'could define default value of string');
deepEqual(obj.array, [], 'could define default value of array');
strictEqual(obj.node, null, 'could define default value of cc.Node');
strictEqual(obj.rawAsset, '', 'could define default value of raw asset');
strictEqual(obj.asset, null, 'could define default value of asset');
ok(obj.vec2.equals(cc.Vec2.ZERO), 'could define default value by using cc.Vec2');
ok(obj.vec2_one.equals(cc.Vec2.ONE), 'could define default value by using cc.Vec2.ONE');
});
test('Inherit', function () {
var Animal = cc.Class({
name: 'cc.Animal',
+22
View File
@@ -392,3 +392,25 @@ test('attach events', function () {
cc.engine.off('node-attach-to-scene', onAttach);
cc.engine.off('node-detach-from-scene', onDetach);
});
test('release sg node', function () {
var parent = new cc.Node();
var child = new cc.Node();
child.parent = parent;
var childReleased = false;
var parentReleased = false;
child._sgNode.release = function () {
childReleased = true;
};
parent._sgNode.release = function () {
parentReleased = true;
};
parent.destroy();
cc.Object._deferredDestroy();
strictEqual(parentReleased, true, 'should release parent sg node');
strictEqual(childReleased, true, 'should release child sg node');
});