Lock MonkeyView while another view is open
Monkey Targets Forums/iOS/Lock MonkeyView while another view is open
| ||
Hey guys, first I hope you will understand me. It´s not easy to explain my problem in english ^^ So, I just want to add GameCenter Support to my game. In this case I need to display the Leaderboard in another view. (GKLeaderboardViewController) Now I added the two Methods to the MonkeyViewController: ( like the methods in the gamekit programming guide on apple developer... ) -(void) ShowLeaderboard -(void) leaderboardViewControllerDidFinish... Ok, now I can display the Leaderboard and quit them, but my problem is that the MainView -> "MonkeyView" isn´t locked and so the user can controll the menu without seeing it. :( So my question is, how could I lock the mainView? Does somebody just tried to display another view? I think that I should check if the MainWindow is appear or disappear and so i change the superview, but I dont know how... I would be happy if somebody could help me =) Thanks |
| ||
Can't you just test if GameCenter is open and return immediately from OnRender and OnUpdate? |
| ||
hmm sometimes I think to complicated .. Oo I just added a variable which save if the mainview opens or closed and so I can block the Input. Lol Thanks.. ^^ |
| ||
Maybe you could share your Game Center module with us? |
| ||
Hey, sorry that i answer so late. I have no Monkeymodule for that. I only add code to the XCode Project. But my problem is still the same. I can lock the input for the leaderboard view, but if I want to register a new GameCenter Account within the app, the same problem come back.. Here is the Code( second try ): The "GameCenter.h": http://www.pucupo-games.com/h_GameCenter.txt and the code within the "main.mm": http://www.pucupo-games.com/mm_GameCenter.txt My second try is just a edited copy from here: http://www.garagegames.com/community/forums/viewthread/122529/ |
| ||
Your code looks pretty clean and it looks like it can be easily turned into module. This could solve your problem. Maybe I'll look into this on Monday. |
| ||
So now my app runs with GameCenter and the Input-problem is fixed. My app is still in review and we will see if apple approves the version. I will tell you what I did to finish them on the afternoon. |
| ||
Great! LOL "...what I did to finish THEM...", sounds like you are finishing Apple. Anyway, could you please add info about which frameworks you had to add to the XCode project for GameCenter? |
| ||
Hey, so I have put it in a little Monkey Module, which you can download here: http://www.pucupo-games.com/GameCenter.zip At this time it only support Leaderboards, but if this works , it wouldn´t no problem to get the archievement run, too. Here are all Monkey-Functions of the module.... Before using this module you need to configure your App on ItunesConnect... Function IsGameCenterAvailable:Bool() Function InitializeGameCenter:Void() Function ReInitGameCenter:Void() Function IsPlayerAvailable:Bool() Function SendScore:Void(scScore%, scCategory$) Function OpenLeaderBoard:Void() Function DeInitGameCenter:Void() Function InitializeGameCenter:Void() This function check if the GameCenter and a player is available... You need to put it on your „OnCreate()“ method... Function ReInitGameCenter:Void() This function checks if the player had changed. Call it in your OnResume() method... Function SendScore:Void(scScore%, scCategory$) Send the score to GameCenter. The string: scCategory is how you called your Leaderboard in your Itunes Connect Account, for example: „leaderboard_easy“ Function OpenLeaderBoard:Void() Open the Leaderboard in a new view... Function DeInitGameCenter:Void() This function deinit your GameCenter class, but I don´t know if there is a OnQuit() Method??? Otherwise you have to edit the main.mm to release it.. Or how could I get this on the AutoRelease pool? What is needed in Xcode? 1.) First you need to import the GameCenter.h file to your Xcode project. ( You can find it in the rar-archive ) 2.) Include the „GameKit-Framework“ to your Xcode project... Targetsettings -> Build Phases -> Link Binary with Libraries It is important to set it to „optional“ ( weak link ), because older devices haven´t the GameKit included and it would crash... 3.) In this function in your „main.mm“ file, I had to make two changes, cause of some trouble with the input... void gxtkInput::OnEvent( UIEvent *event ){ Change 1: UIView *view=app->appDelegate->view; change to: UIView *view=app->appDelegate.viewController.view; Change 2: for( UITouch *touch in [event allTouches] ){ change to: for( UITouch *touch in [event touchesForView:view] ){ In my project I did it without any Monkey module and it works. I hope you could help me to finish this module... How you can see, my english isn´t very well. So I hope someone could translate this, if we can finish it, to a readable english =) |
| ||
So I spent some time with your module and simplified few things. Now you don't need to change main.mm code if you can control your GUI through function isGameCenterVisible() (if yes then don't check controls). The mod has one missing feature at the moment (beside achievements): - it always shows in portrait mode I am still looking for solution to adjust GC to your current device orientation. You can download updated mod from here: http://innotech.pl/anawiki/4people/iosGameCenter.zip It also doesn't need GameCenter.h from previous version of module (included in ios.cpp). New function: IsGameCenterVisible() - returns true if leader board view is opened (at the moment it's the only view in this mode). I'll look into achievements tomorrow. If you spot any bugs please update and let us all know :) |
| ||
And did you have no trouble with the Gamecenter-Registerview? That´s why I changed the code in the main.mm ... So I mean, if there is no player loged in, GameCenter will ask you if you want to register a new player. If you tap on "register new player", a view opens where I got this trouble... ?? |
| ||
Hmm... I don't know. I just logged in to existing account. I'll test it tomorrow and let you know. |
| ||
What kind of problems do you experience? I created the account, but on the last step I either swiped the GameCenter window down or it moved down by itself and I lost ability to click on my GUI... not sure if it's because my GUI wasn't locked for the time and I messed up some things in my game or Monkey lost some view control. |
| ||
My experience in this case is that my Gui isn´t locked during this view is open. If the view lost controll after closing I don´t know. But it could be. I had another problem where the view lost controll. The problem appeared after I opened an Url within my App and resuming to game. I found a part in monkey which is commented, but I don´t know why? Perhaps you know why.. hmm @implementation MonkeyWindow /* -(void)sendEvent:(UIEvent*)event{ [super sendEvent:event]; MonkeyAppDelegate *delegate=(MonkeyAppDelegate*)[[UIApplication sharedApplication] delegate]; [delegate onEvent:event]; } -(void)touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event{ MonkeyAppDelegate *delegate=(MonkeyAppDelegate*)[[UIApplication sharedApplication] delegate]; [delegate onEvent:event]; } -(void)touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event{ MonkeyAppDelegate *delegate=(MonkeyAppDelegate*)[[UIApplication sharedApplication] delegate]; [delegate onEvent:event]; } -(void)touchesEnded:(NSSet*)touches withEvent:(UIEvent*)event{ MonkeyAppDelegate *delegate=(MonkeyAppDelegate*)[[UIApplication sharedApplication] delegate]; [delegate onEvent:event]; } -(void)touchesCancelled:(NSSet*)touches withEvent:(UIEvent*)event{ MonkeyAppDelegate *delegate=(MonkeyAppDelegate*)[[UIApplication sharedApplication] delegate]; [delegate onEvent:event]; } */ After I delete the comment-chars , there aren´t any problems with losing view controll.. ? |
| ||
So, Apple has the version approved and it runs :D If you have an IPhone/Ipod you can get it here: http://itunes.apple.com/app/cubeclacker/id446474539 |
| ||
Hey guys! Thank you all for great mod! GameCenter features are very useful. I wonder why there's no such standard mod in monkey! Just added function that sends Achievements. But it only works if Game Center is available. =( Still working on it. http://www.white-zebra.com/upload/iosGameCenter.zip Good luck! |
| ||
I have some more functions added and "no internet support" too. Will upload later. |
| ||
I emailed you. If you want I can put your mod on my site! My email: alex()white-zebra.com Thanks in advance. OpenLeaderBoard() not seem to work in my app... |