PrEV
Thoughts from a NeXTStep Guy on Cocoa Development

Episode 5 - getting iPhoto photos into the cover flow view is live

Jul 08, 2008 by Bill Dudney

Episode 5 is live, sorry for the delay. I've been swamped with iPhone work the last week +.

Episode 6 should be ready RSN, its the final bits where we add cover flow to the iPhoto photos. It looks really nice :)

Permalink     Add A Comment

CA Screencast Review

Jul 03, 2008 by Bill Dudney

Erica Sadun did a quick write up of my screencasts here.

Thanks Erica!

Permalink     Add A Comment

On Being an Indie & Making Great Software

Jun 29, 2008 by Bill Dudney

Friday just as I was packing up to leave the great state of NJ I noticed this post from Scott. I thought perfect, that is the kind of developer I want to be. The person that thinks always about experience. Not just of my users (but of course, them first) but also about my future self trying to read my code. Did I hack, did I do something that was quick and easy instead of spending the time to make it right? And not just with my games but also with the books too. Did I spend the time to make the section or chapter right, I always want to do that. I never want to settle for less than my best.

Then on the plane while not allowed to use 'personal electronic devices' I stumbled onto page 17 of this. 'The Business of Magic', apparently United is trying to teach their folks that building the plane ride into a positive experience will lead to more committed customers. I doubt they have much chance with the declining nature of air travel its time for a revolution there. But that is another post...

United appears to be turning to Disney to help them. Apart from some of the tactics they use to milk nostalgia for every last $ Disney is a great company. Going to DisneyWorld/Land is a magical experience for a 3 year old. It's like walking into a fairy tail. And its not just the princesses and other characters everyone there is all about the experience. All of the staff want to make your day magical, as a Dad it's just fantastic. From start to finish the whole thing is just immersive. That is why Disney does well, and I think a big part of why Apple does well.

Apple does not settle for iPhone light, that is kinda cool and does some fun stuff. They only settle for fantastic. They don't settle for iPhoto that works, they make iPhoto that delights. That is the kind of software I want to build. The kind that people show to their friends and say 'wow this is cool, look at this!'. I'm working on it, and working and working.

Permalink     Add A Comment

beta 8

Jun 26, 2008 by Bill Dudney

Get it while its hot..

Permalink     Add A Comment

Great review of the CA book :)

Jun 25, 2008 by Bill Dudney

Clint Shryock has some very kind words to say about the CA book.

It is exceedingly gratifying to have someone get something out of a thing you have labored over so hard for so long. Thanks for posting Clint, you made my day!

Permalink     2 Comments - Add Yours

CATiledLayer section...

Jun 24, 2008 by Bill Dudney

After much procrastination I finally got the CA section done on tiled layers. Man what a pain. Not that the tiled layer is hard to work with, I just had a hard time figuring out how to explain the example that I did without miring the reader in detail. I basically took the concepts I talked about here and expanded it to show using a sliced image. I hope it is helpful, for thoes on the beta it should be in the next drop. Your comments are greatly appreciated.

Permalink     1 Comment - Add Yours

iPhoneDevCamp 2 - speaking and hacking

Jun 20, 2008 by Bill Dudney

I am going to be speaking @ iPhoneDevCamp2 about CA on the iPhone. Should be really really cool, now if I can just make time to build the cool app I want to show of in the midst of writing (book & games)...

Hope to see you there!

Permalink     2 Comments - Add Yours

CATiledLayer Example

Jun 13, 2008 by Bill Dudney

One of the examples I put off until I had to do it was CATiledLayer. Basically the docs were not very complete so I was hoping that by the time I really needed them I'd have better docs. Well the docs never materialized but I had 2 or 3 errata about the lack of an example so I figured I'd get off my back side and get something done. I did an example that will make it into the book. It is on drawing png's with multiple versions of the image that are drawn depending on the scale factor, its cool you will like it :).

In the mean time there were still a few things that seemed like I did not grok. So, I went to the CA lab time while out here at WWDC (besides networking that is the other 'coolest thing' about being here). After spending some quality time with the folks in the lab I think I finally have the tiled layer nailed.

I've uploaded the example here.

The example shows a delegate doing all the drawing (which is drop dead simple) and the view setting up the layers. The thing I had wrong in my head was related to levelsOfDetail and levelsOfDetailBias. Levels of detail determines the # of levels of detail (seems obvious doesn't it...) and the bias determines how many are 'reserved' for zooming in. So if you set the levels of detail (LOD) to 4 and the bias to 1, you'd get 2x zooming in (2^1) 'native zoom' (2^0), 2x zoomed out (2^-1) and 4x zoomed out (2^-2). If you set the LOD to 8 and the bias to 5 you'd get 32x zoomed in (2^5) to 4x zoomed out (2^-2). Hope that makes sense, if not feel free to ping me.

Happy animating...

Permalink     4 Comments - Add Yours

New iPhone SDK Posted...

Jun 09, 2008 by Bill Dudney

Beta 7, developer.apple.com/iphone

Permalink     Add A Comment

WWDC Keynote Line...

Jun 09, 2008 by Bill Dudney

So I feel like i'm part of some crazy cult. I was in line this morning @ 4:30 and i'm about 200 folks behind the front. Not bad compared to last year when I got in line @ 5:45 and was about 2500 in line...

The line...

NDA lifted, please please please oh please...

