Dynamic loading of images from server
Monkey Forums/Monkey Programming/Dynamic loading of images from server
| ||
I'm looking into multiplayer and I have noticed that many apps download content after it has started to save dl-time, start-up time and allow for on-the-fly content changes. In Monkey can this be easily done on "all" or "most" targets using the current TCP commands? Anyone tried it in a real App on Android/iOS/web? Any other considerations except hosting costs that I should take into account? |
| ||
See my iconfun banana, there is an example there of loading remote images using monkey. It isn't an ideal way to do it though. If you would like to get messy then you could look at where monkey loads images per target. For example: \targets\android\modules\native\androidgame.java public Bitmap LoadBitmap( String path ){ try{ InputStream in=OpenInputStream( path ); if( in==null ) return null; BitmapFactory.Options opts=new BitmapFactory.Options(); ... ... ... You could potentially write some fairly simple glue code to hook into this functionality and bypass monkeys limitation of loading only pre-compiled images. You would then need to write some more glue to saveimages and/or download images. So it is possible to do it with monkey commands, but if you are talking about doing it efficiently then it would be best to get some native glue going. |
| ||
didn' mark offer this 3 weeks ago? "You can, however, use the new async image loaders to load images from more sources, eg:" Import mojo Class MyApp Extends App Implements IOnLoadImageComplete Field image:Image Method OnCreate() LoadImageAsync( "http://www.monkeycoder.co.nz/img/logo/cute/monkey1.png",,,Self ) SetUpdateRate 60 End |
| ||
ooo that's good news :D wasn't sure if that was html5 only? |
| ||
Awesome, gonna try that! :) |