cocos2d Book, Chapter 11: Isometric Tilemaps

On September 6, 2010, in Announcements, book, cocos2d, by Steffen Itterheim

Chapter 11 – Isometric Tilemaps

After Chapter 10 introduced Tiled and working with orthogonal tilemaps it’s time to step things up a notch and delve into isometric tilemaps. It starts with basic principles of isometric tilemaps and editing before going into detail on what’s different code-wise compared to orthogonal tilemaps. Obviously this has to include how to determine which isometric tile was touched and how to move a character across an isometric tilemap.

Summary of working on Chapter 10 – Working with Tilemaps

This chapter introduces you to tilemaps, what they are and what benefits and tradeoffs they provide. Without a doubt the most popular editor for tilemaps for use with cocos2d is the Tiled Map Editor. I explain how to use it over several pages before going into code and actually loading your first tilemap using cocos2d’s CCTMXTiledMap class.

Loading a tilemap is just half the story. You’ll also learn how to manipulate the tilemap layers and individual tiles, as well as scrolling the tilemap and centering the touched tile on screen. The code takes care that the tilemap is never scrolled outside its boundaries.

While working with the Object Layer feature of Tiled (CCTMXObjectGroup in cocos2d) I noticed it’ll be handy to display the rectangles on the screen. So you’ll also learn a little custom drawing using OpenGL ES respectively cocos2d’s wrapper functions in CCDrawPrimitives.

Tagged with:  

Learn Cocos2d Alpha Book: Source Code now available!!

On August 30, 2010, in Announcements, book, cocos2d, by Steffen Itterheim

The Learn Cocos2d Alpha Book’s page now lists the source code for download. It’s 44 MB, contains the source code for the first 9 (!) chapters as zip files.

I’m not sure if everyone can download the source code, or only eBook purchaser. I wasn’t asked to login, so I think it may be available for everyone. Try it out! Here’s a direct download link:

Direct Download: Learn Cocos2d Alpha Book Source Code

Before you ask: no, Chapter 6 and beyond are still not available yet. They will have to wait until they have gone through the editorial process. I believe Chapter 5 is currently in this process so it will still take at least a week, maybe 2-3, before you’ll get your hands on Chapter 6. But I hope that once the editorial process has caught up with the already available 5 chapters, new ones should be available on a regular basis. Every 1-2 weeks I hope, but no guarantees. This process is very new to me too so I try to be very careful making any assumptions.

Tagged with:  

cocos2d Book, Chapter 10: Working with Tilemaps

On August 28, 2010, in Announcements, book, cocos2d, by Steffen Itterheim

Chapter 10 – Working with Tilemaps

This chapter dives into the depths of the CCTMXTileMap class and how to create, iterate and modify tilemaps in code, including isometric and hexagonal tilemaps. Of course there will be an introduction to the Tiled Map Editor as its the primary tool to create TMX tilemaps that cocos2d supports.

The chapter 11 will then use this newfound information and I’ll walk you through making a scrolling tilemap game, since simply loading, modifying and displaying a tilemap would just be half the story.

Summary of working on Chapter 9 – Particle Effects

This chapter was fun. Particle effects are fun indeed. That is, unless you need to tweak them in code only. I did do that an did my best to describe what each CCParticleSystem property does to a visual effect, although some things you’ll have to see for yourself. You’ll find a lot of detailed information on how to setup or simply modify a particle system in code and a couple tips for designing good particle effects.

Of course with Particle Designer everything changes. Designing a cool particle effect suddenly goes from a treadmill to a mesmerizing activity that you can waste countless hours on. If you check Particle Designer’s Online Library you’ll find four of the Particle Effects that I designed and submitted, starting with the “Colorful Burst” effect. Have a look!

Obviously these cool effects needed to go somewhere, so I added them to the Shoot ’em Up game as you can see in the screenshot (the boss just exploded into purple smudge). Along the way you learn how to load the particle effects created by Particle Designer of course.

cocos2d Book, Chapter 9: Particle Effects

On August 21, 2010, in Announcements, book, cocos2d, by Steffen Itterheim

Chapter 9 – Particle Effects

Those tiny specks which you can see on your touchscreen after a sneeze.

Not exactly. Of course I mean the cocos2d particle system and its built-in particle effects which will be the focus of this chapter. And no discussion of particles would be complete without describing the workflow revolving around the Particle Designer tool.

Summary of working on Chapter 8 – Shoot ’em Up

This certainly wasn’t the easiest chapter for me to write. I had very ambitious goals, maybe too ambitious for 27 pages. I did manage to sneak in quite a lot though, here’s a partial list:

  • how to refactor existing code to make it work better with the new features
  • how to pool bullets and enemies together for easier access and better performance
  • how to not use too many subclasses, instead relying on type switches
  • how to use cocos2d’s node hierarchy as a simple component system for writing reusable game logic components
  • how to implement basic movement, shooting and a healthbar as components
  • how to detect collisions between bullets and enemies

