Thursday, November 18, 2010

Image editor gets some love

After my breakthrough with the line and bezier drawing, I've decided it's time to nickel and dime a few things.

This evening I spent about 2 hours getting images to auto-snap in place in the pict editor as well as toggling the images on and off.  This will help with drawing pictures as you can now toggle the background images on and off and "trace" them to get a better picture.  I wanted to actually resize the image rather than just displaying it resized, but alas that's not as easy as I expected.  Still not sure why, that's where the bulk of my time has gone.  NSImage expects you to know a lot more about images than I do apparently.

This still needs some work -- you can add as many pictures as you want (we should limit to 1) and the images need to be re-sampled down smaller than they are.  We also need to make a category, phrase (hint?) and exact word match meta-data in the editor as well so that the pict app can do something useful with the sketch files.

I may as well post a picture as an example of the image background scaling, since this blog would be awfully boring without pictures.  Well okay, and maybe a little bit boring WITH pictures.  Please excuse zeratul's arm, it's currently part of my desktop background.  You can see the auto-scaling at work, the regular size is in preview.

Monday, November 15, 2010

pitfalls of early optimization

So I don't know that I've mentioned this on this blog, at least not recently.  Pict has had a serious issue drawing straight lines when run on the iPad.  As in it locks up the whole iPad for seconds at a time while drawing straight lines if they are longer than about an inch.

Drawing lines and curves over time isn't something that's normally done for computer graphics.  Most applications want to draw a line or a curve from start to finish, they aren't interested in the user watching this happen.  Incidentally the math is totally different.  Fortunately I'm building on the shoulders of giants.  Well, people better at math than I am.

