 |
 |
|
 |
07-10-2009, 02:22 AM
|
#1 (permalink)
|
|
iPhone Developer
Join Date: May 2009
Location: Pune, India
Age: 23
Posts: 61
|
png images in memory.??
hi everyone,
am facing a problem, in my game i am using 80-90 png images of different size. The problem is that game is slow and unplayable, is there any difference if I crush png images and then use with "imageNamed:" ...... before I used "imageWithContentsofFile" .... but it had taken lots of time to load...
Is there any way to solve this prob
Thanx in advance ..
|
|
|
07-10-2009, 02:58 AM
|
#2 (permalink)
|
|
Senior Member
iPhone Dev SDK Supporter
Join Date: Jul 2008
Location: San Mateo, CA (San Fran)
Posts: 2,448
|
Quote:
Originally Posted by AmitSrivastava
hi everyone,
am facing a problem, in my game i am using 80-90 png images of different size. The problem is that game is slow and unplayable, is there any difference if I crush png images and then use with "imageNamed:" ...... before I used "imageWithContentsofFile" .... but it had taken lots of time to load...
Is there any way to solve this prob
Thanx in advance ..
|
Were you calling "imageWithContentsofFile" every frame? You probably need to load your images into an array at startup, and then reference them each frame without recreating them.
"imageNamed" is faster when you recreate the same image over and over, but you should not need to recreate them over and over; also imageNamed uses more memory (to cache the images.)
Also, how big are the images? If they are full-screen you'll probably only get about 20 images loaded at once before you run out of memory.
__________________
|
|
|
07-10-2009, 03:14 AM
|
#3 (permalink)
|
|
iPhone Developer
Join Date: May 2009
Location: Pune, India
Age: 23
Posts: 61
|
Quote:
Originally Posted by smasher
Were you calling "imageWithContentsofFile" every frame? You probably need to load your images into an array at startup, and then reference them each frame without recreating them.
"imageNamed" is faster when you recreate the same image over and over, but you should not need to recreate them over and over; also imageNamed uses more memory (to cache the images.)
Also, how big are the images? If they are full-screen you'll probably only get about 20 images loaded at once before you run out of memory.
|
Thanks for reply,
i am not recreating the images, i have stored in a NSMutable Array and using index of that Array,
Code:
- (void) initImages{
XImg = [UIImage imageNamed:@"X.png"];
[Xmages addObject:XImg ];
// 33 times
}
- (void) XImage{
Ximageview.image = [Xmages objectAtIndex:XImageCount];
XImageCount++;
if(XImageCount>=33){
XImageCount=0;
}
}
above all 33 image covers 70% of iPhone screen.
if i compress the png file, will it create any dfference?

|
|
|
07-10-2009, 11:32 AM
|
#4 (permalink)
|
|
Senior Member
iPhone Dev SDK Supporter
Join Date: Jul 2008
Location: San Mateo, CA (San Fran)
Posts: 2,448
|
Quote:
Originally Posted by AmitSrivastava
above all 33 image covers 70% of iPhone screen.
if i compress the png file, will it create any dfference?
 
|
Good, you are not recreating the images. I do not think compressing the images will affect the speed.
You could try Ximageview.animationImages = Xmages ; that may run smoother than setting the image by hand.
__________________
|
|
|
 |
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
» Advertisements |
» Online Users: 381 |
| 27 members and 354 guests |
| bluemonkey, chakri_123, CoolApps, dongmark796, dre, Ed99, ethanwa, hinderberg, jasonfan, kikesantos, Lalitpune, mallmertl, MarkC, mizan_102, mlfarrell, msudan, pjlocko, racer_X, rahul, rainbows, raziiq, sanjeev, scalar, shuvo1879, sijo006, steve6546, Tambourin |
| Most users ever online was 779, 05-11-2009 at 10:55 AM. |
» Stats |
Members: 21,463
Threads: 35,753
Posts: 156,615
Top Poster: smasher (2,448)
|
| Welcome to our newest member, dongmark796 |
|