存档

2009年4月 的存档

Are most games on the IPhone done with OpenGL ES?

2009年4月14日 没有评论

I was just wondering if most games on the iPhone are done in OpenGL ES as opposed to using Quartz and Core Animation. Are Quartz and Core Animation mostly used for just creating slick interfaces? Or if there is a point with games where OpenGL probably has to be used over using other tools?

For efficiency reasons OpenGL ES is you best choice for games, unless your writing a “simple” board game or card game (like Solitaire). In this case Core Animation would be a good fit.

You should check out cocos2d-iphone if you are going to do a 2d game. It seems to be a pretty solid foundation. It comes with the chipmunk physics engine and everything all ready to go.

I think OpenGL is your best choice, I can’t agree that the Quartz stuff is any easier to use.

Also if you’re successful then most of your code will be portable to other platforms. Something to consider.

Mostly it comes down to whether you need 3D or not. If your game is entirely 2 dimensional, then using Quartz for your drawing is probably simpler. Not that OpenGL is all that complicated, but it is more complex than the Quartz interface.

Quartz drawing and compositing will be OpenGL accelerated when possible, so there shouldn’t be much performance difference if you’re strictly doing 2D drawing.

分类: stackoverflow精选, unity3d 标签:

Custom easing action with Cocos2D-iphone

2009年4月14日 没有评论

How would one go about creating a custom action in Cocos2D that was able to perform a ‘callback’ over time, making each call to the callback progressively longer than the last call to it (using something similar to the EaseExponentialOut action already provided with Cocos2D.

Something similar to this: (which does not work)

id sequence = [Sequence actions: [CallFunc actionWithTarget: self selector: @selector(spinTick)], [DelayTime actionWithDuration: 0.034f], nil];
id repeat = [Repeat actionWithAction: [sequence copy]  times: 18];
id ease = [EaseExponentialOut actionWithAction: [repeat copy]];
[ease setDuration:4];

id play = [CallFunc actionWithTarget:self selector:@selector(play)];
[self runAction: [Sequence actions: [ease copy], [play copy], nil]];

The above code executes the entire ‘sequence’, 18 times and then executes the ‘play’ callback at the end of the last sequence.

However, the EaseExponentialOut does not appear to have any affect at all on the ‘repeat’ action that is created – I had expected it to adjust the duration of the ‘DelayTime’ action inside of the ‘sequence’ action, but it does not appear to do this.

I also attempted to create my own custom action based on IntervalAction, but failed miserably.

Apparently, the code above is functional, it was just my use of the timing in the durations. It was also not necessary to use ‘copy’, as the actions are usable as is.

If I increased my timing from 0.034 to something more along the lines of 0.25, then the result was closer to what I was hoping to see. Now I just have to play with the values for duration to get it ‘just right’.

分类: stackoverflow精选, unity3d 标签: