Design Considerations for Creating Mobile Games Using Lumberyard - Lumberyard User Guide

Design Considerations for Creating Mobile Games Using Lumberyard

This topic references tools and features that are legacy. If you want to use legacy tools in Lumberyard Editor, disable the CryEntity Removal gem using the Project Configurator or the command line. To learn more about legacy features, see the Lumberyard Legacy Reference.

Lumberyard is a cross-platform game engine, which allows you to develop your game with less concern about the release platform(s). However, some mobile development considerations are discussed below, including game logic, input, and application lifecycle.

Application Lifecycle

Lumberyard provides a Process Life Management Gem (in the Project Configurator) that shows how you can respond to various application lifecycle events in order to pause your game, display a modal splash screen, and any other actions that need to occur if your application loses focus. You can access system-specific events in C++ by connecting to the appropriate EBus; however, Lumberyard also generates platform-agnostic events that you can use for all supported platforms.

Lumberyard Application Lifecycle Events iOS Android
OnApplicationConstrained applicationWillResignActive onPause()
OnApplicationUnconstrained applicationDidBecomeActive onResume()
OnApplicationSuspended applicationDidEnterBackground onPause()
OnApplicationResumed applicationWillEnterForeground onResume()
OnMobileApplicationWillTerminate applicationWillTerminate onDestroy()
OnMobileApplicationLowMemoryWarning applicationDidReceiveMemoryWarning onLowMemory()

To receive process lifecycle events in your game

  1. Derive your class from AzFramework::ApplicationLifecycleEvents::Bus::Handler (or AzFramework::[Ios|Android|Windows]LifecycleEvents::Bus::Handler for platform-specific events).

  2. Override the functions corresponding to the events you wish to override:

    void OnApplicationConstrained(Event /*lastEvent*/) override; void OnApplicationUnconstrained(Event /*lastEvent*/) override; void OnApplicationSuspended(Event /*lastEvent*/) override; void OnApplicationResumed(Event /*lastEvent*/) override
  3. Connect to the event bus when you want to start listening for events (be sure to also disconnect when you no longer wish to receive them):

    ApplicationLifecycleEvents::Bus::Handler::BusConnect(); ??? ApplicationLifecycleEvents::Bus::Handler::BusDisconnect();

For a complete example of how to subscribe and respond to application events, see the Gems\ProcessLifeManagement\Code\Source\ProcessLifeManagementGem.h\.cpp directory.