问题描述
我已经使用 xib 文件创建了一个视图.
I have a view that I already created using a xib file.
现在我想在这个视图中添加一些小元素,以利用 SpriteKit 中的一些物理动画,所以现在我需要一个 SKView.
Now I would like to add some small elements to this view that would make use some of the physics animations from SpriteKit, so now I need an SKView.
是否可以将 SKView 添加为与我的 xib 视图对应的视图的子视图?我试过了,它似乎没有显示任何东西.
Is it possible to add an SKView as a Subview of the view that corresponds to my xib view? I tried this and it does not seem to show anything.
下面是我的XIB视图对应的ViewController中:
The following is in the ViewController corresponding to my XIB view:
this.myCustomSKView = new CustomSKView()
this.View.AddSubview( this.myCustomSKView );
我的自定义 SKView 的 ViewController 有:
and the ViewController for my custom SKView has:
public override void ViewWillLayoutSubviews ()
{
base.ViewWillLayoutSubviews ();
if(this.SKView.Scene == null)
{
this.SKView.ShowsFPS = true;
this.SKView.ShowsNodeCount = true;
this.SKView.ShowsDrawCount = true;
var scene = new MyCustomSKScene (this.SKView.Bounds.Size);
this.SKView.PresentScene (scene);
}
}
推荐答案
我不知道你到底想要实现什么,但我认为你可能想查看提供物理相关功能和视图和其他动态项目的动画".我建议你先看看苹果文档https://developer.apple.com/library/ios/samplecode/DynamicsCatalog/Introduction/Intro.html然后raywenderlich.com 上的一个非常好的教程http://www.raywenderlich.com/50197/uikit-dynamics-tutorial
I don't know what exactly you are trying to achieve but I think instead of SpriteKit you may wanna check out the UIKitDynamics which provides "physics-related capabilities and animations to views and other dynamic items". I would suggest you look at the apple doc firsthttps://developer.apple.com/library/ios/samplecode/DynamicsCatalog/Introduction/Intro.htmlthena really nice tutorial on raywenderlich.comhttp://www.raywenderlich.com/50197/uikit-dynamics-tutorial
希望对你有帮助……
这篇关于将 SpriteKit 视图集成到 xib 视图中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!