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.

Tag Archive for 'source code'

Page 2 of 3

How To Build a Tower Defense Game for the iPhone – Part 1 – Creep Waves!

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

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

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.
Learn Cocos2d - Tower Defense Tutorial for iPhone

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’

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

Building a Slide Image Game (Part 2 – With Solution)

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

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

Building a Match 3 Type Game

So, we’ve set the ground work to start actually building a game with our menu, sprite, touch and animations tutorials using cocos2d. Now lets try something a little more adventurous – Lets actually create a simple “match 3″ game. What’s is a match 3 game, you may be asking… Well you’ve played them before I’m sure if you’ve ever played a flash game on the internet (The most famous of them being bejeweled). You can see the full game here – It’s free for the full game now! Drop Dead – Check it out now on itunes. The game play mechanic is very straight forward -

  1. You create tiles with different looks
  2. You randomly place those tiles in a 7×7 or 8×8 grid
  3. If three of the same objects line up either vertically or horizontally they all get removed from the grid
  4. All objects then fall to fill the gaps left by the removed tiles

Done.   Can’t we do it… Hell yeah we can… So lets ge started.

Source code after the break!
Continue reading ‘Building a Match 3 Type Game’

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

Building a Slide Image Game

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:

  1. Create a “Tile” class that has a sprite, a position and a value
  2. Create a manager type class that will create all the tiles and keep track of them
  3. Add touch components that will allow the user to swap tile locations
  4. 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’

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

Cocos2d Sprite Tutorial Part 3

So in Part 2 we introduced an animated dragon that had 8 directions of movement and was completely controllable via touching the screen. Isn’t cocos2d awesome! Well today we’re going to do a little more, today we’re going to create some villagers – tons of them in fact. We’ll use the information we’ve gotten so far including loading sprites from a sprite sheet and setting up animations.

Source Code after the break!
Continue reading ‘Cocos2d Sprite Tutorial Part 3′

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

Cocos2d Sprite Tutorial

Welcome back friends – Today we’ll be surmounting the world of sprites in Cocos2d. Not as hard as you might imagine and I’m going to prove it to you. First, there are a ton of ways to show an image on the screen… In fact you’ve seen one way when we were playing around with images in part 3 of the menu tutorial.

So what are we going to learn today?  We’re going to learn everything we can about “CCSprite”, “CCSpriteSheets”, “CCSpriteFrame” as well as “Texture2d” and “CCTextureCache”! By the end of this tutorial, we’ll have a dragon flying over a simple background terrain moving to the location the user touched. Pretty great huh?

Source code after the break!
Continue reading ‘Cocos2d Sprite Tutorial’

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

Cocos2d Menu Tutorial – Part 3

So we’ve done a bunch with menus already, what more can we do you ask? Patience my friend! Today we’re going to touch the area of menu item images! How excited are we? Pretty damn excited I can tell you…

To be honest you can ony really get so far without including graphics – People just aren’t incredibly wow’d by black on white text including images… You really need something to stand out in that app store which is why this lesson is one of the most important.

Source code after the break!
Continue reading ‘Cocos2d Menu Tutorial – Part 3′

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

Cocos2d Menu Tutorial – Part 2

If you haven’t hit up the part one of the series, I recommend you do so before moving on to this one since we’ll be building off of information that came up in part one…

Today, we’re going to be adding to the previous tutorial and getting our feed wet with animations and transitions. This will seem like a breeze from the last tutorial, but there is a lot to this so lets jump right in shall we!

Source code after the break!
Continue reading ‘Cocos2d Menu Tutorial – Part 2′

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

Cocos2d Menu Tutorial

So I imagine you’re already coming from the “Getting Started with Cocos2d” tutorial previously posted here, therefore, I’m assuming you’re all squared away with getting the iPhone sdk and XCode setup. For those who might just need a refresher course, the instructions are fairly straightforward to get started with Cocos2d.

Today, we’re going to tackle the wonderful world of menus. You can’t make a game without menus and Cocos2d makes it super easy to do it. But even before we begin we need to make sure we have a system in place so that our game can easily expand so we’re going to also create a Scene Manager.

Source code after the break!
Continue reading ‘Cocos2d Menu Tutorial’

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