Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers AppGameKit Corner / LoadImage() and CreateSprite()

Author
Message
3Dski
4
Years of Service
User Offline
Joined: 8th Jan 2020
Location:
Posted: 11th Jan 2020 21:37
It seems to me that if you have multiple sprites represented by the same sprite that you'd only call LoadImage() once, then use the returned ID to create as many sprites as you want using CreateSprite()?

This may be an odd question, but I think I saw some code where someone always called LoadImage() before CreateSprite() even though the same image was previously loaded, so I'm asking as a reality check here : )

Also, If you want to do clean-up, do you need to delete sprites before you delete their images (does the deletion order matter)? AND... If you created all the sprites you wanted, can you delete the backing image for those Sprites without harming the existence of those sprites?

Thanks!
blink0k
Moderator
11
Years of Service
Recently Online
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 11th Jan 2020 22:12
Quote: "It seems to me that if you have multiple sprites represented by the same sprite that you'd only call LoadImage() once, then use the returned ID to create as many sprites as you want using CreateSprite()?"

Correct. You could also use CloneSprite() to create multiple copies of the same sprite

Quote: "Also, If you want to do clean-up, do you need to delete sprites before you delete their images (does the deletion order matter)?"

I don't think it matters but i would delete sprites before images just to make sure

Quote: "If you created all the sprites you wanted, can you delete the backing image for those Sprites without harming the existence of those sprites?"

I'm not 100% sure but i think that would not be adviseable
smallg
Valued Member
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location: steam
Posted: 16th Jan 2020 23:48
Quote: ""If you created all the sprites you wanted, can you delete the backing image for those Sprites without harming the existence of those sprites?""

if you delete the image the sprites will revert back to the "missing image" image
life's one big game
spec= i5 4ghz, 16gb ram, Nvidia 1070ti gpu
3Dski
4
Years of Service
User Offline
Joined: 8th Jan 2020
Location:
Posted: 20th Jan 2020 17:18
Quote: "if you delete the image the sprites will revert back to the "missing image" image"


Yes, I tested this. My original thought was, "If I created the sprite with the image, maybe I don't need that image anymore.". It turns out you have to keep that image.

My line of questioning originated from the fact that I saw that Studio was creating a scene file that loads the same image file again for each copy of a sprite you drag into the scene, and this struck me as odd and inefficient.
Scraggle
Moderator
20
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire

Login to post a reply

Server time is: 2024-04-19 20:49:55
Your offset time is: 2024-04-19 20:49:55