Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 03-31-2010, 02:42 AM   #1 (permalink)
Johanovski
Divine avenger
 
Johanovski's Avatar
 
Join Date: Nov 2009
Location: Vic, Catalunya (Spain)
Posts: 320
Johanovski is on a distinguished road
Default Is it better to use various images or an imageSet?

Hi there!

I'm working in a 2D OpenGL project and now I'm building the image system. For example, let's say I have an object that must be animated in a 4 sprites loop. It's better to have it's 4 images individually or to have a single image that contains the 4 images?

Here it goes the code assuming the 4 individual images way:
Code:
// Loading 4 images (32 width x 32 height each) in an image array...
img[0] = [[Image alloc] initWithImage:(...)@"sprite1.png"];
img[1] = [[Image alloc] initWithImage:(...)@"sprite2.png"];
img[2] = [[Image alloc] initWithImage:(...)@"sprite3.png"];
img[3] = [[Image alloc] initWithImage:(...)@"sprite4.png"];

(...)

//And to show them:
[img[frame] renderAtPoint:(...)];ç

frame++;

if(frame > 3)
{
        frame = 0;
}
And if I use the one imageSet method...
Code:
// Load a single 64 width x 64 height image
imageSet = [[Image alloc] initWithImage:(...)@"imageSet.png"];

(...)

// And to show them:
switch(frame)
{
        case 0:
                [imageSet renderSubImageAtPointStartingAt:(0,0) Dimensions:(32,32) (...)];
        break;
        case 1:
                [imageSet renderSubImageAtPointStartingAt:(32,0) Dimensions:(32,32) (...)];
        break;
        case 2:
                [imageSet renderSubImageAtPointStartingAt:(0,32) Dimensions:(32,32) (...)];
        break;
        case 3:
                [imageSet renderSubImageAtPointStartingAt:(32,32) Dimensions:(32,32) (...)];
        break;
}

frame++;

if(frame > 3)
{
        frame = 0;
}
Which way is preferred to optimize memory, and which way makes game go faster? Let's say I have like 10 different types of image with 4 to 6 frames each, which means to load around 50 individual images, or to load just 10 images but with higher dimensions...

Thanks in advance!
Johanovski is offline   Reply With Quote
 

» Advertisements
» Online Users: 330
11 members and 319 guests
.Snipe, Bertrand21, chemistry, Domele, greeneye82, HemiMG, jbro, matador1978, mobilaga, Newbie123, Plazor
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,553
Threads: 94,078
Posts: 402,735
Top Poster: BrianSlick (7,990)
Welcome to our newest member, zulemamn37
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 07:54 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.