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 / Array of images

Author
Message
Moosecake
12
Years of Service
User Offline
Joined: 5th Feb 2012
Location:
Posted: 6th Feb 2012 03:56
Hi folks, how would I go about setting up an array of images; so the player can scroll through each image one at a time when they press a button/ the screen?

I have 26 images for them to go through. I know that it'll start with something like this:



but how do I actually populate the array with the images?

Thanks!

Pro noob.
westalke
12
Years of Service
User Offline
Joined: 8th Dec 2011
Location:
Posted: 6th Feb 2012 05:00
You dont really need to go down the root of loading all the images.

Just load each image as needed ... load first image ... link it to sprite ... wait ... user hits next ... load new image
Link it to sprite... wait
Westa
kamac
13
Years of Service
User Offline
Joined: 30th Nov 2010
Location: Poland
Posted: 6th Feb 2012 14:04
BASIC code:



C++ code:



Ofcourse, that'd make you have the same image in every image. To have different images, you'd have to either do it manually or make a .txt with all the images listed in rows, but i don't think that's what you want.

Funnell7
12
Years of Service
User Offline
Joined: 8th Sep 2011
Location: UK, England
Posted: 6th Feb 2012 15:13
Quote: "
To have different images, you'd have to either do it manually or make a .txt with all the images listed in rows, but i don't think that's what you want.
"


Or you could name all the images the same with an incrementing number, i.e. Image1, Image2, Image3 etc etc, then you can do this...



Having said that, if they would only ever have one image at a time, I'd suggest having one sprite and adding every image as an animation frame, and then just scroll through them using 'SetSpriteFrame()'
Moosecake
12
Years of Service
User Offline
Joined: 5th Feb 2012
Location:
Posted: 6th Feb 2012 18:31
Wicked, thanks for the info =]

Pro noob.
JimHawkins
14
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 7th Feb 2012 00:06
Loading them all is ok if you have trivially few of them, but what if there are several hundred big images? You'll run out of memory!

Loading from disk etc is ok, but can be annoyingly slow.

The smart way is to pre-fetch the next image from disk as soon as the current image has loaded. You can then do cute transitions to the next image.

This only needs the current and next images - two.

For smart stuff you need a buffer of three, with a moving buffer pointer. That way the user can go backwards or forwards predictably with transitions. I did this a (very) long time ago on the CDTV/CD32 where there really wasn't much RAM to play with, and fetching from CD was fairly slow. The pathetically Mac-obsessed company I was working for were devastated when they saw how fast it was - beat the Mac hands down, and their badly coded PC version!

Simple techniques like these can make all the difference to the user experience, and lift what looks amateurish into something that looks polished and professional.

-- Jim

Login to post a reply

Server time is: 2024-05-05 21:44:31
Your offset time is: 2024-05-05 21:44:31