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 / Loading large images during gameplay - most efficient way?

Author
Message
SamJ
12
Years of Service
User Offline
Joined: 27th Dec 2011
Location:
Posted: 28th Dec 2011 05:02
Hi guys. I am trying to figure out the best way to load in new images during the game without causing it to freeze and without pausing it. For instance, swapping the background image by loading a new one without any noticeable delay of the game.

Currently, if I try to use LoadImage during the game, there is a moment when everything freezes on the device until the new image has been loaded successfully. Any suggestions? Even if using Tier 2 (in iOS) I can't figure out how to load anything as a background thread (e.g., if I could use the PerformSelectorInBackground action with AGK).
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 28th Dec 2011 10:12
Preload all images before using them.

My signature is NOT a moderator plaything! Stop changing it!
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 28th Dec 2011 12:50
Don't know if ios supports multi-threading like windows, but you could try that using t2.

on darkgdk i used the load commands during gameplay without pause using multi-threading
Marl
12
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 1st Jan 2012 18:55
If you have a lot of images to load, you could set up a queue system and spread the loading over a period of time - go for lots of little (imperceivable) pauses rather than one large one.

The problem may not be code based, just how large are these "large images"? You could look at possibly reducing the size of the files.

Using .png files, I have reduced 24 bit images to 8 or even 4 bits with no noticeable loss in quality but with a file size reduction of 90% in some cases.
SamJ
12
Years of Service
User Offline
Joined: 27th Dec 2011
Location:
Posted: 1st Jan 2012 20:44
Well in my case I'm trying to load in background images, which are 960x640 for retina display and will change over time but without any delay in game (think a seamless scrolling game with different backgrounds transitioning over time).

I obviously can't load in a bunch of large background images before the game starts as that's way too much memory usage. But even loading a single large background image during the game causes a noticeable delay where everything freezes on the device.

iOS supports multithreading and I hoped to be able to load the images in the background thread and then pass them to the main thread but I have no idea how to do that. When I try to load an image in the background thread using tier 2 (with limited knowledge of how to do so) the images don't transfer to the main thread and appear as just white blank images when shown on screen.

Any other thoughts?
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 2nd Jan 2012 09:38
We need a tutorial for using multi threading in AppGameKit T2
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 2nd Jan 2012 10:04
Multi-threading is not covered under the current command set but there must be some info on multi-threading in C++ on the Internet somewhere?

It's a bit much to expect TGC to write a tutorial on something not under their own product. Maybe try the MSDN?

bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 2nd Jan 2012 13:24
No one expects AppGameKit to write tutorials, even though other more popular SDKs are always adding tutorials to cover more aspects of general game making.

Maybe some advanced user who cracked the right way to do it can post some hints, like Halley did with his step by step threads.
MrValentine
AGK Backer
13
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 3rd Jan 2012 12:27
bjadams beat me to it... oh snapĀ”

LeeBamber
TGC Lead Developer
24
Years of Service
User Offline
Joined: 21st Jan 2000
Location: England
Posted: 6th Jan 2012 12:39
How about a Tier 2 guide 'How To Multitask In AGK'? If someone posts the bug/feature here http://code.google.com/p/agk/issues/list, I will assign it to Mike for build 107

I drink tea, and in my spare time I write software.

Login to post a reply

Server time is: 2024-03-29 06:53:43
Your offset time is: 2024-03-29 06:53:43