iOS
Swift Package#
The Replay Swift package is hosted on GitHub. Once added as a package dependency to your Xcode project, you can replace the rootViewController:
Your image and audio assets also need to be added to your Xcode project. See Replay Starter for an example setup.
ReplayViewController(hideStatusBar)#
Parameters#
hideStatusBar: (Optional) A boolean to set if the status bar is hidden or not. Defaulttrue.userStyles: (Optional) CSS code which will be injected into the web view. Useful for defining custom fonts.jsRun: (Optional) The JS code that starts the game - can be overridden to load assets before starting game. Default"renderCanvas.run();".onJsCallback: (Optional) A callback for messages sent from your game. See Bridge.webWorkerFiles: (Optional) An array of additional Web Worker JS file names (without.jsextension) to load (e.g.["file1", "file2"]).
Methods#
jsBridge(messageId: String, jsArg: String): Send a value from Swift to your JS game code. See Bridge.
Inputs#
Since Replay Swift embeds your game as a web view, the device.inputs parameter of Sprite methods is an alias of the Web package's inputs:
The @replay/swift package exports this type for TypeScript projects.
Bridge#
You can send asynchronous messages from your game's JS code to your Swift code, and then respond back using a Promise. This allows you to use native features like in-app purchases.
JS side#
- JavaScript
- TypeScript