mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
Updated iOS (markdown)
parent
4b4e6672cd
commit
341e96cc09
16
iOS.md
16
iOS.md
@ -58,19 +58,19 @@ For an actual example, see [go-inovation's ViewController.m](https://github.com/
|
||||
- (void)viewDidLayoutSubviews {
|
||||
[super viewDidLayoutSubviews];
|
||||
CGRect viewRect = [[self view] frame];
|
||||
double scaleX = (double)viewRect.size.width / (double)GoMobileScreenWidth;
|
||||
double scaleY = (double)viewRect.size.height / (double)GoMobileScreenHeight;
|
||||
double scaleX = (double)viewRect.size.width / (double)MobileScreenWidth;
|
||||
double scaleY = (double)viewRect.size.height / (double)MobileScreenHeight;
|
||||
double scale = MAX(1, MIN(scaleX, scaleY));
|
||||
int width = (int)GoMobileScreenWidth * scale;
|
||||
int height = (int)GoMobileScreenHeight * scale;
|
||||
int width = (int)MobileScreenWidth * scale;
|
||||
int height = (int)MobileScreenHeight * scale;
|
||||
int x = (viewRect.size.width - width) / 2;
|
||||
int y = (viewRect.size.height - height) / 2;
|
||||
CGRect glkViewRect = CGRectMake(x, y, width, height);
|
||||
[[self glkView] setFrame:glkViewRect];
|
||||
|
||||
if (!GoMobileIsRunning()) {
|
||||
if (!MobileIsRunning()) {
|
||||
NSError* err = nil;
|
||||
GoMobileStart(scale, &err);
|
||||
MobileStart(scale, &err);
|
||||
if (err != nil) {
|
||||
NSLog(@"Error: %@", err);
|
||||
}
|
||||
@ -88,7 +88,7 @@ For an actual example, see [go-inovation's ViewController.m](https://github.com/
|
||||
|
||||
- (void)glkView:(GLKView *)view drawInRect:(CGRect)rect {
|
||||
NSError* err = nil;
|
||||
GoMobileUpdate(&err);
|
||||
MobileUpdate(&err);
|
||||
if (err != nil) {
|
||||
NSLog(@"Error: %@", err);
|
||||
}
|
||||
@ -100,7 +100,7 @@ For an actual example, see [go-inovation's ViewController.m](https://github.com/
|
||||
continue;
|
||||
}
|
||||
CGPoint location = [touch locationInView:[self glkView]];
|
||||
GoMobileUpdateTouchesOnIOS(touch.phase, (int64_t)touch, location.x, location.y);
|
||||
MobileUpdateTouchesOnIOS(touch.phase, (int64_t)touch, location.x, location.y);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user