The not so easy part was striking the right balance. Not going too technical. Not doing too much at once. Not dividing things into too many tiny pieces. But most of all I frequently encountered various bugs in the code, or just unexpected behavior of cocos2d which forced me to spend more time debugging and sometimes backtracking changes than I was prepared for.

After a long and hard work week, paired with physical exhaustion and an late-summer allergy burst, my concentration didn’t allow me to work at 100% capacity. In the end I did manage but it took longer than I had planned, I’m over a day late to submit this chapter. The next one will be easier though, and it has to be as I’m preparing for a short trip near the end of next week. I certainly am looking forward to a couple days off now. :)

Starterkit Price Drop, Sales Numbers

On August 16, 2010, in Announcements, Marketing, by Steffen Itterheim

The important bit first: the price of the Line-Drawing Starterkit is back at $179!

The simple reason: customers voted with their wallet, it sold zero units at the $299 price point over the last two weeks while people kept asking me for rebates and price drops. I clearly misjudged the value proposition of the Starterkit and how much potential customers would be willing to spend.

About Thinking, Learning and Knowing

I’m going to be upfront about the sales numbers because I want to be instructive and convey the lesson’s I learned. I also find these numbers posts very intriguing myself. One of the things I love about working under my own terms is that I can choose how transparent you want to be. I feel there’s more to gain from transparency, being open and upfront, and sharing what you know then there is to lose.

I’ve actually been told a few times that you can’t sell to cocos2d developers. Which I find astonishing. “I don’t think there are sufficient willing customers” was the one sentence I received in an email which I find most telling. Thinking is not knowing. Thinking is: not knowing! Trying and not succeeding is ok, but thinking and not even trying is not. The former you might regret financially but seldom will you regret having done it. The latter is just being complacent and accepting the status quo, or simply a reluctance of pursuing unconventional business ideas.

I can only say: I’ve learned a lot from running this website over the past 4 months. Certainly more valuable lessons and knowledge than from most of the books I own, and the above selection is just a fraction of my library. They are the books I hold most dear and are most relevant to my work right now, including Stephen Hawking’s Universe in a Nutshell as the perfect separator between left-brain (hard skill) and right-brain (soft skill) books. It puts everything in the proper perspective. I certainly didn’t expect to learn some of the lessons nor was it easy to deal with the very unexpected ones, but I did nevertheless. The good part about the hard lessons is that they make me think even harder to learn what I need to know to understand. I also have a bunch more unconventional ideas now. And I grok Invictus.

The Numbers

The Line-Drawing Game Starterkit has been on sale (40% off back then) from July 10th to August 1st, that’s 23 days. From July 10th until the public announcement on July 20th the sales were limited to my Newsletter subscribers, close to 670 people were given the password to access the sales page at the time.

When I formed the idea of selling a Starterkit, I punched some numbers about website traffic, pricing, conversion rates, looking at other products, thinking of what certain indicators could mean, why people are having success and why others don’t. Being a pessimist I came to about 3 sales per month if the price is around $200. That would have been nice, and would have allowed me a return of investment in less than 6 months. And when I was optimistic I thought I could be making up to 5-10 sales per month, perhaps by being featured prominently. I definitely had enough positive indicators to go ahead and try making and selling the Starterkit and being sufficiently convinced that it’ll have a positive impact, financially and otherwise.

The reality is that I sold 30 copies at $179 each within 23 days! Way, way more than my expectations. See the screenshot of the payment report to the left for the monetary details. Note that the first section with 3 sales were test sales by myself, so that amount should be deducted from the total. Also, 30 times $179 does not equal the sum on the bill because surcharge fees depending on the payment method have already been deducted. Net sales is the amount after Plimus took their share, which is close to 5% if I remember correctly.

I estimated my return of investment (break even) at about $4,000. So overall it’s not bad. Not bad at all given that I made all those sales in 23 days instead of months.

The downside to this story is that after setting the price high at $299 I did not make a single sale in the past 2 weeks! This price point seems past a certain pain threshold that developers are feeling comfortable spending. Customers voted with their wallets and I basically killed my own business by modifying just one (crucial) aspect of it. I was my own worst enemy by making a wrong judgement call.

And of course I’ll try to fix it: from this day on forward the Starterkit’s regular price will be back at $179! It has proven to sell at this price point and I’m hoping to see sales pick up again. Despite this no-sales period of over 2 weeks the Starterkit earned me $120 per day on average, or an hourly rate of $15 assuming a regular 8-hour work day.

The Future

If it turns out that continued sales from the Starterkit allow me to live off it, I’m going to run this website full-time in the near future. That means more free stuff, more intriguing blog posts and every once in a while a new commercial product that targets very specific unfulfilled needs of cocos2d game developers. You might consider the cocos2d book to be one of these commercial products, and I intend to improve it after press by listening to reader’s feedback and filling any holes with free Tutorials and FAQ entries on this website. It will be a book that continues to get written.

More Lessons to learn