I created my own actions in cocos2d by overriding the CCMoveTo and CCBezierTo classes.  In practice this means that I needed one additional piece of information (the last time we've updated) to be able to draw the points we may have missed along the way in addition to using a CCRenderTexture to draw the "pen" sprite into.

This has been a thorn in my side for months and a point of discouragement on this project.  What's the point of making a drawing app if the drawing takes way too long?  Without that the app is dead.  Very discouraging.

I've been hitting my drawing code off and on for the past four months and have made little headway.  This saturday past I sat down for almost 5 hours and gave it a serious rework.  I know WAY more than I want to about bezier paths and drawing a point on a line.  However I ended up giving up around 1 AM.  The one thing I knew at the end of the night was that most of my approaches had been flawed and I knew why.

However my focus was all for naught.  It seems that due to profiling where my time was being spent with instruments, I was misled. Yes, all of my time was spent drawing and that's where things pointed.  The solution was not how often I was calculating or where I was doing my drawing, but how often I drew to the CCRenderTexture.  Specifically how often I called CCRenderTexture's begin and end functions.  Rather than move my CCSprite and using the method [sprite visit], I saved all of my positions and then drew them in a for loop in my render texture.  In pseudo-code the original was doing something like this:

// figure out the new sprite position that's needed to draw
// draw the sprite into the render texture
  // CCRenderTexture begin drawing
  // set the sprite to the new position
  // [sprite visit]
  // CCRenderTexture end drawing
// repeat as necessary
// return out of our update function

After many many attempts at changing how many and often I drew, I changed the code to do this:

// figure out the new sprite position that's needed to draw
// save the new position
// repeat as necessary

// CCRenderTexture begin drawing
// iterate over my points, moving my sprite
  // [sprite visit]
// CCRenderTexture end drawing
// return out of our update function

This totally fixed the problem.  Ugh, what a pain!  In hindsight it seems somewhat obvious.  Maybe I'm clueless but I'd like to think it wasn't obvious from my previous perspective.

Lesson:  CCRenderTexture (and as an extension, some openGL calls) can be expensive if used too often!

Here is a reference to the (old) cocos2d threads related specifically to my drawing are here, here and here.

Wednesday, August 25, 2010

About this blog

If you've read any of the past entries here they may be a little confusing.  The previous entries are largely a time log of my iPad development activities related to an app I am writing codenamed "Pict".  The game will be a pictionary variant, and I hope successful on the iPad as a social game.  I had planned on starting this blog much sooner to track my development but it worked out to be about 4 months of writing to a text file on my hard drive.  This evening I've spent a couple of hours and posted that log here.  There are some linked gems with little to no background information on what problems they solve, but I figured worst case they wouldn't be useful to anyone, best case they actually helped some poor googling soul out to find a solution.

I hope to have more interesting and elaborate posts in the future concerning my iPad development rather than a simple time log.  That may or may not happen, we shall see.

Thanks for stopping by.

where did I go?

8:45 PM - it's been almost 2 months and little has happened with Pict.  It's been on hold as I've worked with Folder Lite, Updating Folder, been on vacation, played through the starcraft 2 campaign, and generally haven't done much that's difficult in the way of iOS programming in my spare time.  Though at work I've been working the past month almost exclusively on the iPad, on (the back end of) an iPad front end for our company's software.  I've learned a lot but mostly have worked on the back end, so there's not a lot to show.  That's coming to an end, but the UI heavy portion of the project is coming up in the next month.  I think that's part of why I've been set back some -- I'm doing this full time.  I did get to learn core data on the clock though which was nice.  Core Data may be good for some uses, but I haven't found the best scenario for it yet.  I wish we had used SQLite actually for our app at work as what we are doing is the wrong fit for Core Data.  Anyhow.  This evening I'm going to start a new from scratch but copying a lot of code framework for Geopher Lite and turn it into Geopher Geocaching.  I think that will work better as a name and have it do a number of things better.  I guess we will see.  I may also post this time log on the blog it was originally intended for, we'll see on that as well.

More later.

Saturday, June 26, 2010

More love for sketch+Accessibility

5:00-7:00 PM, 8:00-9:30 PM - Today I added the item list tool window to the sketch+accessability project. This window shows all of the objects that are currently stored in the graphics view by name. Right now it's a window with a table in it. It also has a refresh button. Incidentally, the sketch+accessability also uses bindings heavily, and those are kicking my butt. So I'm making refresh calls to the table, which is less than optimal. Someday I'll understand bindings, but for now it's just in my way. :/ Anyhow, the idea is to be able to select multiple items both with your cursor like it did before as well as within this window. This will help to organize the order of the object drawings as well as hopefully make creating and editing a given picture easier, since the selection method is less than ideal. The background is going to have to be done independently of SKTImage I think, otherwise it will get tied up with the rest of the drawing code, which could be bad. I'm not 100% sure how I'm going to handle that yet, but that will have to be finished. Along with other details about the drawing that need to all go together… (category, item name, brief description? etc) Wish me luck, I'll need it. =)

I realize now that at some point I've revisited sketch and ripped out all of the per-pixel specifics and didn't log that.  It's more vanilla and I'll use transforms to get the drawing to draw where I need it.  The window does resize the grey box automatically to the optimal size right now for the iPad, but since I'm not doing other odd pixelly things you can use the already built tools like the grid and zoom features to help draw.  Adding curves to this also helps immensely.  Still no word on if I'll support text, I kind of don't expect to, but we shall see.

Friday, June 25, 2010

Riq is a cool project maintainer

9:30 PM - 10:45 PM - Riq, the creator/maintainer of cocos2d fixed the previous problem. Apparently CCRenderTexture was making bad assumptions on how to get the screen position. I fixed that and added it to my app. I also commented on the cocos2d forums and added (hopefully) proper suspend/resume capability to cocos2d.

Thursday, June 24, 2010

cocos2d revisited

10:45 PM - 12:00 AM - Updated to the new cocos2d release candidate (0.99.4rc2 to be exact) and found a bug with it. Did some exploring and posted how to reproduce it on the cocos2d forums. Pict works respectably well on the new iPhone, it looks pretty close to the iPad version actually, which makes sense as far as the resolution goes. Fun to see it on there and work with the new phone some. Here, have a screenshot of the bug.

This is a screenshot from the new iPhone 4 itself, unmodified. That's a lot of pixels to fit on a 3.5 inch screen!

Monday, June 21, 2010

sketch editor gets some love

10:30 PM - 11:30 PM - Played with the image editor some. I think we are going to need either layer support or some kind of object selection tool more than just the arrow. If you have a bunch of objects then it will be difficult to adjust things around. Additionally, we will want to adjust the points so that they are more or less sequential. When it draws it could be random, but that is probably less ideal than having the person making the image adjust it to the "ideal". We will see, I may need to automate this somehow, but for now it is drawing on the object order added, from back to front.


I fixed the background to be grey instead of white and made it 512x512, which I think we decided upon for the iPad version. The new iPhone version should work OK at this resolution as well, though if I do make this a universal app then I think I will be scaling it down to work with older devices as well. The drawing program already supports images, so I will need to tap into the images code and auto-position the image. No huge technical hurdles (that I'm aware of) left other than possibly the huge performance hit that I'm seeing on straight lines and figuring out particles to add a little spice to the graphics. Going to have to solve that performance one here soon. For now I'm going to try to get a decent example demo going of a drawing that fades into a background picture. But tonight I just need to go to bed.

Friday, June 18, 2010

Wow, I actually did something!

10:15 PM - 1:15 AM:
Did some actual work on Pict this evening. This past week I've taken a couple of hours looking into how to do curves. Lagrange curves, Aitken algorithms, Bezier curves, etc. I ended up using a bezier curve inside of a rectangle in the image editor. So you can now add curves in the line drawing program. I am currently working on finishing adding importing the curves into Pict for drawing but I may not get that completed this evening.

[time passes]

Okay, initial curve support is in and working. Yay! Next stop, background images.


I need to catch up for the past few months, I've neglected my log.

I've worked quite a bit on the Folder app. It's gone from a simple app to load/send files to also be able to email, preview and delete files. Additionally I learned more about the iPhone 4 OS (now called iOS 4) and made it not just for the iPad, but also for the iPhone, iPod touch. That's taken the majority of my programming time. We also purchased some recreational land. We have been looking since the previous summer, I'm happy to have found something! That has taken up a lot of free time as well. I have made the decision in mid-april to have real pictures or images that fade into the drawn pictures. This will add a decent amount of work and means that the drawing needs to be more precise. I guess we will see how that goes.

Thursday, April 8, 2010

iPad received

A lot has happened this past week. Got my iPad, was disturbed that pict didn't run as well as expected. Everything "works" but there is intense lag when drawing straight lines and I have no idea why. I spent probably 3+ hours trying to figure that out over the past week. I also decided to do a "Folder" app this week as a diversion. It's a simple app, acting like a file transfer system via iTunes. It also sends files that are created (where possible) to other applications using apple's document protocol. Seems to work well enough, I got the basics working after about 4 hours of work on it. Needs some polish, but it's just about ready to submit. It needs to look cooler but other than that it should function well.

Tuesday, March 30, 2010


Touched up the game board and made some tweaks. I'll drop in an obligatory screenshot here of what I have so far. I'm hoping to get the game pieces done tonight and the board with some sample game pieces visually drawn. Tons to do! Still need to make the overlays for the gameboard so that the different squares are colored instead of all grey. If we do 4 colors then we can also have 2 wild squares on the board, which could be fun. I guess we will see how that works out once we get closer.

11:00 PM - 12:30 AM - Added random drawing selection to the pict viewer and the ability for the drawing scene to remember what it has drawn (which will need to be generalized later) for less repeat drawings. Added double-tap to go back to the main menu and start over for both the gameboard screen and the drawing screen. Cleaned up some of the test drawings, there will still be more to clean up or add. This is noticeable good stuff though, which is a happy thing! More later, it's late.

Wednesday, March 24, 2010

PDF Viewer done

I finished the iPad viewer on Friday at work (late into the evening) virtually alone, though there were a couple of good contributions to it from co-workers.  It looks more or less the same as in the screenshots, but has a couple of good things to go with it as well.  Today it was approved for sale along with the timer app.  Being burned out a bit I took last weekend off and read Empire by orson scott card.  It was a pretty good, if light, read.  Interesting ideas in it though.  Tonight I spent about 90 minutes designing a gameboard.  I tried the oval came board I had been thinking about first, but it just wasn't working out.  I settled on a rectangle gameboard and hope to have some of the pieces done this evening.  I'm a bit torn as a side-view of the pieces would look the best, but a top-down view of the board would work really well also, so we will see how it goes.  Also did some research on the pieces and got some sample images.  Additionally I decided, with the help of my wonderful wife, that we would take pictures and have the line art transition into the picture.  We will start for that on a trial basis and see where that goes.  That will be a lot of daunting work to get the pictures as well as the line drawings together.

Oh, the PDF viewer is called "Simple PDF Viewer" in the iTunes app store, iPad section, feel free to have a look if you are so inclined.

PDF Viewer - a distraction

8:00 PM - So yesterday at work we talked about the iPad deadline and decided to take the rest of the week to try and get the work iPhone project done and ready for submission (a fairly generic timer app) and decided to do the PDF viewer also. The PDF viewer is looking alright so far, I've pretty well been put in charge of that. Here are some screenshots of what I've got so far, based on the split view controller on the iPad.

Monday, March 22, 2010

Well crap

I should make a note about what's happening. 3 days ago apple made an announcement that you had 8 days to submit your iPad app to the app store to make the launch. Using beta 5, which was released 2 days before that. I was terribly disappointed as I had been expecting apple to give developers time and a more stable SDK rather than spring this at the last minute. I took it pretty hard as one of my primary goals was to have this out by the time apple's deadline happened. This made me realize I'm a bit too close to the project so I'm going to take a week off. I'm planning on writing a simple PDF viewer for the iPad, possibly for launch. I need to decide if it will be free with in-app purchases, ad supported, or paid still. I guess we will see.

Tuesday, March 16, 2010

iPad ordered, should be here on release day!

9:45 PM - 10:30 PM - did some work outlining some of what I have left to do. I've decided to keep the boardgame concept as that will translate well. Lots of category ideas to consider, content to create (graphically, musically, and line drawing wise) profiles to design and numerous other things to do. One step at a time I suppose. I wanted to also get a picture of the cat drawing at this stage since I've been picture happy lately. Oh, and lest I forget, the iPad was ordered last friday morning, and should be here sometime on saturday, April 3rd. Oh, also took a couple of minutes to look at the code for moveTo and adjusted the pencil from the top left to the bottom right as shown in the picture.  For reference, this was me drawing what started as hello kitty for my 4 year old.  I'm not an artist.  =)

I'll also include the sketch reference picture:

I should note I am liking the slightly off circles, it makes it look more hand-drawn. We will see what actually makes it into the final product.

1:00 AM - 1:45 AM - Changed the background texture to be full screen and added tint colors (5 shades, with 2 variations each, red, green, blue, purple, yellow). It pulses right now, these will eventually be the color of the different categories. Time to sleep.

Sunday, March 14, 2010

I'm not a scribe, I'm a translator!

I've had some struggles writing things down lately. I've spent 3-5 hours over the past few days and gotten the lines to be drawing correctly. I also changed the actions that draw lines to act on their target objects instead of on globals. Line drawing is more or less complete. I've changed the line drawing back to white and plan on tinting the background darker depending on the color choices. I've already had one suggestion to make the pen black, so we'll see where that goes as well. No actual work other than this today though.

Wednesday, March 10, 2010

Frustration, thy name is coding

7:00PM-7:45 PM, 10:30 PM-12:45 AM
Well I've missed my time tracking some, I worked on this issue a couple of times in the past few days. I'd guess that this is going on 6 hours of time. :/ I finally go the pencil fixed I think correctly, though I still do not understand why 0,0 is the center of a sprite in general and NOT the center when calling visit when drawing into the render texture. Sucks to be me I guess. So I modified the pencil and got it's positions worked out properly. It may move later but should be OK for now. Next stop is to get the "update" code to draw the pen pixel more than once as needed. Then it's back to some designing on the rest of the content drawing screen (like changing the pen color, making a better background, etc) and more design/decisions on the gameboard screen. See this thread on the cocos2d forums for more info on my struggles and a special thank you to one of the forum members for help.

Saturday, March 6, 2010


9:45 AM - 10:45 AM - well, I didn't get circles done last night, but I did get them done sort of this morning. The math is slightly wrong on the arcs, but it looks a ton better! More later today I hope, for now I have to go watch the kids as the wife is gone.

4:30 - 6:00 PM - Worked more on the pen, got it smaller and made it work a bit smoother, but it has a ways to go to really work properly. Kids hanging off me and crying, maybe more later.

8:00 - 9:30 PM - messed around some more, read some forums, decided I needed to do more fun stuff. Made a pencil image using a free picture of a pencil from the web. Added the pencil path which it almost follows just fine now. Also finished finding/adding SVN repository for pict. Using Beanstalk's free version for now. May need to get something more permanent.

11:00PM - 12:45AM - Fixed a bug with the moveto code at the beginning. Did all sorts of things to try to fix the pencil animation, but it's still off. It looks like the pencil's 0,0 is in the middle of the renderTexture instead of from the top left. Added moveTo's between non-consecutive points. (lineto's might be an issue here, they seem to always use the moveTo code regardless of where they start/end). Added a fairly generic background and colored the pen for fun and added rotation (not shown in the picture below).

Friday, March 5, 2010

Now with pictures!

9:45 PM - Doing some testing, the actions need to call visit every update event or you only get the first and last positions. So. Overriding the actions and making a bezier pen and a lineto pen, which should be plenty for now. Then I'll use those in place of CCBezierTo and CCMoveTo to draw stuff.

11:35 PM -- success! Looks like we will need a constant per-pixel drawing time or you get crazy images that are made up of non-touching dots the longer the lines are around. Apparently update only gets called every so often, so your timespan needs to be bigger to compensate. Also my top half of my circles don't seem to work, so I need to figure out why that is as well. I'll try to get circles done tonight then hit the time based drawing tomorrow. Too bad I didn't get pictures of my line-only OpenGL low level stuff. Maybe I'll have to dig something up for posterity. =)

