Friday, July 26, 2013

Upgrading a Project to a New Version of Cocos2D

A short video tutorial on this subject, since I just had to do this job myself and its not entirely obvious how to go about doing it, or how to solve some of the problems that can occur.


To check out the project used in this tutorial have a look at my earlier tutorials on Lua (linked in the panel on the right) and you'll find a reference to the GitHub repo where you can download the source.

Just to help Google searches finding this post:

  • CTFontManagerRegisterFontsForURL link error?
    • you need to add CoreText framework as this is a new dependency for Cocos
  • CCFontDefinition symbols not found link error?
    • you need to "add files" and re-add the cocos2D libs directory
    • there are some new .m files which are in the distro but not added to your project
Link errors when upgrading Cocos2D are probably due to these issues - new files and dependencies.

See my video above for how to fix 'em!

Sunday, July 21, 2013

Room to Room

This new progress update video shows a bit of a milestone with our animated door sliding open and our heroine able to move to a new room.



I did all the room background artwork for the apartment a few weeks ago and I have been coding like a demon since then ironing out all the issues with moving from room to room and persisting the game state across view and room changes.

For those of you who are coders you might be interested in this aspect of CocosBuilder and Cocos itself - since it is scene based, and your scene is effectively your entire user-interface, moving to a new room basically tears down the whole UI, and it has to be rebuilt again from the CCB file for the next room or view.

This makes for some fun and games when an item has been modified in one view and you need it to reflect those modifications in a new view on the "same item".  Like wise with items that have been added to the inventory, and which to not appear in the next view.

Lastly of course the actual opening of doors and the logic with the character having to wait for the door to slide open before walking through had to be done.

This is done with action queueing which also took quite a while to get working properly.  So for example the sequence to go through to the walk-in-wardrobe is
  • player taps the door to the wardrobe and says "Go"
  • queue a GoTo  action to the wardrobe room
  • that requires the door to be opened first so...
  • queue a GoTo the door
  • queue a Open of the door
  • when the door open occurs it plays an animation of it sliding open
  • finally execute the action to go to the wardrobe
This is all now working.  Whew!

Wednesday, July 17, 2013

CocosBuilder and CGPaths for non-rect Tap Detection

This is just a short post to frame a video how-to on detecting taps for selection on touchscreen devices, using CGPaths - and how to create those CGPaths using CocosBuilder.



What this essentially does is makes CocosBuilder into a tool that you can use to create non-rectangular bounding paths for tap detection.  As a bonus, I show how you can use the CGPath information to create a blue selection sprite image to signify the active selection in the UI.


I reference Bob Ueland's excellent CGPath tutorial, and that does include some code that you can use for the actual hit test.


For the extraction of the CGPath data from the CocosBuilder file I am not posting my code for cutting-and-pasting but if you've followed my earlier tutorials and are building your own game in Cocos2D you should have enough knowledge to follow what I have done.  It is just simply a case of traversing the nodes and using the standard method to build up a path from the CGPoint information stored in the CCNodes.

My technique for creating a selection sprite from the CGPath data is also not tricky - just check the documentation.  Give it a try and if you get really stuck feel free to ask a question here or on G+.

Hope it helps, and enjoy selecting stuff!

Sunday, July 14, 2013

New Climb Animation Sequence

I've been working on a climb animation for our heroine climbing up on to a high surface, which she does in a number of the "puzzles" in the game. 



Here she has to climb on the bed to see a screwdriver sitting on the window sill. The new 38 frame animation dovetails pretty well into the walk cycle, but there is no way to split the character into two so her front leg is "on" the bed while her back leg is behind it. 

If Spine can do that then that might be a compelling case for switching to it finally.
This is what the frames of animation look like in TexturePacker, as a sprite sheet.



Currently that is my pipeline, and of course switching to Spine would mean a big change in workflow - I might be able to reuse the artwork out of Anime Studio (which is what I animate in, and then generate PNG frames from) to create the Spine pieces.

If I do go for Spine it might have to be after I get this Beta done for early August - I'll never hit that date if I have to change now.

Wednesday, July 3, 2013

Head down, tail up - its modelling time

I'm working very hard right now trying to hit my self-imposed deadline of August 12 for having the beta ready.  That means getting all the rooms for the apartment done.

Coding is coming along well and I have killed a bunch of bugs that were stopping things working with the inventory and moving around.

This week I'm modelling the remaining rooms - which is basically the exterior of the apartment, the balcony that is, and the interior of the living room/kitchen/lounge area.  This is the area where the encounter with the "killer" character occurs and puzzles must be solved to successfully set up traps and avoid character death at the end of the first act.


This is one of the first renders and needs lots of fine tuning before I use it in the game.  But this basic scene is going to be used to introduce the killer character who comes climbing up the exterior of the building to attack our heroine.

I used Maxwell Render to do this, from a model that I built up from scratch using Sketchup.  The design for the apartment is from my original drawings.  The concrete texture and (a bit hard to see here) the wooden tile texture for the floor are all Maxwell textures - which are pretty good.  I haven't put an arris on the edge of the concrete balcony or sunshades - that probably needs doing so it matches the concrete elsewhere.

Anyway - good progress.  I have already modelled the whole internal area of the apartment so the rest of the week will mostly be fiddling with lighting, fixing up details and adding polish, while I run renders of all the views.