Permalink     2 Comments - Add Yours

Episode 4 - Core Animation Screen Cast Posted

Jun 03, 2008 by Bill Dudney

I finished it up last night and the gerbils (i.e. Mike Clark) @ PragProg already turned it into a downloadable movie. You can grab it here.

This episode came in a bit long (at 42 minutes) but I could not think of what to delete. The main thrust of the episode is introducing 3D transformations and in order to make that happen I did a bunch of refactoring to the app so the layers would be setup to make beautiful cover flow goodness. At first I was thinking it would be good to just make the refactoring happen off line and then paste it in as canned code. After running though half the episode doing that I thought I was just leaving out too much good stuff about debugging tips and refactoring process. So anyway I put it in and it came in big.

Hope you enjoy it!

Permalink     Add A Comment

Core Animation Screen Cast is Live!

May 27, 2008 by Bill Dudney

In addition to working madly on getting my iPhone apps done I've also been building some really cool screencasts. I'm really excited about this, its a way to realize what I blogged about way back here.

Here is the intro to the series. This is basically the first 3 minutes or so of the first episode pulled out and made free so you can get a feel for what is in the screencast. Hope you enjoy it!

Permalink     Add A Comment

Keyframe Animation

Apr 03, 2008 by Bill Dudney

I have been doing some keyframe animations lately and figured it would make a good entry.

Keyframe animations are cool because they give you more exact control over the way your layers animate. The basic animation does a linear interpolation between the 'start' value and the 'end' value. Which works great in many if not most cases but some times you want the path your animation follows to be something different or more sophisticated. The keyframe allows you full control over the intermediate values of the animation.

Whereas the basic animation does a simple linear interpolation the keyframe allows you to specify values at intermediate times so that you can fully control the value during the whole animation. Keyframes have played a part in animation since the days of hand drawn movies. Senior artists would draw the 'key frames' for a scene and then junior artists would fill in the required frames to make the animation smooth (sometimes this process is called tweening). The keyframe animation takes care of the tweening for us we specify the 'key frames' and it does the rest.

Another cool thing is the 'value' that the keyframe can animate is anything that the basic animation can animate. Specifically that boils down to any property of types number, point, size or rect. So for example if we wanted to animate the opacity of a layer we could specify several different values (i.e. 0.25, 0.50, 0.75) that should be reached at specific times during the animation. The keyframe animation would then interpolate between each of the values that we specify.

Another aspect that is really cool is that we can use CGPath's to specify the values instead of discrete values. In other words instead of specific values at specific time points we can use a path to specify the values. For example we could animate the opacity of a layer with a bell curve, start transparent, fade up to some opacity value and then fade back. We can also use the paths to animate CGPoint and CGSize values. In this case the x value of the path becomes either the x or width value and y becomes the y or height values.

In the example we will have a layer move back and forth across the window. Here is a screen shot of the app running.

The white line is a bezier path that we are using to animate the movie layer across the screen. Its drawn simply so we can see it in greater detail. Here is the code used to create the path.

  CGMutablePathRef path = CGPathCreateMutable();

  CGPathMoveToPoint(path, NULL, _point1.x + _movieSize.width * 0.5f, _point1.y);

  CGPathAddCurveToPoint(path, NULL, _controlPoint1.x + _movieSize.width * 0.5f,

                        _controlPoint1.y, _controlPoint2.x - _movieSize.width * 0.5f, 

                        _controlPoint2.y, _point2.x - _movieSize.width * 0.5f, _point2.y);

  if(NULL != _rightBoundKeyframePath) {

    CGPathRelease(_rightBoundKeyframePath);

  }

  _rightBoundKeyframePath = CGPathCreateCopy(path);

  CGPathRelease(path);

  

  path = CGPathCreateMutable();

  CGPathMoveToPoint(path, NULL, _point2.x - _movieSize.width * 0.5f, _point2.y);

As you can see it straight Quartz path creation code. We then place that path into a keyframe animation like this;

  CAKeyframeAnimation *animation = [CAKeyframeAnimation animation];

  animation.duration = 2.0f;

  if(YES == _atLeftEdge) {

    animation.path = _rightBoundKeyframePath;

    // the rotation mode causes the layer to rotate along with the slope of the path

    animation.rotationMode = kCAAnimationRotateAuto;

  } else {

    animation.path = _leftBoundKeyframePath;

    // since the path is reversed, rotate at 180 degrees off

    animation.rotationMode = kCAAnimationRotateAutoReverse;

  }

  _movieLayer.actions = [NSDictionary dictionaryWithObject:animation forKey:@"position"];

Now when ever the position of the layer is changed it will follow the path instead of the default linear interpolation. There is a lot more to be said here but this at least gives a quick intro do using the keyframe animation. Here is the code.

Have Fun!

Permalink     3 Comments - Add Yours

Prag Prog Podcast

Mar 25, 2008 by Bill Dudney

I seem to be podcasting a bunch lately, which is really fun.

The latest entry into that is here.

Permalink     1 Comment - Add Yours

New iPhone Game - iScramble

Mar 10, 2008 by Bill Dudney

My wife just released her 5th iPhone game here. Its a word scramble game that has several different themes and really nice pics in the background. Some of them might take a while to load over Edge (where is 3G anyway?:). If anything is particularly bad please let us know.

Permalink     Add A Comment