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 / how often to use sync()?

Author
Message
dandrews
4
Years of Service
User Offline
Joined: 26th Jun 2020
Location:
Posted: 29th Sep 2022 17:34
how often should i be calling sync()? specifically when loading elements for a "level". does it help with memory to call it more often? i ask because when playing my game on my phone it runs well but when i try to play on my kids tablets it sometimes crashes and exits the game while loading the level usually on higher levels that require more enemies to spawn at the beginning
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 29th Sep 2022 18:31
you don't need to Sync() when loading media (and shouldn't). are the crashes offering a reason why?

when you advise "later levels" and "more enemies", i'm wondering how much media you've already loaded and, of that, how much will be re-used.

if you're not gonna need it again, delete it.

otherwise, if you've been loading massive amounts of media and continue to do so, at some point it will be "too much" for a given device.
dandrews
4
Years of Service
User Offline
Joined: 26th Jun 2020
Location:
Posted: 29th Sep 2022 19:00 Edited at: 29th Sep 2022 19:00
thanks no mad and my question is, i have code like below where at the beginning of my app i assign names for loading images until i need to create the sprite with the image like below

even if i delete the sprite using the image is the media still loaded??
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 29th Sep 2022 20:47
Quote: "even if i delete the sprite using the image is the media still loaded??"

yes, the images are still there.
dandrews
4
Years of Service
User Offline
Joined: 26th Jun 2020
Location:
Posted: 29th Sep 2022 20:56
i see and will address that. another question though if im using the same image on multiple sprites do i call loadimage for all of them or is there a more effective way? this is my current code for spawning one set of enemies
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 30th Sep 2022 09:03 Edited at: 30th Sep 2022 09:05
I use a method similar to this
PK
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 1st Oct 2022 00:48
@dandrews,

i'm dying to see what you've been working so hard on. Screenshot/GIF/Vid, please?
dandrews
4
Years of Service
User Offline
Joined: 26th Jun 2020
Location:
Posted: 1st Oct 2022 18:21
Quote: "
i'm dying to see what you've been working so hard on. Screenshot/GIF/Vid, please?
"

I will give some updates soon and I appreciate all the help it's been rough learning and creating at the same time. Btw after I use say

Should I then

Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 1st Oct 2022 20:22 Edited at: 1st Oct 2022 20:24
Quote: "Deleteimage(image)"

not if the image is still being used by a sprite, no.

same applies to images still in use in any other fashion beyond sprites (by text, 3D objects, etc).
dandrews
4
Years of Service
User Offline
Joined: 26th Jun 2020
Location:
Posted: 2nd Oct 2022 03:18 Edited at: 2nd Oct 2022 04:01
Here's a little peek

Attachments

Login to view attachments
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 4th Oct 2022 23:51

Login to post a reply

Server time is: 2024-11-23 08:14:36
Your offset time is: 2024-11-23 08:14:36