ios - How to create popup using sprite kit on iphone? -


i beginner developing ios game using sprite kit. have 'pop-up' menu's display objects (skspritenodes) such daily rewards or settings/pause menu. settings pop-up example should able accessed on main home screen or during game. have 1 view controller , home scene , play scene 2 different skscenes. reusability (and clean project, learning) have these pop-ups own class, including handling touches. currently, have class settings pop-up returns sknode, , sknode contains several skspritenodes (the buttons/images correspond settings pop including enabling/disabling sound etc). however, have duplicate touches code in both home scene , play scene interact this. (i have, in each skscene's touchesbegan method, "if nodesettings !=nil", check name of skspritenode corresponds touch-location, call method in setting-pop-up class passing name of skspritenode clicked handle interactions pop-up).

for own knowledge , solve problem, use class can handle touch logic on own (so in play or home skscene, thing create pop-up. interaction, including dismissal, have handled in class. no using skscene's touches methods). have found 1 'solution' this:

ltpopupreward *test = [[ltpopupreward alloc] init]; uipopovercontroller *popover = [[uipopovercontroller alloc] initwithcontentviewcontroller:test]; cgfloat fltheight = [uiscreen mainscreen].bounds.size.height; cgfloat fltwidth = [uiscreen mainscreen].bounds.size.width; popover.popovercontentsize = cgsizemake(fltwidth/2, fltheight/2); //your custom size. cgrect rectpopupreward = cgrectmake(500, 500, fltwidth/2, fltheight/2); [popover presentpopoverfromrect:rectpopupreward inview:self.view permittedarrowdirections: uipopoverarrowdirectionany animated:yes]; 

and can dismiss uipopovercontroller clicking outside of it, uipopovercontroller works on ipad , doesn't work on iphone. i've seen uipopovercontroller iphone not working? wondering if there way solve problem apple won't possibly disapprove of? example, create uiviewcontroller, resize , position (i don't know how this) simulate pop-up?

summarizing: goal have pop-up appear, have of code (including touch) self contained within 1 class, , objects on pop-up skspritenodes.

answering own question: solution used solve problem use different skviews. 1 skview presents main scene , skview presents pop-up scene. can adjust size of second skview , make background transparent. interacting objects in view correctly call touches methods in class of scene presented - pop-up dealt when being created, , there no other code dealing on view-controller or main-scene's logic (all code, including creating objects , handling touch) in second skscene's code. method below called when "something" call 'pop-up'.

-(void)test4 {     skviewpopup=nil;     scenepopupreward=nil;     nslog(@"test4 fired");     cgfloat fltheight = [uiscreen mainscreen].bounds.size.height;     cgfloat fltwidth = [uiscreen mainscreen].bounds.size.width;     cgrect rectpopupreward = cgrectmake(0, 0, fltwidth/2, fltheight/2);     skviewpopup = [[skview alloc] initwithframe:rectpopupreward];     [self.view addsubview:skviewpopup];     skviewpopup.allowstransparency = yes;     scenepopupreward = [[ltscenestoremain alloc] initwithsize:cgsizemake(fltwidth/2, fltheight/2)];     scenepopupreward.backgroundcolor = [uicolor clearcolor];     [skviewpopup presentscene:scenepopupreward]; } 

Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - Chrome Extension: Interacting with iframe embedded within popup -