hi! Let's say i have the url for a png image, how would i create an sprite from it?
Thanks!
How to create sprite from url
(7 posts) (4 voices)-
Posted 2 years ago #
-
I read about it somewhere, but I can't remember where... something with shroom games or something like that.
Not sure about this one, but you I think you can store raw data on a remote server and retrieve it... then create a sprite from an image.
If I'll happen to see that article again, I'll post a link.
I remeber something with loading assets lol.Posted 2 years ago # -
I've done it before. Its a multi-part process as you need to create a UIImage first and then work backwards from there to get your Sprite. Here my code:
NSMutableString *imgAdd = @"http://www.myurl.com/myimage.png"; NSURL *imgUrl = [NSURL URLWithString:imgAdd]; UIImage *image = [UIImage imageWithData:[NSData dataWithContentsOfURL:imgUrl]]; Texture2D *tex = [[Texture2D alloc] initWithImage:image]; Sprite *sprite = [Sprite spriteWithTexture:tex];My original code was much more complicated with checks to make sure the image was loaded, use of a default embedded image in case there was no net connection, etc. but this is the meat and potatos of what you need to do and it should work fine. Obviously replace the URL with whereever your image is located.
Hope this helps.
Posted 2 years ago # -
wouldnt an app like this instantly get a 17+ rating?
Posted 2 years ago # -
Osris: I had some concerns, but the app I used in is already in the store and they didn't mess with the rating at all. Actually my app went a step further because it actually communicates with a PHP page that tells it what image to download. So, yeah it definitely COULD be abused.
As far as Apple is concerned though the main concern is with functionality. I'm pretty sure they check with and without connections, so you need to make sure that it will still function properly when there is no internet connection available. For usability you want that anyway. In our case, we had a "default" image that was used in place of the downloaded on if no connection was detected or if there was any problem getting the data.
One could imagine all kinds of ways to abuse this by writing PHP scripts and modifying them after approval. But of course there would inevitably be either a buzz or user complaints and Apple would likely discover it before long.
Posted 2 years ago # -
and if a developer doesn't properly secure his php and mysql servers, its a potential target for hijacking.
Posted 2 years ago #
Reply
You must log in to post.