Don’t multiply velocity/position changes with delta time! End of story.

Okay, not quite. There’s a rationale that goes with it. And there are situations where applying delta time is important, if not required – but probably not in the way you’ve been taught by tutorials and fellow developers.

This is important stuff because applying delta time wrongly makes for a bad game experience.

What is this delta time thing anyway?

If you integrate velocity to a node’s position every frame, you have the option to multiply that velocity with the delta time passed in the update: method. Delta time is simply the time difference between the previous and the current frame.

Actually that is not entirely accurate – delta time is the time difference between the last and current execution of the update: method. This usually occurs every frame, but doesn’t have to be. On a scheduled selector that runs every second, the delta time is – tadaa – one second.

Okay, not even that is accurate. On a scheduled selector that runs every second, delta time is at least one second. It could be slightly more. This can depend on the resolution of the timer and how well one second divides with the time allocated to render a frame, or (as you’ll see later) whether time delta was calculated with the same means as the screen refresh rate.

What does multiplying with delta time do?

The effect of (not) multiplying a node’s velocity with delta time is as follows, assuming that 60 fps is the maximum achievable framerate as on iOS:

  • Don’t multiply with time delta: the node slows down as the framerate drops below 60 fps. 
  • Multiply with time delta: the node moves the same distance regardless of the framerate.

Multiplying with delta time is often referred to as “framerate independent” (updates, movement, gameplay, etc). In contrast not multiplying with time delta is often called “framerate dependent” (updates, movement, gameplay, etc).

Unfortunately, framerate independent updates are said to be “important” and often taught by fellow game developers without actually teaching the implications, drawbacks and situations where you don’t want to apply delta time. Here’s one key point to take away early:

Applying delta time only makes a difference when the framerate drops below 60 fps.

If your game always runs at 60 fps there’s absolutely no point to multiply with time delta. If time delta is only used to combat the effect of short-lasting framerate drops, possibly introduced by system events, you’re doing it wrong.

In this case, and most others too, you’re almost always better off not applying delta time on iOS. And if you do, there’s a whole set of things to consider, including the architecture of both the game and the engine.

Continue reading »

In order to write Tiled’s TMX file format I needed to do exactly this: figure out how to compress data, encode it as a string, and write it to XML.

I wrote down what I learned from using zlib, base64 and xswi – XML Stream writer for iOS (a single Objective-C class) while writing KoboldTouch‘s TMX writer.

I split it into two articles in the Essential Cocos2D section of the www.KoboldTouch.com homepage:

I was positively surprised how relatively painless zlib and base64 encoding worked (I expected the worst!) and how simple and effective xswi is for writing XML compared to any other XML library.

I’ll probably continue to add those articles to Essential Cocos2D rather than posting them on this blog. Confluence is just so much more convenient for writing technical documentation than WordPress.

Final word: Enjoy! :)

Tagged with:  

It’s hard to find the right words to describe the launch of KoboldTouch. I can’t think of anything else but WOW! right now. :)

I can’t wait to hear what you have to say about KoboldTouch, and then act on your feedback.

For those who were just waiting for the launch:

Sign up on the KoboldTouch product page to get access to KoboldTouch and Essential Cocos2D.

The rest of this post is a summary of what I wrote before on these two-products-in-one. Actually, I think of KoboldTouch & Essential Cocos2D as being much more a service than products. And it’s a full time commitment from myself.

This calls for music! :)

Continue reading »

Tagged with:  

The REAL Trouble With Android

On August 9, 2012, in idevblogaday, by Steffen Itterheim

It isn’t piracy!Not even close.

I have a problem with terms that are not clearly defined. Words like “much”, “a lot” or as in this case: “unbelievably high”. If you argue that the problem with Android is its high piracy rate based on one developer’s subjective statement and general hearsay, it’s not an argument.

Before I get to debunk why piracy can’t be that big an issue for Android developers, allow me to restate which developers regularly complain about piracy to begin with. There always seems to be the issue that low selling apps see a much larger percentage of pirated copies being used than high volume apps. This is because some pirates download and try out almost everything that’s available just because they can.

Interestingly, the badly selling app developers seem to be those who complain the most about piracy. Because it’s so easy to blame a failure to sell on piracy. See this fictive graph:


Continue reading »

Tagged with:  

Learnflash: Great OpenGL ES 2.0 Tutorials & References

On July 13, 2012, in Programming, by Steffen Itterheim

Right now I’m trying to freshen up what little I know of OpenGL ES 1.1 so I’m up to speed with OpenGL ES 2.0. I keep using the old ES 1.1 functions, so I thought I’d take the opportunity to re-learn OpenGL ES 2.0 from the ground up.

This OpenGL ES 2.0 Primer is helpful if you want to gain an understanding what’s different (and cool) about OpenGL ES 2.0 when compared to 1.1. It won’t teach you how to use OpenGL ES 2.0 though. The High-End 3D Graphics with OpenGL ES 2.0 PDF covers the concepts in greater detail, and quickly runs you through all important processes from initialization to compiling shaders to shutting down OpenGL ES 2.0. Again I didn’t learn how to program but it helped me understand the GL ES 2.0 concepts.

But what I really wanted was to learn how to do things with OpenGL in the context of cocos2d. Which means I just need to draw stuff, I don’t need to know how to load textures and setup the viewport and things like that. Nevertheless, Ray Wenderlich has done a great job explaining how to create a OpenGL ES 2.0 iPhone project from scratch. And Jeff LaMarche covered ES 2.0 shaders in great detail.

Continue reading »

Tagged with:  

iPhone Quarterly Sales (Source: Wikipedia / Apple Quarterly Results)

With Apple’s blazing Q1 2012 quarterly results, which sees iPhone sales double (!) that of the previous Q4 2011 and last year’s Q1 quarter, it’s time to update my iOS Device sales statistics from July 2011.

Apple’s Quarterly Results Reports have one big flaw for those interested in per-device numbers: Apple only mentions how many iPhones, iPods and iPads they have sold in each quarter, but this includes all models. So you have to exclude the discontinued models as well as somehow determine (if only by guesstimating) how many iPod touch vs regular iPods, or how many iPhone 3G vs iPhone 3GS have been sold in that quarter.

I took the publicly available numbers and then used a reasonable guesstimate to split the device sales of two combined models in order to get a reasonably accurate estimate. I mainly wanted to determine how the gap is widening between the OpenGL ES 1.1 and OpenGL ES 2.0 models. This is particularly interesting for Cocos2D developers who may be wondering if it’s save to upgrade to Cocos2D 2.x or whether it’s still worthwhile to stick with Cocos2D v1.x to be able to deploy even to 1st and 2nd generation iOS devices.

Continue reading »

The iOS & Android mobile game revenue has jumped from 19% to 58% in 3 years. While these numbers are only percentages and do not reflect an overall growth in the market, it does make one thing very clear: the dedicated handheld gaming devices are losing market share big time. And just as the 3DS has failed to inspire consumers so will in all likelihood the PS Vita.

Continue reading »

Tagged with:  
Page 1 of 212