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.

AppGameKit Classic Chat / Does destroying a class object also remove AGKs load object files?

Author
Message
Tobias_Ripper
11
Years of Service
User Offline
Joined: 24th Mar 2013
Location: REPCONN inc.
Posted: 6th Dec 2017 22:26
Say I've got 5 levels, I've create a class for each level with a sort of "Load Level" function that I fire off when the player picks the level from the main menu. So in that function I load up all the objects, sprites, textures, shaders, music and sfx using the variables stores in the header file of that level class.

Now say the player is done playing that level and wants to exit and play another level. After the player returns to the main menu, will destroying the object of that class also destroy all the assets I've loaded in or should I be coding that in in the destructor function of that class?
Eisenstadt Studio: Eisenstadtstudio.com
Composers Page: Milesthatch.net
MikeMax
AGK Academic Backer
12
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 6th Dec 2017 23:22
you have to create a destroy function which will delete all the assets (deleteObject, deleteSprite, etc..)
Tobias_Ripper
11
Years of Service
User Offline
Joined: 24th Mar 2013
Location: REPCONN inc.
Posted: 7th Dec 2017 03:20
Gotcha. Thank you.

Guessing this way we can have multiple levels without having to load everything all together.
Eisenstadt Studio: Eisenstadtstudio.com
Composers Page: Milesthatch.net
Westa
12
Years of Service
User Offline
Joined: 28th Oct 2011
Location:
Posted: 7th Dec 2017 05:59
You might want to look at using some sort of entity list or vector array of some sort to keep track of all the objects you load into each scene.
That way if you want to for example keep a GUI element or scene loader running - you can do so.

The default way in AppGameKit is to call agk:eleteAllObjects() and agk:eleteAllImages(), agk:eleteAllSprites(); etc - but this wipes everything - so no option to have a splash or loader gui still running while you do it - this needs a fade or dip to black etc.

By making your own entity lists - you can loop thru and delete just the elements you need too when you clear a scene.

Westa

MikeMax
AGK Academic Backer
12
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 7th Dec 2017 16:51 Edited at: 7th Dec 2017 16:51
Yes. On my side, I'm using a asset's level when I load an asset :
load(object,level).
And I use a FreeObjects(level) method.
Tobias_Ripper
11
Years of Service
User Offline
Joined: 24th Mar 2013
Location: REPCONN inc.
Posted: 8th Dec 2017 04:27
Yeah, I figured I'd have to load objects and textures in the consrttuctor and then delete them in the deconstructor manually.
Eisenstadt Studio: Eisenstadtstudio.com
Composers Page: Milesthatch.net

Login to post a reply

Server time is: 2024-04-20 10:29:01
Your offset time is: 2024-04-20 10:29:01