Skip to content

Conversation

@halx99
Copy link
Collaborator

@halx99 halx99 commented Sep 20, 2025

Describe your changes

  • ios (note: tvos not support)
  • android
  • rename all main.m to main.mm for ios

This PR not breaking changes, but for ios, you need use engine AxmolAppController or inherit from it, and delete any orientation control code in your original AppController.mm, refer to templates/common/proj.ios_mac/ios/

example use AxmolAppController directly:

#import <UIKit/UIKit.h>
#include "AppDelegate.h"

int main(int argc, char *argv[]) {
    AppDelegate app;
    @autoreleasepool {
        return UIApplicationMain(argc, argv, nil, @"AxmolAppController");
    }
}

example to use your game app controller

// GameAppController.h
#pragma once

#import "platform/ios/AxmolAppController.h"

@interface GameAppController : AxmolAppController {
}

@end

// GameAppController.mm
#import "GameAppController.h"
#import "GameViewController.h"

@implementation GameAppController

#pragma mark -
#pragma mark Application lifecycle

- createRootViewController {
    GameViewController* viewController = [[GameViewController alloc] init];
    return viewController;
}

@end

// GameViewController.

#pragma once

#import "platform/ios/AxmolViewController.h"

@interface GameViewController : AxmolViewController {
}

@end

// GameViewController.mm
#import "GameViewController.h"

@implementation GameViewController

// Override to allow custom control the app behavior.

@end

then main.mm

// main.mm
#import <UIKit/UIKit.h>
#include "AppDelegate.h"

int main(int argc, char *argv[]) {
    AppDelegate app;
    @autoreleasepool {
        return UIApplicationMain(argc, argv, nil, @"GameAppController");
    }
}

Issue ticket number and link

Checklist before requesting a review

For each PR

  • Add Copyright if it missed:
    - "Copyright (c) 2019-present Axmol Engine contributors (see AUTHORS.md)."

  • I have performed a self-review of my code.

    Optional:

    • I have checked readme and add important infos to this PR.
    • I have added/adapted some tests too.

For core/new feature PR

  • I have checked readme and add important infos to this PR.
  • I have added thorough tests.

Axmol 3.x ------------------------------------------------------------

For each 3.x PR

  • Check the '#include "axmol.h"' and replace it with the needed headers.

@halx99 halx99 added this to the 2.9.0 milestone Sep 20, 2025
@halx99 halx99 marked this pull request as ready for review September 20, 2025 16:52
@halx99 halx99 added the enhancement New feature or request label Sep 20, 2025
@halx99 halx99 changed the title feat: add screen orientation control for mobile devices Add screen orientation control for mobile devices Sep 20, 2025
@halx99 halx99 merged commit d588ca7 into release/2.x Sep 21, 2025
15 checks passed
@halx99 halx99 deleted the screen-orientation-ctl branch September 21, 2025 04:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants