Welcome to iPhoneGameTutorials.com! Check out our Tutorials page for a list of everything we've written
so far, and drop by the Forums to let us know what you would like to see written about on the site.

Archive for the 'Advanced' Category

How to Build a Tower Defense Game for the iPhone – Part 8B – Tower Powers

Hi Again! So in this tutorial we will be implementing towers with splash damage, per-tower upgrades, and creep army upgrades, but before we begin that it’s time to get us ready for these upgrades.

Open the source code and find the files baseAttributes.h and .m. add these files to your project class folder, open them and take a look inside.

Ok, so there are a few variables in here which may be new or unexpected, however if they are not immediately obvious we will be using all these variables in the near future. The main categories of variables are, base health and money variables, Machine Gun variables, Freeze tower variables, Cannon tower variables and Creep variables.

As always – Source code AND download after the break
Continue reading ‘How to Build a Tower Defense Game for the iPhone – Part 8B – Tower Powers’

Share this:
Share this page via Email Share this page via Stumble Upon Share this page via Digg this Share this page via Facebook Share this page via Twitter

How to Build a Tower Defense Game for the iPhone – Part 8 – Some early spring cleaning

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’

Share this:
Share this page via Email Share this page via Stumble Upon Share this page via Digg this Share this page via Facebook Share this page via Twitter

How to Build a Tower Defense Game for the iPhone – Part 7 – Money and Health

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’

Share this:
Share this page via Email Share this page via Stumble Upon Share this page via Digg this Share this page via Facebook Share this page via Twitter

How To Build a Tower Defense Game for the iPhone – Part 6 – Tower Powers

Welcome back to the Tower Defense Tutorial Series! Once again I am assuming that you have read the previous 5 parts of this tutorial and are happy with the content covered in them.

In this Tutorial, we will be incorporating a new tower type into our game, this will give you the knowledge to then continue on and make/implement your own towers types. The tower type which we will be incorporating is a freeze tower, this tower will shoot Ice projectiles at a creep which will freeze it in place for a period of time, before the creep then continues on its journey.

Source code after the break!
Continue reading ‘How To Build a Tower Defense Game for the iPhone – Part 6 – Tower Powers’

Share this:
Share this page via Email Share this page via Stumble Upon Share this page via Digg this Share this page via Facebook Share this page via Twitter

How To Build a Tower Defense Game for the iPhone – Part 5b – More Wave Control

And we are back! Well, wasn’t that fun, we now have a multiple wave game, which we can program to increase in difficulty as we go along. However, there is still one thing nagging at me….. We still have no real control over how many creeps of each type are spawned in a wave, what if we wanted one wave to be completely made up of Red creeps, or Green Creeps. There are a few ways to do this, but I will explain the way that I did it.

Before we get into it, you’ll find things much easier to follow if you’ve already looked at Part5a of this tutorial series – So go there and come back… don’t worry we’ll wait.

Source code after the break…
Continue reading ‘How To Build a Tower Defense Game for the iPhone – Part 5b – More Wave Control’

Share this:
Share this page via Email Share this page via Stumble Upon Share this page via Digg this Share this page via Facebook Share this page via Twitter

How To Build a Tower Defense Game for the iPhone – Part 5a – Multiple Waves

[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.

  1. We have some creeps that go around a set path.
  2. We can place towers around the path.
  3. Towers fire at the nearest Creep.
  4. Creeps have Hp, and when HP is 0 (due to tower projectiles) the creeps “die” and are removed from the game.
  5. 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’

Share this:
Share this page via Email Share this page via Stumble Upon Share this page via Digg this Share this page via Facebook Share this page via Twitter

How to Build an RPG Style Game for the iPhone

Role playing games are a hugely popular genre of game – some of our favorite games over the years have been RPG’s. One of the projects we’ve been working on lately is an RPG style game. It’s been a challenging task, so we thought we should share some of the information on how we put it together! RPG’s can be a complex genre with lots of different game design mechanics, so let’s go ahead and spell out what we’re trying to build here:

  • A Menu system, including both an Options and Credits screen, that will build from our previous Menu tutorials
  • How to build a top down, tile based map using Tiled, a free tool for creating tiled based maps!
  • RPG’s almost always tell a story, and in our case we have some videos to help move the story along. We’ll show how to play an intro video to set things up, as well as a video before starting a mission.
  • Generally, your character(s) have missions to go through with mission objectives and win/lose conditions. We’ll show you how to display these to your player before they start the mission, and later on show how to build these into the game.
  • Our game is going to have multiple playable characters so we’ll have a character select screen. We’ll start with something simple and later on add in more complexity.
  • Dialog is another important aspect so we’ll show some character dialog at the start of our missions.

That’s probably enough to get us started on the road to a working game for now. Let’s talk briefly about role playing games – they have been around for a looong time, before digital games even existed. While there are definitely others, Dungeons & Dragons was probably the most popular pen and paper role playing game. RPG’s have come a long way since then and have transcended all consoles and are still popular to this day in a variety of forms, including MMORPG’s and so on. Hopefully with our help, you all will be able to keep the trend going and create some awesome games for the iPhone! The tutorials will start coming soon so stay posted!

Share this:
Share this page via Email Share this page via Stumble Upon Share this page via Digg this Share this page via Facebook Share this page via Twitter

How To Build a Tower Defense Game for the iPhone – Part 4 – Starting the Tower Attack

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’

Share this:
Share this page via Email Share this page via Stumble Upon Share this page via Digg this Share this page via Facebook Share this page via Twitter

How To Build a Tower Defense Game for the iPhone – Part 3 – Rotation and Realism.

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.’

Share this:
Share this page via Email Share this page via Stumble Upon Share this page via Digg this Share this page via Facebook Share this page via Twitter

How To Build a Tower Defense Game for the iPhone – Part 2 – Placing Towers.

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.’

Share this:
Share this page via Email Share this page via Stumble Upon Share this page via Digg this Share this page via Facebook Share this page via Twitter





Switch to our mobile site