If you want to learn some business & marketing lessons in general I recommend reading The Long Tail to understand how niche markets work and Influence: The Psychology of Persuasion for a lesson in marketing which I find important to understand both from the seller’s and the customer’s point of view. The Long Tail was instrumental for me to actually become comfortable with the thought of selling a product to a niche audience and why that idea might just work. But also instrumental because I just keep shaking my head when I read the naive comments of some people. That’s also where how to deal with critics comes in handy.

cocos2d Book, Chapter 8: Shoot ’em Up

On August 14, 2010, in book, cocos2d, by Steffen Itterheim

Chapter 8 – Shoot ’em Up

This chapter will finish the shoot ’em up game. There will be enemies and powerups. It raises the issue of good code design when certain things like shooting and moving are common to all objects while other things such as what to shoot and where from and to depend on who is shooting. And then to determine who is hit by whose bullets.

Of course no shoot ’em up game is complete with a boss monster that takes a couple hits to kill. So it’ll need a healthbar. At the end of the chapter this shoot’ em up should be a fully playable game, with Chapter 9 complementing it with visual effects by using the cocos2d particle system. But I’m getting ahead of myself here.

Summary of working on Chapter 7 – Scrolling With Joy

Once again I renamed the chapter a bit since it’s divided into two parts: a parallax, infinitely scrolling background and input via SneakyInput, featuring a fire button and an analog thumbstick respectively at the end changed to a 8-way digital pad.

The parallax scrolling background consists of several bands or stripes which were created on different layers each in Seashore and then saved as individual 480×320 images. They were then added to the Texture Atlas by Zwoptex. The cool thing about this is that Zwoptex preserves the original image’s size while stripping away all transparent parts. So the images take up little space in the Texture Atlas but in game you don’t have to position them individually, you’ll simply place them at the center of the screen.

To achieve the endless scrolling effect two of each image where added side-by-side to each other, with one flipped on the X axis so the images align neatly. Whenever one image has scrolled outside the screen it is moved back to the right side of the screen. At the end I also fixed the vertical flicker lines which can appear due to round-off errors when moving the sprites. And of course they all are drawn with a CCSpriteBatchNode.

The SneakyInput fire button allows continuous shooting and faster shooting when you just tap it, while the thumb stick controls the ship’s movement in both analog and digital (8-way) variants. The Ship class’ setPosition method is overridden to keep the player’s ship within screen boundaries at all times. Finally an extension class gives SneakyInput the same autorelease initializers used by cocos2d, and adds another good example of just how useful Objective-C categories can be.

cocos2d Book, Chapter 7: Side-Scrolling Shooter

On August 6, 2010, in Announcements, book, cocos2d, by Steffen Itterheim

Chapter 7 – Side-Scrolling Shooter

The shooter game will be controlled with a virtual joystick using SneakyInput. The background parallax scrolling will be implemented not with the CCParallaxLayer, as it does not support endless scrolling (as far as I know, please correct me if I’m wrong). The rest will be gameplay code, mostly spawning enemies, moving them and collision tests.

The chapter will be submitted on Friday, August 13th. Yup, Friday the 13th. Scary.

Summary of working on Chapter 6 – Sprites In-Depth

I decided to rename this chapter to Sprites In-Depth as it deals mostly with Sprites, Sprite Batching (formerly known as Sprite Sheets), Texture Atlases and Zwoptex as well as general texture memory management. All the while laying the foundation for the game to be made in Chapter 7.

While working on this chapter I noticed that it’s awfully complex to create a CCAnimation class, especially if you’re not using a Texture Atlas. So I decided to illustrate how to add helper methods by adding them via a Objective-C Category to the CCAnimation class. Now you can create a CCAnimation with just one line of code, instead of around ten.

Once more I created some of my now famous doodle artworks. If anything this should show that even a programmer can do art. Or, well, at least something that vaguely resembles art.

I was a bit surprised by one thing though, and that is how little the use of the CCSpriteBatchNode contributed to the framerate in this particular case. I added all the bullets to a CCSpriteBatchNode and found only a 15% increase in performance, it went up from 45 fps to a little over 50 with all those bullets flying. I sort of expected a bigger impact from previous experiences.

I’m happy to announce that the cocos2d book I’m writing is now available for early access as an Alpha Book! If you click on the previous link or the image you can view the book’s description. Look for the “Buy Alpha Book” button on the left side of the book’s website, inside the “Book Details” frame.

Access to the Alpha Book costs $27,99 – the same as the eBook version. You get to read the unedited, unfinished pre-release chapters of the book. The full book isn’t available yet, but when it becomes available, you will be able to download the full eBook.

At the moment 5 chapters are available with new chapters being written on a weekly schedule.

Your feedback will be very valuable to make this book the best it can be! Please send your feedback to Apress, not to me directly. Apress will evaluate your feedback and send it to me with duplicate and already planned or implemented feedback sorted out, so that I can focus on writing.

Tagged with:  
Page 23 of 27« First...10...2122232425...Last »