Procházet zdrojové kódy

Revised examples, added supported file types

Alan Rawkins před 8 roky
rodič
revize
bc3c9f711d
1 změnil soubory, kde provedl 45 přidání a 25 odebrání
  1. 45 25
      modules/monkey/docs/language/assets-management.md

+ 45 - 25
modules/monkey/docs/language/assets-management.md

@@ -2,63 +2,65 @@
 
 Since each of the targets that Monkey2 supports have their own way of managing files, Monkey2 provides an simple abstraction layer managing assets. This allows you to import and use images, files, fonts, and sounds in a consistent way, regardless of the target platform you are deploying to.
 
+For the following examples, assume a project folder structure like this:
+
+```
+main.monkey2
+images/image1.png
+images/image2.png
+sounds/sound1.wav
+sounds/sound2.wav
+```
+
 #### Importing Assets
 
 Import assets for use in your project by using an Import directive.
 
 ```
 'individual files
+
 #Import "relative/local/path/to/your/file"
 
 'entire folders
+
 #Import "relaive/local/path/"
 ```
 
 When importing entire folders, Make sure to include the trailing slash at the end to let the compiler know it's a folder.
 
-For example, assuming a project structure like this:
-
-```
-main.monkey2
-images/image1.jpg
-images/image2.jpg
-sounds/your_sound.wav
-```
-
-You could import your assets into main.monkey2 like so:
-
 ```
 'main.monkey2
 
 'import the entire images subfolder
+
 #Import "images/"
 
 'import a specific sound
-#Import "sounds/your_sound.ogg"
+
+#Import "sounds/sound1.wav"
 ```
 
 These import directives can go anywhere in your source file, but standard practice is to put them at the top of the file.
 
 #### Using Imported Assets
 
-Once you've imported your assets, you can reference them by prefixing the imported filename with 'asset::'
+Once you've imported your assets, you can reference them by prefixing the imported filename with `asset::`
 This allows you to use them with an function or method that asks for a String path to a file.
 
 ```
-#Import "images/spaceship.png"
+#Import "images/image1.png"
 
-Local myShipImage:Image = Image.Load("asset::spaceship.png")
+Local myImage:Image = Image.Load("asset::image1.png")
 ```
 
 If you imported a folder containing several assets, you can reference any of the assets in this way.
 
 ```
-'assuming you have a folder called `data` containing an image named `image.jpg`, and an audio file `sound.ogg`:
+#Import "images/"
 
-#Import "data/"
+Local image1:Image = Image.Load("asset::image1.png")
+Local image2:Image = Image.Load("asset::image2.png")
 
-Local image:Image = Image.Load("asset::image.jpg")
-Local sound:Sound = Sound.Load("asset::sound.ogg")
 ```
 
 
@@ -67,21 +69,39 @@ Local sound:Sound = Sound.Load("asset::sound.ogg")
 If you want to maintain a folder structure when importing, you can specify a target subfolder with `@/target/path/` after the path in the import directive.
 
 ```
-#Import "images/image.jpg@/images/"
-'imports image.jpg into a subfolder called images
+'imports image1.jpg into a subfolder called images
+
+#Import "imagess/image1.jpg@/images/"
 ```
 
 `@/` also works when importing entire folders:
 
 ```
-#Import "data/@/images/"
-'imports everything from data/ into a subfolder called images/
+'imports everything from images/ into a subfolder called images/
+
+#Import "images/@/images/"
 ```
 
 When using the files in your code, make sure to add the target subfolder after `asset::`, for example:
 
 ```
-#Import "images/spaceship.png@images/"
+#Import "images/image1.png@images/"
 
-Local image:Image = Image.Load("asset::images/spaceship.png")
+Local image:Image = Image.Load("asset::images/image1.png")
 ```
+
+#### Supported File Types
+
+Each platform has it's own supported file types. Consult the tables below for your target platform.
+
+##### Images
+
+| Desktop | Android | iOS | HTML5 |
+| --- | --- | --- | --- |
+| png, jpg | png, jpg, bmp, gif | png, jpg, bmp, gif, tif | png, jpg |
+
+##### Sound
+
+| Desktop | Android | iOS | HTML5 |
+| --- | --- | --- | --- |
+| wav, ogg | wav, ogg, m4a, mp3 | wav, mp3, m4a, caf, aiff | wav, ogg, mp3, m4a |