Defold native extension for use with KaiOS. See also extension-kaiads for KaiAds integration.
The extension provides a modified version of the default engine_template.html
from builtins. The modifications are:
- Removed "Made with Defold" and Fullscreen"
<div>
- Hardcoded
Module['isWASMSupported']
to false (WASM is not supported on current KaiOS devices) - Load
Defold.js
(see below) - Canvas always resized to
fit
.
The extension adds support for KaiOS specific keys:
- Left Softkey - Mapped to KEY_F1
- Right Softkey - Mapped to KEY_F2
- Call - Mapped to KEY_MENU
The extension adds the following API functions:
Close a KaiOS application (will call window.close()).
TODO: Should we instead use sys.exit() and hook into the application lifecycle somehow through the extension and do a window.close()
?
Play a sound using JavaScript AudioContext. Sounds must be bundled using the "bundle resources" setting in game.project. Functionality for setting up an AudioContext and keeping track of audio buffers can be found in Defold.js
which is included with the extension.
-- play and loop sound
kaios.play_sound("sound.wav", { loop = true })
Stop a sound played using kaios.play_sound()
. Note: Sounds are of a "fire and forget" nature. If the same sound is played multiple times this function will only ever stop the most recently played instance of the sound.
kaios.stop_sound("sound.wav")