mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 03:08:54 +01:00
cmd/ebitenmobile: Add suspendGame/resumeGame to the ViewController
Updates #894
This commit is contained in:
parent
71b28b6211
commit
16337bb6bf
@ -122,7 +122,9 @@ const objcM = `// Code generated by ebitenmobile. DO NOT EDIT.
|
||||
|
||||
@implementation {{.PrefixUpper}}EbitenViewController {
|
||||
GLKView* glkView_;
|
||||
bool error_;
|
||||
bool started_;
|
||||
bool active_;
|
||||
bool error_;
|
||||
}
|
||||
|
||||
- (GLKView*)glkView {
|
||||
@ -136,6 +138,13 @@ const objcM = `// Code generated by ebitenmobile. DO NOT EDIT.
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
|
||||
if (!started_) {
|
||||
@synchronized(self) {
|
||||
active_ = true;
|
||||
}
|
||||
started_ = true;
|
||||
}
|
||||
|
||||
self.glkView.delegate = (id<GLKViewDelegate>)(self);
|
||||
[self.view addSubview: self.glkView];
|
||||
|
||||
@ -174,6 +183,13 @@ const objcM = `// Code generated by ebitenmobile. DO NOT EDIT.
|
||||
if (error_) {
|
||||
return;
|
||||
}
|
||||
|
||||
@synchronized(self) {
|
||||
if (!active_) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
NSError* err = nil;
|
||||
EbitenmobileviewUpdate(&err);
|
||||
if (err != nil) {
|
||||
@ -214,6 +230,24 @@ const objcM = `// Code generated by ebitenmobile. DO NOT EDIT.
|
||||
[self updateTouches:touches];
|
||||
}
|
||||
|
||||
- (void)suspendGame
|
||||
{
|
||||
NSAssert(started_, @"suspendGame msut not be called before viewDidLoad is called");
|
||||
|
||||
@synchronized(self) {
|
||||
active_ = false;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)resumeGame
|
||||
{
|
||||
NSAssert(started_, @"resumeGame msut not be called before viewDidLoad is called");
|
||||
|
||||
@synchronized(self) {
|
||||
active_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
`
|
||||
|
||||
|
File diff suppressed because one or more lines are too long
@ -214,7 +214,21 @@ const objcH = `// Code generated by ebitenmobile. DO NOT EDIT.
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface {{.PrefixUpper}}EbitenViewController : UIViewController
|
||||
|
||||
// onErrorOnGameUpdate is called on the main thread when an error happens when updating a game.
|
||||
// You can define your own error handler, e.g., using Crashlytics, by overwriting this method.
|
||||
- (void)onErrorOnGameUpdate:(NSError*)err;
|
||||
|
||||
// suspendGame suspends the game.
|
||||
// It is recommended to call this when the application is being suspended e.g.,
|
||||
// UIApplicationDelegate's applicationWillResignActive is called.
|
||||
- (void)suspendGame;
|
||||
|
||||
// resumeGame resumes the game.
|
||||
// It is recommended to call this when the application is being resumed e.g.,
|
||||
// UIApplicationDelegate's applicationDidBecomeActive is called.
|
||||
- (void)resumeGame;
|
||||
|
||||
@end
|
||||
`
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user