cocos / cocos-engine

Cocos simplifies game creation and distribution with Cocos Creator, a free, open-source, cross-platform game engine. Empowering millions of developers to create high-performance, engaging 2D/3D games and instant web entertainment.
https://www.cocos.com/en/creator
Other
8.22k stars 1.94k forks source link

希望提供一个通过 spriteFrame 获得 cc.Texture2D 的API #17394

Open finscn opened 3 months ago

finscn commented 3 months ago

Use Case

目前的 spriteFrame.texture 返回的不是 cc.Texture2D 对象.

Problem Description

cc.SpriteFrame 和 cc.Texture2D 是有关联性的, 希望能从 cc.SpriteFrame 得到 texture. 项目里有 从 SpriteFrame 获得 texture 的需求.

Proposed Solution

No response

How it works

No response

Alternatives Considered

.

Additional Information

No response

finscn commented 3 months ago

目前 spriteFrame 返回的类型是 __private._cocos_asset_assets_texture_base__TextureBase ... 这是什么?

Will-Z666 commented 3 months ago

const node = new Node("New Sprite"); const sprite = node.addComponent(Sprite); const spriteFrame = new SpriteFrame(); const tex = imageAsset._texture; spriteFrame.texture = tex; sprite.spriteFrame = spriteFrame; node.parent = self.node; });

spriteFrame.texture 不就是么

finscn commented 3 months ago

const node = new Node("New Sprite"); const sprite = node.addComponent(Sprite); const spriteFrame = new SpriteFrame(); const tex = imageAsset._texture; spriteFrame.texture = tex; sprite.spriteFrame = spriteFrame; node.parent = self.node; });

spriteFrame.texture 不就是么

对 它是. 我 用 as cc.Texture2D 后 能正常使用. 但是官方 cc.d.ts 里告诉我 spriteFrame.texture 的类型是 "__private._cocos_asset_assets_texture_base__TextureBase" 这是什么鬼?

cocos里大量的这种 长的类型, 无法理解.