Merge pull request #1027 from cocos-creator/v1.2

merge V1.2
This commit is contained in:
Wang Nan
2016-08-12 09:39:58 +08:00
committed by GitHub
32 changed files with 3043 additions and 417 deletions
+1 -1
View File
@@ -58,7 +58,7 @@ _p = null;
* @name cc.ENGINE_VERSION
*/
var engineVersion;
engineVersion = '1.2.0-rc.2';
engineVersion = '1.2.1-beta.1';
window['CocosEngine'] = cc.ENGINE_VERSION = engineVersion;
/**
+6 -6
View File
@@ -451,8 +451,8 @@ cc._initDebugSetting = function (mode) {
* - 在 Chrome 中,错误信息有红色的图标以及红色的消息文本。<br/>
*
* @method error
* @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.
* @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.
*/
if (CC_EDITOR) {
cc.error = Editor.error;
@@ -484,8 +484,8 @@ cc._initDebugSetting = function (mode) {
* - 在 Cocos Creator 中,警告信息显示是黄色的。<br/>
* - 在 Chrome 中,警告信息有着黄色的图标以及黄色的消息文本。<br/>
* @method warn
* @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.
* @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.
*/
if (CC_EDITOR) {
cc.warn = Editor.warn;
@@ -509,8 +509,8 @@ cc._initDebugSetting = function (mode) {
* !#en Outputs a message to the Cocos Creator Console (editor) or Web Console (runtime).
* !#zh 输出一条消息到 Cocos Creator 编辑器的 Console 或运行时 Web 端的 Console 中。
* @method log
* @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.
* @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.
*/
if (CC_JSB) {
cc.log = jsbLog;
+21 -78
View File
@@ -69,36 +69,6 @@ cc.cardinalSplineAt = function (p0, p1, p2, p3, tension, t) {
return cc.p(x, y);
};
/*
* returns a new copy of the array reversed.
* @method reverseControlPoints
* @param {Array} controlPoints
* @return {Array}
*/
cc.reverseControlPoints = function (controlPoints) {
var newArray = [];
for (var i = controlPoints.length - 1; i >= 0; i--) {
newArray.push(cc.p(controlPoints[i].x, controlPoints[i].y));
}
return newArray;
};
/*
* returns a new clone of the controlPoints
* @method cloneControlPoints
* @param {Array} controlPoints
* @returns {Array}
*/
cc.cloneControlPoints = function (controlPoints) {
var newArray = [];
for (var i = 0; i < controlPoints.length; i++)
newArray.push(cc.p(controlPoints[i].x, controlPoints[i].y));
return newArray;
};
cc.copyControlPoints = cc.cloneControlPoints;
/*
* returns a point from the array
* @method getControlPointAt
@@ -111,20 +81,20 @@ cc.getControlPointAt = function (controlPoints, pos) {
return controlPoints[p];
};
/*
* reverse the current control point array inline, without generating a new one <br />
* @method reverseControlPointsInline
* @param {Array} controlPoints
*/
cc.reverseControlPointsInline = function (controlPoints) {
var len = controlPoints.length;
var mid = 0 | (len / 2);
for (var i = 0; i < mid; ++i) {
var temp = controlPoints[i];
controlPoints[i] = controlPoints[len - i - 1];
controlPoints[len - i - 1] = temp;
function reverseControlPoints (controlPoints) {
var newArray = [];
for (var i = controlPoints.length - 1; i >= 0; i--) {
newArray.push(cc.p(controlPoints[i].x, controlPoints[i].y));
}
};
return newArray;
}
function cloneControlPoints (controlPoints) {
var newArray = [];
for (var i = 0; i < controlPoints.length; i++)
newArray.push(cc.p(controlPoints[i].x, controlPoints[i].y));
return newArray;
}
/*
@@ -157,15 +127,6 @@ cc.CardinalSplineTo = cc.ActionInterval.extend({
tension !== undefined && this.initWithDuration(duration, points, tension);
},
/*
* initializes the action with a duration and an array of points
* @method initWithDuration
* @param {Number} duration
* @param {Array} points array of control points
* @param {Number} tension
*
* @return {Boolean}
*/
initWithDuration:function (duration, points, tension) {
if(!points || points.length === 0)
throw new Error("Invalid configuration. It must at least have one control point");
@@ -180,7 +141,7 @@ cc.CardinalSplineTo = cc.ActionInterval.extend({
clone:function () {
var action = new cc.CardinalSplineTo();
action.initWithDuration(this._duration, cc.copyControlPoints(this._points), this._tension);
action.initWithDuration(this._duration, cloneControlPoints(this._points), this._tension);
return action;
},
@@ -234,7 +195,7 @@ cc.CardinalSplineTo = cc.ActionInterval.extend({
},
reverse:function () {
var reversePoints = cc.reverseControlPoints(this._points);
var reversePoints = reverseControlPoints(this._points);
return cc.cardinalSplineTo(this._duration, reversePoints, this._tension);
},
@@ -257,7 +218,7 @@ cc.CardinalSplineTo = cc.ActionInterval.extend({
return this._points;
},
/*
/**
* Points setter
* @method setPoints
* @param {Array} points
@@ -329,7 +290,7 @@ cc.CardinalSplineBy = cc.CardinalSplineTo.extend({
}
// convert to "diffs" to "reverse absolute"
var reverseArray = cc.reverseControlPoints(copyConfig);
var reverseArray = reverseControlPoints(copyConfig);
// 1st element (which should be 0,0) should be here too
p = reverseArray[ reverseArray.length - 1 ];
@@ -351,7 +312,7 @@ cc.CardinalSplineBy = cc.CardinalSplineTo.extend({
return cc.cardinalSplineBy(this._duration, reverseArray, this._tension);
},
/*
/**
* update position of target
* @method updatePosition
* @param {Vec2} newPos
@@ -365,14 +326,9 @@ cc.CardinalSplineBy = cc.CardinalSplineTo.extend({
this.target.setPosition(posX, posY);
},
/*
* returns a new clone of the action
* @method clone
* @returns {CardinalSplineBy}
*/
clone:function () {
var a = new cc.CardinalSplineBy();
a.initWithDuration(this._duration, cc.copyControlPoints(this._points), this._tension);
a.initWithDuration(this._duration, cloneControlPoints(this._points), this._tension);
return a;
}
});
@@ -412,19 +368,13 @@ cc.CatmullRomTo = cc.CardinalSplineTo.extend({
points && this.initWithDuration(dt, points);
},
/*
* Initializes the action with a duration and an array of points
* @method initWithDuration
* @param {Number} dt
* @param {Array} points
*/
initWithDuration:function (dt, points) {
return cc.CardinalSplineTo.prototype.initWithDuration.call(this, dt, points, 0.5);
},
clone:function () {
var action = new cc.CatmullRomTo();
action.initWithDuration(this._duration, cc.copyControlPoints(this._points));
action.initWithDuration(this._duration, cloneControlPoints(this._points));
return action;
}
});
@@ -466,20 +416,13 @@ cc.CatmullRomBy = cc.CardinalSplineBy.extend({
points && this.initWithDuration(dt, points);
},
/*
* initializes the action with a duration and an array of points
*
* @method initWithDuration
* @param {Number} dt
* @param {Array} points
*/
initWithDuration:function (dt, points) {
return cc.CardinalSplineTo.prototype.initWithDuration.call(this, dt, points, 0.5);
},
clone:function () {
var action = new cc.CatmullRomBy();
action.initWithDuration(this._duration, cc.copyControlPoints(this._points));
action.initWithDuration(this._duration, cloneControlPoints(this._points));
return action;
}
});
-166
View File
@@ -1,166 +0,0 @@
/****************************************************************************
Copyright (c) 2008-2010 Ricardo Quesada
Copyright (c) 2011-2012 cocos2d-x.org
Copyright (c) 2013-2014 Chukong Technologies Inc.
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
/**
*
* @class ActionTweenDelegate
* @extends _Class
*/
cc.ActionTweenDelegate = cc._Class.extend(/** @lends cc.ActionTweenDelegate */{
/**
* Update Tween Action.
* @param value
* @param key
*/
updateTweenAction:function(value, key){}
});
/**
* cc.ActionTween
* cc.ActionTween is an action that lets you update any property of an object.
*
* @class
* @extends ActionInterval
* @example
* //For example, if you want to modify the "width" property of a target from 200 to 300 in 2 seconds, then:
* var modifyWidth = cc.actionTween(2,"width",200,300)
* target.runAction(modifyWidth);
*
* //Another example: cc.ScaleTo action could be rewriten using cc.PropertyAction:
* // scaleA and scaleB are equivalents
* var scaleA = cc.scaleTo(2,3);
* var scaleB = cc.actionTween(2,"scale",1,3);
* @param {Number} duration
* @param {String} key
* @param {Number} from
* @param {Number} to
*/
cc.ActionTween = cc.ActionInterval.extend(/** @lends cc.ActionTween */{
key:"",
from:0,
to:0,
delta:0,
/**
* Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. <br />
* Creates an initializes the action with the property name (key), and the from and to parameters.
* @param {Number} duration
* @param {String} key
* @param {Number} from
* @param {Number} to
*/
ctor:function(duration, key, from, to){
cc.ActionInterval.prototype.ctor.call(this);
this.key = "";
to !== undefined && this.initWithDuration(duration, key, from, to);
},
/**
* initializes the action with the property name (key), and the from and to parameters.
* @param {Number} duration
* @param {String} key
* @param {Number} from
* @param {Number} to
* @return {Boolean}
*/
initWithDuration:function (duration, key, from, to) {
if (cc.ActionInterval.prototype.initWithDuration.call(this, duration)) {
this.key = key;
this.to = to;
this.from = from;
return true;
}
return false;
},
/**
* Start this tween with target.
* @param {ActionTweenDelegate} target
*/
startWithTarget:function (target) {
if(!target || !target.updateTweenAction)
throw new Error("cc.ActionTween.startWithTarget(): target must be non-null, and target must implement updateTweenAction function");
cc.ActionInterval.prototype.startWithTarget.call(this, target);
this.delta = this.to - this.from;
},
/**
* Called once per frame. Time is the number of seconds of a frame interval.
*
* @param {Number} dt
*/
update:function (dt) {
this.target.updateTweenAction(this.to - this.delta * (1 - dt), this.key);
},
/**
* returns a reversed action.
* @return {ActionTween}
*/
reverse:function () {
return new cc.ActionTween(this.duration, this.key, this.to, this.from);
},
/**
* to copy object with deep copy.
* returns a clone of action.
*
* @return {ActionTween}
*/
clone:function(){
var action = new cc.ActionTween();
action.initWithDuration(this._duration, this.key, this.from, this.to);
return action;
}
});
/**
* Creates an initializes the action with the property name (key), and the from and to parameters.
* @method
* @param {Number} duration
* @param {String} key
* @param {Number} from
* @param {Number} to
* @return {ActionTween}
*/
cc.actionTween = function (duration, key, from, to) {
return new cc.ActionTween(duration, key, from, to);
};
/**
* Please use cc.actionTween instead.
* Creates an initializes the action with the property name (key), and the from and to parameters.
* @static
* @deprecated since v3.0 <br /> Please use cc.actionTween instead.
* @param {Number} duration
* @param {String} key
* @param {Number} from
* @param {Number} to
* @return {ActionTween}
*/
cc.ActionTween.create = cc.actionTween;
+2 -1
View File
@@ -1,4 +1,5 @@
require('./CCAction.js');
require('./CCActionInterval.js');
require('./CCActionInstant.js');
require('./CCActionEase.js');
require('./CCActionEase.js');
require('./CCActionCatmullRom.js');
+1 -1
View File
@@ -86,7 +86,7 @@ var AnimationClip = cc.Class({
* !#en Crate clip with a set of sprite frames
* !#zh 使用一组序列帧图片来创建动画剪辑
* @method createWithSpriteFrames
* @param {[cc.SpriteFrame]} spriteFrames
* @param {[SpriteFrame]} spriteFrames
* @param {Number} sample
* @return {AnimationClip}
* @example
+8 -4
View File
@@ -389,8 +389,12 @@ cc.Director = Class.extend(/** @lends cc.Director# */{
getZEye: null,
/**
* !#en Pause the director's ticker.
* !#zh 暂停正在运行的场景,该暂停只会停止 Scheduler,但是不会停止渲染和 UI 响应。
* !#en Pause the director's ticker, only involve the game logic execution.
* It won't pause the rendering process nor the event manager.
* If you want to pause the entier game including rendering, audio and event,
* please use {{#crossLink "Game.pause"}}cc.game.pause{{/crossLink}}
* !#zh 暂停正在运行的场景,该暂停只会停止游戏逻辑执行,但是不会停止渲染和 UI 响应。
* 如果想要更彻底得暂停游戏,包含渲染,音频和事件,请使用 {{#crossLink "Game.pause"}}cc.game.pause{{/crossLink}}。
* @method pause
*/
pause: function () {
@@ -818,8 +822,8 @@ cc.Director = Class.extend(/** @lends cc.Director# */{
},
/**
* !#en Resume director after pause, if the current scene is not paused, nothing will happen.
* !#zh 恢复暂停场景,恢复 Scheduler,如果当前场景没有暂停将没任何事情发生。
* !#en Resume game logic execution after pause, if the current scene is not paused, nothing will happen.
* !#zh 恢复暂停场景的游戏逻辑,如果当前场景没有暂停将没任何事情发生。
* @method resume
*/
resume: function () {
+27 -6
View File
@@ -29,6 +29,8 @@ if (!(CC_EDITOR && Editor.isMainProcess)) {
View = require('./platform/CCView');
}
var _isMusicPlaying = false;
/**
* !#en An object to boot the game.
* !#zh 包含游戏主体信息并负责驱动游戏的游戏对象。
@@ -241,15 +243,26 @@ var game = /** @lends cc.game# */{
},
/**
* !#en Pause the game,pause main loop.
* !#zh 暂停游戏,暂停的是整个主循环。
* !#en Pause the game main loop. This will pause:
* game logic execution, rendering process, event manager, background music and all audio effects.
* This is different with cc.director.pause which only pause the game logic execution.
* !#zh 暂停游戏主循环。包含:游戏逻辑,渲染,事件处理,背景音乐和所有音效。这点和只暂停游戏逻辑的 cc.director.pause 不同。
* @method pause
*/
pause: function () {
if (this._paused) return;
this._paused = true;
// Pause audio engine
cc.audioEngine && cc.audioEngine._pausePlaying();
if (cc.audioEngine) {
_isMusicPlaying = cc.audioEngine.isMusicPlaying();
cc.audioEngine.stopAllEffects();
cc.audioEngine.pauseMusic();
}
// Pause event
var scene = cc.director.getScene() || cc.director.getRunningScene();
if (scene) {
cc.eventManager.pauseTarget(scene, true);
}
// Pause main loop
if (this._intervalId)
window.cancelAnimationFrame(this._intervalId);
@@ -257,15 +270,23 @@ var game = /** @lends cc.game# */{
},
/**
* !#en Resume the game from pause.
* !#zh 继续游戏,继续的是整个主循环。
* !#en Resume the game from pause. This will resume:
* game logic execution, rendering process, event manager, background music and all audio effects.
* !#zh 恢复游戏主循环。包含:游戏逻辑,渲染,事件处理,背景音乐和所有音效。
* @method resume
*/
resume: function () {
if (!this._paused) return;
this._paused = false;
// Resume audio engine
cc.audioEngine && cc.audioEngine._resumePlaying();
if (cc.audioEngine && _isMusicPlaying) {
cc.audioEngine.resumeMusic();
}
// Resume event
var scene = cc.director.getScene() || cc.director.getRunningScene();
if (scene) {
cc.eventManager.resumeTarget(scene, true);
}
// Resume main loop
this._runMainLoop();
},
+8 -3
View File
@@ -1264,17 +1264,22 @@ var Node = cc.Class({
/**
* !#en
* Executes an action, and returns the action that is executed.<br/>
* The node becomes the action's target. Refer to cc.Action's getTarget()<br/>
* Calling runAction while the node is not active won't have any effect.
* The node becomes the action's target. Refer to cc.Action's getTarget() <br/>
* Calling runAction while the node is not active won't have any effect. <br/>
* Note:You shouldn't modify the action after runAction, that won't take any effect.<br/>
* if you want to modify, when you define action plus.
* !#zh
* 执行并返回该执行的动作。该节点将会变成动作的目标。<br/>
* 调用 runAction 时,节点自身处于不激活状态将不会有任何效果。
* 调用 runAction 时,节点自身处于不激活状态将不会有任何效果。<br/>
* 注意:你不应该修改 runAction 后的动作,将无法发挥作用,如果想进行修改,请在定义 action 时加入。
* @method runAction
* @param {Action} action
* @return {Action} An Action pointer
* @example
* var action = cc.scaleTo(0.2, 1, 0.6);
* node.runAction(action);
* node.runAction(action).repeatForever(); // fail
* node.runAction(action.repeatForever()); // right
*/
runAction: function (action) {
if (!this.active)
+2 -2
View File
@@ -59,7 +59,7 @@ var SpriteAtlas = cc.Class({
* Returns the sprite frame correspond to the given key in sprite atlas.
* @method getSpriteFrame
* @param {String} key
* @returns {cc.SpriteFrame}
* @returns {SpriteFrame}
*/
getSpriteFrame: function (key) {
return this._spriteFrames[key];
@@ -68,7 +68,7 @@ var SpriteAtlas = cc.Class({
/**
* Returns the sprite frames in sprite atlas.
* @method getSpriteFrames
* @returns {[cc.SpriteFrame]}
* @returns {[SpriteFrame]}
*/
getSpriteFrames: function () {
var frames = [];
@@ -208,10 +208,10 @@ _ccsg.Node.RenderCmd.prototype = {
skx = 99999999;
if (sky === Infinity)
sky = 99999999;
t.a = a + b * sky;
t.b = b + a * sky;
t.c = c + d * skx;
t.d = d + c * skx;
t.a = a + c * sky;
t.b = b + d * sky;
t.c = c + a * skx;
t.d = d + b * skx;
}
if (appX || appY) {
@@ -449,21 +449,21 @@ _ccsg.Node.RenderCmd.prototype = {
var colorDirty = locFlag & dirtyFlags.colorDirty,
opacityDirty = locFlag & dirtyFlags.opacityDirty;
if(locFlag & dirtyFlags.contentDirty) {
if (locFlag & dirtyFlags.contentDirty) {
this._notifyRegionStatus && this._notifyRegionStatus(_ccsg.Node.CanvasRenderCmd.RegionStatus.Dirty);
this._dirtyFlag &= ~dirtyFlags.contentDirty;
}
if(colorDirty)
if (colorDirty)
this._updateDisplayColor();
if(opacityDirty)
if (opacityDirty)
this._updateDisplayOpacity();
if(colorDirty || opacityDirty)
if (colorDirty || opacityDirty)
this._updateColor();
if(locFlag & dirtyFlags.transformDirty){
if (locFlag & dirtyFlags.transformDirty) {
//update the transform
this.transform(this.getParentRenderCmd(), true);
this._dirtyFlag &= ~dirtyFlags.transformDirty;
@@ -487,7 +487,7 @@ _ccsg.Node.RenderCmd.prototype = {
//update the opacity
this._syncDisplayOpacity();
if(colorDirty || opacityDirty)
if (colorDirty || opacityDirty)
this._updateColor();
if (transformDirty)
+36 -5
View File
@@ -156,7 +156,7 @@ function visitNode (node) {
var widget = node._widget;
if (widget) {
alignToParent(node, widget);
if ((!CC_EDITOR || _Scene.AnimUtils.curAnimState) && widget.isAlignOnce) {
if ((!CC_EDITOR || animationState.animatedSinceLastFrame) && widget.isAlignOnce) {
widget.enabled = false;
}
else {
@@ -172,7 +172,34 @@ function visitNode (node) {
}
}
if (CC_EDITOR) {
var animationState = {
previewing: false,
time: 0,
animatedSinceLastFrame: false,
};
}
function refreshScene () {
// check animation editor
if (CC_EDITOR && window._Scene && _Scene.AnimUtils) {
var nowPreviewing = !!_Scene.AnimUtils.curAnimState;
if (nowPreviewing !== animationState.previewing) {
animationState.previewing = nowPreviewing;
if (nowPreviewing) {
animationState.animatedSinceLastFrame = true;
animationState.time = _Scene.AnimUtils.curAnimState.time;
}
else {
animationState.animatedSinceLastFrame = false;
}
}
else if (nowPreviewing && animationState.time !== _Scene.AnimUtils.curAnimState.time) {
animationState.animatedSinceLastFrame = true;
animationState.time = _Scene.AnimUtils.curAnimState.time;
}
}
var scene = cc.director.getScene();
if (scene) {
widgetManager.isAligning = true;
@@ -180,14 +207,14 @@ function refreshScene () {
widgetManager._nodesWithWidget.length = 0;
visitNode(scene);
widgetManager._nodesOrderDirty = false;
} else {
}
else {
var i, node, nodes = widgetManager._nodesWithWidget, len = nodes.length;
if (CC_EDITOR && _Scene.AnimUtils.curAnimState) {
// always check isAlignOnce because animation mode maybe changed
if (CC_EDITOR && window._Scene && _Scene.AnimUtils && _Scene.AnimUtils.curAnimState) {
for (i = len - 1; i >= 0; i--) {
node = nodes[i];
var widget = node._widget;
if (widget.isAlignOnce) {
if (widget.isAlignOnce && animationState.animatedSinceLastFrame) {
// widget contains in _nodesWithWidget should aligned at least once
widget.enabled = false;
}
@@ -206,6 +233,10 @@ function refreshScene () {
widgetManager.isAligning = false;
}
// check animation editor
if (CC_EDITOR) {
animationState.animatedSinceLastFrame = false;
}
}
var adjustWidgetToAllowMovingInEditor = CC_EDITOR && function (event) {
+1 -1
View File
@@ -400,7 +400,7 @@ cc.js.getset(CollisionManager.prototype, 'enabledDebugDraw',
}
else if (!value && this._enabledDebugDraw) {
this._debugDrawer.clear();
cc.director.getScene()._sgNode.removeChild(this._debugDrawer);
this._debugDrawer.removeFromParent(false);
cc.director.off(cc.Director.EVENT_AFTER_SCENE_LAUNCH, this.onSceneLaunched, this);
}
+6 -7
View File
@@ -166,17 +166,16 @@ var Animation = cc.Class({
}
},
__preload: function () {
if (CC_EDITOR || !this.enabled) return;
onEnable: function () {
if (!CC_EDITOR && this.playOnLoad && this._defaultClip) {
this.playOnLoad = false;
if (this.playOnLoad && this._defaultClip) {
var state = this.getAnimationState(this._defaultClip.name);
this._animator.playState(state);
}
},
onEnable: function () {
this.resume();
else {
this.resume();
}
},
onDisable: function () {
+1 -1
View File
@@ -448,7 +448,7 @@ var Button = cc.Class({
},
_onMouseMoveIn: function () {
if (this._pressed || !this.interactable || !this.enabledInHierarchy) return;
if (!this.hoverSprite || this._pressed || !this.interactable || !this.enabledInHierarchy) return;
if (!this._hovered) {
this._hovered = true;
@@ -80,7 +80,7 @@ cc.Component.EventHandler = cc.Class({
/**
* @method emitEvents
* @param {Component.EventHandler[]} events
* @param {Any} ...params
* @param {any} ...params
* @statics
*/
emitEvents: function(events) {
-9
View File
@@ -379,15 +379,6 @@ var Sprite = cc.Class({
SizeMode: SizeMode,
},
/**
* !#en Sets whether the sprite is visible or not.
* !#zh 设置精灵是否可见
* @method setVisible
* @param {Boolean} visible
* @override
* @example
* sprite.setVisible(false);
*/
setVisible: function (visible) {
this.enabled = visible;
},
+1
View File
@@ -163,6 +163,7 @@ cc.Touch = cc._Class.extend(/** @lends cc.Touch# */{
this._id = id;
if(!this._startPointCaptured){
this._startPoint = cc.p(this._point);
cc.view._convertPointWithScale(this._startPoint);
this._startPointCaptured = true;
}
},
+4 -1
View File
@@ -358,6 +358,7 @@ _ccsg.Label = _ccsg.Node.extend({
if (!extName) {
this._fontHandle = fontHandle;
this._labelType = _ccsg.Label.Type.SystemFont;
this._blendFunc = cc.BlendFunc._alphaPremultiplied();
this._notifyLabelSkinDirty();
this.emit('load');
return;
@@ -365,10 +366,12 @@ _ccsg.Label = _ccsg.Node.extend({
if (extName === ".ttf") {
this._labelType = _ccsg.Label.Type.TTF;
this._blendFunc = cc.BlendFunc._alphaPremultiplied();
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._initBMFontWithString(this._string, fontHandle, textureUrl);
}
this._notifyLabelSkinDirty();
@@ -484,7 +487,7 @@ _ccsg.Label = _ccsg.Node.extend({
if (CC_EDITOR) {
this._updateLabel();
} else {
this._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.textDirty);
this._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.textDirty|_ccsg.Node._dirtyFlags.contentDirty);
}
},
_createRenderCmd: function() {
@@ -39,6 +39,11 @@
if (opacityDirty)
this._updateDisplayOpacity();
if(locFlag & dirtyFlags.contentDirty) {
this._notifyRegionStatus && this._notifyRegionStatus(_ccsg.Node.CanvasRenderCmd.RegionStatus.Dirty);
this._dirtyFlag &= ~dirtyFlags.contentDirty;
}
if (colorDirty || opacityDirty || (locFlag & flags.textDirty)) {
this._notifyRegionStatus && this._notifyRegionStatus(_ccsg.Node.CanvasRenderCmd.RegionStatus.Dirty);
this._rebuildLabelSkin();
+2 -11
View File
@@ -104,17 +104,8 @@ proto.uploadData = function (f32buffer, ui32buffer, vertexDataOffset) {
return 0;
// Fill in vertex data with quad information (4 vertices for sprite)
var opacity = this._displayedOpacity;
var r = this._displayedColor.r,
g = this._displayedColor.g,
b = this._displayedColor.b;
if (node._opacityModifyRGB) {
var a = opacity / 255;
r *= a;
g *= a;
b *= a;
}
this._color[0] = ((opacity<<24) | (b<<16) | (g<<8) | r);
// Use 255 because color has been set when baking label
this._color[0] = ((this._displayedOpacity<<24) | (255<<16) | (255<<8) | 255);
var z = node._vertexZ;
var vertices = this._vertices;
+18 -20
View File
@@ -927,32 +927,30 @@ var View = cc._Class.extend({
return this._isRotated ? {x: this._viewPortRect.width - y, y: x} : {x: x, y: y};
},
_convertMouseToLocationInView: function(point, relatedPos) {
var locViewPortRect = this._viewPortRect, _t = this;
point.x = ((_t._devicePixelRatio * (point.x - relatedPos.left)) - locViewPortRect.x) / _t._scaleX;
point.y = (_t._devicePixelRatio * (relatedPos.top + relatedPos.height - point.y) - locViewPortRect.y) / _t._scaleY;
_convertMouseToLocationInView: function (point, relatedPos) {
var viewport = this._viewPortRect, _t = this;
point.x = ((_t._devicePixelRatio * (point.x - relatedPos.left)) - viewport.x) / _t._scaleX;
point.y = (_t._devicePixelRatio * (relatedPos.top + relatedPos.height - point.y) - viewport.y) / _t._scaleY;
},
_convertTouchesWithScale: function(touches){
var locViewPortRect = this._viewPortRect, locScaleX = this._scaleX, locScaleY = this._scaleY,
selTouch, selPoint, selPrePoint, selStartPoint;
for( var i = 0; i < touches.length; i ++){
_convertPointWithScale: function (point) {
var viewport = this._viewPortRect;
point.x = (point.x - viewport.x) / this._scaleX;
point.y = (point.y - viewport.y) / this._scaleY;
},
_convertTouchesWithScale: function (touches) {
var viewport = this._viewPortRect, scaleX = this._scaleX, scaleY = this._scaleY,
selTouch, selPoint, selPrePoint;
for( var i = 0; i < touches.length; i++){
selTouch = touches[i];
hasStartPoint = selTouch._startPointCaptured;
selPoint = selTouch._point;
selPrePoint = selTouch._prevPoint;
selPoint.x = (selPoint.x - locViewPortRect.x) / locScaleX;
selPoint.y = (selPoint.y - locViewPortRect.y) / locScaleY;
selPrePoint.x = (selPrePoint.x - locViewPortRect.x) / locScaleX;
selPrePoint.y = (selPrePoint.y - locViewPortRect.y) / locScaleY;
if (!hasStartPoint) {
selStartPoint = selTouch._startPoint;
selStartPoint.x = selPoint.x;
selStartPoint.y = selPoint.y;
selTouch._startPointCaptured = true;
}
selPoint.x = (selPoint.x - viewport.x) / scaleX;
selPoint.y = (selPoint.y - viewport.y) / scaleY;
selPrePoint.x = (selPrePoint.x - viewport.x) / scaleX;
selPrePoint.y = (selPrePoint.y - viewport.y) / scaleY;
}
}
});
+6 -5
View File
@@ -467,12 +467,13 @@ var _Deserializer = (function () {
* @return {object} the main data(asset)
*/
cc.deserialize = function (data, result, options) {
var classFinder = (options && options.classFinder) || JS._getClassById;
options = options || {};
var classFinder = options.classFinder || JS._getClassById;
// 启用 createAssetRefs 后,如果有 url 属性则会被统一强制设置为 { uuid: 'xxx' },必须后面再特殊处理
var createAssetRefs = (options && options.createAssetRefs) || cc.sys.platform === cc.sys.EDITOR_CORE;
var target = CC_DEV && (options && options.target);
var customEnv = options && options.customEnv;
var ignoreEditorOnly = options && options.ignoreEditorOnly;
var createAssetRefs = options.createAssetRefs || cc.sys.platform === cc.sys.EDITOR_CORE;
var target = CC_DEV && options.target;
var customEnv = options.customEnv;
var ignoreEditorOnly = options.ignoreEditorOnly;
if (CC_EDITOR && Buffer.isBuffer(data)) {
data = data.toString();
+57 -60
View File
@@ -484,28 +484,6 @@ var fillQuadGeneratorBar = {
sprite._uvs = uvs;
}
//build quads
if (webgl) {
vertices[0] = l * wt.a + b * wt.c + wt.tx;
vertices[1] = l * wt.b + b * wt.d + wt.ty;
vertices[2] = r * wt.a + b * wt.c + wt.tx;
vertices[3] = r * wt.b + b * wt.d + wt.ty;
vertices[4] = l * wt.a + t * wt.c + wt.tx;
vertices[5] = l * wt.b + t * wt.d + wt.ty;
vertices[6] = r * wt.a + t * wt.c + wt.tx;
vertices[7] = r * wt.b + t * wt.d + wt.ty;
}
else {
vertices[0] = l;
vertices[1] = b;
vertices[2] = r;
vertices[3] = b;
vertices[4] = l;
vertices[5] = t;
vertices[6] = r;
vertices[7] = t;
}
var quadUV = new Array(8);
if (!spriteFrame._rotated) {
quadUV[0] = quadUV[4] = ul;
@@ -533,13 +511,11 @@ var fillQuadGeneratorBar = {
var progressStart, progressEnd;
switch (fillType) {
case FillType.HORIZONTAL:
progressStart = vertices[0] + (vertices[2] - vertices[0]) * fillStart;
progressEnd = vertices[0] + (vertices[2] - vertices[0]) * fillEnd;
progressStart = l + (r - l) * fillStart;
progressEnd = l + (r - l) * fillEnd;
vertices[0] = progressStart;
vertices[2] = progressEnd;
vertices[4] = progressStart;
vertices[6] = progressEnd;
l = progressStart;
r = progressEnd;
uvs[0] = quadUV[0] + (quadUV[2] - quadUV[0]) * fillStart;
uvs[1] = quadUV[1];
@@ -551,13 +527,11 @@ var fillQuadGeneratorBar = {
uvs[7] = quadUV[7];
break;
case FillType.VERTICAL:
progressStart = vertices[1] + (vertices[5] - vertices[1]) * fillStart;
progressEnd = vertices[1] + (vertices[5] - vertices[1]) * fillEnd;
progressStart = b + (t - b) * fillStart;
progressEnd = b + (t - b) * fillEnd;
vertices[1] = progressStart;
vertices[3] = progressStart;
vertices[5] = progressEnd;
vertices[7] = progressEnd;
b = progressStart;
t = progressEnd;
uvs[0] = quadUV[0];
uvs[1] = quadUV[1] + (quadUV[5] - quadUV[1]) * fillStart;
@@ -572,6 +546,28 @@ var fillQuadGeneratorBar = {
cc.error('Unrecognized fill type in bar fill');
break;
}
//build vertices
if (webgl) {
vertices[0] = l * wt.a + b * wt.c + wt.tx;
vertices[1] = l * wt.b + b * wt.d + wt.ty;
vertices[2] = r * wt.a + b * wt.c + wt.tx;
vertices[3] = r * wt.b + b * wt.d + wt.ty;
vertices[4] = l * wt.a + t * wt.c + wt.tx;
vertices[5] = l * wt.b + t * wt.d + wt.ty;
vertices[6] = r * wt.a + t * wt.c + wt.tx;
vertices[7] = r * wt.b + t * wt.d + wt.ty;
} else{
vertices[0] = l;
vertices[1] = b;
vertices[2] = r;
vertices[3] = b;
vertices[4] = l;
vertices[5] = t;
vertices[6] = r;
vertices[7] = t;
}
sprite._vertCount = 4;
cornerId[0] = 0;
@@ -603,8 +599,7 @@ var fillQuadGeneratorRadial = {
while (fillStart < 0.0) fillStart += 1.0;
var cx = fillCenter.x * contentSize.width,
cy = fillCenter.y * contentSize.height;
var center = cc.v2( webgl ? cx * wt.a + cy * wt.c + wt.tx : cx,
webgl ? cx * wt.b + cy * wt.d + wt.ty : cy);
var center = cc.v2( cx, cy);
fillStart *= Math.PI * 2;
fillRange *= Math.PI * 2;
@@ -697,7 +692,7 @@ var fillQuadGeneratorRadial = {
}
//all in
if(fillRange >= Math.PI * 2) {
this._generateTriangle(offset, center, this._vertPos[triangle[0]], this._vertPos[triangle[1]]);
this._generateTriangle(wt, offset, center, this._vertPos[triangle[0]], this._vertPos[triangle[1]]);
offset += 6;
count += 3;
continue;
@@ -715,10 +710,10 @@ var fillQuadGeneratorRadial = {
} else if (startAngle >= fillStart) {
if(endAngle >= fillEnd) {
//startAngle to fillEnd
this._generateTriangle(offset, center, this._vertPos[triangle[0]], this._intersectPoint_2[triangleIndex]);
this._generateTriangle(wt, offset, center, this._vertPos[triangle[0]], this._intersectPoint_2[triangleIndex]);
} else {
//startAngle to endAngle
this._generateTriangle(offset, center, this._vertPos[triangle[0]], this._vertPos[triangle[1]]);
this._generateTriangle(wt, offset, center, this._vertPos[triangle[0]], this._vertPos[triangle[1]]);
}
offset += 6;
count += 3;
@@ -728,12 +723,12 @@ var fillQuadGeneratorRadial = {
//all out
} else if(endAngle <= fillEnd) {
//fillStart to endAngle
this._generateTriangle(offset, center, this._intersectPoint_1[triangleIndex], this._vertPos[triangle[1]]);
this._generateTriangle(wt, offset, center, this._intersectPoint_1[triangleIndex], this._vertPos[triangle[1]]);
offset += 6;
count += 3;
} else {
//fillStart to fillEnd
this._generateTriangle(offset, center, this._intersectPoint_1[triangleIndex], this._intersectPoint_2[triangleIndex]);
this._generateTriangle(wt, offset, center, this._intersectPoint_1[triangleIndex], this._intersectPoint_2[triangleIndex]);
offset += 6;
count += 3;
}
@@ -751,7 +746,7 @@ var fillQuadGeneratorRadial = {
cornerId[3] = 6;
},
_generateTriangle: function(offset, vert0, vert1, vert2) {
_generateTriangle: function(wt, offset, vert0, vert1, vert2) {
var rawVerts = this.rawVerts;
var rawUvs = this.rawUvs;
var vertices = this.outVerts;
@@ -763,12 +758,22 @@ var fillQuadGeneratorRadial = {
// tl: 0, 1
// bl: 2, 3
// tr: 4, 5
vertices[offset] = vert0.x;
vertices[offset+1] = vert0.y;
vertices[offset+2] = vert1.x;
vertices[offset+3] = vert1.y;
vertices[offset+4] = vert2.x;
vertices[offset+5] = vert2.y;
if(webgl) {
vertices[offset] = vert0.x * wt.a + vert0.y * wt.c + wt.tx;
vertices[offset+1] = vert0.x * wt.b + vert0.y * wt.d + wt.ty;
vertices[offset+2] = vert1.x * wt.a + vert1.y * wt.c + wt.tx;
vertices[offset+3] = vert1.x * wt.b + vert1.y * wt.d + wt.ty;
vertices[offset+4] = vert2.x * wt.a + vert2.y * wt.c + wt.tx;
vertices[offset+5] = vert2.x * wt.b + vert2.y * wt.d + wt.ty;
} else {
vertices[offset] = vert0.x;
vertices[offset+1] = vert0.y;
vertices[offset+2] = vert1.x;
vertices[offset+3] = vert1.y;
vertices[offset+4] = vert2.x;
vertices[offset+5] = vert2.y;
}
progressX = (vert0.x - v0x) / (v1x - v0x);
progressY = (vert0.y - v0y) / (v1y - v0y);
@@ -879,18 +884,10 @@ var fillQuadGeneratorRadial = {
x3 = contentSize.width;
y3 = contentSize.height;
if (webgl) {
this._vertices[0].x = x0 * wt.a + y0 * wt.c + wt.tx;
this._vertices[0].y = x0 * wt.b + y0 * wt.d + wt.ty;
this._vertices[1].x = x3 * wt.a + y3 * wt.c + wt.tx;
this._vertices[1].y = x3 * wt.b + y3 * wt.d + wt.ty;
}
else {
this._vertices[0].x = x0;
this._vertices[0].y = y0;
this._vertices[1].x = x3;
this._vertices[1].y = y3;
}
this._vertices[0].x = x0;
this._vertices[0].y = y0;
this._vertices[1].x = x3;
this._vertices[1].y = y3;
},
_calculateUVs : function (spriteFrame) {
+3
View File
@@ -48,6 +48,9 @@ if (ENABLE_GL_STATE_CACHE) {
var _currBuffers = {};
// IE 10 WebGLRenderingContext does not exist
if (!window.WebGLRenderingContext) return;
WebGLRenderingContext.prototype.glBindBuffer = WebGLRenderingContext.prototype.bindBuffer;
WebGLRenderingContext.prototype.bindBuffer = function (target, buffer) {
if (_currBuffers[target] !== buffer) {
+4 -4
View File
@@ -326,7 +326,7 @@ _ccsg.TMXLayer = _ccsg.Node.extend(/** @lends _ccsg.TMXLayer# */{
* Tile set information for the layer
* @return {cc.TMXTilesetInfo}
*/
getTileset:function () {
getTileSet:function () {
return this.tileset;
},
@@ -334,7 +334,7 @@ _ccsg.TMXLayer = _ccsg.Node.extend(/** @lends _ccsg.TMXLayer# */{
* Tile set information for the layer
* @param {cc.TMXTilesetInfo} Var
*/
setTileset:function (Var) {
setTileSet:function (Var) {
this.tileset = Var;
},
@@ -439,7 +439,7 @@ _ccsg.TMXLayer = _ccsg.Node.extend(/** @lends _ccsg.TMXLayer# */{
return tile;
}
var z = Math.floor(pos.x) + Math.floor(pos.y) * this._layerSize.width;
var z = Math.floor(x) + Math.floor(y) * this._layerSize.width;
tile = this._spriteTiles[z];
// tile not created yet. create it
if (!tile) {
@@ -482,7 +482,7 @@ _ccsg.TMXLayer = _ccsg.Node.extend(/** @lends _ccsg.TMXLayer# */{
return null;
}
var idx = Math.floor(pos.x) + Math.floor(pos.y) * this._layerSize.width;
var idx = Math.floor(x) + Math.floor(y) * this._layerSize.width;
// Bits on the far end of the 32-bit global tile ID are used for tile flags
var tile = this.tiles[idx];
+10 -8
View File
@@ -46,14 +46,17 @@ proto.constructor = _ccsg.TMXLayer.CanvasRenderCmd;
proto.visit = function (parentCmd) {
var node = this._node, renderer = cc.renderer;
parentCmd = parentCmd || this.getParentRenderCmd();
if (parentCmd) {
this._curLevel = parentCmd._curLevel + 1;
}
this._propagateFlagsDown(parentCmd);
// quick return if not visible
if (!node._visible)
return;
parentCmd = parentCmd || this.getParentRenderCmd();
if (parentCmd)
this._curLevel = parentCmd._curLevel + 1;
if (isNaN(node._customZ)) {
node._vertexZ = renderer.assignedZ;
renderer.assignedZ += renderer.assignedZStep;
@@ -62,7 +65,7 @@ proto.visit = function (parentCmd) {
this._syncStatus(parentCmd);
// Visit children
var children = node._children, child, cmd,
var children = node._children, child,
spTiles = node._spriteTiles,
i, len = children.length;
if (len > 0) {
@@ -71,8 +74,7 @@ proto.visit = function (parentCmd) {
for (i = 0; i < len; i++) {
child = children[i];
if (child._localZOrder < 0) {
cmd = child._renderCmd;
cmd.visit(this);
child._renderCmd.visit(this);
}
else {
break;
@@ -87,7 +89,7 @@ proto.visit = function (parentCmd) {
child._vertexZ = renderer.assignedZ;
renderer.assignedZ += renderer.assignedZStep;
}
child._renderCmd.updateStatus(this, true);
child._renderCmd.updateStatus();
continue;
}
child._renderCmd.visit(this);
+7 -2
View File
@@ -32,10 +32,15 @@
*/
/**
* @property {Array} properties - Properties from the group. They can be added using tilemap editors
* Properties from the group. They can be added using tilemap editors.
* @property properties
* @type {Array}
*/
/**
* @property {String} groupName - Name of the group
* Name of the group
* @property groupName
* @type {String}
*/
cc.TMXObjectGroup = cc._Class.extend(/** @lends cc.TMXObjectGroup# */{
properties: null,
File diff suppressed because it is too large Load Diff
+2 -2
View File
@@ -205,6 +205,7 @@ cc.Node.prototype.runAction = function (action) {
action.release();
action._retained = false;
}
return action;
};
function getSGTarget (target) {
@@ -347,13 +348,12 @@ var actionUpdate = {
'JumpTo': syncPositionUpdate,
'JumpBy': syncPositionUpdate,
'Place': syncPositionUpdate,
'CardinalSplineTo': syncPositionUpdate,
'RotateTo': syncRotationUpdate,
'RotateBy': syncRotationUpdate,
'ScaleTo': syncScaleUpdate,
'ScaleBy': syncScaleUpdate,
'RemoveSelf': syncRemoveSelfUpdate,
'SkewTo': syncSkewUpdate,
'SkewBy': syncSkewUpdate,
'Blink': syncOpacityUpdate,
'FadeIn': syncOpacityUpdate,
'FadeOut': syncOpacityUpdate,
+8 -2
View File
@@ -259,6 +259,12 @@ cc.js.mixin(cc.game, {
}
});
cc.EventTarget.call(cc.game);
cc.js.addon(cc.game, cc.EventTarget.prototype);
cc.js.addon(cc.game, cc.EventTarget.prototype);
cc.eventManager.addCustomListener(cc.game.EVENT_HIDE, function () {
cc.game.emit(cc.game.EVENT_HIDE, cc.game);
});
cc.eventManager.addCustomListener(cc.game.EVENT_SHOW, function () {
cc.game.emit(cc.game.EVENT_SHOW, cc.game);
});
+1
View File
@@ -11,6 +11,7 @@
"test": "gulp test"
},
"devDependencies": {
"async": "1.5.2",
"browserify": "13.0.0",
"chalk": "1.1.0",
"del": "1.2.0",