Merge branch 'v1.2' of github.com:cocos-creator/engine into v1.2

This commit is contained in:
Nan Wang
2016-08-19 17:18:55 +08:00
11 changed files with 69 additions and 17 deletions
+1 -1
View File
@@ -58,7 +58,7 @@ _p = null;
* @name cc.ENGINE_VERSION
*/
var engineVersion;
engineVersion = '1.2.1-beta.4';
engineVersion = '1.2.1-rc.1';
window['CocosEngine'] = cc.ENGINE_VERSION = engineVersion;
/**
+6
View File
@@ -969,6 +969,12 @@ var Node = cc.Class({
// activate
cc.director.getActionManager().resumeTarget(this);
cc.eventManager.resumeTarget(this);
if (this._touchListener) {
this._touchListener.mask = _searchMaskParent(this);
}
if (this._mouseListener) {
this._mouseListener.mask = _searchMaskParent(this);
}
}
else {
// deactivate
+5 -1
View File
@@ -813,6 +813,7 @@ var ScrollView = cc.Class({
}
this._moveContent(moveDelta);
this._adjustContentOutOfBoundary();
},
_calculateBoundary: function() {
@@ -1331,6 +1332,7 @@ var ScrollView = cc.Class({
var newPosition = cc.pAdd(this.getContentPosition(), outOfBoundary);
if(this.content) {
this.content.setPosition(newPosition);
this._updateScrollBar(0);
}
}
},
@@ -1339,7 +1341,9 @@ var ScrollView = cc.Class({
this._calculateBoundary();
//Because widget component will adjust content position and scrollview position is correct after visit
//So this event could make sure the content is on the correct position after loading.
cc.director.once(cc.Director.EVENT_AFTER_VISIT, this._adjustContentOutOfBoundary, this);
if(this.content) {
cc.director.once(cc.Director.EVENT_AFTER_VISIT, this._adjustContentOutOfBoundary, this);
}
},
onDestroy: function() {
+2 -2
View File
@@ -280,9 +280,9 @@ _ccsg.EditBox = _ccsg.Node.extend({
},
cleanup: function () {
this._super();
this._renderCmd._removeDomInputControl();
this.stopAllActions();
this.unscheduleAllCallbacks();
},
_onTouchBegan: function (touch) {
+22
View File
@@ -359,6 +359,7 @@ _ccsg.Label = _ccsg.Node.extend({
this._fontHandle = fontHandle;
this._labelType = _ccsg.Label.Type.SystemFont;
this._blendFunc = cc.BlendFunc._alphaPremultiplied();
this._renderCmd._needDraw = true;
this._notifyLabelSkinDirty();
this.emit('load');
return;
@@ -367,16 +368,35 @@ _ccsg.Label = _ccsg.Node.extend({
if (extName === ".ttf") {
this._labelType = _ccsg.Label.Type.TTF;
this._blendFunc = cc.BlendFunc._alphaPremultiplied();
this._renderCmd._needDraw = true;
this._fontHandle = this._loadTTFFont(fontHandle);
} else if (extName === ".fnt") {
//todo add bmfont here
this._labelType = _ccsg.Label.Type.BMFont;
this._blendFunc = cc.BlendFunc._alphaNonPremultiplied();
this._renderCmd._needDraw = false;
this._initBMFontWithString(this._string, fontHandle, textureUrl);
}
this._notifyLabelSkinDirty();
},
cleanup: function () {
this._super();
//remove the created DIV and style due to loading @font-face
if(this._fontFaceStyle) {
if(document.body.contains(this._fontFaceStyle)) {
document.body.removeChild(this._fontFaceStyle);
}
}
if(this._preloadDiv) {
if(document.body.contains(this._preloadDiv)) {
document.body.removeChild(this._preloadDiv);
}
}
},
_loadTTFFont: function(fontHandle) {
var ttfIndex = fontHandle.lastIndexOf(".ttf");
if (ttfIndex === -1) return fontHandle;
@@ -398,6 +418,7 @@ _ccsg.Label = _ccsg.Node.extend({
fontStyle = document.createElement("style");
fontStyle.type = "text/css";
doc.body.appendChild(fontStyle);
this._fontFaceStyle = fontStyle;
var fontStr = "";
if (isNaN(fontFamilyName - 0))
@@ -418,6 +439,7 @@ _ccsg.Label = _ccsg.Node.extend({
_divStyle.left = "-100px";
_divStyle.top = "-100px";
doc.body.appendChild(preloadDiv);
this._preloadDiv = preloadDiv;
self.scheduleOnce(function () {
self._notifyLabelSkinDirty();
self.emit("load");
@@ -69,7 +69,8 @@ proto._updateDisplayOpacity = function (parentOpacity) {
proto.transform = function (parentCmd, recursive) {
this.originTransform(parentCmd, recursive);
var lx = 0, rx = this._labelCanvas.width,
var node = this._node,
lx = 0, rx = this._labelCanvas.width,
by = 0, ty = this._labelCanvas.height,
wt = this._worldTransform;
@@ -83,6 +84,12 @@ proto.transform = function (parentCmd, recursive) {
vert[3].x = rx * wt.a + by * wt.c + wt.tx; // br
vert[3].y = rx * wt.b + by * wt.d + wt.ty;
if (!node._string || (node._labelType !== _ccsg.Label.Type.TTF &&
node._labelType !== _ccsg.Label.Type.SystemFont)) {
// No culling for bmfont
return;
}
var rect = cc.visibleRect,
vl = rect.left.x, vr = rect.right.x, vt = rect.top.y, vb = rect.bottom.y;
if (((vert[0].x-vl) & (vert[1].x-vl) & (vert[2].x-vl) & (vert[3].x-vl)) >> 31 || // All outside left
+9 -6
View File
@@ -1003,10 +1003,10 @@ function parseAttributes (attrs, className, propName) {
}
function parseSimpleAttr (attrName, expectType, attrCreater) {
var val = attrs[attrName];
if (val) {
if (attrName in attrs) {
var val = attrs[attrName];
if (typeof val === expectType) {
if (typeof attrCreater === 'undefined') {
if ( !attrCreater ) {
var attr = {};
attr[attrName] = val;
result.push(attr);
@@ -1016,7 +1016,7 @@ function parseAttributes (attrs, className, propName) {
}
}
else if (CC_DEV) {
cc.error('The %s of %s.%s must be type %s', attrName, className, propName, expectType);
cc.error(ERR_Type, attrName, className, propName, expectType);
}
}
}
@@ -1070,13 +1070,16 @@ function parseAttributes (attrs, className, propName) {
result.push({ min: range[0], max: range[1], step: range[2] });
}
else if (CC_DEV) {
cc.error('The length of range array must be 2');
cc.error('The length of range array must be equal or greater than 2');
}
}
else if (CC_DEV) {
cc.error(ERR_Type, '"range"', className + '.' + propName, 'array');
cc.error(ERR_Type, 'range', className, propName, 'array');
}
}
parseSimpleAttr('min', 'number');
parseSimpleAttr('max', 'number');
parseSimpleAttr('step', 'number');
return result;
}
+12 -1
View File
@@ -154,7 +154,7 @@ var View = cc._Class.extend({
* Constructor of View
*/
ctor: function () {
var _t = this, d = document, _strategyer = cc.ContainerStrategy, _strategy = cc.ContentStrategy;
var _t = this, _strategyer = cc.ContainerStrategy, _strategy = cc.ContentStrategy;
__BrowserGetter.init(this);
@@ -703,6 +703,9 @@ var View = cc._Class.extend({
// reset director's member variables to fit visible rect
director.setGLDefaultValues();
}
else if (cc._renderType === cc.game.RENDER_TYPE_CANVAS) {
cc.renderer._allNeedDraw = true;
}
this._originalScaleX = this._scaleX;
this._originalScaleY = this._scaleY;
@@ -1055,7 +1058,15 @@ cc.ContentStrategy = cc._Class.extend(/** @lends cc.ContentStrategy# */{
*/
var EqualToFrame = cc.ContainerStrategy.extend({
apply: function (view) {
var frameH = view._frameSize.height, containerStyle = cc.container.style;
this._setupContainer(view, view._frameSize.width, view._frameSize.height);
// Setup container's margin and padding
if (view._isRotated) {
containerStyle.marginLeft = frameH + 'px';
}
else {
containerStyle.margin = '0px';
}
}
});
-1
View File
@@ -96,7 +96,6 @@ var Texture2D = cc.Class(/** @lends cc.Texture2D# */{
this._isGray = false;
}
else if (cc._renderType === game.RENDER_TYPE_WEBGL) {
this._hasPremultipliedAlpha = false;
this._pixelFormat = Texture2D.defaultPixelFormat;
this._hasPremultipliedAlpha = false;
this._hasMipmaps = false;
+2 -2
View File
@@ -139,9 +139,9 @@ _ccsg.VideoPlayer = _ccsg.Node.extend(/** @lends _ccsg.VideoPlayer# */{
},
cleanup: function () {
this._super();
this._renderCmd.removeDom();
this.stopAllActions();
this.unscheduleAllCallbacks();
},
onEnter: function () {
+2 -2
View File
@@ -185,9 +185,9 @@ _ccsg.WebView = _ccsg.Node.extend(/** @lends _ccsg.WebView# */{
* remove node
*/
cleanup: function(){
this._super();
this._renderCmd.removeDom();
this.stopAllActions();
this.unscheduleAllCallbacks();
},
setVisible: function ( visible ) {