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 / Can someone help me to understand SUB IMAGES?

Author
Message
xGEKKOx
AGK Master
15
Years of Service
User Offline
Joined: 7th Dec 2008
Location: Italy
Posted: 29th Jun 2013 01:22
Hi all,
i need help to understand the use of the sub images.
I read the help but i can't understand why use them instead creating other images or creating a grid of sprites (for example).
Thx in advance.

Long life to Steve!
Juande
13
Years of Service
User Offline
Joined: 2nd Sep 2011
Location:
Posted: 29th Jun 2013 01:53
Hello xGEKKOx,

Subimages is useful for loading animations (some 2D design applications export animations using sub-images). But you get the same effect... if you load a set of images. It's your choice.

An example subimage (necessarily need to use subimage): You want to change the font type... you must export the font using sub-images.
xGEKKOx
AGK Master
15
Years of Service
User Offline
Joined: 7th Dec 2008
Location: Italy
Posted: 29th Jun 2013 13:18
So, is an extra feature, we can say?
Or they have a real advantage, for example load time or other?

Long life to Steve!
The Zoq2
15
Years of Service
User Offline
Joined: 4th Nov 2009
Location: Linköping, Sweden
Posted: 29th Jun 2013 13:20
If you use subimages for all your sprites instead of one image per sprite, you will get shorter load times aswell as better performance since you only have to store one image in the memory.
xGEKKOx
AGK Master
15
Years of Service
User Offline
Joined: 7th Dec 2008
Location: Italy
Posted: 29th Jun 2013 15:52
So i can add frames to an animation using subimages?
The speed will be the same or will change something?

Example:
For the karate i used 256x256 sprites.
So i used all different images as a grid would be too big.

Do you mean i can use sub images in this way?

Long life to Steve!
The Zoq2
15
Years of Service
User Offline
Joined: 4th Nov 2009
Location: Linköping, Sweden
Posted: 29th Jun 2013 16:01
You could use subimages instead of the individual images, but if you have 256x256 sprites, you won't fit that many inside a 1024x1024 image and you may be better of just using one sprite per frame.
xGEKKOx
AGK Master
15
Years of Service
User Offline
Joined: 7th Dec 2008
Location: Italy
Posted: 30th Jun 2013 01:22
Ok.
In fact, for the karate we used 50Mb of frames and the only way to load it faster (i found) is to load them only when you chose a character.
I think we need to double the width/height from 1024 to 2048.
Why is not possible and they are scaled?
Anyone know the reason?

Long life to Steve!
The Zoq2
15
Years of Service
User Offline
Joined: 4th Nov 2009
Location: Linköping, Sweden
Posted: 30th Jun 2013 01:48
iOS and android have an image size limit of 1024 I believe, scale it up above that and images will be downscaled to 1024.
Marl
13
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 30th Jun 2013 06:59 Edited at: 30th Jun 2013 07:12
Both sub-images and setSpriteAnimation() can be used to access multiple small images held within a larger image, allowing multiple sprites to share a common image source.

Subimages method requires a simulated load command for each frame, setSpriteAnimation() accesses the images using frame numbers based on an imagined grid within the larger image.

The other difference is to do with the size of the images and their placement.

setSpriteAnimation() accesses the frames based on a uniform grid and so requires the smaller images to be on boundaries equivalent to the image size - a 64x64 frame used in this way needs to lie on a 64x64 boundary in the larger image.

Different sized frames can be used providing each lies on a boundary which matches it's size - so 64x64 images can be used in the same image as 64x128 , 32x32 , 16x256, etc. Providing the large image can be subdivided into a grid of those sizes, and the frames sit on equivalent boundaries.

The subimage file specifies the position of the smaller images, allowing frames of varying sizes and (more importantly) frames which cannot be accessed using the grid style approach of setSpriteAnimation().

SO in short.

Tile sets, fixed width fonts and frames of consistent size - use setSpriteAnimation()

Variable width fonts and Frames of varying sizes or on non-boundary positions - use subimages.

If you think you've got that and want more, take a look at how they can be used at the same time to get around odd sizes;

http://forum.thegamecreators.com/?m=forum_view&t=195871&b=41

eg. having a 50 x 50 tile size and using set spriteanimation() to access it on a 1024x1024 image (normally not possible)
xGEKKOx
AGK Master
15
Years of Service
User Offline
Joined: 7th Dec 2008
Location: Italy
Posted: 30th Jun 2013 13:10
And how can i avoid the scaling for example if i wanna do a TILE of 2048px * 2048px

I must size it * 2???
Which is the method to port it again to the real size?

Long life to Steve!
DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 30th Jun 2013 23:19
The 1024x1024 image restriction is really down to hardware. I think the new Iphones' support 2048x2048, but I could be wrong. There's not a lot you can do about it I am afraid.

xGEKKOx
AGK Master
15
Years of Service
User Offline
Joined: 7th Dec 2008
Location: Italy
Posted: 1st Jul 2013 14:44
I understand!
Thx to all for the infos!!!

Long life to Steve!

Login to post a reply

Server time is: 2024-11-24 15:28:32
Your offset time is: 2024-11-24 15:28:32