我在 Xamarin 和 CocosSharp (CocosSharp PCL) 上出现错误,当我加载 Sprite Sheets 应用程序关闭时没有错误,代码加载了一个动画的大约 46 个 spriteSheets,在索引 5 的第二个动画加载中,应用程序关闭,我检测到应用程序关闭的行。这是我的代码:
spriteSheet = 新的 CCSpriteSheet(文件);
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% 基于动画精灵的游戏,所以我真的需要任何帮助,从现在开始谢谢大家