Conversation
| if (this.font.spriteFrame) { | ||
| sgNode = this._sgNode = new _ccsg.Label(this.string, this.font.fntDataStr, this.font.spriteFrame); | ||
| if (CC_JSB) { | ||
| sgNode = this._sgNode = new _ccsg.Label(this.string, this.font.fntDataStr, this.font.spriteFrame); |
There was a problem hiding this comment.
JSB 的 Label 有缓存嘛?还是说也是每次都解析?如果跟 web 一样的话,建议修改 JS 层 Label 的构造函数
There was a problem hiding this comment.
@pandamicro jsb 有 cache 的,不过有一个小 bug,我提交一下。
There was a problem hiding this comment.
cocos/engine-native#572 @pandamicro 这个影响不大,放在 develop 分支了。
There was a problem hiding this comment.
cocos2d/core/label/CCSGLabel.js
Outdated
|
|
||
| //fontHandle it is a system font name, ttf file path or bmfont file path. | ||
| ctor: function(string, fontHandle, spriteFrame) { | ||
| ctor: function(string, fontHandle, spriteFrame, bmfontUUID) { |
There was a problem hiding this comment.
建议把这个参数改成 bmFontAsset,缓存放在 Asset 对象里。好处是 loader 自动确保全局 Asset 对象唯一,所以缓存也唯一。而 BMFont 释放后缓存也会跟着释放。
There was a problem hiding this comment.
缓存在 Asset 对象里面,然后靠 loader 保证全局惟一,貌似耦合有点多。另外 BMFont 释放,其实缓存可以不用释放吧,比如从一个场景切换到另一个场景,如果 bmfont 释放了,那下次进场景又要重新 parser。
There was a problem hiding this comment.
我同意 jare 的看法。这个不能算耦合,是保障自治。
下一个场景依赖同样的 asset 的话,是不会被释放的
|
@jareguo @pandamicro 修改完了,麻烦再 review 一下 |
| self._config = fntConfig; | ||
| } else { | ||
| self._config = FntLoader.parseFnt(fntDataStr); | ||
| this._fontAsset._fntConfig = self._config; |
There was a problem hiding this comment.
其实你已经不再需要 this._config 了,用的地方都用 this._fontAsset._fntConfig 就可以了
Re: https://github.com/cocos-creator/fireball/issues/5410
Changes proposed in this pull request:
@cocos-creator/engine-admins