Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

MasterObiWan

macrumors newbie
Original poster
Jan 12, 2009
18
0
I have tried doing this and the outcome was not good. It works fine in simulator, but when trying to run on a device it is unplayably slow (the sprites will barely move).

My question is if I had made my game in OpenGL would it run properly? Or does this have something to do with my code, and even if I did rewrite it in OpenGL would it be the same outcome?
 

admanimal

macrumors 68040
Apr 22, 2005
3,531
2
My question is if I had made my game in OpenGL would it run properly? Or does this have something to do with my code, and even if I did rewrite it in OpenGL would it be the same outcome?

This question is virtually impossible to answer without knowing what your code looks like, although generally speaking you should get better performance from OpenGL.
 

MasterObiWan

macrumors newbie
Original poster
Jan 12, 2009
18
0
So you are saying it is possible to make a playable game in quartz.

I'd like to paste my entire code , but then someone might figure out what I'm trying to make. I hope this will be enough to figure it out:

What I think might be causing it to run slow:

1)All my methods are written in the same file as my code. So all i have to do is do [self someMethod] to call my method. Do I have to release a method everytime I use one?

2)A timer thread runs every 0.01 calling a bunch of methods, this basically makes my entire program animate and run. example:

timer = [NSTimer scheduledTimerWithTimeInterval:(0.01) target:self selector:mad:selector(onTimer:) userInfo:nil repeats:YES];

In method :eek:nTimer {
[self moveEnemies];
[self movePlayer];
bla bla etc etc...
}

This is how I usually do it in Java btw.
 

firewood

macrumors G3
Jul 29, 2003
8,141
1,384
Silicon Valley
If you have more than just a few sprites, OpenGL is tons faster than Quartz 2D on the iPhone.

It almost seems like the iPhone does not have any actual 2D drawing capability, but converts every 2D command, view or layer into OpenGL textures and such, hidden behind the back, before doing any rendering. Might as well go straight to OpenGL if you can.
 

admanimal

macrumors 68040
Apr 22, 2005
3,531
2
It almost seems like the iPhone does not have any actual 2D drawing capability, but converts every 2D command, view or layer into OpenGL textures and such, hidden behind the back, before doing any rendering. Might as well go straight to OpenGL if you can.

.

It wouldn't be surprising if that was the case, since I'd guess that real OS X uses OpenGL as the bottom layer for most of its drawing as well.
 

detz

macrumors 65816
Jun 29, 2007
1,051
0
The highest I could get mine was around 16fps when using quarts with a bunch of animations. It depends on how complicated your game is going to be.
 

jnic

macrumors 6502a
Oct 24, 2008
567
0
Cambridge
Thirded. Up your NSTimer interval to 0.05 or so and see how it runs. The difference between 100 fps and 20 fps is only barely visible to the eye.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.