iOS
#
Swift PackageThe 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)
#
#
ParametershideStatusBar
: (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.js
extension) to load (e.g.["file1", "file2"]
).
#
MethodsjsBridge(messageId: String, jsArg: String)
: Send a value from Swift to your JS game code. See Bridge.
#
InputsSince 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.
#
BridgeYou 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