将SpriteKit视图集成到xib视图中 [英] Integrating a SpriteKit view into a xib view
问题描述
我有一个视图,我已经使用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);
}
}
推荐答案
我不知道你究竟想要实现什么,但我认为你可能想看看UIKitDynamics而不是SpriteKit,它提供了视图和其他动态项目的物理相关功能和动画。我建议你先看一下apple doc
https ://developer.apple.com/library/ios/samplecode/DynamicsCatalog/Introduction/Intro.html
然后
a关于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 first https://developer.apple.com/library/ios/samplecode/DynamicsCatalog/Introduction/Intro.html then a really nice tutorial on raywenderlich.com http://www.raywenderlich.com/50197/uikit-dynamics-tutorial
希望这会有所帮助......
Hope this helps...
这篇关于将SpriteKit视图集成到xib视图中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!