【问题标题】:SpriteBuilder & CCTexture - copy textures from smart sprite sheet in SpriteBuilderSpriteBuilder 和 CCTexture - 从 SpriteBuilder 中的智能精灵表复制纹理
【发布时间】:2014-07-09 20:12:35
【问题描述】:

我在尝试从 SpriteBuilder 中的智能精灵表复制纹理时遇到了问题。

当我复制 sprite.texture 时,它​​似乎复制了完整的智能精灵表,而不是单个图像。

例子

如果我使用图像名称创建精灵

 CCSprite *redSprite = [CCSprite spriteWithImageNamed:@"Images/Red-Sprite.png"];

并使用该精灵它工作正常。

但是如果我

    _textureRedSprite = redSprite.texture;

它将复制完整的精灵表并将其用作纹理,而不是我需要的单个图像。

任何想法我可能做错了什么?

谢谢

【问题讨论】:

    标签: objective-c cocos2d-iphone spritebuilder


    【解决方案1】:

    而不是使用/引用精灵的纹理:

    _textureRedSprite = redSprite.texture;
    

    .. 使用精灵的精灵帧,其中包含对特定图像的纹理以及纹理图集中的偏移和矩形的引用:

    CCSpriteFrame* redSpriteFrame = redSprite.spriteFrame;
    otherSprite.spriteFrame = redSpriteFrame;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-12-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-22
      相关资源
      最近更新 更多