我在Xamarin和CocosSharp(CocosSharp PCL)上有一个错误,当我加载Sprite表时应用程序Closes没有错误,代码加载一个动画的大约46个spriteSheets,在索引5的第二个动画加载应用程序关闭,我已检测到应用关闭的行。这是我的代码:
spriteSheet = new CCSpriteSheet(File);
class AnimatedSprite : Sprite
{
CCAnimation animation;
CCRepeatForever Repeat;
List<Resource> ImageList;
CCSpriteSheet spriteSheet;
public AnimatedSprite(AnimatedSpriteTemplate template)
: base(template.Folder + template.Screen_Resolution + "/" + template.Image_Prefix + template.Screen_Resolution + template.Image_NumberSubfix + "_00000" + template.Image_Subfix, template.Name, template.Section)
{
//animation = new CCAnimation();
List<CCSpriteFrame> animationFrames = new List<CCSpriteFrame>();
try
{
ImageList = new List<Resource>();
for (int i = 0; i < template.ImagesCount; i += 1)
{
string File = template.Folder + template.Screen_Resolution + "/" + template.Image_Prefix + template.Image_NumberSubfix;
File += i;
File += template.Image_Subfix;
spriteSheet = new CCSpriteSheet(File); //<--------- Here is the line
spriteSheet.Frames.ForEach(animationFrames.Add);
//**********************************************
LoadingScreen.LoadCount += 1;
//**********************************************
}
animation = new CCAnimation(animationFrames, 0.04f);
Repeat = new CCRepeatForever(new CCAnimate(animation));
cCSprite = new CCSprite(animationFrames.First()) { Name = template.Name };
//cCSprite.AddAction(Repeat);
}
catch(Exception ex)
{
System.Console.Write("MSPGSOFT:" + ex.Message);
}
}
}
我必须在动画精灵上开发一款100%的游戏,所以我真的需要任何帮助,谢谢大家吧
答案 0 :(得分:1)
确定,
经过研究我意识到加载的纹理太多了,所以我决定使用 TexturePacker ,将超过600个纹理打包成20个纹理,错误是gpu从内存中返回。目前应用程序正常工作