mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-02 00:22:43 +08:00
@@ -6,7 +6,7 @@
|
||||
*/
|
||||
var SpriteAtlas = cc.Class({
|
||||
name: 'cc.SpriteAtlas',
|
||||
extends: cc.RawAsset,
|
||||
extends: cc.Asset,
|
||||
});
|
||||
|
||||
cc.SpriteAtlas = SpriteAtlas;
|
||||
|
||||
@@ -55,7 +55,7 @@ var SpriteRenderer = cc.Class({
|
||||
*/
|
||||
_atlas: {
|
||||
default: '',
|
||||
url: cc.SpriteAtlas,
|
||||
type: cc.SpriteAtlas,
|
||||
editorOnly: true,
|
||||
visible: true
|
||||
},
|
||||
@@ -77,18 +77,9 @@ var SpriteRenderer = cc.Class({
|
||||
if (force) {
|
||||
this._sgNode._scale9Image = null;
|
||||
}
|
||||
|
||||
// Set atlas
|
||||
if (value._atlasUuid !== undefined) {
|
||||
var self = this;
|
||||
cc.AssetLibrary.queryAssetInfo(value._atlasUuid, function(err, url) {
|
||||
if (url) {
|
||||
self._atlas = url;
|
||||
}
|
||||
else {
|
||||
self._atlas = '';
|
||||
}
|
||||
});
|
||||
}
|
||||
this._applyAtlas(value);
|
||||
}
|
||||
this._applySprite(this._sgNode, lastSprite);
|
||||
// color cleared after reset texture, should reapply color
|
||||
@@ -452,6 +443,22 @@ var SpriteRenderer = cc.Class({
|
||||
this.node.off('size-changed', this._resized, this);
|
||||
},
|
||||
|
||||
_applyAtlas: CC_EDITOR && function ( sprite ) {
|
||||
// Set atlas
|
||||
if (sprite._atlasUuid !== undefined) {
|
||||
var self = this;
|
||||
cc.AssetLibrary.loadAsset(sprite._atlasUuid, function(err, asset) {
|
||||
if (!asset) {
|
||||
self._atlas = null;
|
||||
return;
|
||||
}
|
||||
self._atlas = asset;
|
||||
});
|
||||
} else {
|
||||
this._atlas = null;
|
||||
}
|
||||
},
|
||||
|
||||
_applyCapInset: function (node) {
|
||||
if (this._type === SpriteType.SLICED) {
|
||||
var node = node || this._sgNode;
|
||||
|
||||
@@ -470,7 +470,7 @@ cc.SpriteFrame = cc.Class(/** @lends cc.SpriteFrame# */{
|
||||
return {
|
||||
name: this._name,
|
||||
texture: uuid,
|
||||
atlas: exporting ? this._atlasUuid : undefined, // strip from json if exporting
|
||||
atlas: exporting ? undefined : this._atlasUuid, // strip from json if exporting
|
||||
rect: [rect.x, rect.y, rect.width, rect.height],
|
||||
offset: [offset.x, offset.y],
|
||||
originalSize: [size.width, size.height],
|
||||
|
||||
Reference in New Issue
Block a user