copy all resource files directly to assets root copy all resource files directly to assets root
0.0 0


I’m porting another game from iOS to Android and I found it’s very inconvenient that iOS and Android uses different strategies regarding to resources. On iOS all resources put to the same folder on target (simulator/device) therefore most of the code works only with basenames of resource files, e.g. even if I have Resources/Sounds/foo.wav I can play it simply with short name: playEffect(‘foo.wav’).
But on Android copies all resource files to preserving directory structure. I need some solution to make my game more cross-platform.
I don’t want to put all eggs (resources) in one basket in my sources because it very quickly becomes a real mess (been there done that). So I decided to copy all my resources to without subdirectories and therefore get the same behavior as on iOS.

I googled for such recipe and found
In the comments there is one-liner that uses only find command because on my Mac xargs does not have ~~i option. So I changed in that way:
diff —git a/ b/
index e0cb27f…d4622a7 100755
— a/
**+ b/
@ -38,17 +38,9@ fi
mkdir $GAME_ANDROID_ROOT/assets
~~# copy resources
~~for file in $RESOURCE_ROOT/*
~~ if [ ~~d “$file” ]; then
~~ cp rf “$file” $GAME_ANDROID_ROOT/assets
~~ fi
*# copy resources
type f ~~exec cp ‘{}’ $GAME_ANDROID_ROOT/assets ‘;’
~~ if [ ~~f “$file” ]; then
~~ cp “$file” $GAME_ANDROID_ROOT/assets

  • fi

# copy icons (if they exist)



You could just use playEffect* instead ofplayEffect( “foo.wav” )*
Tried it on iOS and Android and it works fine.