CCSprite 中的图像淡入淡出?

发布于 2024-12-18 04:38:16 字数 90 浏览 1 评论 0原文

是否可以淡出 CCSprite 中的图像?目前我只知道 Cocos2D 中的对象可以淡出,但我不确定这是否可能。 有什么办法可以做到这一点吗?

谢谢!

Is it possible to fade through the images in a CCSprite? Currently I only know its possible to fade through objects in Cocos2D but I wasn't sure if this was possible or not.
Is there any way to do this?

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

万劫不复 2024-12-25 04:38:16

那么,您可以使用 CCFadeOut 删除当前图像,同时在同一位置创建新的精灵,不透明度为 0,并使用 CCFadeIn 使其淡入代码>.如果同时进行,应该会收到不错的效果。

Well, you can use CCFadeOut to remove your current image, while, at the same time, create your new sprite at the same position with opacity 0, and make it fade in with CCFadeIn. If you do it at the same time, you should get a nice effect.

弥繁 2024-12-25 04:38:16

您可以使用 2 个 CCSprites 淡入多张图像。

  1. CCSprite A 到前面不透明 zOrder 1
  2. CCSprite B 到透明(如果 CCSprite A 覆盖了 CCSprite B 则不需要),zOrder 0
  3. 淡出 CCSprite A 然后将其放在背景中,zOrder 0
  4. CCSprite B zOrder 1前面,第2点后看到
  5. 将CCSprite A的图像交换到每个不均匀的地方
  6. 重复一切,这次给出CCSprite的参数A 和 B 以相反的顺序

交换精灵:

CCCallBlock *exchangeImage = [CCCallBlock actionWithBlock:^{
    sprite.texture = [[CCTextureCache sharedTextureCache] addImage:@"image.png"];
}];

如果需要,添加延迟:

CCDelayTime *delayAction = [[CCDelayTime alloc] initWithDuration:0.4f];

放在一起重复:

CCSequence *exchangeSequence = [CCSequence actions:exchangeImage, delayAction, nil];
CCRepeatForever *repeat = [CCRepeatForever actionWithAction:exchangeSequence];
[self runAction:repeat];

You can fade with 2 CCSprites through multiple images.

  1. CCSprite A to opaque to the front zOrder 1
  2. CCSprite B to transparent (if CCSprite A covers the CCSprite B then this is not needed), zOrder 0
  3. FadeOut CCSprite A and after that put it in the background, zOrder 0
  4. CCSprite B zOrder 1 in the front, it is seen after point 2
  5. Exchange image of CCSprite A to every uneven
  6. repeat everything, this time give the argument of CCSprite A and B in opposite order

Exchange the sprite:

CCCallBlock *exchangeImage = [CCCallBlock actionWithBlock:^{
    sprite.texture = [[CCTextureCache sharedTextureCache] addImage:@"image.png"];
}];

Add delay if needed:

CCDelayTime *delayAction = [[CCDelayTime alloc] initWithDuration:0.4f];

Put together an repeat:

CCSequence *exchangeSequence = [CCSequence actions:exchangeImage, delayAction, nil];
CCRepeatForever *repeat = [CCRepeatForever actionWithAction:exchangeSequence];
[self runAction:repeat];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文