By
Walter Reid | Published on
April 11, 2011 in
Advanced, Cocos2d and Tower Defense.
Tags: ccmoveto, CCSprite, cocos2d, Download, game source code, iphone, map, mapeditor, smooth scrolling, source, source code, tile, tower defense game, tower defense games, tutorial, Tutorials.
We made it! We’ve talked a little about design and have a fairly good idea of what the finish product will look like when we’re all done. Now we start the task of coding the thing. The first step for any tower defense game is the “creeps”. Creeps are the enemy characters that are invading your tower defense world and that you need to repel. So what are we going to do in this tutorial? Because this is just the first of a few, this is some of the items we’re going to cover:
- How to make waypoint.
- How to load up a tile based map and use objects from it instead of hardcoding them
- How to create Creeps/Bad Guys/ Enemies you name it
- How to make the move along our predetermined path
- How to do smooth scrolling on the iPhone
Without those things the game will not be much of a tower defense game. Well, some of the items are just nice goodies, but we want them so we’re getting them in right away! So in this first installment I am going to going to show you how to have a basic enemy follow a predefined path on a tilemap, by following a series of waypoints. By the end of this series, you will have all the information to be well on your way to making the next great tower defense game.

Source code after the break!
Continue reading ‘How To Build a Tower Defense Game for the iPhone – Part 1 – Creep Waves!’
By
Walter Reid | Published on
April 11, 2011 in
Advanced, Cocos2d and Tower Defense.
Tags: casual game, cocos2d, code, defense, game, game mechanics, learn cocos2d, objective-c, programming, Script, source, source code, tower, tower defense game, tower defense games, tutorial.
We’ve been doing a lot of simple game mechanics and one of our favorite for a long time has been the tower defense game – So in an effort to do this right, since programming this will take some time, lets talk a little tower defense design and goals.
Tower Defense Description:
- The enemy starts at one side of a map and travels along a path towards a destination ( usually on the opposite side of the map).
- You create towers along these paths that fire on the enemy while they pass through.
Attempt to survive wave after wave of stronger and stronger enemies by upgrading your towers with more powerful abilities.
- You can either win the game by beating the final wave (usually 20 to 50 waves) or keep going till you lose and there by get bragging rights when you die at wave 97.

A simple tower defense game tutorial for the iphone
There is not a “casual game” that better defines the word casual – The player makes a simple placement of a towers and make small upgrades while the battle unfolds. Who hasn’t played a tower defense game and lost on the 48th level of a 50 level game, because you didn’t plan for multiple types of enemies to attack at the same time. You can literally spend hours revising tower defense games to see if you can “beat” the game faster, get the most money or just win with the fewest towers.
Continue reading ‘How To Build a Tower Defense Game for the iPhone’
By
Walter Reid | Published on
March 17, 2011 in
Cocos2d, Intermediate and Slide Image.
Tags: CCLabel, CCSprite, cocos2d, Download, game, getChildByTag, iphone, puzzle, slide image, source, source code, tutorial, Tutorials.
Hi Everyone! We’re going to revisit the image sliding tutorial to add one additional feature. We are going to determine whether the puzzle has been solved or not. The task should be fairly straight forward so lets get started right away!
Source code after the break!
Continue reading ‘Building a Slide Image Game (Part 2 – With Solution)’
By
Walter Reid | Published on
September 23, 2010 in
Cocos2d, Intermediate and Slide Image.
Tags: ccaction, CCDirector, ccmoveto, CCSpriteFrame, cocos2d, code, Download, Example, game, iphone, slide image, source code, sprites, tile based games, tiles, tutorial, Tutorials.
It’s been a week since our last tutorial and in this new tutorial, we’re going to actually tackle a game – A slider game… You know the type of game I’m talking about, the players job is to put a game that is jumbled up, back together again. The great thing about games of this type is that we can use this as our first foray into the world of tile based games.
So what do we need to create this wonderful type of game? Below are a list of steps to make your own tile based slider game:
- Create a “Tile” class that has a sprite, a position and a value
- Create a manager type class that will create all the tiles and keep track of them
- Add touch components that will allow the user to swap tile locations
- Add additional image randomizations so there is more variety in the game
That’s it… Sounds simple when written out, huh? Well, we’re going to go through it and show you that it can be simple.
Source Code after the break!
Continue reading ‘Building a Slide Image Game’
By
Walter Reid | Published on
September 10, 2010 in
Beginner, Cocos2d and Getting Started.
Tags: ccaction, ccmoveto, cctouchbegan, cctouchended, cgpoint, class, cocos2d, code, converttonodespace, coordinatesdegrees, distance, dragon, iphone, istouchenabled, objective-c, radians, runaction, stopaction, touchlocation, tutorial, uievent, uitouch, vector, view.
So last we left, we left our dragon in the middle of a field hovering above the landscape… However, 90% of the animations we worked so hard to put in weren’t even being used and that is just a shame! Well, that changes now! We’ll now add in additional touch controls for the first time to handle user input and have the dragon fly all over the screen and picking a new animation based on the direction and terrorizing the country with your own flying dragon.
Source code after the break!
Continue reading ‘Cocos2d Sprite Tutorial Part 2′
By
Walter Reid | Published on
September 3, 2010 in
Beginner, Cocos2d and Getting Started.
Tags: Build, class, Cocos, cocos2d, code, Download, Example, game, iPad, iphone, Mac OS, objective-c, OpenGL, programming, sample, source, sprites, template, tutorial, vector, view, wiki.
Cocos2D for iPhone is a great open source framework that makes it easy to make some very impressive 2d games with much less effort than having to know OpenGL directly or rely on a third party system that might have performance issues or be unnecessarily bloated. From the official cocos2d for iphone website:
Cocos2D for iPhone is a framework for building 2D games, demos, and other graphical/interactive applications. It is based on the cocos2d design: it uses the same concepts, but instead of using python it uses Objective-C.”
Many of the most complex features are done for you, but like any open source software you can make changes as required. I however, doubt you will need to do many modifications on your own given that it’s very easy to subclass and handle drawing yourself as you become more experienced. Using Cocos2d is really one of the best ways to get your feet wet with OpenGL programming and learning Objective-C. HOWEVER, it is a programming language and that means you will need to understand the fundamental concepts of programming.
Continue reading ‘Getting Started with Cocos2d’
Recent Comments