game.data Suggestions
Monkey Archive Forums/Monkey Discussion/game.data Suggestions
| ||
I suggest game.data subfolders which is specific to platforms! I have .wav (Iphone), .ogg (Android) and .mp3 (Flash) sound files in my game.data folders. I have multiples #if in my code to load the correspondent files. But no matter what Plataform I build, it puts all the files on it. I suggest somethis like this: all game.data files is used in all plataforms, and there is custom subfolders for files specific to custom plataforms. game.data\ios game.data\flash game.data\android Is is possible? |
| ||
This would be nice or something like it. Currently for Flash Monkey now embeds all the data files into the swf, also the Android APK does something similar... with HTML5 you could just delete the unneeded files from the build folder. |
| ||
Good suggestion. One possible extension of that per-target data folders idea... Perhaps allow any files that exist in the custom data folders to override & replace the corresponding file in the "default/generic target" data folder if the path/filename matches? Might be useful for different size images etc. For now, unless anyone has any better ideas, selective loading via preprocessor #if statements is all I can come up with too. Maybe an auto-conversion is possible at compile time? But I guess you'd want some control over compression/quality. |
| ||
I'm voting for it ;-) |
| ||
Totally agreed with this. It's a very good suggestion and I'd love to see it gets implemented |
| ||
Any updates on this? I'm just starting up my first Monkey project and I'm immediately struck by the necessity to have different resolutions of art for e.g Windows/iOS/Android due to different aspect ratios. The "game.data/platform" solution would be excellent. |
| ||
Same here really. There's no way I can use the same assets for an XNA 1280x720 and an Android game. Going with game.data/platform would work fine, especially with Pudsy's suggestion of having a "default" folder to load from that it falls back to if the item isn't in the platform specific one. It's mainly the packaging reasons really, it's easy enough to wrap the load function to append a platform but you don't want all of the hires Xbox assets built into an Android distribution. |
| ||
I guess one would have to modify the "target.monkey" file to acheive this. Method CreateDataDir( dir$,embedTextFiles?=True ) dir=RealPath( dir ) DeleteDir dir,True CreateDir dir If FileType( dataPath )=FILETYPE_DIR CopyDir dataPath,dir,False Endif ...Add something like this after that code: If FileType( dataPath + "/" + ENV_TARGET )=FILETYPE_DIR CopyDir dataPath,dir,False Endif I assume that would overwrite the copied files from the standard "dataPath" dir with any existing files from "dataPath.target". Depending on how CopyDir works, of course. But it should be simple enough to figure out. Unfortunately it'd require rebuilding trans at every new release. |
| ||
...Aaand it seems that there's a simpler solution. Import can be used to import graphics files. I assume everyone already knew this except for me, but this is the basic idea in case someone else needs a solution: #If TARGET = "flash" Import "flash/screen.jpg" #ElseIf TARGET = "html5" Import "html5/screen.jpg" #EndIf |
| ||
its really really simple to work around. im doing it in a similar way karja suggested in the last post. global ressourcefolder:string global soundex:String #If TARGET = "flash" ressourcefolder = "flash" soundex = "mp3" #ElseIf TARGET = "html5" ressourcefolder = "html5" soundex = "mp3" #ElseIF TARGET = "ios" ressourcefolder = "ios" soundex = "mp3" #ElseIF TARGET = "android" ressourcefolder = "android" soundex = "ogg" #EndIf 'Load Ressources Image1 = LoadImage(ressourcefolder+"/images/screen.jpg") Image2 = LoadImage(ressourcefolder+"/images/screen2.jpg") Sound1 = LoadSound (ressourcefolder+"/sounds/sound."+soundex) This way you write it portable for all platforms and for the market deploy, you just delete the unnecessary other ressourcefolders for other platforms i guess there are much more important things to do. maybe its not always the best to say +1 each feature which would make programming just simpler but isn't really neccessary for the creative mind greetz |
| ||
Actually, if I understand Monkey correct (having written a dozen lines of code so far), that solution doesn't really solve the main issue: all of the files in the app.data directory are included into the .swf/.apk/.etc archive. That means that if you have two different PNGs for Flash and Android, both are included in each build. Completely unacceptable for a reasonably large game, and a really important feature to get right. The trick isn't really to make LoadImage and LoadSound load from a different directory, but to ensure that only the relevant files are copied to the data dir when building the archive. That's why I used the Import inside the #If statements. You select which file to actually copy, and then you simply use LoadImage with the same filename each time. E.g: Import mojo.app Import mojo.graphics Import mojo.input #If TARGET = "flash" Import "flash/screen.jpg" #ElseIf TARGET = "html5" Import "html5/screen.jpg" #EndIf Class Game Extends App Field image:Image Method OnCreate() image = LoadImage( "screen.jpg" ) SetUpdateRate 60 End Method OnRender() DrawImage( image, 0, 0 ) End End Function Main() New Game End |
| ||
using import prevents all the files being copied to .data? |
| ||
The normal situation would be: /projectdir/app.data/screen.jpg /projectdir/app.data/common.png But in the example above you place the files like this: /projectdir/flash/screen.jpg /projectdir/html5/screen.jpg /projectdir/app.data/common.png |
| ||
I actually like the idea of subfolders for target-specific assets. It could also be extended to support Android's dpi-based selection of resources (like having a .data/android/ldpi folder for ldpi, one for mdpi, and so on), I don't know, I think it would be a good feature to have at least the per-target folders. Any chance of seeing this officially implemented on Monkey? |