![](/img/trans.png)
[英]How to disable video compression - UIImagePickerController, Xamarin.IOS, C#
[英]How to preload texture atlas (SKTextureAtlas) in Xamarin.iOS (in C#)?
谁能给我看看Xamarin.iOS框架中用C#编写的可以预加载纹理图集的小代码示例吗?
Xamarin网站具有此页面:
https://developer.xamarin.com/api/type/MonoTouch.SpriteKit.SKTextureAtlas/
在该网页上,他们列出了许多预加载纹理图集的方法。 但是,我只对以下两种特定方法感兴趣:
PreloadTextures(SKTextureAtlas [],NSAction)
PreloadTexturesAsync(SKTextureAtlas [])
我猜这两种方法都适合我的游戏。 不幸的是,我不知道如何在Xamarin.iOS框架内的C#中正确调用它们。
尽管网上有很多用于预加载纹理图集的代码示例,但是这些示例是用Objective-C编写的,但是,不幸的是,我还不知道如何将Objective-C代码转换为C#代码。
因此,如果您能向我展示如何使用我上面提到的2种方法在Xamarin.iOS框架内用C#编写一些预加载纹理图集的小代码示例,将不胜感激。
非常感谢你。
我不是游戏开发专家,也没有参与过游戏;但是,我对Xamarin.iOS相当熟悉,可以将Objective-C代码“转换”为Xamarin C#代码。
首先,您需要创建一个“纹理图集”数组
var textureCollection = new SKTextureAtlas[]
{
SKTextureAtlas.FromName("firsttexturename"),
SKTextureAtlas.FromName("secondtexturename"),
};
await SKTextureAtlas.PreloadTexturesAsync(textureCollection);
// rather than using a completion handler like in ObjC xamarin uses the c# 5's await keyword to achieve similar functions
//You can do what you want after it has preloaded here
//for example
this.StartScene()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.