ios - How to make my sprite kit scene appear above a UIView? -
i've done searching haven't found directly addressing issue: have skscene several sknodes each skspritenode objects game, , using background uiimageview (there things need background cannot reasonable done sprite kit - knowledge @ least); problem i'm having uiimageview appears above , can't see game objects.
in view controller (.m file) have following code call scene
@implementation gameviewcontroller - (void)viewdidload { [super viewdidload]; skview * skview = (skview *)self.view; skscene * scene = [gamescene scenewithsize:skview.bounds.size]; scene.scalemode = skscenescalemodeaspectfill; [skview presentscene:scene]; } in gamescene above, have several sknodes game objects children of (for example nodehdu, nodeplay, nodepausemenu...), , using uiimageview background (i switching between background scenes on time , using nice transitions such uiviewanimationoptiontransitioncrossdissolve; couldn't accomplish skspritenode background without using multiple skspritenodes , intricate array of skactions i"m using uiimageview)
uiview *backgrounds = [[uiview alloc] init]; [self.view insertsubview:backgrounds belowsubview:self.view]; uiimageview *imagebackground = [[uiimageview alloc] initwithframe:cgrectmake(0,0,self.view.frame.size.width,self.view.frame.size.height)]; [backgrounds addsubview:imagebackground]; [backgrounds sendsubviewtoback:imagebackground]; [imagebackground setimage:[uiimage imagenamed:@"1-a.png"]]; imagebackground.alpha=1.0; however, imagebackground above thing see when running app in xcode. other objects game (children of other nodes) exist, , various nslog statements getting called, seem appear behind imagebackground have. code above "belowsubview" , "sendsubviewtoback" don't help.
so how can send imagebackground background?
your problem here directly setting skview controller view. overcome issue don't make self.view type of skview. following step in storyboard or xib :
- add
uiimageviewon controller's view first. set image well. - then add
skviewonuiimageviewand setuiclearcolorbackground colour.
so complete hierarchy uiviewcontroller->uiview->uiimageview->skview
Comments
Post a Comment