As drawn in the modified sketch editor:
As drawn in the iPad simulator:

Thursday, March 4, 2010

I hate being sick. But we're getting somewhere.

10:15 PM - Definitely sick. STILL sick in fact. I've done about two hours of research and have a theory I'd like to try: Create a CCRenderTexture with a "pen" sprite. Use CCBezierBy actions to move that sprite around as rendering happens over a given period of time. We'll see how that works!

2:15 AM - Well, 4 hours later and I think I may have lines and circles coded. However, I don't see the drawing if I try to run the action sequence, so either my actions don't work like I am expecting or my coordinates are way off. If I comment out the actions I do get to see my pen dot show up on screen. That's got to count for something right? =) More tomorrow.

Friday, February 26, 2010

SICK. :/

10:45 AM - blegh. Sore throat, I'm sick! DOn't like it. May do some stuff today, depends on how things work out.

Wednesday, February 24, 2010

9:00 PM - 10:45 PM: Back from a small vacation! Got some much needed rest and time away from the
computer. I'm surprised sometimes that it really is rejuvenating. Go figure. =) Anyhow, did some looking aroudn and found out how to flip and mirror the CCLayer (CCNode really).
Links: here and here for some help with transforms and getting those down.  Did I mention I'm not really a graphics programmer?

I did cheat and spend like 15 minutes on vacation to get the drawing port to be centered rather than on the side of the screen also. I also learned about RenderTexture, which is a pseudo-double buffered drawing screen. I need to use that instead of redrawing everything over and over directly.

Friday, February 19, 2010


8:00 AM-8:45 AM - Fixed up my drawing code so that it would have more segments. Changed the custom bezierPath to have each piece store how much it had drawn so that each segment can be redrawn individually. Currently we are drawing the lines inverted and mirrored? Odd. Upped the tick time to 1/60th of a second since that's the FPS we are shooting for here and adjusted the number of segments accordingly. I will have to recode some of this as well due to needing to know how many segments each line is broken up into rather than determining segments when each piece of the bezier path is loaded. This will allow for an overall timeline of 10ish seconds to draw the entire picture regardless of how many bezier path segments it has. Still lots of work to do just to get my lines!

Thursday, February 18, 2010

size 0,0

9:30-10:00 PM - Spent 20 minutes and figured out that my drawing object was size 0,0 and that's why I am not seeing any output. Doh. Also figured out that I need to draw every segment that should be drawn every time rather than only once. Guess that will be a change also.

Tuesday, February 16, 2010

The day after president's day

9:45 PM - after winding down from a regular work day and checking my email, now that it's almost 10 PM back to work! =) Someone on the apple forums helpfully suggested this link, which is fairly cryptic but should help break up the curves.

10:00 PM - 1:00 AM - implemented enough so that lines would theoretically work. The lines are now chunking according to the segment count we pass the lines. The drawing is theoretically happening also except that I can't seem to actually see any drawing happening. It's likely how I'm doing the drawing (I guess?). I'm sort of ignoring everything but lines right now since that's the easiest of what's happening. The code mostly works, tick: is getting called once a second to draw each segment and the segments appear to loop through ok. So definitely close now. Ugh. I gotta stop staying up so late. Oh, also fixed a bunch of stuff with the coord loading code which I haven't been able to test until now, as well as finishing off this odd framework for putting the objects through their paces to draw.

