(action)
| 777 | |
| 778 | // Returns the sprite data parsed from the adobe animate's texture-atlas export |
| 779 | getRasterAtlasSpriteData (action) { |
| 780 | // TODO: Doesn't construct new movieclip definitions and thus all returned `ss` |
| 781 | // objects are the same references. |
| 782 | let animation = __guard__(this.get('actions')[action], x => x.animation) |
| 783 | const splitIndex = action.indexOf('_') |
| 784 | if (!animation && (splitIndex !== -1)) { |
| 785 | let relatedAction; |
| 786 | [action, relatedAction] = Array.from([action.slice(0, splitIndex), action.slice(splitIndex + 1)]) |
| 787 | animation = __guard__(__guard__(this.get('actions')[action], x2 => x2.relatedActions[relatedAction]), x1 => x1.animation) |
| 788 | } |
| 789 | if (!animation) { |
| 790 | console.warn(`action '${action}' doesn't have an animation defined...`) |
| 791 | return {} |
| 792 | } |
| 793 | if (!this.textureAtlases.get(animation) || (!(this.textureAtlases.get(animation).length || []) > 1)) { |
| 794 | console.warn(`animation '${animation}' not loaded or doesn't exist...`) |
| 795 | return {} |
| 796 | } |
| 797 | |
| 798 | let { lib, ss, ssMetadata, images } = this.textureAtlases.get(animation) |
| 799 | |
| 800 | // Add images to ssMetadata |
| 801 | ssMetadata = ssMetadata.map(metadata => { |
| 802 | const imgIndex = images.map(img => img.src) |
| 803 | .map(imgSrc => imgSrc.split('/').pop()) |
| 804 | .map(imgName => imgName.slice(0, -4)) |
| 805 | .indexOf(encodeURIComponent(metadata.name)) |
| 806 | metadata.images = [images[imgIndex]] |
| 807 | return metadata |
| 808 | }) |
| 809 | |
| 810 | const movieClipInstanceName = this.get('rasterAtlasAnimations')[animation].movieClipName |
| 811 | if (!lib[movieClipInstanceName]) { |
| 812 | throw new Error(`Can't find movieclip called '${movieClipInstanceName}' in javascript file...`) |
| 813 | } |
| 814 | return { ssMetadata, ss, movieClip: lib[movieClipInstanceName] } |
| 815 | } |
| 816 | |
| 817 | onLoaded () { |
| 818 | super.onLoaded() |
no test coverage detected