mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-01 07:42:38 +08:00
Merge branch 'master' of github.com:fireball-x/engine
This commit is contained in:
@@ -319,7 +319,9 @@ function sampleMotionPaths (motionPaths, data, duration, fps) {
|
||||
startRatioOffset = 0;
|
||||
}
|
||||
|
||||
addNewDatas(values[values.length - 1], DynamicAnimCurve.Linear, ratios[ratios.length - 1]);
|
||||
if (ratios[ratios.length - 1] !== newRatios[newRatios.length -1]) {
|
||||
addNewDatas(values[values.length - 1], DynamicAnimCurve.Linear, ratios[ratios.length - 1]);
|
||||
}
|
||||
}
|
||||
|
||||
if (CC_TEST) {
|
||||
|
||||
@@ -57,17 +57,41 @@ var Animation = cc.Class({
|
||||
},
|
||||
|
||||
properties: {
|
||||
/**
|
||||
* Animation will play the default clip when start game
|
||||
* @property _defaultClip
|
||||
* @type {AnimationClip}
|
||||
* @private
|
||||
*/
|
||||
|
||||
_defaultClip: {
|
||||
default: null,
|
||||
type: AnimationClip,
|
||||
tooltip: 'i18n:COMPONENT.animation.default_clip',
|
||||
visible: true
|
||||
},
|
||||
|
||||
/**
|
||||
* Animation will play the default clip when start game
|
||||
* @property defaultClip
|
||||
* @type {AnimationClip}
|
||||
*/
|
||||
defaultClip: {
|
||||
type: AnimationClip,
|
||||
get: function () {
|
||||
return this._defaultClip;
|
||||
},
|
||||
set: function (value) {
|
||||
var engine = cc.engine;
|
||||
if (!CC_EDITOR || (engine && engine.isPlaying)) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._defaultClip = value;
|
||||
|
||||
var clips = this._clips;
|
||||
|
||||
for (var i = 0, l = clips.length; i < l; i++) {
|
||||
if (equalClips(value, clips[i])) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
this.addClip(value);
|
||||
},
|
||||
tooltip: 'i18n:COMPONENT.animation.default_clip'
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -135,15 +159,6 @@ var Animation = cc.Class({
|
||||
// Public Methods
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Get the default clip. Animation will play the default clip when start game
|
||||
* @method getDefaultClip
|
||||
* @return {AnimationClip}
|
||||
*/
|
||||
getDefaultClip: function () {
|
||||
return this._defaultClip;
|
||||
},
|
||||
|
||||
/**
|
||||
* Get all the clips used in this animation
|
||||
* @method getClips
|
||||
|
||||
@@ -326,7 +326,7 @@ var Sprite = cc.Class({
|
||||
_applySpriteSize: function (node) {
|
||||
var node = node || this._sgNode;
|
||||
if (this._useOriginalSize) {
|
||||
var rect = this._spriteFrame.getOriginalSize();
|
||||
var rect = this._spriteFrame.getRect();
|
||||
node.setContentSize(cc.size(rect.width, rect.height));
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -380,11 +380,11 @@ ccui.Scale9Sprite = cc.Scale9Sprite = _ccsg.Node.extend({
|
||||
var resourceData = this._resourceData;
|
||||
leftWidth = this._insetLeft;
|
||||
rightWidth = this._insetRight;
|
||||
centerWidth = resourceData._originalSize.width - leftWidth - rightWidth;
|
||||
centerWidth = resourceData._spriteRect.width - leftWidth - rightWidth;
|
||||
|
||||
topHeight = this._insetTop;
|
||||
bottomHeight = this._insetBottom;
|
||||
centerHeight = resourceData._originalSize.height - topHeight - bottomHeight;
|
||||
centerHeight = resourceData._spriteRect.height - topHeight - bottomHeight;
|
||||
|
||||
var preferSize = this.getContentSize();
|
||||
var sizableWidth = preferSize.width - leftWidth - rightWidth;
|
||||
@@ -407,52 +407,6 @@ ccui.Scale9Sprite = cc.Scale9Sprite = _ccsg.Node.extend({
|
||||
y2 = y1 + sizableHeight;
|
||||
y3 = preferSize.height;
|
||||
|
||||
//apply trim
|
||||
var trimmedLeft = resourceData.getTrimmedLeft();
|
||||
var trimmedRight = resourceData.getTrimmedRight();
|
||||
var trimmedBottom = resourceData.getTrimmedBottom();
|
||||
var trimmedTop = resourceData.getTrimmedTop();
|
||||
|
||||
if(trimmedLeft >= 0 && trimmedLeft <= leftWidth) {
|
||||
x0 += trimmedLeft * xScale;
|
||||
} else if (trimmedLeft > leftWidth && trimmedLeft <= leftWidth + centerWidth) {
|
||||
x1 += (trimmedLeft - leftWidth) * sizableWidth / centerWidth;
|
||||
x0 = x1;
|
||||
} else {
|
||||
x2 += (trimmedLeft - (leftWidth + centerWidth)) * xScale;
|
||||
x0 = x1 = x2;
|
||||
}
|
||||
|
||||
if(trimmedRight >= 0 && trimmedRight <= rightWidth) {
|
||||
x3 -= trimmedRight * xScale;
|
||||
} else if( trimmedRight > rightWidth && trimmedRight <= rightWidth + centerWidth) {
|
||||
x2 -= (trimmedRight - rightWidth) * sizableWidth / centerWidth;
|
||||
x3 = x2;
|
||||
} else {
|
||||
x1 -= (trimmedRight - (rightWidth + centerWidth)) * xScale;
|
||||
x3 = x2 = x1;
|
||||
}
|
||||
|
||||
if(trimmedTop >= 0 && trimmedTop <= topHeight) {
|
||||
y3 -= trimmedTop * yScale;
|
||||
} else if(trimmedTop > topHeight && trimmedTop <= topHeight + centerHeight) {
|
||||
y2 -= (trimmedTop - topHeight) * sizableHeight / centerHeight;
|
||||
y3 = y2;
|
||||
} else {
|
||||
y1 -= (trimmedTop - (topHeight + centerHeight)) * yScale;
|
||||
y3 = y2 = y1;
|
||||
}
|
||||
|
||||
if(trimmedBottom >= 0 && trimmedBottom <= bottomHeight) {
|
||||
y0 += trimmedBottom * yScale;
|
||||
} else if(trimmedBottom > bottomHeight && trimmedBottom <= bottomHeight + centerHeight) {
|
||||
y1 += (trimmedBottom - bottomHeight) * sizableHeight / centerHeight;
|
||||
y0 = y1;
|
||||
} else {
|
||||
y2 += (trimmedBottom - (bottomHeight + centerHeight)) * yScale;
|
||||
y0 = y1 = y2;
|
||||
}
|
||||
|
||||
//apply contentscale factor
|
||||
x0 = x0 / cc.contentScaleFactor();
|
||||
x1 = x1 / cc.contentScaleFactor();
|
||||
@@ -482,59 +436,11 @@ ccui.Scale9Sprite = cc.Scale9Sprite = _ccsg.Node.extend({
|
||||
var topHeight, centerHeight, bottomHeight;
|
||||
leftWidth = this._insetLeft;
|
||||
rightWidth = this._insetRight;
|
||||
centerWidth = resourceData._originalSize.width - leftWidth - rightWidth;
|
||||
centerWidth = resourceData._spriteRect.width - leftWidth - rightWidth;
|
||||
|
||||
topHeight = this._insetTop;
|
||||
bottomHeight = this._insetBottom;
|
||||
centerHeight = resourceData._originalSize.height - topHeight - bottomHeight;
|
||||
|
||||
//apply trim
|
||||
var trimmedLeft = this._resourceData.getTrimmedLeft();
|
||||
var trimmedRight = this._resourceData.getTrimmedRight();
|
||||
var trimmedBottom = this._resourceData.getTrimmedBottom();
|
||||
var trimmedTop = this._resourceData.getTrimmedTop();
|
||||
//left
|
||||
leftWidth -= trimmedLeft;
|
||||
if(leftWidth < 0) {
|
||||
centerWidth += leftWidth;
|
||||
leftWidth = 0;
|
||||
}
|
||||
if (centerWidth < 0) {
|
||||
rightWidth += centerWidth;
|
||||
centerWidth = 0;
|
||||
}
|
||||
//right
|
||||
rightWidth -= trimmedRight;
|
||||
if(rightWidth <0) {
|
||||
centerWidth += rightWidth;
|
||||
rightWidth = 0;
|
||||
}
|
||||
if(centerWidth < 0) {
|
||||
leftWidth += centerWidth;
|
||||
centerWidth = 0;
|
||||
}
|
||||
|
||||
//bottom
|
||||
bottomHeight -= trimmedBottom;
|
||||
if(bottomHeight < 0) {
|
||||
centerHeight += bottomHeight;
|
||||
bottomHeight = 0;
|
||||
}
|
||||
if(centerHeight < 0) {
|
||||
topHeight += centerHeight;
|
||||
centerHeight = 0;
|
||||
}
|
||||
|
||||
//top
|
||||
topHeight -= trimmedTop;
|
||||
if(topHeight < 0) {
|
||||
centerHeight += topHeight;
|
||||
topHeight = 0;
|
||||
}
|
||||
if(centerHeight <0) {
|
||||
bottomHeight += centerHeight;
|
||||
centerHeight = 0;
|
||||
}
|
||||
centerHeight = resourceData._spriteRect.height - topHeight - bottomHeight;
|
||||
|
||||
var textureRect = cc.rectPointsToPixels(resourceData._spriteRect);
|
||||
|
||||
|
||||
@@ -478,8 +478,7 @@ test('Animation Component', function () {
|
||||
|
||||
animation.addClip(clip);
|
||||
|
||||
var clips = animation.getClips();
|
||||
strictEqual(clips.length, 1, 'should add 1 clip');
|
||||
strictEqual(animation.getClips().length, 1, 'should add 1 clip');
|
||||
|
||||
var state = animation.getAnimationState('test');
|
||||
strictEqual(state.clip, clip, 'should create state with clip');
|
||||
@@ -497,7 +496,7 @@ test('Animation Component', function () {
|
||||
strictEqual(entity.x, 100, 'target property should equals value in frame 10s');
|
||||
|
||||
animation.removeClip(clip);
|
||||
strictEqual(clips.length, 0, 'should remove clip');
|
||||
strictEqual(animation.getClips().length, 0, 'should remove clip');
|
||||
strictEqual(animation.getAnimationState('test'), null, 'should remove state');
|
||||
});
|
||||
|
||||
@@ -521,7 +520,6 @@ test('CCAnimation._updateClip', function () {
|
||||
};
|
||||
|
||||
animation.addClip(clip);
|
||||
animation.defaultClip = clip;
|
||||
animation._init();
|
||||
|
||||
animation.play('test');
|
||||
|
||||
Reference in New Issue
Block a user