cmd/ebitenmobile: Define an error handler for iOS

Updates #919
This commit is contained in:
Hajime Hoshi 2019-08-18 20:55:33 +09:00
parent 0b1aec4d27
commit 2c770f3644
3 changed files with 14 additions and 2 deletions

View File

@ -122,6 +122,7 @@ const objcM = `// Code generated by ebitenmobile. DO NOT EDIT.
@implementation {{.PrefixUpper}}EbitenViewController {
GLKView* glkView_;
bool error_;
}
- (GLKView*)glkView {
@ -170,13 +171,23 @@ const objcM = `// Code generated by ebitenmobile. DO NOT EDIT.
}
- (void)glkView:(GLKView*)view drawInRect:(CGRect)rect {
if (error_) {
return;
}
NSError* err = nil;
EbitenmobileviewUpdate(&err);
if (err != nil) {
NSLog(@"Error: %@", err);
[self performSelectorOnMainThread:@selector(onErrorOnGameUpdate:)
withObject:err
waitUntilDone:NO];
error_ = true;
}
}
- (void)onErrorOnGameUpdate:(NSError*)err {
NSLog(@"Error: %@", err);
}
- (void)updateTouches:(NSSet*)touches {
for (UITouch* touch in touches) {
if (touch.view != [self glkView]) {

File diff suppressed because one or more lines are too long

View File

@ -212,6 +212,7 @@ const objcH = `// Code generated by ebitenmobile. DO NOT EDIT.
#import <UIKit/UIKit.h>
@interface {{.PrefixUpper}}EbitenViewController : UIViewController
- (void)onErrorOnGameUpdate:(NSError*)err;
@end
`