Monday, February 15, 2010

Happy President's day!

9:45 AM - President's day is a working day for me. Going to start out today by creating a simple line drawing in our editor. Then implement loading in that saved data to the iPad app. Then drawing it. Then Animating the drawing. Also plan on finding a pencil image to go along with the drawing. Also working on thebackground for the drawing. Will go to that point.

10:00 AM-11:45 AM - Created a number of simple drawings to test with. So far so good, our editor will help a lot in creating content. Yay! Then finished with the initial pass of importing objects. We can now read, lines, rectangles and circles into our program. Assuming I coded it correctly. We will be using CGRects instead of point pairs as it's the same size of data, it's easier to downsize a line from that data than upsizing other things, and UIBezierPath has nice functions like bezierPathWithOvalInRect: for ease of drawing some of that.

11:45 AM - 1:30 PM: Talked with Chad, a co-worker, for about half an hour then went to get some lunch and read some slashdot on time estimates for programming. Sounds like most everyone else has about the same amount of luck I do -- it's just an educated guess, it depends on how educated you are. =)

1:30 PM - 2:00 PM: Fixed up what I did before lunch. You now call a function passing in the category and filename. We're now getting drawing objects from the file put into an array and sent back from this function. Next stop is actually looking at the cocos2d way of doing this as well as the new UIBezierPath way of doing things.

