Tuesday, 15 January 2013

MonoGame on iOS (init texture from internet) -



MonoGame on iOS (init texture from internet) -

i'm developing game on ios monogame. possible init texture2d images downloaded internet? if so, there samples can follow? lot.

i'm not sure if maps 1 1 ios, here how did on android monogame. of code came post on stack, unfortunately can't remember post!

/// <summary> /// downloads texture based on url path, , stores in sprites texture. /// </summary> /// <param name="url">the path file.</param> private void downloadtexture(string url) { httpwebrequest request = httpwebrequest.create(new uri(url)) httpwebrequest; request.begingetresponse((ar) => { httpwebresponse response = request.endgetresponse(ar) httpwebresponse; using (stream stream = response.getresponsestream()) { using (memorystream ms = new memorystream()) { int count = 0; { byte[] buf = new byte[1024]; count = stream.read(buf, 0, 1024); ms.write(buf, 0, count); } while (stream.canread && count > 0); ms.seek(0, seekorigin.begin); /*texture2d*/ mtexture = texture2d.fromstream(gameobjectmanager.pinstance.pgraphicsdevice, ms); //.premultiplyalpha(); } } }, null); }

monogame

No comments:

Post a Comment