-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into camera-updates
- Loading branch information
Showing
16 changed files
with
344 additions
and
177 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -138,6 +138,8 @@ Type a suitable name for the new file. The full file name including the file typ | |
|
||
![create file name](images/editor/create_file_name.png){srcset="images/editor/create_[email protected] 2x"} | ||
|
||
It is possible to specify custom templates for each project. To do so, create a new folder named `templates` in the project’s root directory, and add new files named `default.*` with the desired extensions, such as `/templates/default.gui` or `/templates/default.script`. Additionally, if the `{{NAME}}` token is used in these files, it will be replaced with the filename specified in the file creation window. | ||
|
||
## Importing files to your project | ||
|
||
To add asset files (images, sounds, models etc) to your project, simply drag and drop them to the correct position in the *Assets* browser. This will make _copies_ of the files at the selected location in the project file structure. Read more about [how to import assets in our manual](/manuals/importing-assets/). | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--- | ||
title: Using CocoaPods dependencies in iOS and macOS builds | ||
brief: This manual explains how to use CocoaPods to resolve dependencies in iOS and macOS builds. | ||
--- | ||
|
||
# CocoaPods | ||
|
||
[CocoaPods](https://cocoapods.org/) is a dependency manager for Swift and Objective-C Cocoa projects. CocoaPods is typically used to manage and integrate dependencies in Xcode projects. Defold does not use Xcode when building for iOS and macOS, but it still uses Cocoapods to resolve dependencies on the build server. | ||
|
||
|
||
## Resolving dependencies | ||
|
||
Native extensions can include a `Podfile` file in the `manifests/ios` and `manifests/osx` folders to specify the extension dependencies. Example: | ||
|
||
``` | ||
platform :ios '11.0' | ||
pod 'FirebaseCore', '10.22.0' | ||
pod 'FirebaseInstallations', '10.22.0' | ||
``` | ||
|
||
The build server will collect the `Podfile` files from all the extensions and use these to resolve all dependencies and include them when building the native code. | ||
|
||
Examples: | ||
|
||
* [Firebase](https://github.com/defold/extension-firebase/blob/master/firebase/manifests/ios/Podfile) | ||
* [Facebook](https://github.com/defold/extension-facebook/blob/master/facebook/manifests/ios/Podfile) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
--- | ||
title: Using Gradle dependencies in Android builds | ||
brief: This manual explains how to use Gradle to resolve dependencies in Android builds. | ||
--- | ||
|
||
# Gradle for Android | ||
|
||
Contrary to how Android applications are typically built, Defold does not use [Gradle](https://gradle.org/) for the entire build process. Instead Defold uses Android command line tools such as `aapt2` and `bundletool` directly in the local build and only leverages Gradle while resolving dependencies on the build server. | ||
|
||
|
||
## Resolving dependencies | ||
|
||
Native extensions can include a `build.gradle` file in the `manifests/android` folder to specify the extension dependencies. Example: | ||
|
||
``` | ||
repositories { | ||
mavenCentral() | ||
} | ||
dependencies { | ||
implementation 'com.google.firebase:firebase-installations:17.2.0' | ||
implementation 'com.google.android.gms:play-services-base:18.2.0' | ||
} | ||
``` | ||
|
||
The build server will collect the `build.gradle` files from all the extensions and use these to resolve all dependencies and include them when building the native code. | ||
|
||
Examples: | ||
|
||
* [Firebase](https://github.com/defold/extension-firebase/blob/master/firebase/manifests/android/)build.gradle | ||
* [Facebook](https://github.com/defold/extension-facebook/blob/master/facebook/manifests/android/build.gradle) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
title: Optimizing battery usage of a Defold game | ||
brief: This manual describes how to optimize battery usage a Defold game. | ||
--- | ||
|
||
# Optimize battery usage | ||
Battery usage is mainly a concern if you are targeting mobile/handheld devices. High CPU or GPU usage will quickly drain battery and overheat the device. | ||
|
||
Refer to the manuals on how to [optimize runtime performance](/manuals/optimization-speed) of a game to learn how to reduce CPU and GPU usage. | ||
|
||
## Disable accelerometer | ||
If you are creating a mobile game which doesn't make use of the device accelerometer it is recommended to [disable it in *game.project*](/manuals/project-settings/#use-accelerometer) to reduce the number of generated input events. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
--- | ||
title: Optimizing memory usage of a Defold game | ||
brief: This manual describes how to optimize memory usage of a Defold game. | ||
--- | ||
|
||
# Optimizing memory usage | ||
|
||
## Texture compression | ||
The use of texture compression will not only reduce the size of resources within your game archive, but compressed textures may also reduce the amount of GPU memory required. | ||
|
||
## Dynamic loading | ||
Most game have at least some content that is used infrequently. From a memory usage stand point it does not make sense to have such content loaded in memory at all times, but rather load and unload it when it is neded. This will obviously be a trade-off between having something readily accessible at the cost of runtime memory and loading something at the cost of loading time. | ||
|
||
Defold has several different ways of loading content dynamically: | ||
|
||
* [Collection proxies](/manuals/collection-proxy/) | ||
* [Dynamic collection factories](/manuals/collection-factory/#dynamic-loading-of-factory-resources) | ||
* [Dynamic factories](/manuals/factory/#dynamic-loading-of-factory-resources) | ||
* [Live Update](/manuals/live-update/) | ||
|
||
## Optimize component counters | ||
Defold will allocate memory for components and resources once when a collection is created, to reduce memory fragmentation. The amount of memory that is allocated depends on the configuration of various components counters in *game.project*. Use the [profiler](/manuals/profiling/) to get accurate component and resource usage and configure your game to use max values that are closer to the real count of components and resources. This will reduce the amount of memory your game is using (refer to information about component [max count optimizations](/manuals/project-settings/#component-max-count-optimizations)). | ||
|
||
## Optimize GUI node count | ||
Optimize GUI node counts by setting the max number of nodes in the GUI file to only what is needed. The `Current Nodes` field of the [GUI component properties](https://defold.com/manuals/gui/#gui-properties) will show the number of nodes used by the GUI component. | ||
|
||
:[HTML5 Optimizations](../shared/optimization-memory-html5.md) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
--- | ||
title: Optimizing size of a Defold game | ||
brief: This manual describes how to optimize the size of a Defold game. | ||
--- | ||
|
||
# Optimizing game size | ||
|
||
The size of your game can be a critical success factor for platforms such as web and mobile, while it is of less importance on desktop and consoles where disk space is cheap and often plentiful. | ||
|
||
### iOS and Android | ||
Apple and Google has defined application size limits when downloading over mobile networks (as opposed to downloading over Wifi). For Android this limit is 200 MB for apps published with [app bundles](https://developer.android.com/guide/app-bundle#size_restrictions). For iOS users will get a warning if the application is larger than 200 MB, but can still proceed to download it. | ||
|
||
::: sidenote | ||
According to a 2017 study it was shown that "For every 6 MB increase to an APK’s size, we see a decrease in the install conversion rate of 1%." ([source](https://medium.com/googleplaydev/shrinking-apks-growing-installs-5d3fcba23ce2)) | ||
::: | ||
|
||
### HTML5 | ||
Poki and many other web game platforms recommend that the initial download should be no larger than 5 MB. | ||
|
||
Facebook has a recommendation that a Facebook Instant Game should start in less than 5 seconds and preferably less than 3 seconds. What this means for actual application size is not clearly defined but we are talking size in the range of up to 20 MB. | ||
|
||
Playable ads are usually limited to between 2 and 5 MB depending on the ad network. | ||
|
||
|
||
## Size optimization strategies | ||
You can optimize the application size in two ways; by reducing the size of the engine and/or by reducing the size of the game assets. | ||
|
||
To get a better understanding of what makes up the size of your application you can [generate a build report](/manuals/bundling/#build-reports) when bundling. It is quite common that sounds and graphics is what takes up the bulk of the size of any game. | ||
|
||
::: important | ||
Defold will create a dependency tree when building and bundling your application. The build system will start from the bootstrap collection specified in the *game.project* file and inspect every referenced collection, game object and component to build a list of the assets that are in use. It is only these assets that will get included in the final application bundle. Anything not directly referenced will get excluded. While it is good to know that unused assets will not be included you as a developer still needs to consider what goes into the final application and the size of the individual assets and the total size of the application bundle. | ||
::: | ||
|
||
|
||
## Optimize engine size | ||
A quick way to reduce the engine size is to remove functionality in the engine that you do not use. This is done [application manifest file](https://defold.com/manuals/app-manifest/) where it is possible to remove engine components that you do not need. Examples: | ||
|
||
* Physics - If your game does not make use of Box2D or Bullet3D physics then it is strongly advised to remove the physics engines | ||
* LiveUpdate - If your game does not use LiveUpdate it can be removed | ||
* Image loaded - If your game does not manually load and decode images using `image.load()` | ||
* BasisU - If your game has few textures, compare the build size without BasisU (removed via app manifest) and without texture compression versus a build with BasisU and compressed textures. For games with limited textures, it might be more beneficial to reduce the binary size and skip texture compression. Additionally, not using the transcoder can lower the amount of memory required to run your game. | ||
|
||
|
||
## Optimize asset size | ||
The biggest wins in terms of asset size optimizations are usually gained by reducing the size of sounds and textures. | ||
|
||
### Optimize sounds | ||
Defold supports .ogg and .wav files where .ogg is typically used for music and .wav for sound effects. Sounds must be 16-bit with a sampling rate of 44100 so any optimizations must be done on the sounds before encoding them. You can edit the sounds in an external sound editor software to reduce the quality or convert from .wav to .ogg. Also consider converting sounds from stereo to mono. | ||
|
||
### Optimize textures | ||
You have several options when it comes to optimizing the textures used by your game, but the first thing to do is to check the size of the images that gets added to an atlas or used as a tilesource. You should never use a larger size on the images than is actually needed in your game. Importing large images and scaling them down to the appropriate size is a waste of texture memory and should be avoided. Start by adjusting the size of the images using external image editing software to the actual size needed in your game. For things such as background images it might also be ok to use a small image and scale it up to the desired size. Once you have the images down to the correct size and added to atlases or used in tilesources you also need to consider the size of the atlases themselves. The maximum atlas size that can be used varies between platforms and graphics hardware. | ||
|
||
::: sidenote | ||
[This forum posts](https://forum.defold.com/t/texture-management-in-defold/8921/17?u=britzl) suggests several tips on how to resize multiple images using scripts or third party software. | ||
::: | ||
|
||
* Max texture size on HTML5: https://webglstats.com/webgl/parameter/MAX_TEXTURE_SIZE | ||
* Max texture size on iOS: | ||
* iPad: 2048x2048 | ||
* iPhone 4: 2048x2048 | ||
* iPad 2, 3, Mini, Air, Pro: 4096x4096 | ||
* iPhone 4s, 5, 6+, 6s: 4096x4096 | ||
* Max texture size on Android varies greatly but in general all reasonably new devices support at least 4096x4096. | ||
|
||
If an atlas is too large you need to either split it into several smaller atlases, use multi-page atlases or scale the entire atlas using a texture profile. The texture profile system in Defold allows you to not only scale entire atlases but also to apply compression algorithms to reduce the size of the atlas on disk. You can [read more about texture profiles in the manual](/manuals/texture-profiles/). If you don’t know what to use, try to start with these settings as a starting point for further customizations: | ||
|
||
* mipmaps: false | ||
* premultiply_alpha: true | ||
* format: TEXTURE_FORMAT_RGBA | ||
* compression_level: NORMAL | ||
* compression_type: COMPRESSION_TYPE_BASIS_UASTC | ||
|
||
::: sidenote | ||
You can read more about how to optimize and manage textures in [this forum post](https://forum.defold.com/t/texture-management-in-defold/8921). | ||
::: | ||
|
||
### Optimize fonts | ||
The size of your fonts will be smaller if you specify what symbols you are going to use and set this in [Characters](/manuals/font/#properties) instead of using the All Chars checkbox. | ||
|
||
|
||
### Exclude content for download on demand | ||
Another way of reducing initial application size is to exclude parts of the game content from the application bundle and download it on demand. Defold provides a system called Live Update for excluding content for download on demand. | ||
|
||
Excluded content can be anything from entire levels to unlockable characters, skins, weapons or vehicles. If your game has a lot of content, organize the loading process so that the bootstrap collection and the first level collection include the bare minimum resources required for that level. You achieve this by using collection proxies or factories with the "Exclude" checkbox enabled. Split resources according to the player's progress. This approach ensures efficient resource loading and keeps initial memory usage low. Learn more in the [Live Update manual](/manuals/live-update/). | ||
|
||
|
||
|
||
## Android specific size optimizations | ||
Android builds must support both 32-bit and 64-bit CPU architectures. When you [bundle for Android](/manuals/android) you can specify which CPU architectures to include: | ||
|
||
![Signing Android bundle](images/android/sign_bundle.png) | ||
|
||
Google Play has support for [multiple APKs](https://developer.android.com/google/play/publishing/multiple-apks) per release of a game, which means that you can reduce the application size by generating two APKs, one per CPU architecture, and uploading both to Google Play. | ||
|
||
You can also make use of a combination of [APK Expansion Files](https://developer.android.com/google/play/expansion-files) and [Live Update content](/manuals/live-update) thanks to the [APKX extension in the Asset Portal](https://defold.com/assets/apkx/). |
Oops, something went wrong.