123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- /** @format */
- import {Mgr} from '../GameControl'
- const {ccclass, property, executeInEditMode, disallowMultiple, requireComponent, menu} = cc._decorator
- @ccclass
- @executeInEditMode
- @requireComponent(cc.Sprite)
- @disallowMultiple
- @menu('多语言/i18nSprite')
- export class i18nSprite extends cc.Component {
- @property({visible: false})
- private i18n_string: string = ''
- start() {
- Mgr.i18n.addOrDelSprite(this, true)
- this._resetValue()
- }
- @property({type: cc.String})
- get string() {
- return this.i18n_string
- }
- set string(value: string) {
- this.i18n_string = value
- let sprite = this.getComponent(cc.Sprite)
- if (cc.isValid(sprite)) {
- Mgr.i18n.getSprite(value, spriteFrame => {
- if (cc.isValid(sprite)) {
- sprite.spriteFrame = spriteFrame
- }
- })
- }
- }
- _resetValue() {
- this.string = this.i18n_string
- }
- onDestroy() {
- Mgr.i18n.addOrDelSprite(this, false)
- }
- }
|