gpt4 book ai didi

ios - 更改游戏纹理但图像未根据cocos hd definition替换

转载 作者:行者123 更新时间:2023-11-28 23:05:17 28 4
gpt4 key购买 nike

我正在用 cocos2d 制作游戏。我正在检查 Sprite 的级别并相应地更新纹理。现在开始时图像是高清的。现在当游戏开始并且我开始移动 Sprite 时,高清图像被普通图像取代。我正在检查用这段代码替换纹理。

int value = [self.weapon.weaponLevel intValue];
NSString *path = [[NSBundle mainBundle]pathForResource:@"name" ofType:@"png"];
UIImage *imageView = [[UIImage alloc]initWithContentsOfFile:path];
CCTexture2D *frame = [[CCTexture2D alloc]initWithImage:imageView];
[self.player setTexture:frame];

谁能帮帮我。谢谢。问候。

最佳答案

当您可以使用在内部处理所有路径解析和 HD/SD 检测的 CCTextureCache 时,无需通过 NSBundleUIImage .

此外,顾名思义,它会缓存纹理,以便后续使用相同的 Sprite 文件会更快:

这是你需要的:

CCTexture2D *frame = [[CCTextureCache sharedTextureCache] addImage:@"name.png"];
[self.player setTexture:frame];

关于ios - 更改游戏纹理但图像未根据cocos hd definition替换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9407936/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com