From eb988342f7de28e911bff40a3199b33174645fde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20J=2E=20Est=C3=A9banez?= Date: Tue, 24 Jan 2017 16:58:15 +0100 Subject: [PATCH] Update creating_android_modules.rst Add information on how to provide and use resources for custom modules. --- reference/creating_android_modules.rst | 27 ++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/reference/creating_android_modules.rst b/reference/creating_android_modules.rst index c05dc2437..5edab20c4 100644 --- a/reference/creating_android_modules.rst +++ b/reference/creating_android_modules.rst @@ -88,13 +88,18 @@ Java singleton -------------- An android module will usually have a singleton class that will load it, -this class inherits from ``Godot.SingletonBase``. A singleton object -template follows: +this class inherits from ``Godot.SingletonBase``. Resource identifiers for +any additional resources you have provided for the module will be in the +``com.godot.game.R`` class, so you'll likely want to import it. + +A singleton object template follows: .. code:: java // package com.android.godot; // for 1.1 package org.godotengine.godot; // for 2.0 + + import com.godot.game.R; public class MySingleton extends Godot.SingletonBase { @@ -214,6 +219,24 @@ module, add it like this: env.android_add_java_dir("Directory that contain MySingelton.java") env.android_add_to_manifest("AndroidManifestChunk.xml") + + +Resources +--------- + +In order to provide additional resources with your module you have to +add something like this: + +.. code:: python + + def configure(env): + if env['platform'] == 'android': + # [...] + env.android_add_res_dir("Directory that contains resource subdirectories (values, drawable, etc.)") + +Now you can refer to those resources by their id (``R.string.my_string``, and the like) +by importing the ``com.godot.game.R`` class in your Java code. + SDK library -----------