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

Mockup & CodeGen, iPhone & iPad
($9.99)

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

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 03-31-2010, 03:42 AM   #1 (permalink)
Divine avenger
 
Johanovski's Avatar
 
Join Date: Nov 2009
Location: Vic, Catalunya (Spain)
Posts: 320
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
Old 03-31-2010, 05:17 AM   #2 (permalink)
Divine avenger
 
Johanovski's Avatar
 
Join Date: Nov 2009
Location: Vic, Catalunya (Spain)
Posts: 320
Default

Anything about this...? I have to decide how to process the images but I don't want to do anything before knowing which one is best with OpenGL...

Thanks!
Johanovski is offline   Reply With Quote
Reply

Bookmarks

Tags
image, imageset, opengl, renderimage, rendersubimage

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 354
22 members and 332 guests
ADY, Dani77, Duncan C, e2applets, Grinarn, HemiMG, Herbie, JasonR, keeshux, linkmx, macquitzon216, mer10, Monstertaco, prchn4christ, Promo Dispenser, Robiwan, sebasx, sly24, Touchmint, twerner, zulfishah
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,881
Threads: 89,228
Posts: 380,760
Top Poster: BrianSlick (7,129)
Welcome to our newest member, macquitzon216
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 01:37 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0