2:00 PM-5:45 PM: found out some discouraging news. UIBezierPath isn't able to be animated. This means I'll have to implement my own animation for these things. Cross your fingers for me. =) So, not as far as I'd have hoped today. Maybe later tonight I'll get more done here.

7:30 - 7:45 PM: researched one last ditch effort to not write my own. Didn't work out.

8:15 PM - Decided to write my own UIBezierPath clone using openGL and the cocos2d code to get around the over-time issues. We'll see how it works out.

8:15 PM - 12:00 AM: Brutal. I'm well on my way to making it draw incrementally, but I'm worried I'm not understanding everything appropriately. MoveTo is odd, I found out how to implement my own ellipse using rectangles, etc. I'm not sure how well this will work out but it's worth a try. Once I am done I will have a drawing framework that draws in openGL the following: Lines, Circles, Ellipses, MoveTo, Polygons, Quad bezier paths and Cubic bezier paths. This is way more of an education than I'd like on this stuff, but I think it's going as well as can be expected for not having planned to write this myself. Did I mention I'm really bad at trig? Still need to implement the ellipses function and the drawing for Quad/Cubic bezier paths. My other drawing may simply not work at all and I haven't run this yet for anything so who knows what else is left. The animation should work out pretty well though fairly non-standard for cocos2d. Start the animation by calling [self startAnimation] on the CCAnimatedBezierPath layer. I'm hammered, time to go to bed.

Saturday, February 13, 2010

Kid's Birthday

9:00 AM - 11:00 AM: I had to head in to work since I left my power adapter for my laptop here last night. I have until 2:00 PM which is when my daughter's birthday party starts. Going to add the actual app framework this morning. Started looking around at cocos2d, got a universal project started and running. Diverged to purchase a monitor from newegg that could actually run the iPad simulator at full screen without resizing. It's nice to have (a little) seed money from my previous project, Geopher Lite. We'll see if a new monitor helps. Also played around with garageband some, I have a few different composed pieces I might be able to use as well as a few full samples that could be fun profile sounds. Also made the first post to the blog (this blog, back-dated). Now that I'm good and distracted, I'm going to break for an early lunch then hit the app framework hard.

11:45 AM - 2:00 PM: Created the default project. Added a main menu, main menu background layer (to play the music, draw something cool in the background), created a now-traditional rainbow spinning in the background. Added a menu with 2 choices, one to go to the game board placeholder, another to go to the drawing screen placeholder. Also did some research in the cocos2d forums for various things and found a thread about what people wished they knew about when they started using cocos2d. Good stuff there, distracted me for 20+ minutes. Headed to my 2nd daughter's bday party now.

Friday, February 12, 2010

initial closure...

