![](/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.