By
iPhone Game Tutor | Published on
February 12, 2012 in
Advanced, Cocos2d and Tower Defense.
Tags: actionWithTarget, addChild, addObject, CCLabel, CCSprite, CGRectContainsPoint, CGRectMake, Download, iphone, source, source code, tower defense, tower defense game, tutorial, Tutorials.
Ok, so a few issues have been raised over the course of this tutorial series and I have tried to answer them as we go in the comments section. However I feel that we could do with a good clean up of our code. In this tutorial we will be doing a little spring cleaning of the code and preparing for future improvements such as, Splash damage tower, Upgrading towers (real time), Upgrading/Personalizing army stats (between rounds).
Firstly, problem solving:
After downloading the source code, the first thing that anyone with a developers license should see is that when you run the game those pesky lines / tile artifact issues have been solved. This was done by a small edit to the file CCSprite.m, big thank you to DreemLife for your efforts with sorting out this issue. If you are experiencing those tile artifacts in this project, the previous tutorials, or for any other project, then replace your CCsprite.m file with the one from the source code in this project.
Tower shenanigans:
Sometimes after a Creep has been removed, a Tower will send a projectile towards (0,0). This is because we have removed the towers target, without telling it not to shoot. Simply add the following to tower.m -> FinishedFiring method. (This will need to be done for all Tower classes)
Continue reading ‘How to Build a Tower Defense Game for the iPhone – Part 8 – Some early spring cleaning’
Hello, and welcome to part 7 of the Tower Defense Tutorial Series. – Money and Health!
In this tutorial we will incorporate “money” into the game so that towers cost the player, and the amount of money available will slowly increase over time. We shall also be incorporating base health bar into the game so we can ultimately have a game over. This particular tutorial focuses primarily on implementing dynamic labels and images, and the game logic behind them, as part of the gameHUD.
When adding labels to gameHUD.m the first thing we need to do is to decide upon what we want to display, in this case; Money count, abase health label and a base health bar, a wave count, and the prices of each tower.
Source code after the break…
Continue reading ‘How to Build a Tower Defense Game for the iPhone – Part 7 – Money and Health’
[Editor's Note: One of our readers spoke up and decided to help us finish off this series of tutorials. Many thanks to Aiden Fry for stepping up to the plate!]
Welcome to the latest edition of the Tower Defense Tutorial. This is just the start of the long awaited renewal of the Tower Defense Tutorials. I (like many of you I am sure), have been following this particular tutorial series with interest, and was slightly downcast when I realized that part 4 was the last to be released. So hear me now, I vow to take up the challenge and by the end of these tutorials we will have a fully working game!
Yours, Aiden.
[Editor's Note: We are also very happy that Aiden has taken up the challenge as well!]
The Tower Defense Tutorial Part 5a – Multiple Waves!
A Quick Look Back:
I will assume that all of you have been following the tutorial series found here – part 1, part 2, part 3, part 4 – and are mostly OK with what has gone before, however it is good just to mention a few key things about what has already taken place.
- We have some creeps that go around a set path.
- We can place towers around the path.
- Towers fire at the nearest Creep.
- Creeps have Hp, and when HP is 0 (due to tower projectiles) the creeps “die” and are removed from the game.
- At the moment there is only one “Wave” of Creeps.
Aims of this Tutorial:
- Creating Multiple waves of Creeps.
- Defining how many Creeps of each type (red/green) per wave.
Source code after the break…
Continue reading ‘How To Build a Tower Defense Game for the iPhone – Part 5a – Multiple Waves’
By
iPhone Game Tutor | Published on
July 6, 2011 in
Programming, Tutorials and iPhone.
Tags: business tutorials, game, game programming tutorials, graphic tutorials, iphone, mobile business, programming, tutorial, Tutorials.
and… get your game or product some exposure as well? We have hit over 10k uniques this month of people looking for quality game tutorials for the iphone. Unfortunately, for those who have been keeping score… We’re finding it hard to maintain a company and post regular tutorials at the same time
This is where you come in…
You start by contacting us at info ( a t ) iphonegametutorials ( d o t ) com… Then you build off an existing tutorial on the site or maybe come up with a new tutorial all your own! You get full credit for that tutorial and it will be displayed on iphonegametutorials.com for all to see. We plan on including a side bar of “Contributors” as well, so you’ll get tremendous exposure there as well. I don’t know what could be better for someone trying to show off their chops in the mobile game space or get a little more spotlight on the game they’ve made!
Continue reading ‘Want to Help iPhone Game Tutorials?’
By
iPhone Game Tutor | Published on
June 29, 2011 in
Cocos2d, Intermediate, RPG and Tutorials.
Tags: class, cocos2d, Development, Download, framework, game, iphone, map, mapeditor, programming, source, source code, tile, tiles, tutorial, Tutorials, update.
Update: Made some modifications to the source code – changed the title music (Hope you enjoy a remix of Dragon Warrior) and expanded the map to give a better idea of how you can use the space. Also, I added grid lines to the tiles so it didn’t looks so much like a painting. More parts to come!
It’s been a while since part 1 – we know from your comments that it’s not your favorite thing in the world (it’s not ours either) but we’re gonna try to get going again!
That being said, if you haven’t read part 1 of the tutorial, or the intro describing what we’re working towards, now’s your chance to play catch-up before plunging forward into the next piece of unknown – tile based maps using Tiled!
As will be the case for the rest of the tutorial, we’re using the Cocos2D framework for game development, which already includes support for the TMX file format (we’ll get to that later – just know that it makes our lives easier!). To build the map, we’re going to be using Tiled Qt, a fantastic piece of software that makes creating maps a piece of cake!
Source code after the break!
Continue reading ‘RPG Style Game for the iPhone – Part 2: Tiled Maps’
Hi All,
Just want to give everyone an update! Lots been going on over at our place of business and since we do this work for free, the time doesn’t always seem on our side. If you’ve ever felt like donating to the cause of learning and server upkeep now would be a good time – you know it’s cheaper than a book and it’ll help pay for the server and additionally force us to work even later nights
Thanks to those people who have already donated, we really do appreciate it.
Regardless of the those concerns, we are still committed to building out new tutorials and they should be ready to publish soon! So look forward to updates soon about our current series on Tower defense, RPG and Match 3 games. We also have a slew of new tutorials on the way based on the feedback from the polling and the forums.
Ok, enough chit-chat we have tutorials to write.
Cheers,
iPhoneTutor
By
iPhone Game Tutor | Published on
April 21, 2011 in
Advanced, Cocos2d and Tower Defense.
Tags: ccmoveto, CCRotateTo, CCSprite, CGRectIntersectsRect, CGRectMake, cocos2d, defense, iphone, source code, tower defense game, tutorial, Tutorials.
We’re back with another lesson in the never ending saga to create the perfect tower defense game. This is part 4 of the series, you would be well advised to consult the first 3 tutorials in the series, starting here, before attempting this section.

Today we are going to charge right into the newest section in the series – “Starting the tower attack!” This is one of the most important components in a tower defense game and will ultimately be one of the most enjoyable to program. I will definitely not get to all the cooler aspects of attacking towers in this one section, but I promise that we will create all sorts of fun towers soon. You will however, at the end of this particular tutorial, have enough knowledge to make any cool towers you can think of. I’ve tried to make the code robust enough for that!
If you haven’t read “Cocos2d Game Tutorial – How To Build a Tower Defense Game for the iPhone – Part 1 – Creep Waves!“, you may want to review it before you continue on.
Source code after the break.
Continue reading ‘How To Build a Tower Defense Game for the iPhone – Part 4 – Starting the Tower Attack’
By
iPhone Game Tutor | Published on
April 19, 2011 in
Advanced, Cocos2d and Tower Defense.
Tags: cocos2d, Download, iphone, radians, source, source code, tower defense game, tower defense games, tutorial, Tutorials.
Welcome to part 3 of the tower defense series – Today we are going to be delving into the fine art of realism. Nothing ruins the immersion of games like something that doesn’t make sense in the real world (unless that’s what your game is completely about. Since most tower defense games are rooted in the real world, we need to make sure that the items in the game act like real object. If you haven’t read “Cocos2d Game Tutorial – How To Build a Tower Defense Game for the iPhone – Part 1 – Creep Waves!“, you may want to review it before you continue on.
We’re doing a two fold thing, in this tutorial – We’re going to bring Part 1 and Part 2 together and add realism by adding some rotation and targeting to our towers and creeps.
- Towers need to be able to target the nearest creep
- Towers need to face in the direction of the creep they’re targeting
- Creeps need to rotate when they move in a specific direction
Source code after the break.
Continue reading ‘How To Build a Tower Defense Game for the iPhone – Part 3 – Rotation and Realism.’
By
iPhone Game Tutor | Published on
April 15, 2011 in
Advanced, Cocos2d and Tower Defense.
Tags: addChild, addObject, addTargetedDelegate, CCDirector, CCSprite, cctouchbegan, CCTouchDispatcher, cctouchended, CGRectContainsPoint, cocos2d, converttonodespace, convertTouchToNodeSpace, Download, Layers, machine gun, source, source code, sprites, touchlocation, tower, tower defense game, tutorial, Tutorials, UIPanGestureRecognizer, uitouch.
Welcome to part 2 of the tower defense series for the iphone using cocos2d – Today we’re going to be adding code to place towers. Whoa, slow down there you say – “place towers? That’s crazy talk”. I assure you it isn’t and once you are able to place towers in the next section we will combine our lessons together to have a single level of play! If you haven’t read “Cocos2d Game Tutorial – How To Build a Tower Defense Game for the iPhone – Part 1 – Creep Waves!“, you may want to review it before you continue on.
Ok, so one thing you may have learned from the last article was that making games isn’t like real life – it just need to act like real life. We didn’t need a complicated A*, DFS/BFS or Best-first searches to move our enemies around. In fact we didn’t need a tile based map at all. That doesn’t mean we still won’t need one in the future, but for now we follow the K.I.S.S system (keep it simple, stupid).
So lets take a look at what we are trying to recreate. Try to place the tower and see how it works – Please forgive me for my poor “gun tower” skills!

Source code after the break!
Continue reading ‘How To Build a Tower Defense Game for the iPhone – Part 2 – Placing Towers.’
By
iPhone Game Tutor | 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!’
Recent Comments