I spent 4 half hour chunks throughout the day - Fixed up the sketch-accessibility sample some so that it conformed to our drawing standards (mostly). Changed the grid to dots. Turned on snap to grid, disabled line width, disabled appropriate menus, etc. Editor is almost done. Still have to add an export or decide if I want to keep the same format for my drawings. Updated cocos2d for the final time, tomorrow I create the actual project (finally!) that will be used to make the game. I may be getting sick, let's hope not!

Thursday, February 11, 2010


Feb 7-10, 2010
Misc research, more meeps conceptual work, cocos2d research. Dunno on hours at least 4, likely more. I should keep track better.

Feb 11, 2010:
7:00 PM - 9:00 PM: Went to a BYU cocoaheads meeting, topic is multithreading. The presenter I wanted to hear didn't show, so mostly a review. Grand Central Dispatch / blocks isn't as intimidating as I once thought it to be. Prefer NSOperationQueue since it wraps blocks for you. iPad speculation, got a posible lead for work to develop for a guy interested in iPhone development.

10:00 PM - 10:45 PM: I fixed up the sample code so that it has a grid. Determined that the grid should be 3/4ths of the smaller width of the screen, so 576x576 on an iPad, 8 pixels per square each. That's a vector grid of 72x72, which should be enough to work with for most drawings. iPhone should be 54x54 at 4 pixels per grid square. Also took a 20 minute break to do the dishes. I'm so cool. =)

Saturday, February 6, 2010


4:00 PM - 4:45 PM: Browsed the cocos2d forums some to find out more about the new changes. Updated to the lastest cocos2d SVN files (0.99rc0).

7:00 PM - 9:00 PM: Created a new cocos2d project with the intention of porting the meeps to it. Got everything more or less working on it but it's SLOW now. Most of their class names changed to CC classes. i.e. "Sprite" to "CCSprite". Fixed some screen dependent code and updated to have better backgrounds. Also created a new "big" meep. Did some research on conditional compile macros for the iPad vs the iPhone and it looks like that hasn't been added yet. Worked around this for now with #warnings and commented out code. left code in a state where I don't like it. Also spent a bunch of time on a new meep graphic that is not quite right. I am not a graphics artist.

Look here if you don't know what the meeps are.

Monday, February 1, 2010

More issues...

5:15 PM - 6:00 PM: Looked around some a bit after work and figured out what the problem with the nil class was that I was having. Apparently you need to have your file owner as something specific, in my case NSWindowController. Then you need to attach the "window" property to the window in question. Once that happened, the window was then redrawn. I spent about 30 of those minutes talking about what I had learned last Saturday to two co-workers. Slow going so far.

8:00PM - 8:45 PM: kids headed to bed after dinner and a family discussion about baptism. (My oldest daughter will be baptized shortly) Time to implement what I learned right after work! That wasn't too bad, also fixed up drawing our window to the appropriate context. NSEraseRect() always fills white, [NSColor clearColor] and NSFillRect(rect) work quite well to clear a drawing area. note to self, when setting bounds you want to set the frame, not the bounds of a CALayer. Setting the bounds doesn't change the frame size. Taking a break, my eyes are burning. One major milestone accomplished, something that works! Wohoo!

10:15 PM - 11:00 PM: After talking with the wife about the app and some possible vacation plans (not related, heh), I realized that we don't have to do a custom moveto -- you get that with the ordering of coordinates and checking to see if the next object starts from the last location. Nice! Also explained how the editor will work as my wife will theoretically be helping me use that in content creation. Next stop will be creating the tools that make the points and then save/load functionality. I may have to mess with undo/redo as well. Actually probably.

11:00 PM - 11:15 PM: AARGH! So I've been spending all this time writing an editor. I figured out that some (old) apple code does exactly what I need minus curves and saving to my custom coordinate system. It's a sample called "sketch", 2 versions located here and here.

I've also archived this code in my "sample code" folder. I will be using this as a foundation for sure! This cuts out a lot of dev time and will be immensely helpful.

Sunday, January 31, 2010


10:15 PM - 10:30 PM - Did some looking around and it sounds like [CALayer setNeedsDisplay] should be what forces a redraw. Fixed the graph checkbox to turn it on and off.  See this link for more details.

Saturday, January 30, 2010

Day 1, all day Saturday.

9:30 AM to 12:15 PM

