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 / A way to determine the amount of subimages in an image-file?

Author
Message
Zwarteziel
13
Years of Service
User Offline
Joined: 22nd Jan 2011
Location: Netherlands
Posted: 9th Jan 2013 21:54
Hi all,

I've been experimenting with the LoadSubImages-command, which is quite nice and straightforward. However, I've been wondering: is there a way to automatically determine the amount of subimages an image-file actually contains?

(Something along the lines of 'GetSubImageExist' or something?)
kamac
13
Years of Service
User Offline
Joined: 30th Nov 2010
Location: Poland
Posted: 9th Jan 2013 21:58 Edited at: 9th Jan 2013 22:01
Well, it's easy to write that.
Just open certain subimages file, and iterate through each line.

Here's an example function:



Should work.

Follow me on twitter! @MotionStruct
Motion Struct blog
Zwarteziel
13
Years of Service
User Offline
Joined: 22nd Jan 2011
Location: Netherlands
Posted: 9th Jan 2013 23:24
Thanks kamac!

I thought that, since the subimages.txt-file contains a single string of info without line breaks, the fileEOF would give a wrong number. Here's the way I use it in AGK.



Once again, you have my gratitude!
Marl
12
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 11th Jan 2013 18:52
Quote: "I thought that, since the subimages.txt-file contains a single string of info without line breaks, the fileEOF would give a wrong number."

This may be down to what you are using to create the subimages file.

As a standard text file it works fine with line breaks - such as with font subimages;

I frequently use spare space in a font file for game graphics - either using subimages or directly using setSpriteAnimation/setSpriteFrame() or a little of both depending on placement.

Login to post a reply

Server time is: 2024-05-03 23:04:05
Your offset time is: 2024-05-03 23:04:05