Created the sidebar for the drawing editor, called artist. I'll focus on the drawing editor today. You've got to have drawing before you can have the iPad draw! Also did some research on UIBezierPath (new in 3.2, iPad only). Decided that UIBezierPath will make things tons easier, so we will use that and worry about this app being ported to the iPhone/touch later. Determined optimal drawing sizes to be 600x600 and 280x280 for the iPad and phone/touch respectively. If things go well these should be scalable with a little math but better to plan for the actual pixel size at first since I'm a graphics n00b. Also installed accessorizer and did a small amount of forum posting in the beta forums about GPS and UIBezierPath. Also messed around with my iPhone syncing, getting that organized and emailed a friend about waiting on doing a business together. Next lunch, then on to creating the drawing window and making the sidebar work.

12:45 PM: Mmm, reheated pizza. Started work on main drawing window. Fought a bit with creating a suitable view controller attached to the window. I'm such a cocoa n00b still in many ways. Got an email back from a friend that said simply "kk sounds good". I expected differently. I worry too much. I then checked my apple beta forum posts and found that I had been flamed for asking if the 3G version of the iPad really did have a GPS in it. Great.

1:30 PM - 3:30 PM: Researching core graphics/animation so I can actually draw the content in the window like I should. Still working through some of that, but have learned to use CALayers and (I think) add them to the window's view appropriately. To draw dynamically I will still have to use either NSBezierPath or CG drawing techniques. (You can also use static images apparently quite easily). This is Still in progress. Got a response to my UIBezierPath question from an apple rep named rincewind. Here is the quote:
"UIBezierPath basically just wraps around CGPathRef in order to add a bit of state (basically attributes of the path). While useful, it doesn't really provide anything that you don't already have with Quartz, and if you chose to do so you could replicate its functionality entirely with Quartz."

3:30 PM - 5:30 PM: After doing a bunch of CALayer coding I figured out that my window wasn't loading my view controllers as I thought it should be. :/ So, I redid it inside it's own xib file and it's now working. Well, the window is being created properly, but my CALayer code for some reason goes into an infinite loop. Should be enough there to attach four layers, a root layer, a graph layer, a pen drawing layer and an animation layer. Breaking for dinner and to help my poor wife with the kids for a few.

6:30 PM - 8:00 PM:  Starting back in by looking for a CALayer example. After 10 minutes I see I should have done this from the start. see this link for a very good example of CALayer. Too bad this guy doesn't use a delegate method to draw his code. More churning... I found this example also, but I appear to be doing the same thing and my draw code doesn't work. :(

8:15 PM - 9:05 PM: After helping the kids get to bed (in bed not asleep, that takes far longer) I'm still working on the delegate for CALayer not getting called. Work on this for 15 more mins and get it working (move [self setWantsLayer:YES] to the top?) and now the CALayer is constrained into a much smaller space than anticipated. I need a break.

11:45 PM - 1:45 AM: I'm a glutton I guess. Had a 30 minute nap, some food and watched some Heroes. Let's see what we can do in the next few hours... Well, got it working. Nothing groundbreaking, but it appears you shouldn't mix NSBezierPath with the low lvl CG calls, once I took those out (and called NSBezierPath's stroke method) things began to work. Almost to the point of having the grid turn on and off, just have to figure out how to force a refresh on the grid drawing. Better get to bed.

Friday, January 29, 2010


As a quick note, I'm also going to use this blog as a time tracking tool, and maybe show a few developers what they are getting into by following along. For reference... Up until now I've spent the following time, from about January 24th thru January 29th:
4 hours of brainstorming, specs.
1 hour installing the new SDK.
1.5 hours researching (general iPad newness stuff related to this)
1 hour of research into cocos2d.

Here's to hoping this is useful to someone out there.

So it begins

After a month or so of scheming, planning, hand-wringing, indecision and angst, I've begun the process of iPad development in earnest.

This blog will be my journal so to speak, insight into my development process. I'll likely come across looking like the ignorant wannabe coder and self-publisher that I am. However, as my kids like to say, "You get what you get and you don't throw a fit". So it is with you, dear reader. You get what you get.

Today I have created the actual iPad project for my next project codenamed pict. I have a number of other ideas that may or may not actually happen, but we are starting here. Today.

I'll keep you updated.